[]
        
(Showing Draft Content)

GrapeCity.Documents.Common.StructList-1

Class StructList<T>

Namespace
GrapeCity.Documents.Common
Assembly
GcDocs.Imaging.dll

Represents a strongly typed list of structs that can be effectively accessed by index.

public class StructList<T> where T : struct

Type Parameters

T

The type of structs in the list.

Inheritance
object
StructList<T>
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Constructors

StructList()

Initializes a new instance of the StructList<T> class that is empty.

public StructList()

StructList(T[], int, int)

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)

Parameters

array T[]

The array whose elements should be added to the StructList<T>.

arrayIndex int

The zero-based index of the first element in the array to add.

count int

The number of elements to add.

StructList(IEnumerable<T>)

Initializes a new instance of the StructList<T> class that contains elements copied from the specified collection.

public StructList(IEnumerable<T> collection)

Parameters

collection System.Collections.Generic.IEnumerable<T><T>

The collection whose elements are copied to the new list.

StructList(int)

Initializes a new instance of the StructList<T> class that is empty and has the specified initial capacity.

public StructList(int capacity)

Parameters

capacity int

The number of elements that the new list can initially store.

Properties

Capacity

Gets or sets the total number of elements the internal array can hold without resizing.

public int Capacity { get; set; }

Property Value

int

Count

Gets the number of elements actually contained in the StructList<T>.

public int Count { get; }

Property Value

int

InnerArray

Gets the current array containing the elements of the StructList<T>.

public T[] InnerArray { get; }

Property Value

T[]

this[int]

Gets a reference to the struct at the specified index.

public ref T this[int index] { get; }

Parameters

index int

Property Value

T

SyncRoot

Gets an object that can be used to synchronize access to the StructList<T>.

public object SyncRoot { get; }

Property Value

object

Methods

Add(in T)

Adds a struct to the end of the StructList<T>.

public void Add(in T item)

Parameters

item T

The struct to be added to the end of the StructList<T>.

AddArray(T[], int, int)

Adds the elements of the specified array to the end of the StructList<T>.

public void AddArray(T[] array, int arrayIndex, int count)

Parameters

array T[]

The array whose elements should be added to the end of the StructList<T>.

arrayIndex int

The zero-based index of the first element in the array to add.

count int

The number of elements to add.

AddRange(IEnumerable<T>)

Adds the elements of the specified collection to the end of the StructList<T>.

public void AddRange(IEnumerable<T> collection)

Parameters

collection System.Collections.Generic.IEnumerable<T><T>

The collection whose elements should be added to the end of the StructList<T>.

AsReadOnly()

Returns a read-only ReadOnlyStructList<T> wrapper for the current StructList<T>.

public ReadOnlyStructList<T> AsReadOnly()

Returns

ReadOnlyStructList<T>

A ReadOnlyStructList<T> that acts as a read-only wrapper around the current StructList<T>.

BinarySearch(int, int, in T, IStructComparer<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)

Parameters

index int

The zero-based starting index of the range to search.

count int

The length of the range to search.

item T

The object to locate.

comparer IStructComparer<T>

The IStructComparer<T> implementation to use when comparing elements.

Returns

int

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.

BinarySearch(int, int, in T, StructComparison<T>)

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)

Parameters

index int

The zero-based starting index of the range to search.

count int

The length of the range to search.

item T

The object to locate.

comparison StructComparison<T>

The StructComparison<T> to use when comparing elements.

Returns

int

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.

Clear()

Removes all elements from the StructList<T>.

public void Clear()

ConvertAll<TOutput>(StructConverter<T, TOutput>)

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

Parameters

converter StructConverter<T, TOutput>

A StructConverter<TInput, TOutput> delegate that converts each element from one type to another type.

Returns

StructList<TOutput>

A StructList<T> of the target type containing the converted elements from the current StructList<T>.

Type Parameters

TOutput

The type of the elements of the target array.

CopyTo(T[], int)

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)

Parameters

array T[]

The one-dimensional System.Array that is the destination of the elements copied from StructList<T>.

arrayIndex int

The zero-based index in array at which copying begins.

CopyTo(int, T[], int, int)

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)

Parameters

index int

The 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 int

The zero-based index in array at which copying begins.

count int

The number of elements to copy.

CountAll(StructPredicate<T>)

Gets the number of elements in the StructList<T> that match the conditions defined by the specified predicate.

public int CountAll(StructPredicate<T> match)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the elements to match.

Returns

int

The number of elements that match the conditions defined by the predicate.

Exists(StructPredicate<T>)

Determines whether the StructList<T> contains elements that match the conditions defined by the specified predicate.

public bool Exists(StructPredicate<T> match)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the elements to search for.

Returns

