public NodeHT(Object key, Object value, int hash, NodeHT next) { this.key = key; this.value = value; this.hash = hash; this.next = next; }
public Object Get(Object key) { if (key == null) { return(null); } int hash = HashCode(key); NodeHT node = table[hash]; while (node != null) { if (node.key.Equals(key)) { return(node.value); } node = node.next; } return(null); }
public void Put(Object key, Object value) { int hash = HashCode(key); NodeHT newNode = new NodeHT(key, value, hash, null); NodeHT node = table[hash]; while (node != null) { if (node.key.Equals(key)) { node.value = value; return; } node = node.next; } newNode.next = table[hash]; table[hash] = newNode; size++; }