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