Beispiel #1
0
 public ChainedHashSet(ICollection <T> collection) : this()
 {
     _buckets = new LinkedList <T> [PrimeNumbersProvider.GetNextPrime(collection.Count)];
     foreach (T entity in collection)
     {
         AddInternal(entity);
     }
 }
 public OpenAddressedHashSet(IList <T> collection)
 {
     _buckets = new HashSetItem[PrimeNumbersProvider.GetNextPrime(collection.Count)];
     for (int index = 0; index < collection.Count; index++)
     {
         T entity = collection[index];
         AddInternal(entity);
     }
 }
        private void IncreaseSize()
        {
            int newSize    = PrimeNumbersProvider.GetNextPrime(_buckets.Length + 1);
            var oldBuckets = _buckets;

            _count   = 0;
            _buckets = new HashSetItem[newSize];

            foreach (HashSetItem bucket in oldBuckets)
            {
                AddInternal(bucket.Entity);
            }
        }
Beispiel #4
0
        private void IncreaseSize()
        {
            int newSize = PrimeNumbersProvider.GetNextPrime(_capacity + 1);

            _count    = 0;
            _capacity = 0;

            LinkedList <T>[] oldBuckets = _buckets;
            _buckets = new LinkedList <T> [newSize];

            for (int i = 0; i < oldBuckets.Length; i++)
            {
                for (var node = oldBuckets[i].First; node != null; node = node.Next)
                {
                    AddInternal(node.Value);
                }
            }
        }