Class AllocationArray<T>
Represents a dynamically resizing array allocation.
public class AllocationArray<T> : IEnumerable<T>, IEnumerable
Type Parameters
TThe type of elements stored in the array.
- Inheritance
-
AllocationArray<T>
- Implements
-
IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
AllocationArray(int)
Initializes a new instance of the AllocationArray<T> class with the specified capacity.
public AllocationArray(int capacity = 1)
Parameters
capacityintThe initial capacity of the array. Must be at least 1.
Properties
Buffer
Gets the underlying buffer array.
public T[] Buffer { get; }
Property Value
- T[]
Count
Gets or sets the current number of elements in the array.
public int Count { get; set; }
Property Value
this[int]
Gets or sets the element at the specified index.
public T this[int index] { get; set; }
Parameters
indexintThe zero-based index of the element to get or set.
Property Value
- T
The element at the specified index.
MaxCount
Gets or sets the maximum allowed count of elements.
public int MaxCount { get; set; }
Property Value
Methods
Add(T)
Adds an item to the end of the array.
public void Add(T item)
Parameters
itemTThe item to add.
Add(T[], int, int)
Adds a range of items from an array to the end of the allocation array.
public void Add(T[] items, int offset, int count)
Parameters
itemsT[]The array of items to add.
offsetintThe zero-based index at which to start copying from the source array.
countintThe number of items to copy.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator for the allocation array.
RemoveAt(int)
Removes the item at the specified index.
public void RemoveAt(int index)
Parameters
indexintThe zero-based index of the item to remove.
RemoveRange(int, int)
Removes a range of items from the array.
public void RemoveRange(int startIndex, int count)
Parameters
startIndexintThe zero-based starting index of the range to remove.
countintThe number of items to remove.
Reset(int)
Resets the array, clearing all elements and optionally resizing the buffer.
public void Reset(int capacity = 1)
Parameters
capacityintThe desired capacity. Must be at least 1.