GenericExtensions Class |
Namespace: DHI.Mike1D.Generic
The GenericExtensions type exposes the following members.
Name | Description | |
---|---|---|
BinarySearchT(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)) | |
BinarySearchT(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] | |
BinarySearchT(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] | |
BinarySearchT, 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. | |
BinarySearchT, 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. | |
ChainageAsDiagnosticsValue |
Get chainage as DiagnosticsValue (includes unit)
| |
ChainageEquals(ILocation, Double) |
Returns true if the chainage equals, withing LOCATION_EQUAL_TOLERANCE | |
ChainageEquals(ILocation, Double, Double) |
Returns true if the chainage equals, withing tolerance
| |
CopyTo |
Convert a double array to a float array.
| |
CopyToFloatArray |
Convert a double array to a float array.
| |
Error |
Add an error to the diagnostics item.
| |
ExceptionToError |
Add an error DiagnosticItem, and throw an exception
| |
ExceptionToString |
Create string from exception, including inner exceptions
| |
FindIndexT(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. | |
FindIndexT(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. | |
FirstInMonth |
Returns the first day in a month, at time 00:00:00.
| |
GetValueT(IDictionaryString, T, String) |
Get value, based on key. If no data exist for value, null is returned
| |
GetValueT(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.
| |
GetValueT(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.
| |
GetValuesT(IVectorGetterT) | ||
GetValuesT(IVectorGetterT, T) | ||
GetValuesT(IVectorFractionGetterT, T, Double) | ||
IndexOf(IListIQuantity, IQuantity, Boolean) |
Search the list of quantities for the given quantity | |
IndexOf(IListIQuantity, IQuantity, IListString) |
Search the list of quantities for the given
quantity, allow the description to be
also one listed in descriptions.
| |
IsOneOf |
Returns true if enumeration is one of the listed ones.
| |
IsSediment |
True if component type is a sediment type
| |
LargestMultipleOf |
Make span the largest multiple of the spanRef that is smaller than span | |
Min |
Returns the smallest of t1 and t2
| |
Multiply |
Multiply the timespane 'dt' by a double. If the double is larger than 1e6, then 1e6 is used in order to prevent overflow
| |
OverLap(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.
| |
OverLap(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.
| |
RuntimeError |
Add an error DiagnosticItem, and throw an exception
| |
Set |
Set a value to the table
| |
Sort(IXYTable) |
Sort table by x-value, using a quick-sort algorithm
| |
SortT(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). | |
SortT(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). | |
SortStable(IXYTable) |
Sort table by x-value, using a stable sort
| |
SortStableT(IListT) | ||
SortStableT(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. | |
SortStableT(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. | |
SwapT |
Swapping two elements.
| |
TryGetValueT(IDictionaryString, Object, String, T) |
Get additional data, based on key. If no data exist for value, return the defaultValue | |
TryGetValueT(IDictionaryString, Object, String, T) |
Get additional data, based on key. If value is not of type {T}, false is returned.
| |
Warning |
Add a warning message
|