public int put(int key, int value) {
    int hash = key % capacity;
    IntToIntHashMapEntry e, head;

    head = data[hash];
    for (e = head; e != null; e = e.next) {
      if (e.key == key) {
        int i = e.value;
        e.value = value;
        return i;
      }
    }

    data[hash] = new IntToIntHashMapEntry(key, value, head);
    if (++size >= cutoff) {
      rehash(2 * capacity + 1);
    }
    return defaultValue;
  }
  public boolean containsKey(int key) {
    int hash = key % capacity;
    IntToIntHashMapEntry e, tmp;

    for (tmp = null, e = data[hash]; e != null; tmp = e, e = e.next) {
      if (e.key == key) {
        /* Assume that it is likely that
         * an eventual call to get() for the same
         * key is near */
        if (tmp != null) {
          tmp.next = e.next;
          e.next = data[hash];
          data[hash] = e;
        }
        return true;
      }
    }

    return false;
  }
  private void rehash(int newCapacity) {
    if (newCapacity > capacity) {
      IntToIntHashMapEntry newData[];
      IntToIntHashMapEntry entry, tmp;
      int newHash;

      newData = new IntToIntHashMapEntry[newCapacity];
      for (int i = 0; i < capacity; i++) {
        for (entry = data[i]; entry != null; ) {
          tmp = entry.next;
          newHash = entry.key % newCapacity;
          entry.next = newData[newHash];
          newData[newHash] = entry;
          entry = tmp;
        }
      }

      data = newData;
      capacity = newCapacity;
      cutoff = (int) (newCapacity * loadFactor);
    }
  }
  public int remove(int key) {
    int hash = key % capacity;
    IntToIntHashMapEntry e, tmp;

    for (tmp = null, e = data[hash]; e != null; tmp = e, e = e.next) {
      if (e.key == key) {
        if (tmp == null) {
          data[hash] = e.next;
        } else {
          tmp.next = e.next;
        }
        int i = e.value;
        /*
        e.next = entryPool;
        entryPool = e;
        */
        e = null;
        size--;
        return i;
      }
    }

    return defaultValue;
  }