/** {@inheritDoc} */ @Override public void transformValues(TCharFunction function) { TByteOffheapArray states = _states; TCharOffheapArray values = _values; for (int i = capacity(); i-- > 0; ) { if (states.get(i) == FULL) { values.put(i, function.execute(values.get(i))); } } }
/** {@inheritDoc} */ @Override public boolean adjustValue(char key, char amount) { int index = index(key); if (index < 0) { return false; } else { char val = _values.get(index); _values.put(index, (char) (val + amount)); return true; } }
private char doPut(char key, char value, int index) { char previous = no_entry_value; boolean isNewMapping = true; if (index < 0) { index = -index - 1; previous = _values.get(index); isNewMapping = false; } _values.put(index, value); if (isNewMapping) { postInsertHook(consumeFreeSlot); } return previous; }
/** {@inheritDoc} */ @Override public char adjustOrPutValue(char key, char adjust_amount, char put_amount) { int index = insertKey(key); final boolean isNewMapping; final char newValue; if (index < 0) { index = -index - 1; newValue = (char) (_values.get(index) + adjust_amount); isNewMapping = false; } else { newValue = put_amount; isNewMapping = true; } _values.put(index, newValue); if (isNewMapping) { postInsertHook(consumeFreeSlot); } return newValue; }
/** {@inheritDoc} */ @Override protected void rehash(int newCapacity) { int oldCapacity = capacity(); TCharOffheapArray oldKeys = _set; TCharOffheapArray oldVals = _values; TByteOffheapArray oldStates = _states; _set = new TCharOffheapArray(newCapacity); _values = new TCharOffheapArray(newCapacity); _states = new TByteOffheapArray(newCapacity); for (int i = oldCapacity; i-- > 0; ) { if (oldStates.get(i) == FULL) { char o = oldKeys.get(i); int index = insertKey(o); _values.put(index, oldVals.get(i)); } } oldKeys.free(); oldVals.free(); oldStates.free(); }
/** {@inheritDoc} */ @Override protected void removeAt(int index) { _values.put(index, no_entry_value); super.removeAt(index); // clear key, state; adjust size }