ArrayEx

public static class ArrayEx
Extension methods for T[]

Methods

AllElementsEqual<T>

#Example
public static bool AllElementsEqual<T>(this T[] array, T match, Func<T, T, bool> comparison)
Test whether all entries in an array are equal to a given value.
array (T[])
match (T)
comparison (Func<T, T, bool>)

AllElementsEqual<T>

#Example
public static bool AllElementsEqual<T>(this T[] array, T match)
Test whether all entries in an array are equal to a given value.
array (T[])
match (T)

AllNull<T>

#Example
public static bool AllNull<T>(this Pear<T>[] pears)
Tests whether all pears are null.
pears (Pear<T>[])Pears to test.
True if all pears are null.

AnyMeta<T>

#Example
public static bool AnyMeta<T>(this Pear<T>[] pears)
Tests whether any of the pears contain meta data.
pears (Pear<T>[])Pears to test.
True if any pear contains meta data.

AnyNull<T>

#Example
public static bool AnyNull<T>(this Pear<T>[] pears)
Tests whether any of the pears are null.
pears (Pear<T>[])Pears to test.
True if any of the pears are null.

Append<T>

#Example
public static T[] Append<T>(this T[] array, params T[] items)
Append a collection of items to the end of this array.
array (T[])Array to modify.
items (params T[])Items to insert.

Append<T>

#Example
public static T[] Append<T>(this T[] array, T item)
Append an item to the end of this array.
array (T[])Array to modify.
item (T)Item to insert.

Chain<T>

#Example
public static IEnumerable<T> Chain<T>(this IEnumerable<T> initial, params IEnumerable<T>[] subsequent)
Chain a set of enumerations.
initial (IEnumerable<T>)First collection.
subsequent (params IEnumerable<T>[])Subsequent collections.
Chained enumerable.

CollateMap<T>

#Example
public static int CollateMap<T>(this T[] array, IEnumerable<bool> map)
Collate all array elements that line up with true array in the map at the start of the array.
array (T[])Array to collate.
map (IEnumerable<bool>)Collate map.
New 'length' of the array. Ie. the highest index+1 that was included in the result.

CollateNulls<T>

#Example
public static void CollateNulls<T>(this T[] array, CollateDirection direction)
Collate all null elements in an array.
array (T[])Array to modify.
direction (CollateDirection)Direction.

ContainsMetaData

#Example
public static bool ContainsMetaData(this IEnumerable<IPear> pears)
Gets whether a collection of pears contains any meta data.
pears (IEnumerable<IPear>)

ContainsMetaData<T>

#Example
public static bool ContainsMetaData<T>(this IEnumerable<Pear<T>> pears)
Gets whether a collection of pears contains any meta data.
pears (IEnumerable<Pear<T>>)

Convert<T, TQ>

#Example
public static TQ[] Convert<T, TQ>(this T[] array, Func<T, TQ> conversion)
Convert an array of one type into another.
array (T[])Array to convert.
conversion (Func<T, TQ>)Conversion delegate.
Converted array.

Convert<T, TQ>

#Example
public static TQ[][] Convert<T, TQ>(this T[][] array, Func<T, TQ> conversion)
Convert nested arrays of one type to another.
array (T[][])Array to convert.
conversion (Func<T, TQ>)Conversion delegate.
Converted arrays.

Copy<T>

#Example
public static T[] Copy<T>(this T[] array, bool[] filter)
Copies specific elements from an array into another array.
array (T[])Array to copy from.
filter (bool[])Filter, if there's a TRUE the element will be copied. Filter may not be longer than array.
Array with copied elements.

CopyFirstItems<T>

#Example
public static void CopyFirstItems<T>(this T[] source, T[] target, int n)
Copy the first N items from one array to the start of another.
source (T[])Array to copy from.
target (T[])Array to copy to.
n (int)Number of items, must be less than or equal to the shortest array.

CopyLastItems<T>

#Example
public static void CopyLastItems<T>(this T[] source, T[] target, int n)
Copy the last N items from one array to the end of another.
source (T[])Array to copy from.
target (T[])Array to copy to.
n (int)Number of items, must be less than or equal to the shortest array.

CountOrDefault<T>

#Example
public static int CountOrDefault<T>(this IEnumerable<T> enumerable, int defaultCount)
Guess the length of a collection. If the type cannot be quickly resolved, a default value is returned.
enumerable (IEnumerable<T>)Collection to inspect.
defaultCount (int)Default count if collection cannot be easily inspected.
Length or default.

Create

#
public static double[] Create(IEnumerable<double> values)
Create an array out of all non-NaN elements in a collection.
values (IEnumerable<double>)

Create<T>

