Pidgin

Class PooledList<T>

A version of List<T> which uses an array pool.

For efficiency, PooledList<T> is implemented as a mutable struct. It's intended to be passed by reference.

Inheritance
Implements
Declaration
public sealed class PooledList<T> : ValueType
Type Parameters
Name Description

T

The type of elements of the list.

Constructors

PooledList(ArrayPool<T>)

Creates a PooledList<T> which uses the supplied ArrayPool<T>.

Declaration
public PooledList(ArrayPool<T> arrayPool)
Parameters
Type Name Description

ArrayPool<T>

arrayPool

The array pool.

Properties

Count

The number of elements in the list.

Declaration
public int Count { get; }
Property Value
Type Description

Int32

IsReadOnly

Returns false.

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description

Boolean

False.

Item[Int32]

Gets or sets the element at index index.

Declaration
public T this[int index] { get; set; }
Parameters
Type Name Description

Int32

index

The index.

Property Value
Type Description

T

The element at index index.

Methods

Add(T)

Adds an item to the end of the list.

Declaration
public void Add(T item)
Parameters
Type Name Description

T

item

The item to add.

AddRange(ICollection<T>)

Adds a collection of items to the end of the list.

Declaration
public void AddRange(ICollection<T> items)
Parameters
Type Name Description

ICollection<T>

items

The items to add.

AddRange(IEnumerable<T>)

Adds a collection of items to the end of the list.

Declaration
public void AddRange(IEnumerable<T> items)
Parameters
Type Name Description

IEnumerable<T>

items

The items to add.

AddRange(ImmutableArray<T>)

Adds a collection of items to the end of the list.

Declaration
public void AddRange(ImmutableArray<T> items)
Parameters
Type Name Description

ImmutableArray<T>

items

The items to add.

AddRange(ReadOnlySpan<T>)

Adds a collection of items to the end of the list.

Declaration
public void AddRange(ReadOnlySpan<T> items)
Parameters
Type Name Description

ReadOnlySpan<T>

items

The items to add.

AsSpan()

Returns a Span<T> view of the list.

Declaration
public Span<T> AsSpan()
Returns
Type Description

Span<T>

A Span<T> view of the list.

Clear()

Empties the list.

Declaration
public void Clear()

Contains(T)

Searches for item in the list.

Declaration
public bool Contains(T item)
Parameters
Type Name Description

T

item

The item to search for.

Returns
Type Description

Boolean

True if the item is in the list, false if it is not.

CopyTo(T[], Int32)

Copies the list into an array.

Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description

T[]

array

The destination array to copy the list into.

Int32

arrayIndex

The starting index in the destination array.

Exceptions
Type Condition

ArgumentNullException

array was null.

ArgumentOutOfRangeException

arrayIndex was less than 0.

ArgumentException

There was not enough space in the array.

Dispose()

Returns any allocated memory to the pool.

Declaration
public void Dispose()

IndexOf(T)

Searches for item in the list and returns its index. Returns -1 if the item is missing.

Declaration
public int IndexOf(T item)
Parameters
Type Name Description

T

item

The item to search for.

Returns
Type Description

Int32

The index of item, or -1 if it is missing.

Insert(Int32, T)

Inserts item into the list at index.

Declaration
public void Insert(int index, T item)
Parameters
Type Name Description

Int32

index

The index at which to insert the item.

T

item

The item to insert.

Exceptions
Type Condition

ArgumentOutOfRangeException

The index is outside the bounds of the list.

Pop()

Removes and returns an item from the end of the list.

Declaration
public T Pop()
Returns
Type Description

T

The last item in the list.

Exceptions
Type Condition

InvalidOperationException

The list is empty.

Remove(T)

Searches for item in the list and removes it. Returns false if the item is missing.

Declaration
public bool Remove(T item)
Parameters
Type Name Description

T

item

The item to search for.

Returns
Type Description

Boolean

True if the item was removed, false if it was missing.

RemoveAt(Int32)

Removes the item at index.

Declaration
public void RemoveAt(int index)
Parameters
Type Name Description

Int32

index

The index from which to remove the item.

Exceptions
Type Condition

ArgumentOutOfRangeException

The index is outside the bounds of the list.

Implements

System.IDisposable
System.Collections.Generic.IList<T>
System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable