Table of Contents

Class AllocationArray<T>

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Represents a dynamically resizing array allocation.

public class AllocationArray<T> : IEnumerable<T>, IEnumerable

Type Parameters

T

The type of elements stored in the array.

Inheritance
AllocationArray<T>
Implements
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

capacity int

The 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

int

this[int]

Gets or sets the element at the specified index.

public T this[int index] { get; set; }

Parameters

index int

The 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

int

Methods

Add(T)

Adds an item to the end of the array.

public void Add(T item)

Parameters

item T

The 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

items T[]

The array of items to add.

offset int

The zero-based index at which to start copying from the source array.

count int

The 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

index int

The 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

startIndex int

The zero-based starting index of the range to remove.

count int

The 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

capacity int

The desired capacity. Must be at least 1.