AllocationArray

Ecng.Common

Represents a dynamically resizing array allocation.

Реализует: IEnumerable<T>, IEnumerable

Конструкторы

AllocationArray
public AllocationArray(int capacity)
allocationArray = AllocationArray(capacity)

Initializes a new instance of the AllocationArray class with the specified capacity.

capacity
The initial capacity of the array. Must be at least 1.

Свойства

Buffer
public T[] Buffer { get; }
value = allocationArray.Buffer

Gets the underlying buffer array.

Count
public int Count { get; set; }
value = allocationArray.Count
allocationArray.Count = value

Gets or sets the current number of elements in the array.

Item
public T Item { get; set; }
value = allocationArray.Item
allocationArray.Item = value

Gets or sets the element at the specified index.

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

Возвращает: The element at the specified index.

MaxCount
public int MaxCount { get; set; }
value = allocationArray.MaxCount
allocationArray.MaxCount = value

Gets or sets the maximum allowed count of elements.

Методы

Add
public void Add(T item)
allocationArray.Add(item)

Adds an item to the end of the array.

item
The item to add.
Add
public void Add(T[] items, int offset, int count)
allocationArray.Add(items, offset, count)

Adds a range of items from an array to the end of the allocation array.

items
The array of items to add.
offset
The zero-based index at which to start copying from the source array.
count
The number of items to copy.
EnsureCapacity
private void EnsureCapacity(int newSize)
allocationArray.EnsureCapacity(newSize)

Ensures that the array has the specified new size capacity.

newSize
The required size.
GetEnumerator
public IEnumerator<T> GetEnumerator()
result = allocationArray.GetEnumerator()

Returns an enumerator that iterates through the collection.

Возвращает: An enumerator for the allocation array.

RemoveAt
public void RemoveAt(int index)
allocationArray.RemoveAt(index)

Removes the item at the specified index.

index
The zero-based index of the item to remove.
RemoveRange
public void RemoveRange(int startIndex, int count)
allocationArray.RemoveRange(startIndex, count)

Removes a range of items from the array.

startIndex
The zero-based starting index of the range to remove.
count
The number of items to remove.
Reset
public void Reset(int capacity)
allocationArray.Reset(capacity)

Resets the array, clearing all elements and optionally resizing the buffer.

capacity
The desired capacity. Must be at least 1.
Resize
private void Resize(int capacity)
allocationArray.Resize(capacity)

Resizes the buffer array to the specified capacity.

capacity
The new capacity of the buffer.
System#Collections#IEnumerable#GetEnumerator()

Returns an enumerator that iterates through the collection.

Возвращает: An enumerator for the allocation array.