[]
Represents a strongly typed list of structs that can be effectively accessed by index.
public class StructList<T> where T : struct
T
The type of structs in the list.
Initializes a new instance of the StructList<T> class that is empty.
public StructList()
Initializes a new instance of the StructList<T> class that contains elements copied from the specified array.
public StructList(T[] array, int arrayIndex, int count)
array
T[]The array whose elements should be added to the StructList<T>.
arrayIndex
intThe zero-based index of the first element in the array
to add.
count
intThe number of elements to add.
Initializes a new instance of the StructList<T> class that contains elements copied from the specified collection.
public StructList(IEnumerable<T> collection)
collection
System.Collections.Generic.IEnumerable<T><T>The collection whose elements are copied to the new list.
Initializes a new instance of the StructList<T> class that is empty and has the specified initial capacity.
public StructList(int capacity)
capacity
intThe number of elements that the new list can initially store.
Gets or sets the total number of elements the internal array can hold without resizing.
public int Capacity { get; set; }
Gets the number of elements actually contained in the StructList<T>.
public int Count { get; }
Gets the current array containing the elements of the StructList<T>.
public T[] InnerArray { get; }
Gets a reference to the struct at the specified index.
public ref T this[int index] { get; }
index
intGets an object that can be used to synchronize access to the StructList<T>.
public object SyncRoot { get; }
Adds a struct to the end of the StructList<T>.
public void Add(in T item)
item
TThe struct to be added to the end of the StructList<T>.
Adds the elements of the specified array to the end of the StructList<T>.
public void AddArray(T[] array, int arrayIndex, int count)
array
T[]The array whose elements should be added to the end of the StructList<T>.
arrayIndex
intThe zero-based index of the first element in the array
to add.
count
intThe number of elements to add.
Adds the elements of the specified collection to the end of the StructList<T>.
public void AddRange(IEnumerable<T> collection)
collection
System.Collections.Generic.IEnumerable<T><T>The collection whose elements should be added to the end of the StructList<T>.
Returns a read-only ReadOnlyStructList<T> wrapper for the current StructList<T>.
public ReadOnlyStructList<T> AsReadOnly()
A ReadOnlyStructList<T> that acts as a read-only wrapper around the current StructList<T>.
Searches a range of elements in the sorted StructList<T> for an element using the specified comparer and returns the zero-based index of the element.
public int BinarySearch(int index, int count, in T item, IStructComparer<T> comparer)
index
intThe zero-based starting index of the range to search.
count
intThe length of the range to search.
item
TThe object to locate.
comparer
IStructComparer<T>The IStructComparer<T> implementation to use when comparing elements.
The zero-based index of item
in the sorted StructList<T>, if item
is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item
or, if there is no larger element, the bitwise complement of Count.
Searches a range of elements in the sorted StructList<T> for an element using the specified StructComparison<T> and returns the zero-based index of the element.
public int BinarySearch(int index, int count, in T item, StructComparison<T> comparison)
index
intThe zero-based starting index of the range to search.
count
intThe length of the range to search.
item
TThe object to locate.
comparison
StructComparison<T>The StructComparison<T> to use when comparing elements.
The zero-based index of item
in the sorted StructList<T>, if item
is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item
or, if there is no larger element, the bitwise complement of Count.
Removes all elements from the StructList<T>.
public void Clear()
Converts the elements in the current StructList<T> to another type, and returns a list containing the converted elements.
public StructList<TOutput> ConvertAll<TOutput>(StructConverter<T, TOutput> converter) where TOutput : struct
converter
StructConverter<T, TOutput>A StructConverter<TInput, TOutput> delegate that converts each element from one type to another type.
A StructList<T> of the target type containing the converted elements from the current StructList<T>.
TOutput
The type of the elements of the target array.
Copies the entire StructList<T> to a compatible one-dimensional array, starting at the specified index of the target array.
public void CopyTo(T[] array, int arrayIndex)
array
T[]The one-dimensional System.Array that is the destination of the elements copied from StructList<T>.
arrayIndex
intThe zero-based index in array
at which copying begins.
Copies a range of elements from the StructList<T> to a compatible one-dimensional array, starting at the specified index of the target array.
public void CopyTo(int index, T[] array, int arrayIndex, int count)
index
intThe zero-based index in the source StructList<T> at which copying begins.
array
T[]The one-dimensional System.Array that is the destination of the elements copied from StructList<T>.
arrayIndex
intThe zero-based index in array
at which copying begins.
count
intThe number of elements to copy.
Gets the number of elements in the StructList<T> that match the conditions defined by the specified predicate.
public int CountAll(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the elements to match.
The number of elements that match the conditions defined by the predicate.
Determines whether the StructList<T> contains elements that match the conditions defined by the specified predicate.
public bool Exists(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the elements to search for.
true if the StructList<T> contains one or more elements that match the conditions defined by the specified predicate; otherwise, false.
Retrieves all the elements that match the conditions defined by the specified predicate.
public StructList<T> FindAll(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the elements to search for.
A StructList<T> containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty StructList<T>.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire StructList<T>.
public int FindIndex(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the first occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the StructList<T> that extends from the specified index to the last element.
public int FindIndex(int startIndex, StructPredicate<T> match)
startIndex
intThe zero-based starting index of the search.
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the first occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the StructList<T> that starts at the specified index and contains the specified number of elements.
public int FindIndex(int startIndex, int count, StructPredicate<T> match)
startIndex
intThe zero-based starting index of the search.
count
intThe number of elements in the section to search.
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the first occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire StructList<T>.
public int FindLastIndex(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the last occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the StructList<T> that extends from the first element to the specified index.
public int FindLastIndex(int startIndex, StructPredicate<T> match)
startIndex
intThe zero-based starting index of the backward search.
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the last occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the StructList<T> that contains the specified number of elements and ends at the specified index.
public int FindLastIndex(int startIndex, int count, StructPredicate<T> match)
startIndex
intThe zero-based starting index of the backward search.
count
intThe number of elements in the section to search.
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the element to search for.
The zero-based index of the last occurrence of an element that matches the conditions defined by match
, if found; otherwise, –1.
Performs the specified action on each element of the StructList<T>.
public void ForEach(StructAction<T> action)
action
StructAction<T>The StructAction<T> delegate to perform on each element of the StructList<T>.
Creates a shallow copy of a range of elements in the source StructList<T>.
public StructList<T> GetRange(int index, int count)
index
intThe zero-based StructList<T> index at which the range starts.
count
intThe number of elements in the range.
A shallow copy of a range of elements in the source StructList<T>.
Inserts a struct into the StructList<T> at the specified index.
public void Insert(int index, in T item)
index
intThe zero-based index at which item
should be inserted.
item
TThe struct to insert.
Inserts the elements of an array into the StructList<T> at the specified index.
public void InsertArray(int index, T[] array, int arrayIndex, int count)
index
intThe zero-based index at which the new elements should be inserted.
array
T[]The array whose elements should be inserted into the StructList<T>.
arrayIndex
intThe zero-based index of the first element in the array
to insert.
count
intThe number of elements to insert.
Inserts the elements of a collection into the StructList<T> at the specified index.
public void InsertRange(int index, IEnumerable<T> collection)
index
intThe zero-based index at which the new elements should be inserted.
collection
System.Collections.Generic.IEnumerable<T><T>The collection whose elements should be inserted into the StructList<T>.
Removes all the elements that match the conditions defined by the specified predicate.
public int RemoveAll(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions of the elements to remove.
The number of elements removed from the StructList<T>.
Removes the element at the specified index of the StructList<T>.
public void RemoveAt(int index)
index
intThe zero-based index of the element to remove.
Removes a range of elements from the StructList<T>.
public void RemoveRange(int index, int count)
index
intThe zero-based starting index of the range of elements to remove.
count
intThe number of elements to remove.
Reverses the order of the elements in the entire StructList<T>.
public void Reverse()
Reverses the order of the elements in the specified range.
public void Reverse(int index, int count)
index
intThe zero-based starting index of the range to reverse.
count
intThe number of elements in the range to reverse.
Sorts the elements in the entire StructList<T> using the specified comparer.
public void Sort(IStructComparer<T> comparer)
comparer
IStructComparer<T>The IStructComparer<T> implementation to use when comparing elements.
Sorts the elements in the entire StructList<T> using the specified StructComparison<T>.
public void Sort(StructComparison<T> comparison)
comparison
StructComparison<T>The StructComparison<T> to use when comparing elements.
Sorts the elements in a range of elements in StructList<T> using the specified comparer.
public void Sort(int index, int count, IStructComparer<T> comparer)
index
intThe zero-based starting index of the range to sort.
count
intThe length of the range to sort.
comparer
IStructComparer<T>The IStructComparer<T> implementation to use when comparing elements.
Sorts the elements in a range of elements in StructList<T> using the specified StructComparison<T>.
public void Sort(int index, int count, StructComparison<T> comparison)
index
intThe zero-based starting index of the range to sort.
count
intThe length of the range to sort.
comparison
StructComparison<T>The StructComparison<T> to use when comparing elements.
Copies the elements of the StructList<T> to a new array.
public T[] ToArray()
An array containing copies of the elements of the StructList<T>.
Sets the capacity to the actual number of elements in the StructList<T>, if that number is less than a threshold value.
public void TrimExcess()
Determines whether every element in the StructList<T> matches the conditions defined by the specified predicate.
public bool TrueForAll(StructPredicate<T> match)
match
StructPredicate<T>The StructPredicate<T> delegate that defines the conditions to check against the elements.
true if every element in the StructList<T> matches the conditions defined by the specified predicate; otherwise, false. If the list has no elements, the return value is true.