bool

true if the StructList<T> contains one or more elements that match the conditions defined by the specified predicate; otherwise, false.

FindAll(StructPredicate<T>)

Retrieves all the elements that match the conditions defined by the specified predicate.

public StructList<T> FindAll(StructPredicate<T> match)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the elements to search for.

Returns

StructList<T>

A StructList<T> containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty StructList<T>.

FindIndex(StructPredicate<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)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the element to search for.

Returns

int

The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

FindIndex(int, StructPredicate<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 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)

Parameters

startIndex int

The zero-based starting index of the search.

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the element to search for.

Returns

int

The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

FindIndex(int, int, StructPredicate<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 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)

Parameters

startIndex int

The zero-based starting index of the search.

count int

The 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.

Returns

int

The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

FindLastIndex(StructPredicate<T>)

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)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the element to search for.

Returns

int

The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

FindLastIndex(int, StructPredicate<T>)

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)

Parameters

startIndex int

The 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.

Returns

int

The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

FindLastIndex(int, int, StructPredicate<T>)

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)

Parameters

startIndex int

The zero-based starting index of the backward search.

count int

The 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.

Returns

int

The zero-based index of the last occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

ForEach(StructAction<T>)

Performs the specified action on each element of the StructList<T>.

public void ForEach(StructAction<T> action)

Parameters

action StructAction<T>

The StructAction<T> delegate to perform on each element of the StructList<T>.

GetRange(int, int)

Creates a shallow copy of a range of elements in the source StructList<T>.

public StructList<T> GetRange(int index, int count)

Parameters

index int

The zero-based StructList<T> index at which the range starts.

count int

The number of elements in the range.

Returns

StructList<T>

A shallow copy of a range of elements in the source StructList<T>.

Insert(int, in T)

Inserts a struct into the StructList<T> at the specified index.

public void Insert(int index, in T item)

Parameters

index int

The zero-based index at which item should be inserted.

item T

The struct to insert.

InsertArray(int, T[], int, int)

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)

Parameters

index int

The 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 int

The zero-based index of the first element in the array to insert.

count int

The number of elements to insert.

InsertRange(int, IEnumerable<T>)

Inserts the elements of a collection into the StructList<T> at the specified index.

public void InsertRange(int index, IEnumerable<T> collection)

Parameters

index int

The 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>.

RemoveAll(StructPredicate<T>)

Removes all the elements that match the conditions defined by the specified predicate.

public int RemoveAll(StructPredicate<T> match)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions of the elements to remove.

Returns

int

The number of elements removed from the StructList<T>.

RemoveAt(int)

Removes the element at the specified index of the StructList<T>.

public void RemoveAt(int index)

Parameters

index int

The zero-based index of the element to remove.

RemoveRange(int, int)

Removes a range of elements from the StructList<T>.

public void RemoveRange(int index, int count)

Parameters

index int

The zero-based starting index of the range of elements to remove.

count int

The number of elements to remove.

Reverse()

Reverses the order of the elements in the entire StructList<T>.

public void Reverse()

Reverse(int, int)

Reverses the order of the elements in the specified range.

public void Reverse(int index, int count)

Parameters

index int

The zero-based starting index of the range to reverse.

count int

The number of elements in the range to reverse.

Sort(IStructComparer<T>)

Sorts the elements in the entire StructList<T> using the specified comparer.

public void Sort(IStructComparer<T> comparer)

Parameters

comparer IStructComparer<T>

The IStructComparer<T> implementation to use when comparing elements.

Sort(StructComparison<T>)

Sorts the elements in the entire StructList<T> using the specified StructComparison<T>.

public void Sort(StructComparison<T> comparison)

Parameters

comparison StructComparison<T>

The StructComparison<T> to use when comparing elements.

Sort(int, int, IStructComparer<T>)

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)

Parameters

index int

The zero-based starting index of the range to sort.

count int

The length of the range to sort.

comparer IStructComparer<T>

The IStructComparer<T> implementation to use when comparing elements.

Sort(int, int, StructComparison<T>)

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)

Parameters

index int

The zero-based starting index of the range to sort.

count int

The length of the range to sort.

comparison StructComparison<T>

The StructComparison<T> to use when comparing elements.

ToArray()

Copies the elements of the StructList<T> to a new array.

public T[] ToArray()

Returns

T[]

An array containing copies of the elements of the StructList<T>.

TrimExcess()

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()

TrueForAll(StructPredicate<T>)

Determines whether every element in the StructList<T> matches the conditions defined by the specified predicate.

public bool TrueForAll(StructPredicate<T> match)

Parameters

match StructPredicate<T>

The StructPredicate<T> delegate that defines the conditions to check against the elements.

Returns

bool

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.