@Override
public <P> V getIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter)
{
int hash = this.hash(key);
AtomicReferenceArray currentArray = this.table;
V newValue = null;
boolean createdValue = false;
while (true)
{
int length = currentArray.length();
int index = ConcurrentHashMap.indexFor(hash, length);
Object o = currentArray.get(index);
if (o == RESIZED || o == RESIZING)
{
currentArray = this.helpWithResizeWhileCurrentIndex(currentArray, index);
}
else
{
Entry<K, V> e = (Entry<K, V>) o;
while (e != null)
{
Object candidate = e.getKey();
if (candidate.equals(key))
{
return e.getValue();
}
e = e.getNext();
}
if (!createdValue)
{
createdValue = true;
newValue = function.valueOf(parameter);
}
Entry<K, V> newEntry = new Entry<K, V>(key, newValue, (Entry<K, V>) o);
if (currentArray.compareAndSet(index, o, newEntry))
{
this.incrementSizeAndPossiblyResize(currentArray, length, o);
return newValue;
}
}