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
collectionICollection<T>The collection to add objects to.
poolIPool<T>The pool to get objects from.
countintThe number of objects to get.
Type Parameters
TThe 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
countis negative.- ArgumentNullException
collectionis null.- InvalidOperationException
The pool does not have enough objects to satisfy the request.
- See Also