Struct MicroCollection<T>
- Namespace
- LfrlAnvil
- Assembly
- LfrlAnvil.Core.dll
Represents a collection of objects optimized for zero or one element(s).
public struct MicroCollection<T>
Type Parameters
TElement type.
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of elements contained in this collection.
public readonly int Count { get; }
Property Value
this[int]
Gets an element at the given index.
public T this[int index] { get; set; }
Parameters
indexintThe zero-based index of the element to get.
Property Value
- T
Exceptions
- ArgumentOutOfRangeException
When
indexis out of bounds.
Methods
Add(T)
Adds item to the end of this collection.
public void Add(T item)
Parameters
itemTItem to add.
Clear()
Removes all elements from this collection.
public void Clear()
Create()
Creates a new empty MicroCollection<T> instance.
[Pure]
public static MicroCollection<T> Create()
Returns
- MicroCollection<T>
New MicroCollection<T> instance.
GetEnumerator()
Creates a new MicroCollection<T>.Enumerator instance for this collection.
[Pure]
public MicroCollection<T>.Enumerator GetEnumerator()
Returns
- MicroCollection<T>.Enumerator
New MicroCollection<T>.Enumerator instance.
IndexOf(T)
Searches for the specified item in this collection and returns the index of its first occurrence.
[Pure]
public int IndexOf(T item)
Parameters
itemTItem to search for.
Returns
- int
The zero-based index of the first occurrence of
item, if it exists in this collection, otherwise -1.
Remove(T)
Removes the first occurrence of item from this collection.
public bool Remove(T item)
Parameters
itemTItem to remove.
Returns
- bool
true when
itemoccurrence was removed successfully, otherwise false.