Table of Contents

Method AddFromPool

Namespace
Gamelogic.Extensions
Assembly
Gamelogic.Extensions.dll

AddFromPool<T>(ICollection<T>, IPool<T>, int)

Gets a number of objects from a pool, and adds them to the given collection.

public static void AddFromPool<T>(this ICollection<T> collection, IPool<T> pool, int count)

Parameters

collection ICollection<T>

The collection to add objects to.

pool IPool<T>

The pool to get objects from.

count int

The number of objects to get.

Type Parameters

T

The type of the objects in the pool.

Remarks

The idea with this method is that you may often want a bunch of object from a pool, but we do not want to create new objects (which may defy the point of pooling in the first place). Therefore, this method adds it directly to your collection.

Exceptions

ArgumentOutOfRangeException

count is negative.

ArgumentNullException

collection is null.

InvalidOperationException

The pool does not have enough objects to satisfy the request.

See Also