/// <summary> /// Allocates the given number of elements and adds to the collection. /// </summary> static public void Alloc <T>(this IPool <T> inThis, ICollection <T> inDest, int inCount) where T : class { for (int i = 0; i < inCount; ++i) { inDest.Add(inThis.Alloc()); } }
/// <summary> /// Allocates the given number of elements and writes to the array. /// Returns the total number of allocated elements. /// </summary> static public int Alloc <T>(this IPool <T> inThis, T[] inDest, int inStartIndex, int inCount) where T : class { int allocCount = 0; for (int i = 0; i < inCount; ++i) { int idx = inStartIndex + i; if (inDest[idx] == null) { inDest[idx] = inThis.Alloc(); ++allocCount; } } return(allocCount); }
/// <summary> /// Retrieves a PooledStringBuilder for use. /// </summary> static public PooledStringBuilder Create() { return(s_ObjectPool.Alloc()); }
/// <summary> /// Retrieves a PooledList for use. /// </summary> static public PooledSet <T> Create() { return(s_ObjectPool.Alloc()); }
/// <summary> /// Returns a temporary allocation. /// </summary> static public TempAlloc <T> TempAlloc <T>(this IPool <T> inThis) where T : class { T obj = inThis.Alloc(); return(new TempAlloc <T>(inThis, obj)); }