@Override public int putIfAbsent(short key, int value) { int index = insert(key, value); if (index < 0) { // key was absent return defaultValue(); } else { // key is present return values[index]; } }
@Override public int get(short key) { int index = index(key); if (index >= 0) { // key is present return values[index]; } else { // key is absent return defaultValue(); } }
@Override public int putIfAbsent(short key, int value) { int index = insert(key, value); if (index < 0) { // key was absent return defaultValue(); } else { // key is present return values[index]; } }
@Override public int get(short key) { int index = index(key); if (index >= 0) { // key is present return values[index]; } else { // key is absent return defaultValue(); } }
@Override public int put(short key, int value) { int index = insert(key, value); if (index < 0) { // key was absent return defaultValue(); } else { // key is present int[] vals = values; int prevValue = vals[index]; vals[index] = value; return prevValue; } }
@Override public int replace(short key, int value) { int index = index(key); if (index >= 0) { // key is present int[] vals = values; int oldValue = vals[index]; vals[index] = value; return oldValue; } else { // key is absent return defaultValue(); } }
@Override public int put(short key, int value) { int index = insert(key, value); if (index < 0) { // key was absent return defaultValue(); } else { // key is present int[] vals = values; int prevValue = vals[index]; vals[index] = value; return prevValue; } }
@Override public int replace(short key, int value) { int index = index(key); if (index >= 0) { // key is present int[] vals = values; int oldValue = vals[index]; vals[index] = value; return oldValue; } else { // key is absent return defaultValue(); } }
@Override public int computeIfPresent(short key, ShortIntToIntFunction remappingFunction) { if (remappingFunction == null) throw new java.lang.NullPointerException(); int index = index(key); if (index >= 0) { // key is present int[] vals = values; int newValue = remappingFunction.applyAsInt(key, vals[index]); vals[index] = newValue; return newValue; } else { // key is absent return defaultValue(); } }
@Override public int computeIfPresent(short key, ShortIntToIntFunction remappingFunction) { if (remappingFunction == null) throw new java.lang.NullPointerException(); int index = index(key); if (index >= 0) { // key is present int[] vals = values; int newValue = remappingFunction.applyAsInt(key, vals[index]); vals[index] = newValue; return newValue; } else { // key is absent return defaultValue(); } }
int newValue = remappingFunction.applyAsInt(key, defaultValue()); incrementModCount(); keys[index] = key;
int newValue = remappingFunction.applyAsInt(key, defaultValue()); incrementModCount(); keys[index] = key;