@Override public V put(K key, V value) { HashNode<V> hashNode = new HashNode<V>(key.hashCode(), value); int index = calculateHash(hashNode.getCode()); if (array[index] == null) array[index] = hashNode; else { HashNode<V> arrayNode = array[index]; while (arrayNode.getNext() != null) { arrayNode = arrayNode.getNext(); } arrayNode.setNext(hashNode); } return value; }
@Override public V get(Object key) { int code = key.hashCode(); int index = calculateHash(code); HashNode<V> arrayNode = array[index]; while (arrayNode != null && arrayNode.getCode() != code) { arrayNode = arrayNode.getNext(); } if (arrayNode == null) return null; else return arrayNode.getObject(); }