/** * rehashes the map to the new capacity. * * @param newCapacity an <code>int</code> value */ protected void rehash(int newCapacity) { int oldCapacity = _set.length; long oldKeys[] = _set; Object oldVals[] = _values; byte oldStates[] = _states; _set = new long[newCapacity]; _values = new Object[newCapacity]; _states = new byte[newCapacity]; for (int i = oldCapacity; i-- > 0;) { if(oldStates[i] == FULL) { long o = oldKeys[i]; int index = insertionIndex(o); _set[index] = o; _values[index] = oldVals[i]; _states[index] = FULL; } } }
/** * Inserts a key/value pair into the map. * * @param key an <code>long</code> value * @param value an <code>Object</code> value * @return the previous value associated with <tt>key</tt>, * or null if none was found. */ public Object put(long key, Object value) { byte previousState; Object previous = null; int index = insertionIndex(key); boolean isNewMapping = true; if (index < 0) { index = -index -1; previous = _values[index]; isNewMapping = false; } previousState = _states[index]; _set[index] = key; _states[index] = FULL; _values[index] = value; if (isNewMapping) { postInsertHook(previousState == FREE); } return previous; }