OrderedCollection<T> Class
Namespace: Stride.Core.CollectionsAssembly: 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.
[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 |
|
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() |
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. |
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
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 |
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 |
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 |