public void Add(Type type, ExplicitRegistration registration) { var key = new HashKey(type, registration.Name); var bucket = key.HashCode % _buckets.Length; var collisionCount = 0; for (int i = _buckets[bucket]; --i >= 0; i = _entries[i].Next) { ref var entry = ref _entries[i]; if (entry.Key == key) { entry.Registration = registration; return; } collisionCount++; }
public bool Add(string?name) { var collisions = 0; var key = new HashKey(name); var targetBucket = key.HashCode % Buckets.Length; // Check for the existing for (var i = Buckets[targetBucket]; i >= 0; i = Entries[i].Next) { ref var candidate = ref Entries[i]; if (candidate.Key != key) { collisions++; continue; } return(false); // Already exists }
public int GetMeta(ref HashKey key, out int[]?data) { var targetBucket = key.HashCode % Buckets.Length; // Check if metadata exists for (var i = Buckets[targetBucket]; i >= 0; i = Entries[i].Next) { if (Entries[i].HashKey != key) { continue; } // Get a fix on the buffer data = Entries[i].Value; return(data[0]); } // Nothing is found data = null; return(0); }