public override void Store(string name, object value) { int num = hash(name); if (vals[num] == null) { vals[num] = new Node(name, value); } else { Node temp = vals[num]; Node prev = null; bool done = false; while (temp != null) { if (temp.getKey() == name) { temp.setPair(name, value); done = true; } prev = temp; temp = temp.getNext(); } if (!done) { prev.setNext(new Node(name, value)); } } count++; }
public override IEnumerator <KeyValuePair <string, object> > GetEnumerator() { for (Node temp = head; temp != null; temp = temp.getNext()) { yield return(new KeyValuePair <string, object>(temp.getKey(), temp.getValue())); } }
public override object Lookup(string key) { Node temp = head; while (temp != null) { if (temp.getKey() == key) { return(temp.getValue()); } temp = temp.getNext(); } throw new DictionaryKeyNotFoundException(key); }
public override object Lookup(string name) { int num = hash(name); Node temp = vals[num]; while (temp != null) { if (temp.getKey() == name) { return(temp.getValue()); } temp = temp.getNext(); } throw new DictionaryKeyNotFoundException(name); }
public override void Store(string key, object value) { Node temp = head; Node prev = temp; if (head == null) { head = new Node(key, value); length++; return; } while (temp != null) { if (temp.getKey() == key) { temp.setPair(key, value); return; } prev = temp; temp = temp.getNext(); } prev.setNext(new Node(key, value)); length++; }