Class CollectionPool<TCollection, TValue>
A pool of collection objects for avoiding allocations when new empty collections are needed frequently.
Inherited Members
Namespace: Unity.XR.CoreUtils
Syntax
public static class CollectionPool<TCollection, TValue>
where TCollection : ICollection<TValue>, new()
Type Parameters
Name | Description |
---|---|
TCollection | The desired type of collection. |
TValue | The value type of the ICollection specified in TCollection. |
Methods
GetCollection()
Gets a collection of the given type from the pool. Creates a new collection object if the pool is empty.
Declaration
public static TCollection GetCollection()
Returns
Type | Description |
---|---|
TCollection | An empty collection. |
RecycleCollection(TCollection)
Returns a collection to the pool. The collection is cleared.
Declaration
public static void RecycleCollection(TCollection collection)
Parameters
Type | Name | Description |
---|---|---|
TCollection | collection | The collection to be added to the pool. |