ArrayEx

public static class ArrayEx
Extension methods for T[]

Methods

AllElementsEqual<T>

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

AllElementsEqual<T>

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

AllNull<T>

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

AnyMeta<T>

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

AnyNull<T>

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

Append<T>

#Example
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<T>

#Example
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<T>

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

CollateMap<T>

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

CollateNulls<T>

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

ContainsMetaData

#Example
Gets whether a collection of pears contains any meta data.
public static bool ContainsMetaData(
pears
)

ContainsMetaData<T>

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

Convert<T, TQ>

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

Convert<T, TQ>

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

Copy<T>

#Example
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.
)
Array with copied elements.

CopyFirstItems<T>

#Example
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.
)

CopyLastItems<T>

#Example
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.
)

CountOrDefault<T>

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

Create

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

Create<T>

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

Create<T>

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

Create<T>

#
Create a two 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.
)
Two-dimensional array.

Create<T>

#
Create a three 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.
)
Three-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.
)
Four-dimensional array.

CreatePluralityMap<T>

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

CreatePluralityMap<T>

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

Cull<T>

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

Duplicate<T>

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

Duplicate<T>

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

Duplicate<T>

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

EntrywiseEquals

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

EntrywiseEquals<T>

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

EntrywiseEquals<T>

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

ExpandArray<T>

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

ExpandArray<T>

#Example
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.
)
Expanded array, or same array if it cannot be expanded.

FindInclusion

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

FindLocalMaximum

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

FindLocalMaximum

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

FindLocalMaximum

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

FindLocalMaximum

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

FindLocalMinimum

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

FindLocalMinimum

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

FindLocalMinimum

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

FindLocalMinimum

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

FindRange<T>

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

FindRange<T>

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

FirstIndexOf<T>

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

FirstIndexOf<T>

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

FirstIndexOf<T>

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

FirstIndexOf<T>

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

Flip<T>

#Example
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.
)
Flipped array.

ForEachBackwards<T>

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

ForEachForwards<T>

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

Format<T>

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

Format<T>

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

FromFunc<T>

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

HorizontalIntersect

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

IndexOf

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

Insert<T>

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

Insert<T>

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

Invert

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

IsNullOrEmpty

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

IsNullOrEmpty<T>

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

IsNullOrOnlyHasNulls<T>

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

Item<T>

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

Item<T>

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

Keep<T>

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

Last<T>

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

LastIndexOf<T>

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

LastIndexOf<T>

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

MetaDataCount

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

MostDerivedTypeConstraint<T>

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

Negate

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

NoneNull<T>

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

Normalise

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

Normalise

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

Normalise

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

Normalise

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

Normalise

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

Normalise

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

Normalise

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

Normalise

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

NullIfEmpty<T>

#Example
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.
)
Either array or null.

OrderedHash<T>

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

PadLeft<T>

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

PadRight<T>

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

Pop<T>

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

PopFirst<T>

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

Process<T>

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

Push<T>

#Example
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.
)
New array with added item.

Push<T>

#Example
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.
)
New array with added item.

PushFirst<T>

#Example
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.
)
New array with added item.

Random<T>

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

RemoveAll<T>

#Example
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.
)
Array with all specific items removed.

RemoveAll<T>

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

RemoveAt<T>

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

RemoveDuplicates<T>

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

RemoveDuplicates<T>

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

RemoveDuplicates<T>

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

RemoveRange<T>

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

ReorderByKey<T>

#Example
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.
)

ReplaceFirst<T>

#Example
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
)

ReplaceLast<T>

#Example
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
)

ReplacePattern

#Example
Replaces all occurrences of a Guid pattern within a source array with a single replacement Guid.
public static Guid[] ReplacePattern(
this Guid[]
source,
The source array to perform replacements on.
Guid[]
pattern,
The pattern array to search for.
replacement
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
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.
public static void ReplaceWithinIntervals(
this double[]
array,
Array of doubles. Must be sorted small to large.
domains,
Array of intervals.
replacement,
Replacement value.
strict
If true, only array strictly within each interval are replaced.
)

Reverse<T>

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

SameAccess

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

SetAll<T>

#Example
Set a range of 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.
index,
First index to set.
length
Number of elements to set.
)

SetAll<T>

#Example
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.
)

SetFirstAndLast<T>

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

ShrinkArray<T>

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

ShrinkArray<T>

#Example
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.
)
Shrunk array, or same array if it cannot be shrunk.

Slice<T>

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

SortAndMerge

#Example
Sort all intervals in an array from left to right and merge overlapping intervals.
public static Interval[] SortAndMerge(
this Interval[]
array
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
Sort an array and create a sorting map using a default comparer.
public static T[] SortMap<T>(
this T[]
array,
Array to sort.
map,
Sorting map.
comparer
)
Sorted array.

SortMap<T>

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

SortMapWithNulls<T>

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

SortStable<T>

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

SortTopological<T>

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

SortTopological<T>

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

Stack<T>

#Example
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.
)

SumTotal<T>

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

SumTotal<T>

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

SumTotal<T>

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

Swap<T>

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

ToByteArray

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

ToByteArray

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

ToByteArray

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

ToByteArray

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

ToCoordinateArray

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

ToCoordinateArray

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

ToCoordinateArray

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

ToCoordinateArray

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

ToDoubleArray

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

ToFloatArray

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

ToHashByteArray

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

ToIntArray

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

ToItemArray<T>

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

ToLongArray

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

ToMetaArray<T>

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

ToNullArray<T>

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

ToPoint2dArray

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

ToPoint3dArray

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

ToSpatialVectorArray

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

ToTypeArray<T>

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

ToVector3dArray

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

Trim<T>

#Example
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.
)
Trimmed array.

UnorderedHash<T>

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

Withdraw<T>

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

Wrap<T, TQ>

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