/** * Does the map contain a value for a given key which is not {@link #initialValue()}. * * @param key the key to check. * @return true if the map contains the key with a value other than {@link #initialValue()}, false otherwise. */ public boolean containsKey(final long key) { return get(key) != initialValue; }
/** * Try get a value for a key and if not present then apply mapping function. * * @param key to search on. * @param mappingFunction to provide a value if the get returns null. * @return the value if found otherwise the missing value. */ public long computeIfAbsent(final long key, final LongUnaryOperator mappingFunction) { long value = get(key); if (value == initialValue) { value = mappingFunction.applyAsLong(key); if (value != initialValue) { put(key, value); } } return value; }