#
public static T[] Create<T>(IEnumerable<(T value, bool include)> elements)
Create a one dimensional array from a collection of values and inclusion flags.
elements (IEnumerable<(T value, bool include)>)Potential elements of the array.
Array containing only include=true elements.

Create<T>

#
public static T[] Create<T>(T initialValue, int width)
Create a one dimensional array.
initialValue (T)Initial value to assign to each element.
width (int)Width, or length of array.
One-dimensional array.

Create<T>

#
public static T[][] Create<T>(T initialValue, int width, int height)
Create a two dimensional, nested array.
initialValue (T)Initial value to assign to each element.
width (int)Width, or length of top level array.
height (int)Height, or length of all primary nested arrays.
Two-dimensional array.

Create<T>

#
public static T[][][] Create<T>(T initialValue, int width, int height, int depth)
Create a three dimensional, nested array.
initialValue (T)Initial value to assign to each element.
width (int)Width, or length of top level array.
height (int)Height, or length of all primary nested arrays.
depth (int)Depth, or length of all secondary nested arrays.
Three-dimensional array.

Create<T>

#
public static T[][][][] Create<T>(T initialValue, int width, int height, int depth, int plonk)
Create a four dimensional, nested array.
initialValue (T)Initial value to assign to each element.
width (int)Width, or length of top level array.
height (int)Height, or length of all primary nested arrays.
depth (int)Depth, or length of all secondary nested arrays.
plonk (int)Plonk (ie. four-dimensional depth), or length of all tertiary nested arrays.
Four-dimensional array.

CreatePluralityMap<T>

#Example
public static void CreatePluralityMap<T>(this IEnumerable<T> collection, Func<T, T, bool> equality, out T[] map, out int[] valence)
Convert a collection of elements into a set with valence tracking.
collection (IEnumerable<T>)Collection to parse.
equality (Func<T, T, bool>)Equality comparer.
map (out T[])Resulting array of unique array.
valence (out int[])Valence map for each value.
Number of remaining unique array.

CreatePluralityMap<T>

#Example
public static void CreatePluralityMap<T>(this IEnumerable<T> collection, out T[] map, out int[] valence)
Convert a collection of elements into a set with valence tracking.
collection (IEnumerable<T>)Collection to parse.
map (out T[])Resulting array of unique array.
valence (out int[])Valence map for each value.
Number of remaining unique array.

Cull<T>

#Example
public static T[] Cull<T>(this T[] array, bool[] pattern)
Apply a culling pattern to an array.
array (T[])Array to cull.
pattern (bool[])Culling pattern (true = remove, false = keep)
Culled array.

Duplicate<T>

#Example
public static T[] Duplicate<T>(this T[] array)
Clone a jagged array.
array (T[])Jagged array to clone.
Cloned jagged array.

Duplicate<T>

#Example
public static T[][] Duplicate<T>(this T[][] array)
Clone a jagged array.
array (T[][])Jagged array to clone.
Cloned jagged array.

Duplicate<T>

#Example
public static T[][][] Duplicate<T>(this T[][][] array)
Clone a multiply jagged array.
array (T[][][])Jagged array to clone.
Cloned jagged array.

EntrywiseEquals

#Example
public static bool EntrywiseEquals(this string[] array, string[] other, StringComparison comparison)
Compare two string arrays.
array (string[])Array.
other (string[])Other array.
comparison (StringComparison)String comparison.
True if both arrays contain the same strings in the same order.

EntrywiseEquals<T>

#Example
public static bool EntrywiseEquals<T>(this T[] array, params T[] other)
Perform an entrywise equality test on two arrays.
array (T[])First array.
other (params T[])Second array.
True if all elements are equal.

EntrywiseEquals<T>

#Example
public static bool EntrywiseEquals<T>(this T[] array, T[] other, Func<T, T, bool> areEqual)
Perform an entrywise equality test on two arrays.
array (T[])First array.
other (T[])Second array.
areEqual (Func<T, T, bool>)Equality comparer.
True if all elements are equal.

ExpandArray<T>

#Example
public static T[] ExpandArray<T>(this T[] array, int newCount, ExpandMethod method)
Expand an array.
array (T[])Array to expand.
newCount (int)Target count.
method (ExpandMethod)Expansion method.
Expanded array, or same array if it cannot be expanded.

ExpandArray<T>

#Example
public static T[] ExpandArray<T>(this T[] array, int oldCount, int newCount, ExpandMethod method)
Expand an array.
array (T[])Array to expand.
oldCount (int)Count of existing array, you can specify a value lower than array.Length to ignore a portion of the array.
newCount (int)Target count.
method (ExpandMethod)Expansion method.
Expanded array, or same array if it cannot be expanded.

