Table of Contents

Class Pool<T>

Namespace
OmegaEngine.Collections
Assembly
OmegaEngine.dll

A very fast pseudo-collection (it does not implement IEnumerable<T>) that supports fast adding at the beginning.

public sealed class Pool<T> : IPoolable<T> where T : class, IPoolable<T>

Type Parameters

T

The type of items to store in the pool.

Inheritance
Pool<T>
Implements
Inherited Members
Extension Methods

Remarks

An item can always only be in one pool at any given time.

Properties

Count

Gets the number of elements contained in the pool

public int Count { get; }

Property Value

int

The number of elements contained in the pool

Methods

Add(T)

Adds an item to the beginning pool

public void Add(T item)

Parameters

item T

The object to add to the pool

Exceptions

ArgumentException

item is already in a pool.

Clear()

Removes all items from the pool

public void Clear()

Contains(T)

Determines whether the pool contains a specific value.

public bool Contains(T item)

Parameters

item T

The object to locate in the pool

Returns

bool

true if item is found in the pool; otherwise, false.

ForEach(Action<T>)

Performs the specified action on each element of the pool

public void ForEach(Action<T> action)

Parameters

action Action<T>

A delegate to perform on each element of the pool

Remove(T)

Removes the first occurrence of a specific object from the pool

public bool Remove(T item)

Parameters

item T

The object to remove from the pool

Returns

bool

true if item was successfully removed from the buffer list; otherwise, false. This method also returns false if item is not found in the original pool

Remarks

Not all too fast, try to avoid using this

RemoveAll(Action<T>)

Removes all the items in the buffer one-by-one, executing action after each removal.

public void RemoveAll(Action<T> action)

Parameters

action Action<T>

A delegate that is executed right after an item is removed.

Remarks

Ideal for moving all elements to a new data structure.

RemoveFirst(Predicate<T>)

Removes the first item in the buffer that satisfies the condition defined by predicate.

public void RemoveFirst(Predicate<T> predicate)

Parameters

predicate Predicate<T>

A delegate that defines the condition to check for.

Remarks

Ideal for selectively picking the first suitable element from the pool.

RemoveWhere(Predicate<T>)

Removes all the items in the buffer that satisfy the condition defined by predicate.

public void RemoveWhere(Predicate<T> predicate)

Parameters

predicate Predicate<T>

A delegate that defines the condition to check for.

Remarks

Ideal for selectively picking all suitable elements from the pool.