public HashRegistry(HashRegistry <TKey, TValue> dictionary) { var size = Prime.GetPrime(dictionary.Entries.Length * 2); Buckets = new int[size]; Entries = new Entry[size]; for (var i = 0; i < Buckets.Length; i++) { Buckets[i] = -1; } Array.Copy(dictionary.Entries, 0, Entries, 0, dictionary.Count); for (var i = 0; i < dictionary.Count; i++) { var hashCode = Entries[i].HashCode; if (hashCode < 0) { continue; } var bucket = hashCode % size; Entries[i].Next = Buckets[bucket]; Buckets[bucket] = i; } Count = dictionary.Count; dictionary.Count = 0; }
public HashRegistry(HashRegistry dictionary) : this(HashHelpers.GetPrime(dictionary.Entries.Length * 2)) { Array.Copy(dictionary.Entries, 0, Entries, 0, dictionary.Count); for (var i = 0; i < dictionary.Count; i++) { var hashCode = Entries[i].HashCode; if (hashCode < 0) { continue; } var bucket = hashCode % Buckets.Length; Entries[i].Next = Buckets[bucket]; Buckets[bucket] = i; } Count = dictionary.Count; dictionary.Count = 0; }
public LinkedRegistry(HashRegistry registry) { // TODO: Implement this throw new NotImplementedException(); }