FindInclusion

#Example
public static int FindInclusion(this Interval[] array, double value)
Find the index of the first interval which contains the given value.
array (Interval[])
value (double)

FindLocalMaximum

#Example
public static int FindLocalMaximum(this double[] array, int index0, int index1)
Find the first local maximum in an array of doubles.
array (double[])Array to search.
index0 (int)First index to take into account.
index1 (int)Last index to take into account. If last index is smaller than first index, then a backwards search is performed.
Index of first maximum or -1.

FindLocalMaximum

#Example
public static int FindLocalMaximum(this double[] array, int index0)
Find the first local maximum in an array of doubles.
array (double[])Array to search.
index0 (int)First index to take into account.
Index of first maximum or -1.

FindLocalMaximum

#Example
public static int FindLocalMaximum(this double[] array)
Find the first local maximum in an array of doubles.
array (double[])Array to search.
Index of first maximum or -1.

FindLocalMaximum

#Example
public static int FindLocalMaximum(this int[] array, int index0, int index1)
Find the first local maximum in an array of integers.
array (int[])Array to search.
index0 (int)First index to take into account.
index1 (int)Last index to take into account. If last index is smaller than first index, then a backwards search is performed.
Index of first maximum or -1.

FindLocalMaximum

#Example
public static int FindLocalMaximum(this int[] array, int index0)
Find the first local maximum in an array of integers.
array (int[])Array to search.
index0 (int)First index to take into account.
Index of first maximum or -1.

FindLocalMaximum

#Example
public static int FindLocalMaximum(this int[] array)
Find the first local maximum in an array of integers.
array (int[])Array to search.
Index of first maximum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this double[] array, int index0, int index1)
Find the first local minimum in an array of doubles.
array (double[])Array to search.
index0 (int)First index to take into account.
index1 (int)Last index to take into account. If last index is smaller than first index, then a backwards search is performed.
Index of first minimum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this double[] array, int index0)
Find the first local minimum in an array of doubles.
array (double[])Array to search.
index0 (int)First index to take into account.
Index of first minimum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this double[] array)
Find the first local minimum in an array of doubles.
array (double[])Array to search.
Index of first minimum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this int[] array, int index0, int index1)
Find the first local minimum in an array of integers.
array (int[])Array to search.
index0 (int)First index to take into account.
index1 (int)Last index to take into account. If last index is smaller than first index, then a backwards search is performed.
Index of first minimum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this int[] array, int index0)
Find the first local minimum in an array of integers.
array (int[])Array to search.
index0 (int)First index to take into account.
Index of first minimum or -1.

FindLocalMinimum

#Example
public static int FindLocalMinimum(this int[] array)
Find the first local minimum in an array of integers.
array (int[])Array to search.
Index of first minimum or -1.

FindRange<T>

#Example
public static bool FindRange<T>(this T[] array, Predicate<T> predicate, int firstIndex, int lastIndex, out int index0, out int index1)
Find the first range that passes the predicate.
array (T[])Array to search.
predicate (Predicate<T>)Predicate method.
firstIndex (int)First index to take into account.
lastIndex (int)Last index to take into account.
index0 (out int)First index which passes the predicate.
index1 (out int)Last index which passes the predicate.
True if a range was found.

FindRange<T>

#Example
public static bool FindRange<T>(this T[] array, Predicate<T> predicate, int firstIndex, out int index0, out int index1)
Find the first range that passes the predicate.
array (T[])Array to search.
predicate (Predicate<T>)Predicate method.
firstIndex (int)First index to take into account.
index0 (out int)First index which passes the predicate.
index1 (out int)Last index which passes the predicate.
True if a range was found.

FirstIndexOf<T>

#Example
public static int FirstIndexOf<T>(this T[] array, Func<T, bool> predicate, int start)
Return the first index within the array where a specific predicate returns true.
array (T[])Array to search.
predicate (Func<T, bool>)Predicate to test against.
start (int)First index to take into consideration.
Index within array or -1 if value is not found.

FirstIndexOf<T>

#Example
public static int FirstIndexOf<T>(this T[] array, Func<T, bool> predicate)
Return the first index within the array where a specific predicate returns true.
array (T[])Array to search.
predicate (Func<T, bool>)Predicate to test against.
Index within array or -1 if value is not found.

FirstIndexOf<T>

#Example
public static int FirstIndexOf<T>(this T[] array, T value, int start)
Return the first index within the array where a specific value can be found.
array (T[])Array to search.
value (T)Value to match.
start (int)First index to take into consideration.
Index within array or -1 if value is not found.

FirstIndexOf<T>

#Example
public static int FirstIndexOf<T>(this T[] array, T value)
Return the first index within the array where a specific value can be found.
array (T[])Array to search.
value (T)Value to match.
Index within array or -1 if value is not found.

Flip<T>

#Example
public static T[][] Flip<T>(this T[][] array)
Flip a two-dimensional, rectangular nested array.
array (T[][])Array to flip. All secondary arrays must be the same length.
Flipped array.

ForEachBackwards<T>

#Example
public static IEnumerable<T> ForEachBackwards<T>(this T[] array)
Enumerate over an array in a backwards fashion (from the highest to the lowest index).
array (T[])

ForEachForwards<T>

#Example
public static IEnumerable<T> ForEachForwards<T>(this T[] array)
Enumerate over an array in a forwards fashion (from the lowest to the highest index).
array (T[])

Format<T>

#Example
public static string Format<T>(this T[] array, string pattern, string separator = ", ", int maximumCharacters = 2147483647, int maximumElements = 2147483647)
Format an array.
array (T[])Array to format.
pattern (string)Formatting pattern.
separator (string = ", ")Separator text.
maximumCharacters (int = 2147483647)Maximum allowed characters in the format.
maximumElements (int = 2147483647)Maximum number of elements to format.

Format<T>

#Example
public static string Format<T>(this T[][] array)
Format a two-dimensional jagged array.
array (T[][])Array to format.
Format showing array as a table.

FromFunc<T>

#
public static T[] FromFunc<T>(int length, Func<int, T> method)
Create and populate an array.
length (int)Length of array.
method (Func<int, T>)Method for generating each element from its index.
Populated array.

HorizontalIntersect

#Example
public static bool HorizontalIntersect(this double[] array, double constant, out int index, out double partial)
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.
array (double[])Array of increasing doubles.
constant (double)Constant intersection.
index (out int)Index in array of first value less than or equal to the constant.
partial (out double)Linear interpolation factor between the indexed value and the next value in the array.
True if an intersection was found.

IndexOf

#Example
public static int IndexOf(this Guid[] source, Guid[] pattern)
Finds the first occurrence of an array within another array.
source (Guid[])The source array to search within.
pattern (Guid[])The pattern array to search for.
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<T>

#Example
public static void Inject<T>(this T[] array, int index, T item)
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.
array (T[])Array to modify.
index (int)Index to inject into.
item (T)Item to inject.

Insert<T>

#Example
public static T[] Insert<T>(this T[] array, int index, params T[] items)
Insert a collection of items into this array.
array (T[])Array to modify.
index (int)Index to insert at.
items (params T[])Items to insert.

Insert<T>

#Example
public static T[] Insert<T>(this T[] array, int index, T item)
Insert an item into this array.
array (T[])Array to modify.
index (int)Index to insert at.
item (T)Item to insert.

Invert

#
public static IEnumerable<bool> Invert(IEnumerable<bool> enumeration)
Invert a bool enumeration.
enumeration (IEnumerable<bool>)Enumeration to invert.
Inverted enumeration.

IsNullOrEmpty

#Example
public static bool IsNullOrEmpty(this Array array)
Test an array for null-ness of empty-ness.
array (Array)

IsNullOrEmpty<T>

#Example
public static bool IsNullOrEmpty<T>(this T[] array)
Gets whether the array instance is null or empty.
array (T[])Array to test.
True if array is either null or empty.

IsNullOrOnlyHasNulls<T>

#Example
public static bool IsNullOrOnlyHasNulls<T>(this T[] array)
Gets whether the array instance is null, empty, or contains only null items.
array (T[])Array to test.
True if array is either null, empty or blank.

Item<T>

#Example
public static T Item<T>(this T[] array, int cyclicalIndex)
Gets the item at a cyclical index.
array (T[])Array to query.
cyclicalIndex (int)Cyclical index. -1 equals the last item in the array.
Item at cyclical index.

Item<T>

#Example
public static void Item<T>(this T[] array, int cyclicalIndex, T item)
Sets the item at a cyclical index.
array (T[])Array to query.
cyclicalIndex (int)Cyclical index. -1 equals the last item in the array.
item (T)Item to set.

Keep<T>

#Example
public static T[] Keep<T>(this T[] array, bool[] pattern)
Apply a culling pattern to an array.
array (T[])Array to cull.
pattern (bool[])Culling pattern (true = keep, false = remove)
Culled array.

Last<T>

#Example
public static T Last<T>(this T[] array)
Gets the last item in an array.
array (T[])Array to query.
Last item in array.

LastIndexOf<T>

