private void Initialize(int capacity) { var size = HashHelpers.GetPrime(capacity); _buckets = new PoolingListVal <int>(); for (var i = 0; i < size; i++) { _buckets.Add(-1); } _entries = new PoolingListVal <Entry>(); _freeList = -1; }
public PoolingDictionary <TKey, TValue> Init(int capacity = 0, IEqualityComparer <TKey> comparer = default) { if (_buckets != default) { return(this); } _refType = typeof(TKey).IsClass; var size = HashHelpers.GetPrime(capacity); _buckets = Pool <PoolingList <int> > .Get().Init(); for (var i = 0; i < size; i++) { _buckets.Add(EndOfChain); } _entries = Pool <PoolingList <Entry> > .Get().Init(); _freeList = EndOfChain; _comparer = comparer ?? EqualityComparer <TKey> .Default; return(this); }