Interpolator
RhinoList<1>Exposes a set of standard numeric interpolation algorithms.
Constructors
Constructs an Interpolator from a collection of numbers.
Parameters:
| collection (IEnumerable<double>) | Collection of numbers to duplicate. |
Constructs a new Interpolator with a specified amount of numbers.
Constructs an empty Interpolator with a certain capacity.
Parameters:
| initialCapacity (int) | Number of items this interpolator can store without resizing. |
Properties
Capacity
Gets or sets the total number of elements the internal data structure can hold without resizing.
Gets or sets a value indicating whether or not the values inside this Interpolator are to be treated as cyclical (i.e. circular).
First
public T First { get; set; }
Gets or sets the first item in the list. This is synonymous to calling List[0].
Last
public T Last { get; set; }
Gets or sets the last item in the list. This is synonymous to calling List[Count-1].
NullCount
Gets the number of null references (Nothing in Visual Basic) in this list. If T is a ValueType, this property always return zero.
Indexers
Parameters:
| index (int) | The zero-based index of the element to get or set. |
Returns: The element at the specified index.
Methods
Add
public void Add(T item)
Adds an object to the end of the List.
Parameters:
| item (T) | Item to append. |
AddRange
Adds the elements of the specified collection to the end of the List.
Parameters:
| collection (IEnumerable) | The collection whose elements should be added to the end of the List. The collection itself cannot be a null reference (Nothing in Visual Basic), but it can contain elements that are a null reference (Nothing in Visual Basic). Objects in collection which cannot be represented as T will throw exceptions. |
AddRange
Adds the elements of the specified collection to the end of the List.
Parameters:
| collection (IEnumerable<T>) | The collection whose elements should be added to the end of the List. The collection itself cannot be a null reference (Nothing in Visual Basic), but it can contain elements that are a null reference (Nothing in Visual Basic), if type T is a reference type. |
Returns: A wrapper.
BinarySearch
Searches the entire sorted List for an element using the specified comparer and returns the zero-based index of the element.
Parameters:
| index (int) | The zero-based starting index of the range to search. |
| count (int) | The length of the range to search. |
| item (T) | The object to locate. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| comparer (IComparer<T>) | The IComparer(T) implementation to use when comparing elements. Or a null reference (Nothing in Visual Basic) to use the default comparer Comparer(T)::Default. |
Returns: The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.
BinarySearch
Searches the entire sorted List for an element using the specified comparer and returns the zero-based index of the element.
Parameters:
| item (T) | The object to locate. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| comparer (IComparer<T>) | The IComparer(T) implementation to use when comparing elements. Or a null reference (Nothing in Visual Basic) to use the default comparer Comparer(T)::Default. |
Returns: The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.
BinarySearch
Searches the entire sorted List for an element using the default comparer and returns the zero-based index of the element.
Parameters:
| item (T) | The object to locate. The value can be a null reference (Nothing in Visual Basic) for reference types. |
Returns: The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.
Clear
public void Clear()
Removes all elements from the List.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
Returns: true if item is found in the List; otherwise, false.
ConvertAll<TOutput>
Aggregates all results of a conversion function over this table into a new list.
Parameters:
| converter (Converter<T, TOutput>) | A conversion function that can transform from T to TOutput. |
Returns: The new list.
CopyTo
Copies a range of elements from the List to a compatible one-dimensional array, starting at the specified index of the target array.
Parameters:
| index (int) | The zero-based index in the source List at which copying begins. |
| array (T[]) | The one-dimensional Array that is the destination of the elements copied from List. The Array must have zero-based indexing. |
| arrayIndex (int) | The zero-based index in array at which copying begins. |
| count (int) | The number of elements to copy. |
CopyTo
Copies the entire List to a compatible one-dimensional array, starting at the specified index of the target array.
Parameters:
| array (T[]) | The one-dimensional Array that is the destination of the elements copied from List. The Array must have zero-based indexing. |
| arrayIndex (int) | The zero-based index in array at which copying begins. |
CopyTo
public void CopyTo(T[] array)
Copies the entire List to a compatible one-dimensional array, starting at the beginning of the target array.
Parameters:
| array (T[]) | The one-dimensional Array that is the destination of the elements copied from List. The Array must have zero-based indexing. |
Duplicate
Returns a shallow copy of this instance. If the generic type is comprised of only value types (struct, enum, ptr), then the result will be a deep copy.
Returns: The duplicated list.
Exists
Determines whether the List contains elements that match the conditions defined by the specified predicate.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the elements to search for. |
Returns: true if the List contains one or more elements that match the conditions defined by the specified predicate; otherwise, false.
Find
Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire List.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type T.
FindAll
Retrieves all the elements that match the conditions defined by the specified predicate.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the elements to search for. |
Returns: A ON_List(T) containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty ON_List(T).
FindIndex
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 that extends from the specified index to the last element.
Parameters:
| startIndex (int) | The zero-based starting index of the search. |
| count (int) | The number of elements in the section to search. |
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
FindIndex
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 entire List.
Parameters:
| startIndex (int) | The zero-based starting index of the search. |
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
FindIndex
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 entire List.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
FindLast
Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire List.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The last element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type T.
FindLastIndex
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List.
Parameters:
| startIndex (int) | The zero-based starting index of the backward search. |
| count (int) | The number of elements in the section to search. |
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
FindLastIndex
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List.
Parameters:
| startIndex (int) | The zero-based starting index of the backward search. |
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
FindLastIndex
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire List.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the element to search for. |
Returns: The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, -1.
ForEach
Performs the specified action on each element of the List.
Parameters:
| action (Action<T>) | The Action(T) delegate to perform on each element of the List. |
GetEnumerator
Constructs an enumerator that is capable of iterating over all items in this list.
Returns: The new enumerator.
GetRange
Constructs a shallow copy of a range of elements in the source List.
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List that starts at the specified index and contains the specified number of elements.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| index (int) | The zero-based starting index of the search. |
| count (int) | The number of elements in the section to search. |
Returns: The zero-based index of the first occurrence of item within the entire List, if found; otherwise, -1.
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the List that extends from the specified index to the last element.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| index (int) | The zero-based starting index of the search. |
Returns: The zero-based index of the first occurrence of item within the entire List, if found; otherwise, -1.
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire List.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
Returns: The zero-based index of the first occurrence of item within the entire List, if found; otherwise, -1.
Parameters:
| index (int) | The zero-based index at which item should be inserted. |
| item (T) | The object to insert. The value can be a null reference (Nothing in Visual Basic) for reference types. |
InsertRange
Inserts the elements of a collection into the List at the specified index.
Parameters:
| index (int) | The zero-based index at which the new elements should be inserted. |
| collection (IEnumerable<T>) | The collection whose elements should be inserted into the List. The collection itself cannot be a null reference (Nothing in Visual Basic), but it can contain elements that are a null reference (Nothing in Visual Basic), if type T is a reference type. |
Sample the list of numbers with Catmull-Rom interpolation.
Parameters:
| t (double) | Parameter to sample at. The integer portion of the parameter indicates the index of the left-hand value. If this Interpolator is cyclical, parameters will be wrapped. |
Returns: The sampled value at t.
Sample the list of numbers with cosine interpolation.
Parameters:
| t (double) | Parameter to sample at. The integer portion of the parameter indicates the index of the left-hand value. If this Interpolator is cyclical, parameters will be wrapped. |
Returns: The sampled value at t.
Sample the list of numbers with cubic interpolation.
Parameters:
| t (double) | Parameter to sample at. The integer portion of the parameter indicates the index of the left-hand value. If this Interpolator is cyclical, parameters will be wrapped. |
Returns: The sampled value at t.
Sample the list of numbers with linear interpolation.
Parameters:
| t (double) | Parameter to sample at. The integer portion of the parameter indicates the index of the left-hand value. If this Interpolator is cyclical, parameters will be wrapped. |
Returns: The sampled value at t.
Sample the list of numbers with Nearest Neighbor interpolation.
Parameters:
| t (double) | Parameter to sample at. The integer portion of the parameter indicates the index of the left-hand value. If this Interpolator is cyclical, parameters will be wrapped. |
Returns: The sampled value at t.
LastIndexOf
Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the List that contains the specified number of elements and ends at the specified index.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| index (int) | The zero-based starting index of the backward search. |
| count (int) | The number of elements in the section to search. |
Returns: The zero-based index of the last occurrence of item within the entire the List, if found; otherwise, -1.
LastIndexOf
Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the List that extends from the first element to the specified index.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
| index (int) | The zero-based starting index of the backward search. |
Returns: The zero-based index of the last occurrence of item within the entire the List, if found; otherwise, -1.
LastIndexOf
Searches for the specified object and returns the zero-based index of the last occurrence within the entire List.
Parameters:
| item (T) | The object to locate in the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
Returns: The zero-based index of the last occurrence of item within the entire the List, if found; otherwise, -1.
RemapIndex
Remap an index in the infinite range onto the List index range.
Parameters:
| index (int) | Index to remap. |
Returns: Remapped index.
Parameters:
| item (T) | The object to remove from the List. The value can be a null reference (Nothing in Visual Basic) for reference types. |
Returns: true if item is successfully removed; otherwise, false. This method also returns false if item was not found in the List.
RemoveAll
Removes the all the elements that match the conditions defined by the specified predicate.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions of the elements to remove. |
Returns: The number of elements removed from the List.
Parameters:
| index (int) | The zero-based index of the element to remove. |
RemoveNulls
Removes all elements from the List that are null references (Nothing in Visual Basic). This function will not do anything if T is not a Reference type.
Returns: The number of nulls removed from the List.
Reverse
public void Reverse()
Reverses the order of the elements in the entire List.
Reverse
Reverses the order of the elements in the specified range.
Sort
public void Sort()
Sorts the elements in the entire List using the default comparer.
Sort
Sorts the elements in the entire list using the specified comparer.
Parameters:
| comparison (Comparison<T>) | The System.Comparison(T) to use when comparing elements. |
Sort
Sort this list based on a list of numeric keys of equal length. The keys array will not be altered.
Remarks: This function does not exist on the DotNET List class. David thought it was a good idea.
Parameters:
| keys (double[]) | Numeric keys to sort with. |
Sort
Sorts the elements in the entire list using the specified System.Comparison(T)
Parameters:
| comparer (IComparer<T>) | The IComparer(T) implementation to use when comparing elements, or a null reference (Nothing in Visual Basic) to use the default comparer Comparer(T).Default. |
Sort
Sorts the elements in a range of elements in list using the specified comparer.
Sort
Sort this list based on a list of numeric keys of equal length. The keys array will not be altered.
Remarks: This function does not exist on the DotNET List class. David thought it was a good idea.
Parameters:
| keys (int[]) | Numeric keys to sort with. |
ToArray
public T[] ToArray()
Constructs an array that contains all items in this list.
Returns: An array containing all items in this list.
TrimExcess
public void TrimExcess()
Sets the capacity to the actual number of elements in the List, if that number is less than a threshold value.
Remarks: This function differs from the DotNET implementation of List<T> since that one only trims the excess if the excess exceeds 10% of the list length.
TrueForAll
Determines whether every element in the List matches the conditions defined by the specified predicate.
Parameters:
| match (Predicate<T>) | The Predicate(T) delegate that defines the conditions to check against the elements. |
Returns: true if every element in the List matches the conditions defined by the specified predicate; otherwise, false. If the list has no elements, the return value is true.