#Example
public static int LastIndexOf<T>(this T[] array, T value, int start)
Return the last index within the array where a specific value can be found.
array (T[])Array to search.
value (T)Value to match.
start (int)First index to take into consideration.
Index within array or -1 if value is not found.

LastIndexOf<T>

#Example
public static int LastIndexOf<T>(this T[] array, T value)
Return the last index within the array where a specific value can be found.
array (T[])Array to search.
value (T)Value to match.
Index within array or -1 if value is not found.
public static int Map(this ExpandMethod method, int unexpandedCount, int expandedCount, int expandedIndex)
Map an index specified within a expanded collection to the appropriate index in the unexpanded collection.
method (ExpandMethod)Shrinking method context.
unexpandedCount (int)Length of unexpanded collection.
expandedCount (int)Length of expanded collection.
expandedIndex (int)Index into expanded collection.
Index in unexpanded collection or -1 if not a valid mapping.
public static int Map(this ShrinkMethod method, int unshrunkCount, int shrunkCount, int shrunkIndex)
Map an index specified within a shrunk collection to the appropriate index in the unshrunk collection.
method (ShrinkMethod)Shrinking method context.
unshrunkCount (int)Length of unshrunk collection.
shrunkCount (int)Length of shrunk collection.
shrunkIndex (int)Index into shrunk collection.
Index in unshrunk collection or -1 if not a valid mapping.

MetaDataCount

#Example
public static int MetaDataCount(this MetaData[] array)
Count the number of meta data entries. An entry with zero key-value fields does not count towards the total.
array (MetaData[])

MostDerivedTypeConstraint<T>

#Example
public static Type MostDerivedTypeConstraint<T>(this T[] array, bool[] nulls = null)
Gets the most derived type constraint required to store all the elements in the array.
array (T[])Array to examine.
nulls (bool[] = null)Optional null array used for skipping elements.
Tightest possible type of array which could still contain all elements in array.

Negate

#Example
public static bool[] Negate(this bool[] array)
Invert all array in a boolean array.
array (bool[])Array to negate.
Negated array.

NoneNull<T>

#Example
public static bool NoneNull<T>(this Pear<T>[] pears)
Tests whether none of the pears are null.
pears (Pear<T>[])Pears to test.
True if none of the pears are null.

Normalise

#Example
public static bool Normalise(this double[] array, double target)
Normalise all values in an array so they sum to a specific value.
array (double[])Array to normalise.
target (double)Normalisation target.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this double[] array)
Normalise all values in an array so they sum to 1.
array (double[])Array to normalise.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this double[][] array, double target)
Normalise all values in a nested array so they sum up to a specific value.
array (double[][])Array to normalise.
target (double)Normalisation target.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this double[][] array)
Normalise all values in a nested array so they sum up to 1.
array (double[][])Array to normalise.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this float[] array, float target)
Normalise all array in an array so they sum to a specific value.
array (float[])Array to normalise.
target (float)Normalisation target.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this float[] array)
Normalise all array in an array so they sum to 1.
array (float[])Array to normalise.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this float[][] array, float target)
Normalise all values in a nested array so they sum up to a specific value.
array (float[][])Array to normalise.
target (float)Normalisation target.
True on success, false on failure.

Normalise

#Example
public static bool Normalise(this float[][] array)
Normalise all values in a nested array so they sum up to 1.
array (float[][])Array to normalise.
True on success, false on failure.

NullIfEmpty<T>

#Example
public static T[] NullIfEmpty<T>(this T[] array)
Returns a null reference if the array contains only null array. Otherwise returns the same array.
array (T[])Array to inspect.
Either array or null.

OrderedHash<T>

#Example
public static int OrderedHash<T>(this T[] array)
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}.
array (T[])

PadLeft<T>

#Example
public static T[] PadLeft<T>(this T[] array, int targetLength, T padding)
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.
array (T[])Array to pad.
targetLength (int)Target length.
padding (T)Value to insert for padding.
Padded array.

PadRight<T>

#Example
public static T[] PadRight<T>(this T[] array, int targetLength, T padding)
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.
array (T[])Array to pad.
targetLength (int)Target length.
padding (T)Value to insert for padding.
Padded array.

Pop<T>

#Example
public static T[] Pop<T>(this T[] array)
Remove the last item from an array.
array (T[])Array to modify.
Popped array.

PopFirst<T>

#Example
public static T[] PopFirst<T>(this T[] array)
Remove the first item from an array.
array (T[])Array to modify.
Popped array.

Process<T>

#
public static IEnumerable<T> Process<T>(IEnumerable<T> enumeration, Func<T, T> process)
Apply a function to an enumeration.
enumeration (IEnumerable<T>)Enumeration to process.
process (Func<T, T>)Process function.
Processed enumeration.

