Methods
Test whether all entries in an array are equal to a given value.
Test whether all entries in an array are equal to a given value.
Tests whether all pears are null.
Returns: True if all pears are null.
Tests whether any of the pears contain meta data.
Returns: True if any pear contains meta data.
Tests whether any of the pears are null.
Returns: True if any of the pears are null.
Append a collection of items to the end of this array.
public static T[] Append<T>()
this T[]
array,
Array to modify.
params T[]
items
Items to insert.
Append an item to the end of this array.
public static T[] Append<T>()
this T[]
array,
Array to modify.
T
item
Item to insert.
Chain a set of enumerations.
Returns: Chained enumerable.
Collate all array elements that line up with true array in the map at the start of the array.
Returns: New 'length' of the array. Ie. the highest index+1 that was included in the result.
Collate all null elements in an array.
public static void CollateNulls<T>()
Gets whether a collection of pears contains any meta data.
Gets whether a collection of pears contains any meta data.
Convert an array of one type into another.
public static TQ[] Convert<T, TQ>()
Returns: Converted array.
Convert nested arrays of one type to another.
public static TQ[][] Convert<T, TQ>()
Returns: Converted arrays.
Copies specific elements from an array into another array.
public static T[] Copy<T>()
this T[]
array,
Array to copy from.
bool[]
filter
Filter, if there's a TRUE the element will be copied. Filter may not be longer than array.
Returns: Array with copied elements.
Copy the first N items from one array to the start of another.
public static void CopyFirstItems<T>()
this T[]
source,
Array to copy from.
T[]
target,
Array to copy to.
n
Number of items, must be less than or equal to the shortest array.
Copy the last N items from one array to the end of another.
public static void CopyLastItems<T>()
this T[]
source,
Array to copy from.
T[]
target,
Array to copy to.
n
Number of items, must be less than or equal to the shortest array.
Guess the length of a collection. If the type cannot be quickly resolved, a default value is returned.
public static int CountOrDefault<T>()
enumerable,
Collection to inspect.
defaultCount
Default count if collection cannot be easily inspected.
Returns: Length or default.
Create<T>
#Create a one dimensional array from a collection of values and inclusion flags.
public static T[] Create<T>()
Returns: Array containing only include=true elements.
Create<T>
#Create a one dimensional array.
public static T[] Create<T>()
Returns: One-dimensional array.
Create<T>
#Create a four dimensional, nested array.
public static T[][][][] Create<T>()
T
initialValue,
Initial value to assign to each element.
width,
Width, or length of top level array.
height,
Height, or length of all primary nested arrays.
depth,
Depth, or length of all secondary nested arrays.
plonk
Plonk (ie. four-dimensional depth), or length of all tertiary nested arrays.
Returns: Four-dimensional array.
Convert a collection of elements into a set with valence tracking.
public static void CreatePluralityMap<T>()
collection,
Collection to parse.
equality,
Equality comparer.
out T[]
map,
Resulting array of unique array.
valence
Valence map for each value.
Returns: Number of remaining unique array.
Convert a collection of elements into a set with valence tracking.
public static void CreatePluralityMap<T>()
collection,
Collection to parse.
out T[]
map,
Resulting array of unique array.
valence
Valence map for each value.
Returns: Number of remaining unique array.
Apply a culling pattern to an array.
public static T[] Cull<T>()
Returns: Culled array.
Clone a jagged array.
public static T[] Duplicate<T>()
this T[]
array
Jagged array to clone.
Returns: Cloned jagged array.
Clone a jagged array.
public static T[][] Duplicate<T>()
this T[][]
array
Jagged array to clone.
Returns: Cloned jagged array.
Clone a multiply jagged array.
public static T[][][] Duplicate<T>()
this T[][][]
array
Jagged array to clone.
Returns: Cloned jagged array.
Compare two string arrays.
Returns: True if both arrays contain the same strings in the same order.
Perform an entrywise equality test on two arrays.
Returns: True if all elements are equal.
Perform an entrywise equality test on two arrays.
Returns: True if all elements are equal.
Expand an array.
public static T[] ExpandArray<T>()
Returns: Expanded array, or same array if it cannot be expanded.
Expand an array.
public static T[] ExpandArray<T>()
this T[]
array,
Array to expand.
oldCount,
Count of existing array, you can specify a value lower than array.Length to ignore a portion of the array.
newCount,
Target count.
method
Expansion method.
Returns: Expanded array, or same array if it cannot be expanded.
Find the index of the first interval which contains the given value.
Find the first local maximum in an array of doubles.
Returns: Index of first maximum or -1.
Find the first local maximum in an array of doubles.
Returns: Index of first maximum or -1.
Find the first local maximum in an array of doubles.
Returns: Index of first maximum or -1.
Find the first local maximum in an array of integers.
Returns: Index of first maximum or -1.
Find the first local maximum in an array of integers.
Returns: Index of first maximum or -1.
Find the first local maximum in an array of integers.
Returns: Index of first maximum or -1.
Find the first local minimum in an array of doubles.
Returns: Index of first minimum or -1.
Find the first local minimum in an array of doubles.
Returns: Index of first minimum or -1.
Find the first local minimum in an array of doubles.
Returns: Index of first minimum or -1.
Find the first local minimum in an array of integers.
Returns: Index of first minimum or -1.
Find the first local minimum in an array of integers.
Returns: Index of first minimum or -1.
Find the first local minimum in an array of integers.
Returns: Index of first minimum or -1.
Find the first range that passes the predicate.
Returns: True if a range was found.
Find the first range that passes the predicate.
Returns: True if a range was found.
Return the first index within the array where a specific predicate returns true.
Returns: Index within array or -1 if value is not found.
Return the first index within the array where a specific predicate returns true.
Returns: Index within array or -1 if value is not found.
Return the first index within the array where a specific value can be found.
Returns: Index within array or -1 if value is not found.
Return the first index within the array where a specific value can be found.
Returns: Index within array or -1 if value is not found.
Flip a two-dimensional, rectangular nested array.
public static T[][] Flip<T>()
this T[][]
array
Array to flip. All secondary arrays must be the same length.
Returns: Flipped array.
Enumerate over an array in a backwards fashion (from the highest to the lowest index).
Enumerate over an array in a forwards fashion (from the lowest to the highest index).
Format an array.
Format a two-dimensional jagged array.
Returns: Format showing array as a table.
Perform an inverse transform sampling on an array of increasing doubles. This means treat the array as a polyline and intersect it with a horizontal ray whose y-value is constant. If the array is not strictly increasing, the results of this method cannot be relied upon.
Returns: True if an intersection was found.
Finds the first occurrence of an array within another array.
Returns: The index of the first occurrence of the pattern array within the source array, or -1 if the pattern is not found or if either array is null or empty.
Inject an item into the array. All items starting at the index will be moved one position to the right. The last item will disappear. This method differs from Insert in that Inject does not change the array size, nor does it create a second, modified array.
public static void Inject<T>()
Insert a collection of items into this array.
public static T[] Insert<T>()
Insert an item into this array.
public static T[] Insert<T>()
Test an array for null-ness of empty-ness.
Gets whether the array instance is null or empty.
Returns: True if array is either null or empty.
Gets whether the array instance is null, empty, or contains only null items.
Returns: True if array is either null, empty or blank.
Gets the item at a cyclical index.
Returns: Item at cyclical index.
Sets the item at a cyclical index.
Apply a culling pattern to an array.
public static T[] Keep<T>()
Returns: Culled array.
Gets the last item in an array.
public static T Last<T>()
this T[]
array
Array to query.
Returns: Last item in array.
Return the last index within the array where a specific value can be found.
Returns: Index within array or -1 if value is not found.
Return the last index within the array where a specific value can be found.
Returns: Index within array or -1 if value is not found.
Map an index specified within a expanded collection to the appropriate index in the unexpanded collection.
public static int Map()
this ExpandMethod
method,
Shrinking method context.
unexpandedCount,
Length of unexpanded collection.
expandedCount,
Length of expanded collection.
expandedIndex
Index into expanded collection.
Returns: Index in unexpanded collection or -1 if not a valid mapping.
Map an index specified within a shrunk collection to the appropriate index in the unshrunk collection.
public static int Map()
this ShrinkMethod
method,
Shrinking method context.
unshrunkCount,
Length of unshrunk collection.
shrunkCount,
Length of shrunk collection.
shrunkIndex
Index into shrunk collection.
Returns: Index in unshrunk collection or -1 if not a valid mapping.
Count the number of meta data entries. An entry with zero key-value fields does not count towards the total.
Gets the most derived type constraint required to store all the elements in the array.
Returns: Tightest possible type of array which could still contain all elements in array.
Invert all array in a boolean array.
Returns: Negated array.
Tests whether none of the pears are null.
Returns: True if none of the pears are null.
Normalise all values in an array so they sum to a specific value.
Returns: True on success, false on failure.
Normalise all values in an array so they sum to 1.
Returns: True on success, false on failure.
Normalise all values in a nested array so they sum up to a specific value.
Returns: True on success, false on failure.
Normalise all values in a nested array so they sum up to 1.
Returns: True on success, false on failure.
Normalise all array in an array so they sum to a specific value.
Returns: True on success, false on failure.
Normalise all array in an array so they sum to 1.
Returns: True on success, false on failure.
Normalise all values in a nested array so they sum up to a specific value.
Returns: True on success, false on failure.
Normalise all values in a nested array so they sum up to 1.
Returns: True on success, false on failure.
Returns a null reference if the array contains only null array. Otherwise returns the same array.
public static T[] NullIfEmpty<T>()
this T[]
array
Array to inspect.
Returns: Either array or null.
Compute the hash for an array of values, taking into account ordering. I.e. the hash for {0, 1, 2} will be different than the hash for {0, 2, 1}.
Pad an array on the left side (before the first index) until it has a specific length. This method will not reduce the length of an array if it is already longer than the target length. If the array need not be modified the same instance is returned.
public static T[] PadLeft<T>()
Returns: Padded array.
Pad an array on the right side (after the last index) until it has a specific length. This method will not reduce the length of an array if it is already longer than the target length. If the array need not be modified the same instance is returned.
public static T[] PadRight<T>()
Returns: Padded array.
Remove the last item from an array.
public static T[] Pop<T>()
this T[]
array
Array to modify.
Returns: Popped array.
Remove the first item from an array.
public static T[] PopFirst<T>()
this T[]
array
Array to modify.
Returns: Popped array.
Process<T>
#Apply a function to an enumeration.
Returns: Processed enumeration.
Append a collection of items to the end of an array.
public static T[] Push<T>()
this T[]
array,
Array to modify.
params T[]
items
Items to add.
Returns: New array with added item.
Append an item to the end of an array.
public static T[] Push<T>()
this T[]
array,
Array to modify.
T
item
Item to add.
Returns: New array with added item.
Push an item into the first position of an array.
public static T[] PushFirst<T>()
this T[]
array,
Array to modify.
T
item
Item to push.
Returns: New array with added item.
Gets a random item out of this array.
Returns: Ranodm item.
Remove specific items from an array.
public static T[] RemoveAll<T>()
this T[]
array,
Array to operate on.
predicate
Removal predicate, must return true when an item is to be removed.
Returns: Array with all specific items removed.
Remove all instances from an array.
public static T[] RemoveAll<T>()
this T[]
array,
Array to operate on.
T
item
Items to remove.
Returns: Array with all instances of item removed.
Remove a specific element from an array.
Returns: Modified array.
Remove all duplicate array elements using a custom comparer.
Returns: Array containing only unique array elements.
Remove all duplicate array elements using a custom comparer.
public static T[] RemoveDuplicates<T>()
Returns: Array containing only unique array elements.
Remove all duplicate array elements using the standard comparer.
public static T[] RemoveDuplicates<T>()
this T[]
array
Array to simplify.
Returns: Array containing only unique array elements.
Remove a range of items from an array.
Returns: Modified array.
Apply a minimal, stable reordering to an array based on an ordering constraint. Do note that this method replaces values in the array with values in the keys, so this should only be used when that swap doesn't matter.
public static void ReorderByKey<T>()
this T[]
array,
Array to reorder.
T[]
keys
Order constraint for (some) items in array.
Replace the first occurance of a value within an array with another one.
public static T[] ReplaceFirst<T>()
this T[]
array,
T
search,
T
replace
Replace the last occurance of a value within an array with another one.
public static T[] ReplaceLast<T>()
this T[]
array,
T
search,
T
replace
Replaces all occurrences of a Guid pattern within a source array with a single replacement Guid.
Returns: A new array with all pattern occurrences replaced with the specified Guid, or the original array if no replacements were made or if any array is null or empty.
Replace all array in an array of doubles that fall inside any of the domains with a different value. This method is significantly faster than checking each element against each domain, but it does require the array of doubles is already sorted.
Create a reversed copy of an array.
public static T[] Reverse<T>()
this T[]
array
Array.
Returns: Reversed copy.
Checks whether all access flags are of a single kind.
Returns: True if all access flags are identical.
Set a range of array of an array to a specific value.
Set all array of an array to a specific value.
public static void SetAll<T>()
this T[]
array,
Array to modify.
T
value
Value to assign to each element.
Set the first and last elements in an array simultaneously.
public static void SetFirstAndLast<T>()
this T[]
array,
T
first,
T
last
Shrink an array.
public static T[] ShrinkArray<T>()
Returns: Shrunk array, or same array if it cannot be shrunk.
Shrink an array.
public static T[] ShrinkArray<T>()
this T[]
array,
Array to shrink.
oldCount,
Count of existing array, you can specify a value lower than array.Length to ignore a portion of the array.
newCount,
Target count.
method
Shrinking method.
Returns: Shrunk array, or same array if it cannot be shrunk.
Slice the array between two indices. I.e. extract the sub-array limited by the indices.
Sort all intervals in an array from left to right and merge overlapping intervals.
Returns: Sorted and merged array. The returned array may be the same array, if no modifications were made.
Sort an array and create a sorting map using a default comparer.
Returns: Sorted array.
Sort an array and create a sorting map using a default comparer.
Returns: Sorted array.
Create a sorting map for an array with a null-mask array.
Perform a count sort using integers as keys. CountSort (unlike QuickSort or IntrospectiveSort as used by the .NET framework) is stable, meaning the order of the input items is preserved in case of identical keys. It is however slower than QuickSort and doesn't like big or negative key array.
Perform a topological sort on an array.
Returns: Sorted array.
Perform a topological sort on an array.
Returns: Sorted array.
Stack up the elements until the array is filled up.
public static void Stack<T>()
this T[]
array,
Array to fill up.
params T[][]
elements
Stacking elements.
Sum all elements in a collection.
Sum all elements in a collection.
Sum all elements in a collection.
Swap two items in an array.
Convert a double[] into a byte[].
Returns: Byte array.
Convert a float[] into a byte[].
Returns: Byte array.
Convert an int[] into a byte[].
Returns: Byte array.
Convert a long[] into a byte[].
Returns: Byte array.
Convert an array of SpatialVector array into an xyz coordinate array.
Returns: Coordinate array.
Convert an array of Point2d array into an xy coordinate array.
Returns: Coordinate array.
Convert an array of Point3d array into an xyz coordinate array.
Returns: Coordinate array.
Convert an array of Vector3d array into an xyz coordinate array.
Returns: Coordinate array.
Convert a byte[] into a double[].
Returns: Array.
Convert a byte[] into a float[].
Returns: Array.
Create a byte array containing all the hashcodes of a collection of objects.
Returns: Byte array.
Convert a byte[] into an int[].
Returns: Array.
Create an item array from a pear array.
Returns: Array of items.
Convert a byte[] into a long[].
Returns: Array.
Create a meta array from a pear array.
Returns: Array of meta data.
Create a null array from a pear array.
Returns: Array of nulls.
Convert an array of sequential xy coordinates into a Point2d array.
Returns: Point array.
Convert an array of sequential xyz coordinates into a Point3d array.
Returns: Point array.
Convert an array of sequential xyz coordinates into a SpatialVector array.
Returns: Vector array.
Create a type array from a pear array.
Returns: Array of types.
Convert an array of sequential xyz coordinates into a Vector3d array.
Returns: Vector array.
Resize an array to contain all items until a specific value.
public static T[] Trim<T>()
this T[]
array,
Array to resize.
T
trimmingValue
Value to trim at.
Returns: Trimmed array.
Compute the hash for an array of array, not taking into account ordering. I.e. the hash for {0, 1, 2} will be the same as the hash for {0, 2, 1}.
Withdraw an item from the array. All items to the right of the index will be moved one position to the left. This method differs from RemoveAt in that Withdraw does not change the array size, nor does it create a second, modified array.
Wrap an IEnumerable into another IEbumerable of a different type.