/** * 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; }