Push<T>

#Example
public static T[] Push<T>(this T[] array, params T[] items)
Append a collection of items to the end of an array.
array (T[])Array to modify.
items (params T[])Items to add.
New array with added item.

Push<T>

#Example
public static T[] Push<T>(this T[] array, T item)
Append an item to the end of an array.
array (T[])Array to modify.
item (T)Item to add.
New array with added item.

PushFirst<T>

#Example
public static T[] PushFirst<T>(this T[] array, T item)
Push an item into the first position of an array.
array (T[])Array to modify.
item (T)Item to push.
New array with added item.

Random<T>

#Example
public static T Random<T>(this T[] array, Random random)
Gets a random item out of this array.
array (T[])Array.
random (Random)Random engine.
Ranodm item.

RemoveAll<T>

#Example
public static T[] RemoveAll<T>(this T[] array, Predicate<T> predicate)
Remove specific items from an array.
array (T[])Array to operate on.
predicate (Predicate<T>)Removal predicate, must return true when an item is to be removed.
Array with all specific items removed.

RemoveAll<T>

#Example
public static T[] RemoveAll<T>(this T[] array, T item)
Remove all instances from an array.
array (T[])Array to operate on.
item (T)Items to remove.
Array with all instances of item removed.

RemoveAt<T>

#Example
public static T[] RemoveAt<T>(this T[] array, int index)
Remove a specific element from an array.
array (T[])Array to modify.
index (int)Index to remove.
Modified array.

RemoveDuplicates<T>

#Example
public static T[] RemoveDuplicates<T>(this T[] array, Func<T, T, bool> comparer)
Remove all duplicate array elements using a custom comparer.
array (T[])Array to simplify.
comparer (Func<T, T, bool>)Custom comparer.
Array containing only unique array elements.

RemoveDuplicates<T>

#Example
public static T[] RemoveDuplicates<T>(this T[] array, IEqualityComparer<T> comparer)
Remove all duplicate array elements using a custom comparer.
array (T[])Array to simplify.
comparer (IEqualityComparer<T>)Custom comparer.
Array containing only unique array elements.

RemoveDuplicates<T>

#Example
public static T[] RemoveDuplicates<T>(this T[] array)
Remove all duplicate array elements using the standard comparer.
array (T[])Array to simplify.
Array containing only unique array elements.

RemoveRange<T>

#Example
public static T[] RemoveRange<T>(this T[] array, int index, int length)
Remove a range of items from an array.
array (T[])Array to modify.
index (int)Index of first item to remove.
length (int)Number of items to remove.
Modified array.

ReorderByKey<T>

#Example
public static void ReorderByKey<T>(this T[] array, T[] keys)
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.
array (T[])Array to reorder.
keys (T[])Order constraint for (some) items in array.

ReplaceFirst<T>

#Example
public static T[] ReplaceFirst<T>(this T[] array, T search, T replace)
Replace the first occurance of a value within an array with another one.
array (T[])
search (T)
replace (T)

ReplaceLast<T>

#Example
public static T[] ReplaceLast<T>(this T[] array, T search, T replace)
Replace the last occurance of a value within an array with another one.
array (T[])
search (T)
replace (T)

ReplacePattern

#Example
public static Guid[] ReplacePattern(this Guid[] source, Guid[] pattern, Guid replacement)
Replaces all occurrences of a Guid pattern within a source array with a single replacement Guid.
source (Guid[])The source array to perform replacements on.
pattern (Guid[])The pattern array to search for.
replacement (Guid)The Guid to use as replacement.
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.

ReplaceWithinIntervals

#Example
public static void ReplaceWithinIntervals(this double[] array, Interval[] domains, double replacement, bool strict)
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.
array (double[])Array of doubles. Must be sorted small to large.
domains (Interval[])Array of intervals.
replacement (double)Replacement value.
strict (bool)If true, only array strictly within each interval are replaced.

Reverse<T>

#Example
public static T[] Reverse<T>(this T[] array)
Create a reversed copy of an array.
array (T[])Array.
Reversed copy.

SameAccess

#Example
public static bool SameAccess(this Access[] array, out Access access)
Checks whether all access flags are of a single kind.
array (Access[])Array to test.
access (out Access)Shared access.
True if all access flags are identical.

SetAll<T>

#Example
public static void SetAll<T>(this T[] array, T value, int index, int length)
Set a range of array of an array to a specific value.
array (T[])Array to modify.
value (T)Value to assign to each element.
index (int)First index to set.
length (int)Number of elements to set.

SetAll<T>

#Example
public static void SetAll<T>(this T[] array, T value)
Set all array of an array to a specific value.
array (T[])Array to modify.
value (T)Value to assign to each element.

