public CachedPool(TAllocator allocator) { this.Cache = new LinkedList <T>(); this.Pool = new LinkedList <T>(); this.Allocator = allocator; }
public CachedPool(int capacity, TAllocator allocator) { this.Cache = new LinkedList <T>(); this.Pool = new LinkedList <T>(); this.Allocator = allocator; this.Reserve(capacity); }
public FixedPool(int capacity, int reserveCount, TAllocator allocator) { if (0 >= capacity || 0 > reserveCount) { throw new System.InvalidOperationException(string.Format("ERROR: new FixedPool create failed. invalid param. capacity = {0}, reserveCount = {1}", capacity, reserveCount)); } if (capacity < reserveCount) { throw new System.InvalidOperationException(string.Format("ERROR: new FixedPool create failed. capacity < reserveCount. capacity = {0}, reserveCount = {1}", capacity, reserveCount)); } this._Capacity = capacity; this._Cache = new T[capacity]; this._Pool = new T[capacity]; this._Allocator = allocator; this.ReserveAdd(reserveCount); }
public static SearchProcessingUnit_A_KnuthMorrisPratt <T, TListPattern, TEqualityComparer, TAllocator> Create(TListPattern pattern, IntT start, IntT count, TEqualityComparer equalityComparer, TAllocator allocator) { if (count > 0) { var(skip_table, skip_table_start) = allocator.Invoke(count); var i = (IntT)0; var j = -1; skip_table[skip_table_start] = j; while (count - 1 > i) { while (j > -1 && !equalityComparer.Invoke(pattern[start + i], pattern[start + j])) { j = skip_table[skip_table_start + j]; } ++i; ++j; if (equalityComparer.Invoke(pattern[start + i], pattern[start + j])) { skip_table[skip_table_start + i] = skip_table[skip_table_start + j]; } else { skip_table[skip_table_start + i] = j; } } return(new SearchProcessingUnit_A_KnuthMorrisPratt <T, TListPattern, TEqualityComparer, TAllocator>(skip_table, skip_table_start, pattern, start, count, equalityComparer)); } { return(new SearchProcessingUnit_A_KnuthMorrisPratt <T, TListPattern, TEqualityComparer, TAllocator>(Array_Empty <IntT> .Value, 0, pattern, start, count, equalityComparer)); } }