Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    OrderedCollection<T> Class

    Namespace: Stride.Core.Collections
    Assembly: Stride.Core.dll

    A collection that maintains the order of the elements and lightter implementation of System.Collections.ObjectModel.Collection<T> with value types enumerators to avoid allocation in foreach loops, and various helper functions.

    System.Object → OrderedCollection<T>
    Derived from OrderedCollection<T>: EntityProcessorCollection

    [DataSerializer(typeof(ListAllSerializer<, >), Mode = DataSerializerGenericMode.TypeAndGenericArguments)]
    public class OrderedCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable
    Type Parameters
    Name Description
    T

    Type of elements of this collection

    Name Description
    Constructors
    OrderedCollection(IComparer<T>)

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

    OrderedCollection(IComparer<T>, Int32)

    Initializes a new instance of the OrderedCollection<T> class with a default capacity.

    Properties
    Capacity
    Count
    Item[Int32]

    Gets the element at the specified index.

    Methods
    Add(T)
    AddItem(T)

    Adds an item to this collection. Can be overriden.

    AddRange<TE>(TE)

    Adds the elements of the specified source to the end of FastCollection<T>.

    Clear()
    ClearItems()

    Clears all the items in this collection. Can be overriden.

    Contains(T)
    CopyTo(T[], Int32)
    EnsureCapacity(Int32)
    GetEnumerator()

    Inline Enumerator used directly by foreach.

    IndexOf(T)
    RemoteItem(Int32)
    Remove(T)
    RemoveAt(Int32)
    Explicit Interface Implementations
    ICollection<T>.IsReadOnly
    IEnumerable<T>.GetEnumerator()
    IEnumerable.GetEnumerator()
    | Improve this Doc View Source

    Constructors


    OrderedCollection(IComparer<T>)

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

    public OrderedCollection(IComparer<T> comparer)
    Parameters
    Type Name Description
    System.Collections.Generic.IComparer<T> comparer

    The comparer providing information about order between elements.

    Exceptions
    Type Condition
    System.ArgumentNullException

    If comparer is null


    OrderedCollection(IComparer<T>, Int32)

    Initializes a new instance of the OrderedCollection<T> class with a default capacity.

    public OrderedCollection(IComparer<T> comparer, int capacity)
    Parameters
    Type Name Description
    System.Collections.Generic.IComparer<T> comparer

    The comparer.

    System.Int32 capacity

    The capacity.

    | Improve this Doc View Source

    Properties


    Capacity

    public int Capacity { get; set; }
    Property Value
    Type Description
    System.Int32

    Count

    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    Item[Int32]

    Gets the element at the specified index.

    public T this[int index] { get; }
    Parameters
    Type Name Description
    System.Int32 index

    The index.

    Property Value
    Type Description
    T

    The element at the specified index

    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    If index is out of range

    | Improve this Doc View Source

    Methods


    Add(T)

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

    AddItem(T)

    Adds an item to this collection. Can be overriden.

    protected virtual void AddItem(T item)
    Parameters
    Type Name Description
    T item

    The item.


    AddRange<TE>(TE)

    Adds the elements of the specified source to the end of FastCollection<T>.

    public void AddRange<TE>(TE itemsArgs)
        where TE : IEnumerable<T>
    Parameters
    Type Name Description
    TE itemsArgs

    The items to add to this collection.

    Type Parameters
    Name Description
    TE

    Clear()

    public void Clear()

    ClearItems()

    Clears all the items in this collection. Can be overriden.

    protected virtual void ClearItems()

    Contains(T)

    public bool Contains(T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    System.Boolean

    CopyTo(T[], Int32)

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

    EnsureCapacity(Int32)

    public void EnsureCapacity(int min)
    Parameters
    Type Name Description
    System.Int32 min

    GetEnumerator()

    Inline Enumerator used directly by foreach.

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

    An enumerator of this collection


    IndexOf(T)

    public int IndexOf(T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    System.Int32

    RemoteItem(Int32)

    protected virtual void RemoteItem(int index)
    Parameters
    Type Name Description
    System.Int32 index

    Remove(T)

    public bool Remove(T item)
    Parameters
    Type Name Description
    T item
    Returns
    Type Description
    System.Boolean

    RemoveAt(Int32)

    public void RemoveAt(int index)
    Parameters
    Type Name Description
    System.Int32 index
    | Improve this Doc View Source

    Explicit Interface Implementations


    ICollection<T>.IsReadOnly

    bool ICollection<T>.IsReadOnly { get; }
    Returns
    Type Description
    System.Boolean

    IEnumerable<T>.GetEnumerator()

    IEnumerator<T> IEnumerable<T>.GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<T>

    IEnumerable.GetEnumerator()

    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    System.Collections.IEnumerator

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    ArrayExtensions.ComputeHash<T>(ICollection<T>, IEqualityComparer<T>)
    EnumerableExtensions.IsNullOrEmpty(IEnumerable)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
    EnumerableExtensions.IndexOf<T>(IEnumerable<T>, Func<T, Boolean>)
    EnumerableExtensions.LastIndexOf<T>(IEnumerable<T>, Func<T, Boolean>)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation