public IEnumerator <KeyValuePair <string, TValue> > GetEnumerator() { HashNode <TValue> current = Head; while (current != null) { yield return(new KeyValuePair <string, TValue>(current.Key, current.Value)); current = current.Next; } }
public TValue KeyValue(string key) { HashNode <TValue> current = Head; while (current != null) { if (current.Key == key) { return(current.Value); } current = current.Next; } throw new KeyNotFoundException(); }
public bool Includes(string key) { HashNode <TValue> current = Head; while (current != null) { if (current.Key == key) { return(true); } current = current.Next; } return(false); }
public void Insert(string key, int hash, TValue value) { HashNode <TValue> newNode = new HashNode <TValue>(Bucket, key, hash, value); if (Head != null) { Helper(newNode); newNode.Next.Last = newNode; } else { Helper(newNode); } }
public void Remove(string key) { HashNode <TValue> current = Head; while (current != null) { if (current.Key == key && Head != current) { current.Last.Next = current.Next; current.Next.Last = current.Last; Head = current.Next; } if (current.Key == key && Head == current) { Head = current.Next; } current = current.Next; } }
private void Helper(HashNode <TValue> newNode) { newNode.Next = Head; Head = newNode; }