Class ListUtil
- Namespace
- Hi.Common.Collections
- Assembly
- HiGeom.dll
Provides utility methods for working with lists and collections.
public static class ListUtil
- Inheritance
-
ListUtil
- Inherited Members
Methods
GetCeilIndex<Item, ItemKey>(IList<Item>, ItemKey, Func<Item, ItemKey, int>, out int)
Gets the ceiling index of an item in a sorted list based on a key comparison.
public static BinarySearchResult GetCeilIndex<Item, ItemKey>(this IList<Item> sortedItems, ItemKey key, Func<Item, ItemKey, int> comparingFunc, out int index)
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyItemKeyThe key to search for.
comparingFuncFunc<Item, ItemKey, int>A function that compares an item to the key.
indexintWhen this method returns, contains the index of the ceiling item if found; otherwise, -1.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
ItemThe type of items in the list.
ItemKeyThe type of the key to search for.
GetCeilIndex<TKey, Item>(IList<Item>, TKey, Func<Item, TKey>, out int)
Gets the ceiling index of an item in a sorted list based on a key selector function.
public static BinarySearchResult GetCeilIndex<TKey, Item>(this IList<Item> sortedItems, TKey keyQuantity, Func<Item, TKey> getKeyQuantityFunc, out int index) where TKey : IComparable<TKey>
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyQuantityTKeyThe key to search for.
getKeyQuantityFuncFunc<Item, TKey>A function that extracts the key from an item.
indexintWhen this method returns, contains the index of the ceiling item if found; otherwise, -1.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
TKeyThe type of the key.
ItemThe type of items in the list.
GetCeil<TKey, Item>(IList<Item>, TKey, Func<Item, TKey>, out Item)
Gets the ceiling item in a sorted list based on a key selector function.
public static BinarySearchResult GetCeil<TKey, Item>(this IList<Item> sortedItems, TKey keyQuantity, Func<Item, TKey> getKeyQuantityFunc, out Item dst) where TKey : IComparable<TKey>
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyQuantityTKeyThe key to search for.
getKeyQuantityFuncFunc<Item, TKey>A function that extracts the key from an item.
dstItemWhen this method returns, contains the ceiling item if found; otherwise, the default value for the type.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
TKeyThe type of the key.
ItemThe type of items in the list.
GetFloorIndex<Item, ItemKey>(IList<Item>, ItemKey, Func<Item, ItemKey, int>, out int)
Gets the floor index of an item in a sorted list based on a key comparison.
public static BinarySearchResult GetFloorIndex<Item, ItemKey>(this IList<Item> sortedItems, ItemKey key, Func<Item, ItemKey, int> comparingFunc, out int index)
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyItemKeyThe key to search for.
comparingFuncFunc<Item, ItemKey, int>A function that compares an item to the key.
indexintWhen this method returns, contains the index of the floor item if found; otherwise, -1.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
ItemThe type of items in the list.
ItemKeyThe type of the key to search for.
GetFloorIndex<TKey, Item>(IList<Item>, TKey, Func<Item, TKey>, out int)
Gets the floor index of an item in a sorted list based on a key selector function.
public static BinarySearchResult GetFloorIndex<TKey, Item>(this IList<Item> sortedItems, TKey key, Func<Item, TKey> getKeyFunc, out int index) where TKey : IComparable<TKey>
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyTKeyThe key to search for.
getKeyFuncFunc<Item, TKey>A function that extracts the key from an item.
indexintWhen this method returns, contains the index of the floor item if found; otherwise, -1.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
TKeyThe type of the key.
ItemThe type of items in the list.
GetFloor<TKey, Item>(IList<Item>, TKey, Func<Item, TKey>, out Item)
Gets the floor item in a sorted list based on a key selector function.
public static BinarySearchResult GetFloor<TKey, Item>(this IList<Item> sortedItems, TKey keyQuantity, Func<Item, TKey> getKeyQuantityFunc, out Item dst) where TKey : IComparable<TKey>
Parameters
sortedItemsIList<Item>The sorted list to search in.
keyQuantityTKeyThe key to search for.
getKeyQuantityFuncFunc<Item, TKey>A function that extracts the key from an item.
dstItemWhen this method returns, contains the floor item if found; otherwise, the default value for the type.
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search.
Type Parameters
TKeyThe type of the key.
ItemThe type of items in the list.
GetIndexBasedEnumerable<TItem>(IList<TItem>)
Creates an enumerable that provides access to all elements in a list by index.
public static ListIndexBasedEnumerable<TItem> GetIndexBasedEnumerable<TItem>(this IList<TItem> src)
Parameters
srcIList<TItem>The source list
Returns
- ListIndexBasedEnumerable<TItem>
A ListIndexBasedEnumerable for the entire list
Type Parameters
TItemThe type of elements in the list
GetIndexBasedEnumerable<TItem>(IList<TItem>, int, int)
Creates an enumerable that provides access to a range of elements in a list by index.
public static ListIndexBasedEnumerable<TItem> GetIndexBasedEnumerable<TItem>(this IList<TItem> src, int begin, int end)
Parameters
srcIList<TItem>The source list
beginintThe starting index (inclusive)
endintThe ending index (exclusive)
Returns
- ListIndexBasedEnumerable<TItem>
A ListIndexBasedEnumerable for the specified range
Type Parameters
TItemThe type of elements in the list
GetIndexByBinarySearch<TItem>(IList<TItem>, TItem)
Performs a binary search on the specified collection.
public static int GetIndexByBinarySearch<TItem>(this IList<TItem> sortedItems, TItem value)
Parameters
sortedItemsIList<TItem>The list to be searched.
valueTItemThe value to search for.
Returns
Type Parameters
TItemThe type of the item.
GetIndexByBinarySearch<TItem>(IList<TItem>, TItem, IComparer<TItem>)
Performs a binary search on the specified collection.
public static int GetIndexByBinarySearch<TItem>(this IList<TItem> sortedItems, TItem value, IComparer<TItem> comparer)
Parameters
sortedItemsIList<TItem>The list to be searched.
valueTItemThe value to search for.
comparerIComparer<TItem>The comparer that is used to compare the value with the list items.
Returns
Type Parameters
TItemThe type of the item.
GetIndexByBinarySearch<TItem, TSearch>(IList<TItem>, TSearch, Func<TSearch, TItem, int>)
Performs a binary search on the specified collection.
public static int GetIndexByBinarySearch<TItem, TSearch>(this IList<TItem> sortedItems, TSearch value, Func<TSearch, TItem, int> comparer)
Parameters
sortedItemsIList<TItem>The list to be searched.
valueTSearchThe value to search for.
comparerFunc<TSearch, TItem, int>The comparer that is used to compare the value with the list items.
Returns
Type Parameters
TItemThe type of the item.
TSearchThe type of the searched item.
GetInterpolatedBoundary<TItem>(List<TItem>, double, double, Func<TItem, double>, out TItem, out TItem, out TItem)
Gets interpolated boundary items from a list based on a key value and interval.
public static void GetInterpolatedBoundary<TItem>(this List<TItem> scpList, double z, double zInterval, Func<TItem, double> keyFunc, out TItem cur, out TItem floor, out TItem ceil) where TItem : IAdditionOperators<TItem, TItem, TItem>, IMultiplyOperators<TItem, double, TItem>
Parameters
scpListList<TItem>The source list.
zdoubleThe key value to find or interpolate at.
zIntervaldoubleThe interval to consider around the key value.
keyFuncFunc<TItem, double>A function that extracts the key from an item.
curTItemWhen this method returns, contains the interpolated item at the key value.
floorTItemWhen this method returns, contains the floor item.
ceilTItemWhen this method returns, contains the ceiling item.
Type Parameters
TItemThe type of items in the list, which must support addition and multiplication operators.
GetInterpolatedValue<TItem>(List<TItem>, double, Func<TItem, double>, OuterPolationMode)
Gets an interpolated value from a sorted list based on a double key, using operators for addition and multiplication.
public static TItem GetInterpolatedValue<TItem>(this List<TItem> sortedItems, double keyQuantity, Func<TItem, double> getKeyQuantityFunc, ListUtil.OuterPolationMode outerPolationMode) where TItem : IAdditionOperators<TItem, TItem, TItem>, IMultiplyOperators<TItem, double, TItem>
Parameters
sortedItemsList<TItem>The sorted list to interpolate from.
keyQuantitydoubleThe key to find or interpolate at.
getKeyQuantityFuncFunc<TItem, double>A function that extracts the key from an item.
outerPolationModeListUtil.OuterPolationModeThe mode to use when the key is outside the range of the list.
Returns
- TItem
The interpolated value.
Type Parameters
TItemThe type of items in the list, which must support addition and multiplication operators.
GetInterpolatedValue<TItem>(List<TItem>, double, Func<TItem, double>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>, OuterPolationMode)
Gets an interpolated value from a sorted list based on a double key.
public static TItem GetInterpolatedValue<TItem>(this List<TItem> sortedItems, double key, Func<TItem, double> getKeyFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc, ListUtil.OuterPolationMode outerPolationMode)
Parameters
sortedItemsList<TItem>The sorted list to interpolate from.
keydoubleThe key to find or interpolate at.
getKeyFuncFunc<TItem, double>A function that extracts the key from an item.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
outerPolationModeListUtil.OuterPolationModeThe mode to use when the key is outside the range of the list.
Returns
- TItem
The interpolated value.
Type Parameters
TItemThe type of items in the list.
GetInterpolatedValue<TItem>(List<TItem>, TimeSpan, Func<TItem, TimeSpan>, OuterPolationMode)
Gets an interpolated value from a sorted list based on a TimeSpan key, using operators for addition and multiplication.
public static TItem GetInterpolatedValue<TItem>(this List<TItem> sortedItems, TimeSpan keyQuantity, Func<TItem, TimeSpan> getKeyQuantityFunc, ListUtil.OuterPolationMode outerPolationMode) where TItem : IAdditionOperators<TItem, TItem, TItem>, IMultiplyOperators<TItem, double, TItem>
Parameters
sortedItemsList<TItem>The sorted list to interpolate from.
keyQuantityTimeSpanThe TimeSpan key to find or interpolate at.
getKeyQuantityFuncFunc<TItem, TimeSpan>A function that extracts the TimeSpan key from an item.
outerPolationModeListUtil.OuterPolationModeThe mode to use when the key is outside the range of the list.
Returns
- TItem
The interpolated value.
Type Parameters
TItemThe type of items in the list, which must support addition and multiplication operators.
GetInterpolatedValue<TItem>(List<TItem>, TimeSpan, Func<TItem, TimeSpan>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>, OuterPolationMode)
Gets an interpolated value from a sorted list based on a TimeSpan key.
public static TItem GetInterpolatedValue<TItem>(this List<TItem> sortedItems, TimeSpan key, Func<TItem, TimeSpan> getKeyFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc, ListUtil.OuterPolationMode outerPolationMode)
Parameters
sortedItemsList<TItem>The sorted list to interpolate from.
keyTimeSpanThe TimeSpan key to find or interpolate at.
getKeyFuncFunc<TItem, TimeSpan>A function that extracts the TimeSpan key from an item.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
outerPolationModeListUtil.OuterPolationModeThe mode to use when the key is outside the range of the list.
Returns
- TItem
The interpolated value.
Type Parameters
TItemThe type of items in the list.
GetInterpolatedValue<TKey, TItem>(List<TItem>, TKey, Func<TItem, TKey>, Func<TKey, TKey, int>, Func<TKey, TKey, TKey>, Func<TKey, TKey, double>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>, OuterPolationMode)
Gets an interpolated value from a sorted list based on a key using custom comparison and arithmetic functions.
public static TItem GetInterpolatedValue<TKey, TItem>(this List<TItem> sortedItems, TKey key, Func<TItem, TKey> getKeyFunc, Func<TKey, TKey, int> keyCompareFunc, Func<TKey, TKey, TKey> keyMinusFunc, Func<TKey, TKey, double> keyDivFunc, Func<TItem, TItem, TItem> addingFunc, Func<TItem, double, TItem> scalingFunc, ListUtil.OuterPolationMode outerPolationMode)
Parameters
sortedItemsList<TItem>The sorted list of items
keyTKeyThe key to search for
getKeyFuncFunc<TItem, TKey>A function that extracts the key from an item
keyCompareFuncFunc<TKey, TKey, int>A function that compares two keys
keyMinusFuncFunc<TKey, TKey, TKey>A function that subtracts one key from another
keyDivFuncFunc<TKey, TKey, double>A function that divides one key by another
addingFuncFunc<TItem, TItem, TItem>A function that adds two items
scalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor
outerPolationModeListUtil.OuterPolationModeThe mode for handling values outside the range
Returns
- TItem
The interpolated value
Type Parameters
TKeyThe type of the key
TItemThe type of elements in the list
GetListByKeyBoundary<TKey, TItem>(List<TItem>, Func<TItem, TKey>, TKey, bool, TKey, bool)
Gets a subset of a sorted list based on key boundaries.
public static List<TItem> GetListByKeyBoundary<TKey, TItem>(this List<TItem> sortedItems, Func<TItem, TKey> getKeyQuantityFunc, TKey begin, bool isIncludingBeginFloor, TKey end, bool isIncludingEndCeil) where TKey : IComparable<TKey>
Parameters
sortedItemsList<TItem>The sorted list to filter.
getKeyQuantityFuncFunc<TItem, TKey>A function that extracts the key from an item.
beginTKeyThe beginning key of the range.
isIncludingBeginFloorboolWhether to include the floor of the beginning key.
endTKeyThe ending key of the range.
isIncludingEndCeilboolWhether to include the ceiling of the ending key.
Returns
- List<TItem>
A new list containing only the items within the specified key range.
Type Parameters
TKeyThe type of the key, which must be comparable.
TItemThe type of items in the list.
GetNearestIndex<TItem, TItemKey>(IList<TItem>, TItemKey, Func<TItem, TItemKey, double>, out int)
Finds the index of the element in a sorted list that is nearest to the specified key.
public static BinarySearchResult GetNearestIndex<TItem, TItemKey>(this IList<TItem> src, TItemKey key, Func<TItem, TItemKey, double> itemToKeyDistanceFunc, out int index)
Parameters
srcIList<TItem>The source list
keyTItemKeyThe key to search for
itemToKeyDistanceFuncFunc<TItem, TItemKey, double>A function that calculates the distance between an item and the key
indexintWhen this method returns, contains the index of the nearest element if found; otherwise, -1
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search
Type Parameters
TItemThe type of elements in the list
TItemKeyThe type of the key to search for
GetNearestIndex<TItem, TItemKey>(IList<TItem>, TItemKey, Func<TItem, TItemKey, int>, Func<TItem, TItemKey, double>, out int)
Finds the index of the element in a sorted list that is nearest to the specified key using custom comparison functions.
public static BinarySearchResult GetNearestIndex<TItem, TItemKey>(this IList<TItem> src, TItemKey key, Func<TItem, TItemKey, int> itemCompareToKeyFunc, Func<TItem, TItemKey, double> itemToKeyDistanceFunc, out int index)
Parameters
srcIList<TItem>The source list (must be in ascending order)
keyTItemKeyThe key to search for
itemCompareToKeyFuncFunc<TItem, TItemKey, int>A function that compares an item to the key
itemToKeyDistanceFuncFunc<TItem, TItemKey, double>A function that calculates the distance between an item and the key
indexintWhen this method returns, contains the index of the nearest element if found; otherwise, -1
Returns
- BinarySearchResult
A BinarySearchResult indicating the result of the search
Type Parameters
TItemThe type of elements in the list
TItemKeyThe type of the key to search for
Exceptions
- InvalidProgramException
Thrown when an unexpected search result occurs
GetSubListWithInterpolatedHeadAndTail<TItem>(List<TItem>, double, double, Func<TItem, double>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with interpolated head and tail items based on the specified double key range.
public static List<TItem> GetSubListWithInterpolatedHeadAndTail<TItem>(this List<TItem> src, double beginKey, double endKey, Func<TItem, double> getKeyFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc)
Parameters
srcList<TItem>The source list.
beginKeydoubleThe beginning key of the range.
endKeydoubleThe ending key of the range.
getKeyFuncFunc<TItem, double>A function that extracts the double key from an item.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with interpolated head and tail items.
Type Parameters
TItemThe type of items in the list.
GetSubListWithInterpolatedHeadAndTail<TItem>(List<TItem>, TimeSpan, TimeSpan, Func<TItem, TimeSpan>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with interpolated head and tail items based on the specified TimeSpan key range.
public static List<TItem> GetSubListWithInterpolatedHeadAndTail<TItem>(this List<TItem> src, TimeSpan beginKey, TimeSpan endKey, Func<TItem, TimeSpan> getKeyFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc)
Parameters
srcList<TItem>The source list.
beginKeyTimeSpanThe beginning TimeSpan key of the range.
endKeyTimeSpanThe ending TimeSpan key of the range.
getKeyFuncFunc<TItem, TimeSpan>A function that extracts the TimeSpan key from an item.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with interpolated head and tail items.
Type Parameters
TItemThe type of items in the list.
GetSubListWithInterpolatedHeadAndTail<TKey, TItem>(List<TItem>, TKey, TKey, Func<TItem, TKey>, Func<TKey, TKey, int>, Func<TKey, TKey, TKey>, Func<TKey, TKey, double>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with interpolated head and tail items based on the specified key range.
public static List<TItem> GetSubListWithInterpolatedHeadAndTail<TKey, TItem>(this List<TItem> src, TKey beginKey, TKey endKey, Func<TItem, TKey> getKeyFunc, Func<TKey, TKey, int> keyCompareFunc, Func<TKey, TKey, TKey> keyMinusFunc, Func<TKey, TKey, double> keyDivFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc)
Parameters
srcList<TItem>The source list.
beginKeyTKeyThe beginning key of the range.
endKeyTKeyThe ending key of the range.
getKeyFuncFunc<TItem, TKey>A function that extracts the key from an item.
keyCompareFuncFunc<TKey, TKey, int>A function that compares two keys.
keyMinusFuncFunc<TKey, TKey, TKey>A function that subtracts one key from another.
keyDivFuncFunc<TKey, TKey, double>A function that divides one key by another to get a ratio.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with interpolated head and tail items.
Type Parameters
TKeyThe type of the key.
TItemThe type of items in the list.
GetSubListWithInterpolatedTail<TItem>(List<TItem>, TimeSpan, Func<TItem, TimeSpan>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with an interpolated tail item based on the specified TimeSpan key.
public static List<TItem> GetSubListWithInterpolatedTail<TItem>(this List<TItem> src, TimeSpan endKey, Func<TItem, TimeSpan> getKeyFunc, Func<TItem, TItem, TItem> addingFunc, Func<TItem, double, TItem> scalingFunc)
Parameters
srcList<TItem>The source list.
endKeyTimeSpanThe ending TimeSpan key for interpolation.
getKeyFuncFunc<TItem, TimeSpan>A function that extracts the TimeSpan key from an item.
addingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
scalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with an interpolated tail item.
Type Parameters
TItemThe type of items in the list.
GetSubListWithInterpolatedTail<TKey, TItem>(List<TItem>, TKey, Func<TItem, TKey>)
Creates a new list with an interpolated tail item based on the specified key, using operators for both key and item operations.
public static List<TItem> GetSubListWithInterpolatedTail<TKey, TItem>(this List<TItem> src, TKey endKey, Func<TItem, TKey> getKeyFunc) where TKey : IComparable<TKey>, ISubtractionOperators<TKey, TKey, TKey>, IDivisionOperators<TKey, TKey, double> where TItem : IAdditionOperators<TItem, TItem, TItem>, IMultiplyOperators<TItem, double, TItem>
Parameters
srcList<TItem>The source list.
endKeyTKeyThe ending key for interpolation.
getKeyFuncFunc<TItem, TKey>A function that extracts the key from an item.
Returns
- List<TItem>
A new list with an interpolated tail item.
Type Parameters
TKeyThe type of the key, which must support comparison, subtraction, and division operators.
TItemThe type of items in the list, which must support addition and multiplication operators.
GetSubListWithInterpolatedTail<TKey, TItem>(List<TItem>, TKey, Func<TItem, TKey>, Func<TKey, TKey, int>, Func<TKey, TKey, TKey>, Func<TKey, TKey, double>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with an interpolated tail item based on the specified key.
public static List<TItem> GetSubListWithInterpolatedTail<TKey, TItem>(this List<TItem> src, TKey endKey, Func<TItem, TKey> getKeyFunc, Func<TKey, TKey, int> keyCompareFunc, Func<TKey, TKey, TKey> keyMinusFunc, Func<TKey, TKey, double> keyDivFunc, Func<TItem, TItem, TItem> itemAddingFunc, Func<TItem, double, TItem> itemScalingFunc)
Parameters
srcList<TItem>The source list.
endKeyTKeyThe ending key for interpolation.
getKeyFuncFunc<TItem, TKey>A function that extracts the key from an item.
keyCompareFuncFunc<TKey, TKey, int>A function that compares two keys.
keyMinusFuncFunc<TKey, TKey, TKey>A function that subtracts one key from another.
keyDivFuncFunc<TKey, TKey, double>A function that divides one key by another to get a ratio.
itemAddingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
itemScalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with an interpolated tail item.
Type Parameters
TKeyThe type of the key.
TItemThe type of items in the list.
GetSubListWithInterpolatedTail<TKey, TItem>(List<TItem>, TKey, Func<TItem, TKey>, Func<TItem, TItem, TItem>, Func<TItem, double, TItem>)
Creates a new list with an interpolated tail item based on the specified key, using operators for key operations.
public static List<TItem> GetSubListWithInterpolatedTail<TKey, TItem>(this List<TItem> src, TKey endKey, Func<TItem, TKey> getKeyFunc, Func<TItem, TItem, TItem> addingFunc, Func<TItem, double, TItem> scalingFunc) where TKey : IComparable<TKey>, ISubtractionOperators<TKey, TKey, TKey>, IDivisionOperators<TKey, TKey, double>
Parameters
srcList<TItem>The source list.
endKeyTKeyThe ending key for interpolation.
getKeyFuncFunc<TItem, TKey>A function that extracts the key from an item.
addingFuncFunc<TItem, TItem, TItem>A function that adds two items together.
scalingFuncFunc<TItem, double, TItem>A function that scales an item by a factor.
Returns
- List<TItem>
A new list with an interpolated tail item.
Type Parameters
TKeyThe type of the key, which must support comparison, subtraction, and division operators.
TItemThe type of items in the list.
Swap<TItem>(IList<TItem>, int, int)
Swaps two elements in a list at the specified indices.
public static void Swap<TItem>(this IList<TItem> src, int indexA, int indexB)
Parameters
srcIList<TItem>The source list
indexAintThe index of the first element to swap
indexBintThe index of the second element to swap
Type Parameters
TItemThe type of elements in the list
TestFloorCeil()
Tests the floor and ceiling functionality with sample data.
public static void TestFloorCeil()