SetFirstAndLast<T>

#Example
public static void SetFirstAndLast<T>(this T[] array, T first, T last)
Set the first and last elements in an array simultaneously.
array (T[])
first (T)
last (T)

ShrinkArray<T>

#Example
public static T[] ShrinkArray<T>(this T[] array, int newCount, ShrinkMethod method)
Shrink an array.
array (T[])Array to shrink.
newCount (int)Target count.
method (ShrinkMethod)Shrinking method.
Shrunk array, or same array if it cannot be shrunk.

ShrinkArray<T>

#Example
public static T[] ShrinkArray<T>(this T[] array, int oldCount, int newCount, ShrinkMethod method)
Shrink an array.
array (T[])Array to shrink.
oldCount (int)Count of existing array, you can specify a value lower than array.Length to ignore a portion of the array.
newCount (int)Target count.
method (ShrinkMethod)Shrinking method.
Shrunk array, or same array if it cannot be shrunk.

Slice<T>

#Example
public static T[] Slice<T>(this T[] array, int start, int end)
Slice the array between two indices. I.e. extract the sub-array limited by the indices.
array (T[])Array to slice.
start (int)Inclusive start index.
end (int)Exclusive end index.

SortAndMerge

#Example
public static Interval[] SortAndMerge(this Interval[] array)
Sort all intervals in an array from left to right and merge overlapping intervals.
array (Interval[])Array of intervals to merge. All intervals must be increasing.
Sorted and merged array. The returned array may be the same array, if no modifications were made.

SortMap<T>

#Example
public static T[] SortMap<T>(this T[] array, out IndexMap map, IComparer<T> comparer)
Sort an array and create a sorting map using a default comparer.
array (T[])Array to sort.
map (out Maths.IndexMap)Sorting map.
comparer (IComparer<T>)
Sorted array.

SortMap<T>

#Example
public static T[] SortMap<T>(this T[] array, out IndexMap map)
Sort an array and create a sorting map using a default comparer.
array (T[])Array to sort.
map (out Maths.IndexMap)Sorting map.
Sorted array.

SortMapWithNulls<T>

#Example
public static Maths.IndexMap SortMapWithNulls<T>(this T[] array, bool[] nullMap, IComparer<T> comparer)
Create a sorting map for an array with a null-mask array.
array (T[])Array to sort.
nullMap (bool[])nullMap to sort.
comparer (IComparer<T>)Comparer to use.

SortStable<T>

#Example
public static void SortStable<T>(this int[] keys, T[] values)
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.
keys (int[])Sorting keys.
values (T[])Synchronous array.

SortTopological<T>

#Example
public static T[] SortTopological<T>(this T[] array, int[] edge0, int[] edge1)
Perform a topological sort on an array.
array (T[])Array to sort.
edge0 (int[])Start index of each topological edge.
edge1 (int[])End index of each topological edge.
Sorted array.

SortTopological<T>

#Example
public static T[] SortTopological<T>(this T[] array, params (int start, int end)[] edges)
Perform a topological sort on an array.
array (T[])Array to sort.
edges (params (int start, int end)[])Collection of edges defined by start and end indices.
Sorted array.

Stack<T>

#Example
public static void Stack<T>(this T[] array, params T[][] elements)
Stack up the elements until the array is filled up.
array (T[])Array to fill up.
elements (params T[][])Stacking elements.

SumTotal<T>

#Example
public static double SumTotal<T>(this IEnumerable<T> collection, Func<T, double> map)
Sum all elements in a collection.
collection (IEnumerable<T>)
map (Func<T, double>)

SumTotal<T>

#Example
public static float SumTotal<T>(this IEnumerable<T> collection, Func<T, float> map)
Sum all elements in a collection.
collection (IEnumerable<T>)
map (Func<T, float>)

SumTotal<T>

#Example
public static int SumTotal<T>(this IEnumerable<T> collection, Func<T, int> map)
Sum all elements in a collection.
collection (IEnumerable<T>)
map (Func<T, int>)

Swap<T>

#Example
public static void Swap<T>(this T[] array, int index0, int index1)
Swap two items in an array.
array (T[])Array to modify.
index0 (int)First index.
index1 (int)Second index.

ToByteArray

#Example
public static byte[] ToByteArray(this double[] array)
Convert a double[] into a byte[].
array (double[])Array to convert.
Byte array.

ToByteArray

#Example
public static byte[] ToByteArray(this float[] array)
Convert a float[] into a byte[].
array (float[])Array to convert.
Byte array.

ToByteArray

