private int doPut(K key, int value, int index) { int previous = (int) 0; boolean isNewMapping = true; if (index < 0) { index = -index - 1; previous = _values[index]; isNewMapping = false; } K oldKey = (K) _set[index]; _set[index] = key; _values[index] = value; if (isNewMapping) { postInsertHook(oldKey == 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 int adjustOrPutValue(final K key, final int adjust_amount, final int put_amount) { int index = insertionIndex(key); final boolean isNewMapping; final int newValue; if (index < 0) { index = -index - 1; newValue = (_values[index] += adjust_amount); isNewMapping = false; } else { newValue = (_values[index] = put_amount); isNewMapping = true; } K oldKey = (K) _set[index]; _set[index] = key; if (isNewMapping) { postInsertHook(oldKey == FREE); } return newValue; }