Click or drag to resize

GenericExtensions Methods

The GenericExtensions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleBinarySearchT(IListT, FuncT, Int32)
Searches the entire sorted IListT for an element using the provided comparer and returns the zero-based index of the element.

This differs from the "ordinary" binary search in allowing a comparer delegate that defines whether an item is found (returning 0), whether the item in the list is before (<0) or after (>0) that knows how to compare a class with its key. Example, if the list contains classes of type T having an id number and the class is sorted on that id, then the keySelector returns the id number for that class.

Examples
If having a list of doubles, to find 4.5 in the list, use:
int index = list.BinarySearch(d => d.CompareTo(4.5))
Public methodStatic memberBinarySearchT(IListT, T)
Searches the entire sorted IListT for an element and returns the zero-based index of the element.

If the key is not found, a negative number is returned, which can be intepreted as the bitwise complement of the interval of indices that the key is in between, i.e.

list[interval-1] < key < list[interval]

Public methodStatic memberBinarySearchT(IListT, T, IComparerT)
Searches the entire sorted IListT for an element using the provided comparer and returns the zero-based index of the element.

If the key is not found, a negative number is returned, which can be intepreted as the bitwise complement of the interval of indices that the key is in between, i.e.

list[interval-1] < key < list[interval]

Public methodStatic memberBinarySearchT, TKey(IListT, FuncT, TKey, TKey)
Searches the entire sorted IListT for an element and returns the zero-based index of the element.

If the key is not found, a negative number is returned, which can be intepreted as the bitwise complement of the interval of indices that the key is in between, i.e.

list[interval-1] < key < list[interval]

This differs from the "ordinary" binary search in allowing a keySelectorcomparer that knows how to compare a class with its key. Example, if the list contains classes of type T having an id number and the class is sorted on that id, then the keySelector returns the id number for that class.

Public methodStatic memberBinarySearchT, TKey(IListT, FuncT, TKey, TKey, IComparerTKey)
Searches the entire sorted IListT for an element using the provided comparer and returns the zero-based index of the element.

If the key is not found, a negative number is returned, which can be intepreted as the bitwise complement of the interval of indices that the key is in between, i.e.

list[interval-1] < key < list[interval]

This differs from the "ordinary" binary search in allowing a keySelectorcomparer that knows how to compare a class with its key. Example, if the list contains classes of type T having an id number and the class is sorted on that id, then the keySelector returns the id number for that class.

Public methodStatic memberChainageAsDiagnosticsValue
Get chainage as DiagnosticsValue (includes unit)
Public methodStatic memberChainageEquals(ILocation, Double)
Returns true if the chainage equals, withing LOCATION_EQUAL_TOLERANCE
Public methodStatic memberChainageEquals(ILocation, Double, Double)
Returns true if the chainage equals, withing tolerance
Public methodStatic memberCopyTo
Convert a double array to a float array.
Public methodStatic memberCopyToFloatArray
Convert a double array to a float array.
Public methodStatic memberError
Add an error to the diagnostics item.
Public methodStatic memberExceptionToError
Add an error DiagnosticItem, and throw an exception
Public methodStatic memberExceptionToString
Create string from exception, including inner exceptions
Public methodStatic memberFindIndexT(IListT, PredicateT)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the list.
Public methodStatic memberFindIndexT(IListT, Int32, PredicateT)
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the ListT that extends from the specified index to the last element.
Public methodStatic memberFirstInMonth
Returns the first day in a month, at time 00:00:00.
Public methodStatic memberGetValueT(IDictionaryString, T, String)
Get value, based on key. If no data exist for value, null is returned
Public methodStatic memberGetValueT(NetworkDataT, ILocation)
Get a value from the networkData at the given location. If no value is found at location, the global value is used. If no global value is defined, an exception is thrown.
Public methodStatic memberGetValueT(NetworkDataT, ILocation, T)
Get a value from the networkData at the given location. If no value is found at location, the global value is used. If no global value is defined, the default value is returned.
Public methodStatic memberGetValuesT(IVectorGetterT)
Public methodStatic memberGetValuesT(IVectorGetterT, T)
Public methodStatic memberGetValuesT(IVectorFractionGetterT, T, Double)
Public methodStatic memberIndexOf(IListIQuantity, IQuantity, Boolean)
Search the list of quantities for the given quantity
Public methodStatic memberIndexOf(IListIQuantity, IQuantity, IListString)
Search the list of quantities for the given quantity, allow the description to be also one listed in descriptions.
Public methodStatic memberIsOneOf
Returns true if enumeration is one of the listed ones.
Public methodStatic memberIsSediment
True if component type is a sediment type
Public methodStatic memberCode exampleLargestMultipleOf
Make span the largest multiple of the spanRef that is smaller than span
Public methodStatic memberMin
Returns the smallest of t1 and t2
Public methodStatic memberMultiply
Multiply the timespane 'dt' by a double. If the double is larger than 1e6, then 1e6 is used in order to prevent overflow
Public methodStatic memberOverLap(ILocationSpan, ILocationSpan)
Calculate overlap of location span and another locationSpan. If the result is positive, the value is the actual overlap. If the result is negative, there is no overlap, and the value is the negative distance between the two spans.
Public methodStatic memberOverLap(ILocationSpan, Double, Double)
Calculate overlap of location span and the chainages of another locationSpan. If the result is positive, the value is the actual overlap. If the result is negative, there is no overlap, and the value is the negative distance between the two spans.
Public methodStatic memberRuntimeError
Add an error DiagnosticItem, and throw an exception
Public methodStatic memberSet
Set a value to the table
Public methodStatic memberSort(IXYTable)
Sort table by x-value, using a quick-sort algorithm
Public methodStatic memberSortT(IListT)
Sorts the elements in the entire List{T} using the default comparer.

A quick sort algorithm is used. Quick sort is a un-stable sort algorithm i.e. if two elements are equal their order may not be preserved.

If the provided IList is either an array or a list, the build in sorting method is used (also quick sort).

Public methodStatic memberSortT(IListT, IComparerT)
Sorts the elements in the entire List{T} using the provided comparer.

A quick sort algorithm is used. Quick sort is a un-stable sort algorithm i.e. if two elements are equal their order may not be preserved.

If the provided IList is either an array or a list, the build in sorting method is used (also quick sort).

Public methodStatic memberSortStable(IXYTable)
Sort table by x-value, using a stable sort
Public methodStatic memberSortStableT(IListT)
Public methodStatic memberSortStableT(IListT, IComparerT)
Sorts the elements in the entire List{T} using the provided comparer.

A merge sort algorithm is used. merge sort is a stable sort algorithm i.e. if two elements are equal their order are preserved.

Public methodStatic memberSortStableT(IListT, ComparisonT)
Sorts the elements in the entire List{T} using the provided comparer.

A merge sort algorithm is used. merge sort is a stable sort algorithm i.e. if two elements are equal their order are preserved.

Public methodStatic memberSwapT
Swapping two elements.
Public methodStatic memberTryGetValueT(IDictionaryString, Object, String, T)
Get additional data, based on key. If no data exist for value, return the defaultValue
Public methodStatic memberTryGetValueT(IDictionaryString, Object, String, T)
Get additional data, based on key. If value is not of type {T}, false is returned.
Public methodStatic memberWarning
Add a warning message
Top
See Also