[]
Represents a strongly typed read-only list of structs that can be effectively accessed by index.
public class ReadOnlyStructList<T> where T : struct
T
The type of structs in the list.
Initializes a new instance of the ReadOnlyStructList<T> class from a given instance of StructList<T>.
public ReadOnlyStructList(StructList<T> list)
list
StructList<T>Gets the number of elements actually contained in the ReadOnlyStructList<T>.
public int Count { 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 ReadOnlyStructList<T>.
public object SyncRoot { get; }
Searches a range of elements in the sorted ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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.
Converts the elements in the current ReadOnlyStructList<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 ReadOnlyStructList<T>.
TOutput
The type of the elements of the target array.
Copies the entire ReadOnlyStructList<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 ReadOnlyStructList<T>.
arrayIndex
intThe zero-based index in array
at which copying begins.
Copies a range of elements from the ReadOnlyStructList<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 ReadOnlyStructList<T> at which copying begins.
array
T[]The one-dimensional System.Array that is the destination of the elements copied from ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<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 ReadOnlyStructList<T>.
public void ForEach(StructAction<T> action)
action
StructAction<T>The StructAction<T> delegate to perform on each element of the ReadOnlyStructList<T>.
Creates a shallow copy of a range of elements in the source ReadOnlyStructList<T>.
public StructList<T> GetRange(int index, int count)
index
intThe zero-based ReadOnlyStructList<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 ReadOnlyStructList<T>.
Copies the elements of the ReadOnlyStructList<T> to a new array.
public T[] ToArray()
An array containing copies of the elements of the ReadOnlyStructList<T>.
Determines whether every element in the ReadOnlyStructList<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 ReadOnlyStructList<T> matches the conditions defined by the specified predicate; otherwise, false. If the list has no elements, the return value is true.