GenericExtensions Class |
Namespace: DHI.Mike1D.Generic
public static class GenericExtensions
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)
| |
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
| |
FirstInMonth |
Returns the first day in a month, at time 00:00:00.
| |
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.
| |
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.
| |
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
| |
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.
| |
Warning |
Add a warning message
|