Search Results for

    Show / Hide Table of Contents

    Class FastList<T>

    List<T> implementation that allows you to access the internal array.

    Inheritance
    object
    FastList<T>
    RenderObjectSource
    Namespace: Evergine.Common.Collections
    Assembly: Evergine.Common.dll
    Syntax
    public class FastList<T>
    Type Parameters
    Name Description
    T

    The element type.

    Constructors

    FastList()

    Initializes a new instance of the FastList<T> class.

    Declaration
    public FastList()

    FastList(IEnumerable<T>)

    Initializes a new instance of the FastList<T> class.

    Declaration
    public FastList(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The item collection.

    FastList(int)

    Initializes a new instance of the FastList<T> class.

    Declaration
    public FastList(int capacity)
    Parameters
    Type Name Description
    int capacity

    The capacity of the list.

    Properties

    Capacity

    Gets or sets the capacity of the list.

    Declaration
    public int Capacity { get; set; }
    Property Value
    Type Description
    int

    Count

    Gets the number of elements in the collection.

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    int

    The number of elements in the collection.

    this[int]

    Gets or sets the element at the specified index.

    Declaration
    public T this[int index] { get; set; }
    Parameters
    Type Name Description
    int index

    The zero-based index of the element to get or set.

    Property Value
    Type Description
    T

    The element at the specified index.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    index is not a valid index in the IList<T>.

    NotSupportedException

    The property is set and the IList<T> is read-only.

    Items

    Gets the items.

    Declaration
    public T[] Items { get; }
    Property Value
    Type Description
    T[]

    Methods

    Add(T)

    Adds an item to the ICollection<T>.

    Declaration
    public void Add(T item)
    Parameters
    Type Name Description
    T item

    The object to add to the ICollection<T>.

    Exceptions
    Type Condition
    NotSupportedException

    The ICollection<T> is read-only.

    AddRange(IEnumerable<T>)

    Adds a collection of elements to the list.

    Declaration
    public void AddRange(IEnumerable<T> collection)
    Parameters
    Type Name Description
    IEnumerable<T> collection

    The collection to add.

    AsReadOnly()

    Returns the list as a ReadOnlyCollection.

    Declaration
    public ReadOnlyCollection<T> AsReadOnly()
    Returns
    Type Description
    ReadOnlyCollection<T>

    A ReadOnlyCollection object containing the items of the list.

    BinarySearch(int, int, T, IComparer<T>)

    Searches for an item using the binary search method.

    Declaration
    public int BinarySearch(int index, int count, T item, IComparer<T> comparer)
    Parameters
    Type Name Description
    int index

    The starting index of the range to search.

    int count

    The length of the range to search.

    T item

    The object to search for.

    IComparer<T> comparer

    The comparer implementation to use when comparing elements, or null to use the default comparison for each element.

    Returns
    Type Description
    int

    The index of the specified value in the specified array, if found; otherwise, a negative number.

    BinarySearch(T)

    Searches for an item using the binary search method.

    Declaration
    public int BinarySearch(T item)
    Parameters
    Type Name Description
    T item

    The object to search for.

    Returns
    Type Description
    int

    The index of the specified value in the specified array if the value is found; otherwise, a negative number.

    BinarySearch(T, IComparer<T>)

    Searches for an item using the binary search method.

    Declaration
    public int BinarySearch(T item, IComparer<T> comparer)
    Parameters
    Type Name Description
    T item

    The object to search for.

    IComparer<T> comparer

    The comparer implementation to use when comparing elements, or null to use the comparable implementation of each element.

    Returns
    Type Description
    int

    The index of the specified value in the array, if found; otherwise, a negative number.

    Clear()

    Removes all items from the ICollection<T>.

    Declaration
    public void Clear()
    Exceptions
    Type Condition
    NotSupportedException

    The ICollection<T> is read-only.

    Clear(bool)

    Clears this list with a fast-clear option.

    Declaration
    public void Clear(bool fastClear)
    Parameters
    Type Name Description
    bool fastClear

    If set to true, this method only resets the count of elements but doesn't clear items already stored in the list.

    Contains(T)

    Determines whether the ICollection<T> contains a specific value.

    Declaration
    public bool Contains(T item)
    Parameters
    Type Name Description
    T item

    The object to locate in the ICollection<T>.

    Returns
    Type Description
    bool

    true if item is found in the ICollection<T>; otherwise, false.

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

    Copies the elements of this list to another array.

    Declaration
    public void CopyTo(int index, T[] array, int arrayIndex, int count)
    Parameters
    Type Name Description
    int index

    The starting index of this list.

    T[] array

    The destination array where the elements will be copied.

    int arrayIndex

    The starting index of the destination array.

    int count

    The number of elements to be copied.

    CopyTo(T[])

    Copies the elements of this list to another array.

    Declaration
    public void CopyTo(T[] array)
    Parameters
    Type Name Description
    T[] array

    The destination array to which the elements of this list will be copied.

    CopyTo(T[], int)

    Copies the elements of the ICollection<T> to an Array, starting at a particular Array index.

    Declaration
    public void CopyTo(T[] array, int arrayIndex)
    Parameters
    Type Name Description
    T[] array

    The one-dimensional Array that is the destination of the elements copied from ICollection<T>. The Array must have zero-based indexing.

    int arrayIndex

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

    Exceptions
    Type Condition
    ArgumentNullException

    array is null.

    ArgumentOutOfRangeException

    arrayIndex is less than 0.

    ArgumentException

    The number of elements in the source ICollection<T> is greater than the available space from arrayIndex to the end of the destination array.

    EnsureCapacity(int)

    Increases the list capacity, ensuring the minimum size is provided.

    Declaration
    public void EnsureCapacity(int min)
    Parameters
    Type Name Description
    int min

    The minimum capacity.

    Exists(Predicate<T>)

    Checks if the list contains an item that satisfies the predicate.

    Declaration
    public bool Exists(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    bool

    True if an element exists that matches the predicate, false otherwise.

    Find(Predicate<T>)

    Finds the first item in this list that matches a predicate.

    Declaration
    public T Find(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    T

    The item that matches the predicate, or the default value if none is found.

    FindAll(Predicate<T>)

    Finds all the items of this list that match a predicate.

    Declaration
    public FastList<T> FindAll(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    FastList<T>

    A FastList containing the items that match the predicate.

    FindIndex(int, int, Predicate<T>)

    Finds the index of the first item in the list that matches the predicate.

    Declaration
    public int FindIndex(int startIndex, int count, Predicate<T> match)
    Parameters
    Type Name Description
    int startIndex

    The starting index to search.

    int count

    The number of elements to search.

    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    int

    The index of the matching item if it exists; a negative value otherwise.

    FindIndex(int, Predicate<T>)

    Finds the index of the first item in the list that matches the predicate.

    Declaration
    public int FindIndex(int startIndex, Predicate<T> match)
    Parameters
    Type Name Description
    int startIndex

    The starting index to search from.

    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    int

    The index of the matching item if it exists; a negative value otherwise.

    FindIndex(Predicate<T>)

    Finds the index of the first item in the list that matches the predicate.

    Declaration
    public int FindIndex(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    int

    The index of the matching item if it exists; a negative value otherwise.

    FindLast(Predicate<T>)

    Finds the last item of this list that matches the predicate.

    Declaration
    public T FindLast(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    T

    The last item that matches the predicate; its default value otherwise.

    FindLastIndex(int, int, Predicate<T>)

    Finds the index of the last item in this list that matches the predicate.

    Declaration
    public int FindLastIndex(int startIndex, int count, Predicate<T> match)
    Parameters
    Type Name Description
    int startIndex

    The starting index for the search.

    int count

    The number of items to search.

    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    int

    The index of the last item that matches the predicate, if it exists; a negative value otherwise.

    FindLastIndex(int, Predicate<T>)

    Finds the index of the last item in this list that matches the predicate.

    Declaration
    public int FindLastIndex(int startIndex, Predicate<T> match)
    Parameters
    Type Name Description
    int startIndex

    The starting index for the search.

    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    int

    The index of the last item that matches the predicate if it exists; a negative value otherwise.

    FindLastIndex(Predicate<T>)

    Finds the index of the last item in this list that matches the predicate.

    Declaration
    public int FindLastIndex(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    int

    The index of the last item that matches the predicate if it exists; a negative value otherwise.

    ForEach(Action<T>)

    Executes an action for each item in this list.

    Declaration
    public void ForEach(Action<T> action)
    Parameters
    Type Name Description
    Action<T> action

    The action to execute for each element.

    GetEnumerator()

    Gets the list enumerator.

    Declaration
    public FastList<T>.Enumerator GetEnumerator()
    Returns
    Type Description
    FastList<T>.Enumerator

    Returns the list enumerator.

    GetRange(int, int)

    Gets another FastList containing a range of elements from this list.

    Declaration
    public FastList<T> GetRange(int index, int count)
    Parameters
    Type Name Description
    int index

    The start index.

    int count

    The range size.

    Returns
    Type Description
    FastList<T>

    A FastList containing a range of elements from this list.

    IncreaseCapacity(int)

    Increases the capacity of this list.

    Declaration
    public void IncreaseCapacity(int amount)
    Parameters
    Type Name Description
    int amount

    The amount by which to increase the capacity.

    IndexOf(T)

    Determines the index of a specific item in the IList<T>.

    Declaration
    public int IndexOf(T item)
    Parameters
    Type Name Description
    T item

    The object to locate in the IList<T>.

    Returns
    Type Description
    int

    The index of item if found in the list; otherwise, -1.

    IndexOf(T, int)

    Gets the index of an item in this list, starting at a specified index.

    Declaration
    public int IndexOf(T item, int index)
    Parameters
    Type Name Description
    T item

    The item to search for.

    int index

    The starting index.

    Returns
    Type Description
    int

    The index of the item if it exists in the list; a negative value otherwise.

    IndexOf(T, int, int)

    Gets the index of an item in this list, starting at a specified index.

    Declaration
    public int IndexOf(T item, int index, int count)
    Parameters
    Type Name Description
    T item

    The item to search for.

    int index

    The starting index.

    int count

    The number of elements to search.

    Returns
    Type Description
    int

    The index of the item if it exists in the list; a negative value otherwise.

    Insert(int, T)

    Inserts an item to the IList<T> at the specified index.

    Declaration
    public void Insert(int index, T item)
    Parameters
    Type Name Description
    int index

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

    T item

    The object to insert into the IList<T>.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    index is not a valid index in the IList<T>.

    NotSupportedException

    The IList<T> is read-only.

    InsertRange(int, IEnumerable<T>)

    Inserts a collection of items into this list at a specified index.

    Declaration
    public void InsertRange(int index, IEnumerable<T> collection)
    Parameters
    Type Name Description
    int index

    The index at which to insert.

    IEnumerable<T> collection

    The collection of items to insert.

    LastIndexOf(T)

    Gets the last index of an item in this list.

    Declaration
    public int LastIndexOf(T item)
    Parameters
    Type Name Description
    T item

    The item to search for.

    Returns
    Type Description
    int

    The index of the last occurrence of the item if it exists in the list; a negative value otherwise.

    LastIndexOf(T, int)

    Gets the last index of an item in this list.

    Declaration
    public int LastIndexOf(T item, int index)
    Parameters
    Type Name Description
    T item

    The item to be searched for.

    int index

    The starting index.

    Returns
    Type Description
    int

    The index of the last item if it exists in the list; a negative value otherwise.

    LastIndexOf(T, int, int)

    Gets the last index of an item in this list.

    Declaration
    public int LastIndexOf(T item, int index, int count)
    Parameters
    Type Name Description
    T item

    The item to be searched.

    int index

    The start index.

    int count

    The number of elements to search through.

    Returns
    Type Description
    int

    The index of the last item if it exists in the list; a negative value otherwise.

    Remove(T)

    Removes the first occurrence of a specific object from the ICollection<T>.

    Declaration
    public bool Remove(T item)
    Parameters
    Type Name Description
    T item

    The object to remove from the ICollection<T>.

    Returns
    Type Description
    bool

    true if item was successfully removed from the ICollection<T>; otherwise, false. This method also returns false if item is not found in the original ICollection<T>.

    Exceptions
    Type Condition
    NotSupportedException

    The ICollection<T> is read-only.

    RemoveAll(Predicate<T>)

    Removes all the elements of this array that match the predicate.

    Declaration
    public int RemoveAll(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to be matched.

    Returns
    Type Description
    int

    The number of items removed.

    RemoveAt(int)

    Removes the IList<T> item at the specified index.

    Declaration
    public void RemoveAt(int index)
    Parameters
    Type Name Description
    int index

    The zero-based index of the item to remove.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    index is not a valid index in the IList<T>.

    NotSupportedException

    The IList<T> is read-only.

    RemoveRange(int, int)

    Removes a range of items from this list.

    Declaration
    public void RemoveRange(int index, int count)
    Parameters
    Type Name Description
    int index

    The starting index for removal.

    int count

    The number of items to remove.

    Resize(int, bool)

    Resizes this list.

    Declaration
    public void Resize(int newSize, bool fastClear)
    Parameters
    Type Name Description
    int newSize

    The new list size.

    bool fastClear

    Specifies whether the inner array should not be cleared when resizing.

    Reverse()

    Reverses the elements in this list.

    Declaration
    public void Reverse()

    Reverse(int, int)

    Reverses a range within the list.

    Declaration
    public void Reverse(int index, int count)
    Parameters
    Type Name Description
    int index

    The starting index.

    int count

    The number of elements to reverse.

    Sort()

    Sorts the list.

    Declaration
    public void Sort()

    Sort(IComparer<T>)

    Sorts the list.

    Declaration
    public void Sort(IComparer<T> comparer)
    Parameters
    Type Name Description
    IComparer<T> comparer

    The comparer used in the operation.

    Sort(int, int, IComparer<T>)

    Sorts the list.

    Declaration
    public void Sort(int index, int count, IComparer<T> comparer)
    Parameters
    Type Name Description
    int index

    The starting item of the sort range.

    int count

    The number of items in the range to be sorted.

    IComparer<T> comparer

    The comparer used for sorting.

    ToArray()

    Gets the list as an array.

    Declaration
    public T[] ToArray()
    Returns
    Type Description
    T[]

    A new array containing all the items in the list.

    TrimExcess()

    Adjusts the capacity of the list to match its current size.

    Declaration
    public void TrimExcess()

    TrueForAll(Predicate<T>)

    Checks if all the items of the list match a predicate.

    Declaration
    public bool TrueForAll(Predicate<T> match)
    Parameters
    Type Name Description
    Predicate<T> match

    The predicate to match.

    Returns
    Type Description
    bool

    True if all the items of the list match the predicate; false otherwise.

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In this article
    Back to top
    Generated by DocFX