NanoByte.Common  2.6.1
NanoByte.Common.Collections.ArrayExtensions Class Reference

Provides extension methods for arrays. More...

Static Public Member Functions

static T[] Append< T > (this T[] array, T element)
 Appends an element to an array. More...
 
static T[] Prepend< T > (this T[] array, T element)
 Prepends an element to an array. More...
 
static bool SequencedEquals< T > (this T[] first, T[] second, IEqualityComparer< T >? comparer=null)
 Determines whether two arrays contain the same elements in the same order. More...
 
static T[] GetAddedElements< T > (this T[]? newArray, T[]? oldArray)
 Assumes two sorted arrays. Determines which elements are present in newArray but not in oldArray . More...
 
static T[] GetAddedElements< T > (this T[]? newArray, T[]? oldArray, IComparer< T > comparer)
 Assumes two sorted arrays. Determines which elements are present in newArray but not in oldArray . More...
 

Detailed Description

Provides extension methods for arrays.

Member Function Documentation

◆ Append< T >()

static T [] NanoByte.Common.Collections.ArrayExtensions.Append< T > ( this T[]  array,
element 
)
inlinestatic

Appends an element to an array.

◆ GetAddedElements< T >() [1/2]

static T [] NanoByte.Common.Collections.ArrayExtensions.GetAddedElements< T > ( this T?[]  newArray,
T?[]  oldArray 
)
static

Assumes two sorted arrays. Determines which elements are present in newArray but not in oldArray .

Parameters
newArrayThe new list of elements; can be null (will be treated as an empty array).
oldArrayThe original list of elements; can be null (will be treated as an empty array).
Returns
An array of elements that were added.

Elements that are present in oldArray but not in newArray are ignored. Elements that are equal for IComparable<T>.CompareTo but have been otherwise modified will be added.

Type Constraints
T :IComparable<T> 
T :IEquatable<T> 
T :GetAddedElements 
T :newArray 
T :oldArray 
T :DefaultComparer<T> 
T :Instance 

◆ GetAddedElements< T >() [2/2]

static T [] NanoByte.Common.Collections.ArrayExtensions.GetAddedElements< T > ( this T?[]  newArray,
T?[]  oldArray,
IComparer< T >  comparer 
)
inlinestatic

Assumes two sorted arrays. Determines which elements are present in newArray but not in oldArray .

Parameters
newArrayThe new list of elements; can be null (will be treated as an empty array).
oldArrayThe original list of elements; can be null (will be treated as an empty array).
comparerAn object that compares to elements to determine which one is bigger.
Returns
An array of elements that were added.

Elements that are present in oldArray but not in newArray are ignored. Elements that are equal for IComparable<T>.CompareTo but have been otherwise modified will be added.

◆ Prepend< T >()

static T [] NanoByte.Common.Collections.ArrayExtensions.Prepend< T > ( this T[]  array,
element 
)
inlinestatic

Prepends an element to an array.

◆ SequencedEquals< T >()

static bool NanoByte.Common.Collections.ArrayExtensions.SequencedEquals< T > ( this T[]  first,
T[]  second,
IEqualityComparer< T >?  comparer = null 
)
inlinestatic

Determines whether two arrays contain the same elements in the same order.

Parameters
firstThe first of the two collections to compare.
secondThe first of the two collections to compare.
comparerControls how to compare elements; leave null for default comparer.

The documentation for this class was generated from the following file: