private long doPut(short key, long value, int index) { byte previousState; long previous = (long) 0; 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; }
/** * Adjusts the primitive value mapped to the key if the key is present in the map. Otherwise, * the <tt>initial_value</tt> is put in the map. * * @param key the key of the value to increment * @param adjust_amount the amount to adjust the value by * @param put_amount the value put into the map if the key is not initial present * @return the value present in the map after the adjustment or put operation * @since 2.0b1 */ public long adjustOrPutValue(final short key, final long adjust_amount, final long put_amount) { int index = insertionIndex(key); final boolean isNewMapping; final long newValue; if (index < 0) { index = -index - 1; newValue = (_values[index] += adjust_amount); isNewMapping = false; } else { newValue = (_values[index] = put_amount); isNewMapping = true; } byte previousState = _states[index]; _set[index] = key; _states[index] = FULL; if (isNewMapping) { postInsertHook(previousState == FREE); } return newValue; }