#Example
public static byte[] ToByteArray(this int[] array)
Convert an int[] into a byte[].
array (int[])Array to convert.
Byte array.

ToByteArray

#Example
public static byte[] ToByteArray(this long[] array)
Convert a long[] into a byte[].
array (long[])Array to convert.
Byte array.

ToCoordinateArray

#Example
public static double[] ToCoordinateArray(this Locus[] vectors)
Convert an array of SpatialVector array into an xyz coordinate array.
vectors (Locus[])Vectors to sequence.
Coordinate array.

ToCoordinateArray

#Example
public static double[] ToCoordinateArray(this Point2d[] points)
Convert an array of Point2d array into an xy coordinate array.
points (Point2d[])Points to sequence.
Coordinate array.

ToCoordinateArray

#Example
public static double[] ToCoordinateArray(this Point3d[] points)
Convert an array of Point3d array into an xyz coordinate array.
points (Point3d[])Points to sequence.
Coordinate array.

ToCoordinateArray

#Example
public static double[] ToCoordinateArray(this Vector3d[] vectors)
Convert an array of Vector3d array into an xyz coordinate array.
vectors (Vector3d[])Vectors to sequence.
Coordinate array.

ToDoubleArray

#Example
public static double[] ToDoubleArray(this byte[] array)
Convert a byte[] into a double[].
array (byte[])Array to convert.
Array.

ToFloatArray

#Example
public static float[] ToFloatArray(this byte[] array)
Convert a byte[] into a float[].
array (byte[])Array to convert.
Array.

ToHashByteArray

#Example
public static byte[] ToHashByteArray(this IEnumerable<object> objects)
Create a byte array containing all the hashcodes of a collection of objects.
objects (IEnumerable<object>)Objects to hash.
Byte array.

ToIntArray

#Example
public static int[] ToIntArray(this byte[] array)
Convert a byte[] into an int[].
array (byte[])Array to convert.
Array.

ToItemArray<T>

#Example
public static T[] ToItemArray<T>(this Pear<T>[] array)
Create an item array from a pear array.
array (Pear<T>[])Array of pears.
Array of items.

ToLongArray

#Example
public static long[] ToLongArray(this byte[] array)
Convert a byte[] into a long[].
array (byte[])Array to convert.
Array.

ToMetaArray<T>

#Example
public static MetaData[] ToMetaArray<T>(this Pear<T>[] array)
Create a meta array from a pear array.
array (Pear<T>[])Array of pears.
Array of meta data.

ToNullArray<T>

#Example
public static bool[] ToNullArray<T>(this Pear<T>[] array)
Create a null array from a pear array.
array (Pear<T>[])Array of pears.
Array of nulls.

ToPoint2dArray

#Example
public static Point2d[] ToPoint2dArray(this double[] coordinates)
Convert an array of sequential xy coordinates into a Point2d array.
coordinates (double[])Array of coordinates, length must be a multiple of 2.
Point array.

ToPoint3dArray

#Example
public static Point3d[] ToPoint3dArray(this double[] coordinates)
Convert an array of sequential xyz coordinates into a Point3d array.
coordinates (double[])Array of coordinates, length must be a multiple of 3.
Point array.

ToSpatialVectorArray

#Example
public static Locus[] ToSpatialVectorArray(this double[] coordinates)
Convert an array of sequential xyz coordinates into a SpatialVector array.
coordinates (double[])Array of coordinates, length must be a multiple of 3.
Vector array.

ToTypeArray<T>

#Example
public static Type[] ToTypeArray<T>(this Pear<T>[] array)
Create a type array from a pear array.
array (Pear<T>[])Array of pears.
Array of types.

ToVector3dArray

#Example
public static Vector3d[] ToVector3dArray(this double[] coordinates)
Convert an array of sequential xyz coordinates into a Vector3d array.
coordinates (double[])Array of coordinates, length must be a multiple of 3.
Vector array.

Trim<T>

#Example
public static T[] Trim<T>(this T[] array, T trimmingValue)
Resize an array to contain all items until a specific value.
array (T[])Array to resize.
trimmingValue (T)Value to trim at.
Trimmed array.

UnorderedHash<T>

#Example
public static int UnorderedHash<T>(this T[] 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}.
array (T[])

Withdraw<T>

#Example
public static void Withdraw<T>(this T[] array, int index)
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.
array (T[])Array to modify.
index (int)Index to withdraw.

Wrap<T, TQ>

#Example
public static IEnumerable<TQ> Wrap<T, TQ>(this IEnumerable<T> collection, Func<T, TQ> converter)
Wrap an IEnumerable into another IEbumerable of a different type.
collection (IEnumerable<T>)Collection.
converter (Func<T, TQ>)Conversion method.