diff --git a/src/main/java/speiger/src/collections/booleans/lists/AbstractBooleanList.java b/src/main/java/speiger/src/collections/booleans/lists/AbstractBooleanList.java
index f0d9e8fe..7d47bc48 100644
--- a/src/main/java/speiger/src/collections/booleans/lists/AbstractBooleanList.java
+++ b/src/main/java/speiger/src/collections/booleans/lists/AbstractBooleanList.java
@@ -12,6 +12,7 @@
import speiger.src.collections.booleans.collections.BooleanCollection;
import speiger.src.collections.booleans.collections.BooleanIterator;
import speiger.src.collections.booleans.collections.BooleanSplititerator;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.booleans.utils.BooleanSplititerators;
import speiger.src.collections.utils.SanityChecks;
@@ -205,13 +206,23 @@ public BooleanIterator iterator() {
public BooleanListIterator listIterator() {
return listIterator(0);
}
-
+
@Override
public BooleanListIterator listIterator(int index) {
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
return new BooleanListIter(index);
}
+ @Override
+ public BooleanListIterator indexedIterator(int...indecies) {
+ return new IndexedIterator(indecies);
+ }
+
+ @Override
+ public BooleanListIterator indexedIterator(IntList indecies) {
+ return new ListIndexedIterator(indecies);
+ }
+
@Override
public void size(int size) {
while(size > size()) add(false);
@@ -566,7 +577,153 @@ public int back(int amount) {
}
}
}
+
+ private class ListIndexedIterator implements BooleanListIterator {
+ IntList indecies;
+ int index;
+ int lastReturned = -1;
+
+ ListIndexedIterator(IntList indecies) {
+ this.indecies = indecies;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return index < indecies.size();
+ }
+
+ @Override
+ public boolean nextBoolean() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getBoolean((lastReturned = indecies.getInt(i)));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public boolean previousBoolean() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getBoolean((lastReturned = indecies.getInt(index)));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(boolean e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(boolean e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractBooleanList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.size() - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
+ private class IndexedIterator implements BooleanListIterator {
+ int[] indecies;
+ int index;
+ int lastReturned = -1;
+
+ IndexedIterator(int[] indecies) {
+ this.indecies = indecies;
+ }
+ @Override
+ public boolean hasNext() {
+ return index < indecies.length;
+ }
+
+ @Override
+ public boolean nextBoolean() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getBoolean((lastReturned = indecies[i]));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public boolean previousBoolean() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getBoolean((lastReturned = indecies[index]));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(boolean e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(boolean e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractBooleanList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.length - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
private class BooleanListIter implements BooleanListIterator {
int index;
int lastReturned = -1;
@@ -644,7 +801,7 @@ public int back(int amount) {
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
int steps = Math.min(amount, index);
index -= steps;
- if(steps > 0) lastReturned = Math.min(index, size()-1);
+ if(steps > 0) lastReturned = Math.max(index, 0);
return steps;
}
}
diff --git a/src/main/java/speiger/src/collections/booleans/lists/BooleanList.java b/src/main/java/speiger/src/collections/booleans/lists/BooleanList.java
index a28cd9f0..d31cb4db 100644
--- a/src/main/java/speiger/src/collections/booleans/lists/BooleanList.java
+++ b/src/main/java/speiger/src/collections/booleans/lists/BooleanList.java
@@ -11,6 +11,7 @@
import speiger.src.collections.booleans.functions.BooleanComparator;
import speiger.src.collections.booleans.utils.BooleanArrays;
import speiger.src.collections.booleans.utils.BooleanLists;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.booleans.utils.BooleanSplititerators;
/**
@@ -320,6 +321,24 @@ public default void forEachIndexed(IntBooleanConsumer action) {
@Override
public BooleanListIterator listIterator(int index);
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public BooleanListIterator indexedIterator(int...indecies);
+
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public BooleanListIterator indexedIterator(IntList indecies);
+
/**
* A Type-Specific List of subList
* @see java.util.List#subList(int, int)
diff --git a/src/main/java/speiger/src/collections/booleans/queues/BooleanArrayFIFOQueue.java b/src/main/java/speiger/src/collections/booleans/queues/BooleanArrayFIFOQueue.java
index 77967c64..1c7d010d 100644
--- a/src/main/java/speiger/src/collections/booleans/queues/BooleanArrayFIFOQueue.java
+++ b/src/main/java/speiger/src/collections/booleans/queues/BooleanArrayFIFOQueue.java
@@ -146,6 +146,15 @@ public boolean peek(int index) {
return index >= array.length ? array[index-array.length] : array[index];
}
+ @Override
+ public boolean contains(boolean e) {
+ if(first == last) return false;
+ for(int i = 0,m=size();i iterator, int r
return new RepeatingIterator(wrap(iterator), repeats);
}
+ /**
+ * A Helper function that creates a infinitely looping iterator
+ * @param iterator that should be looping infinitely
+ * @return a infinitely looping iterator
+ */
+ public static BooleanIterator infinite(BooleanIterator iterator) {
+ return new InfiniteIterator(iterator);
+ }
+
+ /**
+ * A Helper function that creates a infinitely looping iterator from a Java Iterator
+ * @param iterator that should be looping infinitely
+ * @return a infinitely looping iterator
+ */
+ public static BooleanIterator infinite(Iterator extends Boolean> iterator) {
+ return new InfiniteIterator(wrap(iterator));
+ }
+
/**
* A Helper function that hard limits the Iterator to a specific size
* @param iterator that should be limited
@@ -841,6 +862,40 @@ public T next() {
}
}
+ private static class InfiniteIterator implements BooleanIterator
+ {
+ BooleanIterator iter;
+ CollectionWrapper looper = BooleanCollections.wrapper();
+ int index = 0;
+
+ public InfiniteIterator(BooleanIterator iter) {
+ this.iter = iter;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public boolean nextBoolean() {
+ if(iter != null) {
+ if(iter.hasNext()) {
+ boolean value = iter.nextBoolean();
+ looper.add(value);
+ return value;
+ }
+ else iter = null;
+ }
+ return looper.getBoolean((index++) % looper.size());
+ }
+
+ @Override
+ public void forEachRemaining(BooleanConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ public void forEachRemaining(Consumer super Boolean> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ public void forEachRemaining(E input, ObjectBooleanConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ }
+
private static class RepeatingIterator implements BooleanIterator
{
final int repeats;
diff --git a/src/main/java/speiger/src/collections/booleans/utils/BooleanLists.java b/src/main/java/speiger/src/collections/booleans/utils/BooleanLists.java
index 75ffdc7b..c05f5763 100644
--- a/src/main/java/speiger/src/collections/booleans/utils/BooleanLists.java
+++ b/src/main/java/speiger/src/collections/booleans/utils/BooleanLists.java
@@ -11,6 +11,7 @@
import speiger.src.collections.booleans.functions.BooleanConsumer;
import speiger.src.collections.booleans.lists.AbstractBooleanList;
import speiger.src.collections.booleans.lists.BooleanList;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.booleans.lists.BooleanListIterator;
import speiger.src.collections.utils.SanityChecks;
@@ -313,6 +314,16 @@ public BooleanListIterator listIterator(int index) {
return l.listIterator(index);
}
+ @Override
+ public BooleanListIterator indexedIterator(int...indecies) {
+ return l.indexedIterator(indecies);
+ }
+
+ @Override
+ public BooleanListIterator indexedIterator(IntList indecies) {
+ return l.indexedIterator(indecies);
+ }
+
@Override
public BooleanList subList(int from, int to) {
return BooleanLists.synchronize(l.subList(from, to));
@@ -420,6 +431,16 @@ public BooleanListIterator listIterator(int index) {
return BooleanIterators.unmodifiable(l.listIterator(index));
}
+ @Override
+ public BooleanListIterator indexedIterator(int...indecies) {
+ return BooleanIterators.unmodifiable(l.indexedIterator(indecies));
+ }
+
+ @Override
+ public BooleanListIterator indexedIterator(IntList indecies) {
+ return BooleanIterators.unmodifiable(l.indexedIterator(indecies));
+ }
+
@Override
public BooleanList subList(int from, int to) {
return BooleanLists.unmodifiable(l.subList(from, to));
@@ -508,6 +529,16 @@ public BooleanListIterator listIterator(int index) {
return BooleanIterators.empty();
}
+ @Override
+ public BooleanListIterator indexedIterator(int...indecies) {
+ return BooleanIterators.empty();
+ }
+
+ @Override
+ public BooleanListIterator indexedIterator(IntList indecies) {
+ return BooleanIterators.empty();
+ }
+
@Override
public int hashCode() { return 1; }
diff --git a/src/main/java/speiger/src/collections/booleans/utils/BooleanPriorityQueues.java b/src/main/java/speiger/src/collections/booleans/utils/BooleanPriorityQueues.java
index fd8011e9..6fda575c 100644
--- a/src/main/java/speiger/src/collections/booleans/utils/BooleanPriorityQueues.java
+++ b/src/main/java/speiger/src/collections/booleans/utils/BooleanPriorityQueues.java
@@ -89,6 +89,8 @@ protected SynchronizedPriorityQueue(BooleanPriorityQueue queue, Object mutex) {
@Override
public boolean peek(int index) { synchronized(mutex) { return queue.peek(index); } }
@Override
+ public boolean contains(boolean e) { synchronized(mutex) { return queue.contains(e); } }
+ @Override
public boolean removeFirst(boolean e) { synchronized(mutex) { return queue.removeFirst(e); } }
@Override
public boolean removeLast(boolean e) { synchronized(mutex) { return queue.removeLast(e); } }
diff --git a/src/main/java/speiger/src/collections/bytes/functions/ByteSupplier.java b/src/main/java/speiger/src/collections/bytes/functions/ByteSupplier.java
index de0e3f6c..54367744 100644
--- a/src/main/java/speiger/src/collections/bytes/functions/ByteSupplier.java
+++ b/src/main/java/speiger/src/collections/bytes/functions/ByteSupplier.java
@@ -8,5 +8,5 @@ public interface ByteSupplier
/**
* @return the supplied value
*/
- public byte getAsInt();
+ public byte getAsByte();
}
\ No newline at end of file
diff --git a/src/main/java/speiger/src/collections/bytes/lists/AbstractByteList.java b/src/main/java/speiger/src/collections/bytes/lists/AbstractByteList.java
index 52aeb213..360803f8 100644
--- a/src/main/java/speiger/src/collections/bytes/lists/AbstractByteList.java
+++ b/src/main/java/speiger/src/collections/bytes/lists/AbstractByteList.java
@@ -12,6 +12,7 @@
import speiger.src.collections.bytes.collections.ByteCollection;
import speiger.src.collections.bytes.collections.ByteIterator;
import speiger.src.collections.bytes.collections.ByteSplititerator;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.bytes.utils.ByteSplititerators;
import speiger.src.collections.utils.SanityChecks;
@@ -205,13 +206,23 @@ public ByteIterator iterator() {
public ByteListIterator listIterator() {
return listIterator(0);
}
-
+
@Override
public ByteListIterator listIterator(int index) {
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
return new ByteListIter(index);
}
+ @Override
+ public ByteListIterator indexedIterator(int...indecies) {
+ return new IndexedIterator(indecies);
+ }
+
+ @Override
+ public ByteListIterator indexedIterator(IntList indecies) {
+ return new ListIndexedIterator(indecies);
+ }
+
@Override
public void size(int size) {
while(size > size()) add((byte)0);
@@ -566,7 +577,153 @@ public int back(int amount) {
}
}
}
+
+ private class ListIndexedIterator implements ByteListIterator {
+ IntList indecies;
+ int index;
+ int lastReturned = -1;
+
+ ListIndexedIterator(IntList indecies) {
+ this.indecies = indecies;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return index < indecies.size();
+ }
+
+ @Override
+ public byte nextByte() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getByte((lastReturned = indecies.getInt(i)));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public byte previousByte() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getByte((lastReturned = indecies.getInt(index)));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(byte e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(byte e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractByteList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.size() - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
+ private class IndexedIterator implements ByteListIterator {
+ int[] indecies;
+ int index;
+ int lastReturned = -1;
+
+ IndexedIterator(int[] indecies) {
+ this.indecies = indecies;
+ }
+ @Override
+ public boolean hasNext() {
+ return index < indecies.length;
+ }
+
+ @Override
+ public byte nextByte() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getByte((lastReturned = indecies[i]));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public byte previousByte() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getByte((lastReturned = indecies[index]));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(byte e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(byte e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractByteList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.length - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
private class ByteListIter implements ByteListIterator {
int index;
int lastReturned = -1;
@@ -644,7 +801,7 @@ public int back(int amount) {
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
int steps = Math.min(amount, index);
index -= steps;
- if(steps > 0) lastReturned = Math.min(index, size()-1);
+ if(steps > 0) lastReturned = Math.max(index, 0);
return steps;
}
}
diff --git a/src/main/java/speiger/src/collections/bytes/lists/ByteList.java b/src/main/java/speiger/src/collections/bytes/lists/ByteList.java
index 459044e7..b47b05a4 100644
--- a/src/main/java/speiger/src/collections/bytes/lists/ByteList.java
+++ b/src/main/java/speiger/src/collections/bytes/lists/ByteList.java
@@ -14,6 +14,7 @@
import speiger.src.collections.bytes.functions.ByteComparator;
import speiger.src.collections.bytes.utils.ByteArrays;
import speiger.src.collections.bytes.utils.ByteLists;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.bytes.utils.ByteSplititerators;
import speiger.src.collections.utils.SanityChecks;
@@ -342,6 +343,24 @@ public default void forEachIndexed(IntByteConsumer action) {
@Override
public ByteListIterator listIterator(int index);
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public ByteListIterator indexedIterator(int...indecies);
+
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public ByteListIterator indexedIterator(IntList indecies);
+
/**
* A Type-Specific List of subList
* @see java.util.List#subList(int, int)
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2BooleanMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2BooleanMap.java
index 6b2eaf73..5d930b71 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2BooleanMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2BooleanMap.java
@@ -151,6 +151,39 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
return newValue;
}
+ @Override
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ boolean newValue = mappingFunction.test(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ boolean newValue = valueProvider.getAsBoolean();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ boolean newValue = mappingFunction.applyAsBoolean(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -167,17 +200,6 @@ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappi
return newValue;
}
- @Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- boolean newValue = mappingFunction.test(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -192,17 +214,6 @@ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingF
return value;
}
- @Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- boolean newValue = valueProvider.getAsBoolean();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -217,17 +228,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return value;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- boolean newValue = mappingFunction.applyAsBoolean(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ByteMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ByteMap.java
index cf08f102..62847fc7 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ByteMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ByteMap.java
@@ -155,6 +155,39 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ byte newValue = mappingFunction.applyAsByte(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ byte newValue = valueProvider.getAsByte();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ byte newValue = mappingFunction.applyAsByte(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -171,17 +204,6 @@ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- byte newValue = mappingFunction.applyAsByte(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -196,23 +218,12 @@ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFun
return value;
}
- @Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- byte newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
byte value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -221,17 +232,6 @@ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
return value;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- byte newValue = mappingFunction.applyAsByte(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2CharMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2CharMap.java
index 8a6190f0..97f5398f 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2CharMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2CharMap.java
@@ -157,6 +157,39 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ char newValue = mappingFunction.applyAsChar(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ char newValue = valueProvider.getAsChar();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ char newValue = mappingFunction.applyAsChar(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- char newValue = mappingFunction.applyAsChar(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFun
return value;
}
- @Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- char newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
char value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
return value;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- char newValue = mappingFunction.applyAsChar(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2DoubleMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2DoubleMap.java
index 75181013..0e3db33d 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2DoubleMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2DoubleMap.java
@@ -157,6 +157,39 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ double newValue = mappingFunction.applyAsDouble(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ double newValue = valueProvider.getAsDouble();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ double newValue = mappingFunction.applyAsDouble(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingF
return newValue;
}
- @Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- double newValue = mappingFunction.applyAsDouble(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mapp
return value;
}
- @Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- double newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return value;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- double newValue = mappingFunction.applyAsDouble(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2FloatMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2FloatMap.java
index 585d3648..9d8c6bb2 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2FloatMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2FloatMap.java
@@ -157,6 +157,39 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ float newValue = mappingFunction.applyAsFloat(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ float newValue = valueProvider.getAsFloat();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ float newValue = mappingFunction.applyAsFloat(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunc
return newValue;
}
- @Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- float newValue = mappingFunction.applyAsFloat(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mapping
return value;
}
- @Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- float newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
float value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) != Float.floatToIntBits(getDefaultReturnValue())) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider
return value;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- float newValue = mappingFunction.applyAsFloat(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2IntMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2IntMap.java
index 8ca1f7a0..f2b7195c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2IntMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2IntMap.java
@@ -157,6 +157,39 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ int newValue = mappingFunction.applyAsInt(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ int newValue = valueProvider.getAsInt();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ int newValue = mappingFunction.applyAsInt(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- int newValue = mappingFunction.applyAsInt(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFuncti
return value;
}
- @Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- int newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return value;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- int newValue = mappingFunction.applyAsInt(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2LongMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2LongMap.java
index 9c89cce7..8d551173 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2LongMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2LongMap.java
@@ -157,6 +157,39 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ long newValue = mappingFunction.applyAsLong(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ long newValue = valueProvider.getAsLong();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ long newValue = mappingFunction.applyAsLong(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- long newValue = mappingFunction.applyAsLong(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFun
return value;
}
- @Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- long newValue = valueProvider.getAsLong();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return value;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- long newValue = mappingFunction.applyAsLong(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ObjectMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ObjectMap.java
index 45682390..e258494c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ObjectMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ObjectMap.java
@@ -159,22 +159,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value = get(key);
- V newValue = mappingFunction.apply(key, value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- if(!Objects.equals(value, getDefaultReturnValue()) || containsKey(key)) {
- remove(key);
- return getDefaultReturnValue();
- }
- return getDefaultReturnValue();
- }
- put(key, newValue);
- return newValue;
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -189,20 +173,6 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
return value;
}
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value;
- if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- V newValue = mappingFunction.apply(key);
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- }
- return value;
- }
-
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -217,20 +187,6 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
return value;
}
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- V value;
- if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- V newValue = valueProvider.get();
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- }
- return value;
- }
-
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -246,21 +202,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return getDefaultReturnValue();
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value;
- if(!Objects.equals((value = get(key)), getDefaultReturnValue()) || containsKey(key)) {
- V newValue = mappingFunction.apply(key, value);
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- remove(key);
- }
- return getDefaultReturnValue();
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ShortMap.java b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ShortMap.java
index 64b0ebc3..3922aa3f 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ShortMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/abstracts/AbstractByte2ShortMap.java
@@ -157,6 +157,39 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ short newValue = mappingFunction.applyAsShort(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ short newValue = valueProvider.getAsShort();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ short newValue = mappingFunction.applyAsShort(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunc
return newValue;
}
- @Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- short newValue = mappingFunction.applyAsShort(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mapping
return value;
}
- @Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- short newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
short value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider
return value;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- short newValue = mappingFunction.applyAsShort(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2BooleanConcurrentOpenHashMap.java
index 856c9eb7..866147a5 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2BooleanConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2BooleanConcurrentOpenHashMap.java
@@ -438,13 +438,6 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -452,13 +445,6 @@ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -467,17 +453,31 @@ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
}
@Override
- public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2032,35 +2032,29 @@ protected boolean compute(int hash, byte key, ByteBooleanUnaryOperator mappingFu
}
}
- protected boolean computeNonDefault(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) {
+ protected boolean computeIfAbsent(int hash, byte key, BytePredicate mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected boolean computeIfAbsent(int hash, byte key, BytePredicate mappingFunction) {
+
+ protected boolean supplyIfAbsent(int hash, byte key, BooleanSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2071,23 +2065,37 @@ protected boolean computeIfAbsent(int hash, byte key, BytePredicate mappingFunct
unlockWrite(stamp);
}
}
+
+ protected boolean computeIfPresent(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected boolean computeIfAbsentNonDefault(int hash, byte key, BytePredicate mappingFunction) {
+ protected boolean computeNonDefault(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2095,16 +2103,22 @@ protected boolean computeIfAbsentNonDefault(int hash, byte key, BytePredicate ma
}
}
- protected boolean supplyIfAbsent(int hash, byte key, BooleanSupplier valueProvider) {
+ protected boolean computeIfAbsentNonDefault(int hash, byte key, BytePredicate mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2135,20 +2149,6 @@ protected boolean supplyIfAbsentNonDefault(int hash, byte key, BooleanSupplier v
}
}
- protected boolean computeIfPresent(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected boolean computeIfPresentNonDefault(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ByteConcurrentOpenHashMap.java
index 1f020dfd..1c24085b 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ByteConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ByteConcurrentOpenHashMap.java
@@ -444,13 +444,6 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -458,13 +451,6 @@ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -473,17 +459,31 @@ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
}
@Override
- public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2069,35 +2069,29 @@ protected byte compute(int hash, byte key, ByteByteUnaryOperator mappingFunction
}
}
- protected byte computeNonDefault(int hash, byte key, ByteByteUnaryOperator mappingFunction) {
+ protected byte computeIfAbsent(int hash, byte key, ByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected byte computeIfAbsent(int hash, byte key, ByteUnaryOperator mappingFunction) {
+
+ protected byte supplyIfAbsent(int hash, byte key, ByteSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2108,23 +2102,14 @@ protected byte computeIfAbsent(int hash, byte key, ByteUnaryOperator mappingFunc
unlockWrite(stamp);
}
}
-
- protected byte computeIfAbsentNonDefault(int hash, byte key, ByteUnaryOperator mappingFunction) {
+
+ protected byte computeIfPresent(int hash, byte key, ByteByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- byte newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2132,16 +2117,22 @@ protected byte computeIfAbsentNonDefault(int hash, byte key, ByteUnaryOperator m
}
}
- protected byte supplyIfAbsent(int hash, byte key, ByteSupplier valueProvider) {
+ protected byte computeNonDefault(int hash, byte key, ByteByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2149,19 +2140,19 @@ protected byte supplyIfAbsent(int hash, byte key, ByteSupplier valueProvider) {
}
}
- protected byte supplyIfAbsentNonDefault(int hash, byte key, ByteSupplier valueProvider) {
+ protected byte computeIfAbsentNonDefault(int hash, byte key, ByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsByte(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2172,13 +2163,22 @@ protected byte supplyIfAbsentNonDefault(int hash, byte key, ByteSupplier valuePr
}
}
- protected byte computeIfPresent(int hash, byte key, ByteByteUnaryOperator mappingFunction) {
+ protected byte supplyIfAbsentNonDefault(int hash, byte key, ByteSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ byte newValue = valueProvider.getAsByte();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsByte();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2CharConcurrentOpenHashMap.java
index c27fcbd7..98ca658e 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2CharConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2CharConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
}
@Override
- public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected char compute(int hash, byte key, ByteCharUnaryOperator mappingFunction
}
}
- protected char computeNonDefault(int hash, byte key, ByteCharUnaryOperator mappingFunction) {
+ protected char computeIfAbsent(int hash, byte key, Byte2CharFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected char computeIfAbsent(int hash, byte key, Byte2CharFunction mappingFunction) {
+
+ protected char supplyIfAbsent(int hash, byte key, CharSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected char computeIfAbsent(int hash, byte key, Byte2CharFunction mappingFunc
unlockWrite(stamp);
}
}
-
- protected char computeIfAbsentNonDefault(int hash, byte key, Byte2CharFunction mappingFunction) {
+
+ protected char computeIfPresent(int hash, byte key, ByteCharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- char newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected char computeIfAbsentNonDefault(int hash, byte key, Byte2CharFunction m
}
}
- protected char supplyIfAbsent(int hash, byte key, CharSupplier valueProvider) {
+ protected char computeNonDefault(int hash, byte key, ByteCharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected char supplyIfAbsent(int hash, byte key, CharSupplier valueProvider) {
}
}
- protected char supplyIfAbsentNonDefault(int hash, byte key, CharSupplier valueProvider) {
+ protected char computeIfAbsentNonDefault(int hash, byte key, Byte2CharFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsChar(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected char supplyIfAbsentNonDefault(int hash, byte key, CharSupplier valuePr
}
}
- protected char computeIfPresent(int hash, byte key, ByteCharUnaryOperator mappingFunction) {
+ protected char supplyIfAbsentNonDefault(int hash, byte key, CharSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ char newValue = valueProvider.getAsChar();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsChar();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2DoubleConcurrentOpenHashMap.java
index 5eb8cf64..2ddbfc76 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2DoubleConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2DoubleConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunctio
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
}
@Override
- public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected double compute(int hash, byte key, ByteDoubleUnaryOperator mappingFunc
}
}
- protected double computeNonDefault(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) {
+ protected double computeIfAbsent(int hash, byte key, Byte2DoubleFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected double computeIfAbsent(int hash, byte key, Byte2DoubleFunction mappingFunction) {
+
+ protected double supplyIfAbsent(int hash, byte key, DoubleSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected double computeIfAbsent(int hash, byte key, Byte2DoubleFunction mapping
unlockWrite(stamp);
}
}
+
+ protected double computeIfPresent(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected double computeIfAbsentNonDefault(int hash, byte key, Byte2DoubleFunction mappingFunction) {
+ protected double computeNonDefault(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected double computeIfAbsentNonDefault(int hash, byte key, Byte2DoubleFuncti
}
}
- protected double supplyIfAbsent(int hash, byte key, DoubleSupplier valueProvider) {
+ protected double computeIfAbsentNonDefault(int hash, byte key, Byte2DoubleFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected double supplyIfAbsentNonDefault(int hash, byte key, DoubleSupplier val
}
}
- protected double computeIfPresent(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected double computeIfPresentNonDefault(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2FloatConcurrentOpenHashMap.java
index 239fdbc9..179dffb3 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2FloatConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2FloatConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction)
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
}
@Override
- public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected float compute(int hash, byte key, ByteFloatUnaryOperator mappingFuncti
}
}
- protected float computeNonDefault(int hash, byte key, ByteFloatUnaryOperator mappingFunction) {
+ protected float computeIfAbsent(int hash, byte key, Byte2FloatFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected float computeIfAbsent(int hash, byte key, Byte2FloatFunction mappingFunction) {
+
+ protected float supplyIfAbsent(int hash, byte key, FloatSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected float computeIfAbsent(int hash, byte key, Byte2FloatFunction mappingFu
unlockWrite(stamp);
}
}
-
- protected float computeIfAbsentNonDefault(int hash, byte key, Byte2FloatFunction mappingFunction) {
+
+ protected float computeIfPresent(int hash, byte key, ByteFloatUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- float newValue = values[index];
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected float computeIfAbsentNonDefault(int hash, byte key, Byte2FloatFunction
}
}
- protected float supplyIfAbsent(int hash, byte key, FloatSupplier valueProvider) {
+ protected float computeNonDefault(int hash, byte key, ByteFloatUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected float supplyIfAbsent(int hash, byte key, FloatSupplier valueProvider)
}
}
- protected float supplyIfAbsentNonDefault(int hash, byte key, FloatSupplier valueProvider) {
+ protected float computeIfAbsentNonDefault(int hash, byte key, Byte2FloatFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = mappingFunction.applyAsFloat(key);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected float supplyIfAbsentNonDefault(int hash, byte key, FloatSupplier value
}
}
- protected float computeIfPresent(int hash, byte key, ByteFloatUnaryOperator mappingFunction) {
+ protected float supplyIfAbsentNonDefault(int hash, byte key, FloatSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ float newValue = valueProvider.getAsFloat();
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = valueProvider.getAsFloat();
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2IntConcurrentOpenHashMap.java
index d4af8ac2..cf35fa1f 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2IntConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2IntConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
}
@Override
- public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected int compute(int hash, byte key, ByteIntUnaryOperator mappingFunction)
}
}
- protected int computeNonDefault(int hash, byte key, ByteIntUnaryOperator mappingFunction) {
+ protected int computeIfAbsent(int hash, byte key, Byte2IntFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected int computeIfAbsent(int hash, byte key, Byte2IntFunction mappingFunction) {
+
+ protected int supplyIfAbsent(int hash, byte key, IntSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected int computeIfAbsent(int hash, byte key, Byte2IntFunction mappingFuncti
unlockWrite(stamp);
}
}
+
+ protected int computeIfPresent(int hash, byte key, ByteIntUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected int computeIfAbsentNonDefault(int hash, byte key, Byte2IntFunction mappingFunction) {
+ protected int computeNonDefault(int hash, byte key, ByteIntUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected int computeIfAbsentNonDefault(int hash, byte key, Byte2IntFunction map
}
}
- protected int supplyIfAbsent(int hash, byte key, IntSupplier valueProvider) {
+ protected int computeIfAbsentNonDefault(int hash, byte key, Byte2IntFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected int supplyIfAbsentNonDefault(int hash, byte key, IntSupplier valueProv
}
}
- protected int computeIfPresent(int hash, byte key, ByteIntUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected int computeIfPresentNonDefault(int hash, byte key, ByteIntUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2LongConcurrentOpenHashMap.java
index 7185e272..f350730d 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2LongConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2LongConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
}
@Override
- public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected long compute(int hash, byte key, ByteLongUnaryOperator mappingFunction
}
}
- protected long computeNonDefault(int hash, byte key, ByteLongUnaryOperator mappingFunction) {
+ protected long computeIfAbsent(int hash, byte key, Byte2LongFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected long computeIfAbsent(int hash, byte key, Byte2LongFunction mappingFunction) {
+
+ protected long supplyIfAbsent(int hash, byte key, LongSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected long computeIfAbsent(int hash, byte key, Byte2LongFunction mappingFunc
unlockWrite(stamp);
}
}
+
+ protected long computeIfPresent(int hash, byte key, ByteLongUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected long computeIfAbsentNonDefault(int hash, byte key, Byte2LongFunction mappingFunction) {
+ protected long computeNonDefault(int hash, byte key, ByteLongUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected long computeIfAbsentNonDefault(int hash, byte key, Byte2LongFunction m
}
}
- protected long supplyIfAbsent(int hash, byte key, LongSupplier valueProvider) {
+ protected long computeIfAbsentNonDefault(int hash, byte key, Byte2LongFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected long supplyIfAbsentNonDefault(int hash, byte key, LongSupplier valuePr
}
}
- protected long computeIfPresent(int hash, byte key, ByteLongUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected long computeIfPresentNonDefault(int hash, byte key, ByteLongUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ObjectConcurrentOpenHashMap.java
index 4ab870a8..bf4042ed 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ObjectConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ObjectConcurrentOpenHashMap.java
@@ -426,13 +426,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -440,13 +433,6 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -454,13 +440,6 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
}
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
- }
-
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -468,13 +447,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -2011,29 +1983,6 @@ protected V compute(int hash, byte key, ByteObjectUnaryOperator mappingFuncti
}
}
- protected V computeNonDefault(int hash, byte key, ByteObjectUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected V computeIfAbsent(int hash, byte key, ByteFunction mappingFunction) {
long stamp = writeLock();
try {
@@ -2056,30 +2005,7 @@ protected V computeIfAbsent(int hash, byte key, ByteFunction mappingFunction)
unlockWrite(stamp);
}
}
-
- protected V computeIfAbsentNonDefault(int hash, byte key, ByteFunction mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
+
protected V supplyIfAbsent(int hash, byte key, ObjectSupplier valueProvider) {
long stamp = writeLock();
try {
@@ -2102,30 +2028,7 @@ protected V supplyIfAbsent(int hash, byte key, ObjectSupplier valueProvider)
unlockWrite(stamp);
}
}
-
- protected V supplyIfAbsentNonDefault(int hash, byte key, ObjectSupplier valueProvider) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
+
protected V computeIfPresent(int hash, byte key, ByteObjectUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
@@ -2144,11 +2047,16 @@ protected V computeIfPresent(int hash, byte key, ByteObjectUnaryOperator mapp
}
}
- protected V computeIfPresentNonDefault(int hash, byte key, ByteObjectUnaryOperator mappingFunction) {
+ protected V computeNonDefault(int hash, byte key, ByteObjectUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
+ if(index < 0) {
+ V newValue = mappingFunction.apply(key, getDefaultReturnValue());
+ if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
V newValue = mappingFunction.apply(key, values[index]);
if(Objects.equals(newValue, getDefaultReturnValue())) {
removeIndex(index);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ShortConcurrentOpenHashMap.java
index 5f301058..8ea1dd68 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ShortConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/concurrent/Byte2ShortConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction)
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
}
@Override
- public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected short compute(int hash, byte key, ByteShortUnaryOperator mappingFuncti
}
}
- protected short computeNonDefault(int hash, byte key, ByteShortUnaryOperator mappingFunction) {
+ protected short computeIfAbsent(int hash, byte key, Byte2ShortFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected short computeIfAbsent(int hash, byte key, Byte2ShortFunction mappingFunction) {
+
+ protected short supplyIfAbsent(int hash, byte key, ShortSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected short computeIfAbsent(int hash, byte key, Byte2ShortFunction mappingFu
unlockWrite(stamp);
}
}
-
- protected short computeIfAbsentNonDefault(int hash, byte key, Byte2ShortFunction mappingFunction) {
+
+ protected short computeIfPresent(int hash, byte key, ByteShortUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- short newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected short computeIfAbsentNonDefault(int hash, byte key, Byte2ShortFunction
}
}
- protected short supplyIfAbsent(int hash, byte key, ShortSupplier valueProvider) {
+ protected short computeNonDefault(int hash, byte key, ByteShortUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected short supplyIfAbsent(int hash, byte key, ShortSupplier valueProvider)
}
}
- protected short supplyIfAbsentNonDefault(int hash, byte key, ShortSupplier valueProvider) {
+ protected short computeIfAbsentNonDefault(int hash, byte key, Byte2ShortFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsShort(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected short supplyIfAbsentNonDefault(int hash, byte key, ShortSupplier value
}
}
- protected short computeIfPresent(int hash, byte key, ByteShortUnaryOperator mappingFunction) {
+ protected short supplyIfAbsentNonDefault(int hash, byte key, ShortSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ short newValue = valueProvider.getAsShort();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsShort();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2BooleanOpenCustomHashMap.java
index b09b2520..fb5bfb67 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2BooleanOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2BooleanOpenCustomHashMap.java
@@ -441,30 +441,24 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
-
+
@Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
@@ -473,34 +467,50 @@ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
}
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -523,16 +533,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ByteOpenCustomHashMap.java
index 4a2322ae..616f06df 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ByteOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ByteOpenCustomHashMap.java
@@ -455,30 +455,24 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
-
+
@Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
@@ -487,34 +481,50 @@ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -523,30 +533,20 @@ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2CharOpenCustomHashMap.java
index f7dda8ef..f0db65c7 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2CharOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2CharOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
-
+
@Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
}
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2DoubleOpenCustomHashMap.java
index 2d5d7f35..96a025be 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2DoubleOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2DoubleOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
-
+
@Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunctio
}
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2FloatOpenCustomHashMap.java
index 9f71328b..452bc6d5 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2FloatOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2FloatOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
-
+
@Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction)
}
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2IntOpenCustomHashMap.java
index 164803f8..b8ac58fc 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2IntOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2IntOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
-
+
@Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
}
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2LongOpenCustomHashMap.java
index 98280eb9..6b68b2de 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2LongOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2LongOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
-
+
@Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
}
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ObjectOpenCustomHashMap.java
index b1c1bd46..0e3d8ab0 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ObjectOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ObjectOpenCustomHashMap.java
@@ -432,25 +432,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -469,26 +450,7 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
}
return newValue;
}
-
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -508,25 +470,6 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
return newValue;
}
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -541,20 +484,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ShortOpenCustomHashMap.java
index 4942d142..d27135f3 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ShortOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/customHash/Byte2ShortOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
}
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
-
+
@Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction)
}
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2BooleanOpenHashMap.java
index 24f196fb..ba5debd5 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2BooleanOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2BooleanOpenHashMap.java
@@ -408,68 +408,78 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
values[index] = newValue;
return newValue;
}
-
+
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
@Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
return newValue;
}
+
+ @Override
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -492,16 +502,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ByteOpenHashMap.java
index f69eb936..90ff012a 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ByteOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ByteOpenHashMap.java
@@ -424,68 +424,78 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
@Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
return newValue;
}
+
+ @Override
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -494,30 +504,20 @@ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2CharOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2CharOpenHashMap.java
index 977f6769..bf4e02a2 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2CharOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2CharOpenHashMap.java
@@ -430,68 +430,78 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
@Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
return newValue;
}
+
+ @Override
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2DoubleOpenHashMap.java
index 179487fc..1d8a415b 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2DoubleOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2DoubleOpenHashMap.java
@@ -430,68 +430,78 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
@Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
return newValue;
}
+
+ @Override
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2FloatOpenHashMap.java
index 3ec3f763..4aae4401 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2FloatOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2FloatOpenHashMap.java
@@ -430,68 +430,78 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
@Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
return newValue;
}
+
+ @Override
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2IntOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2IntOpenHashMap.java
index d0be51a2..42b872aa 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2IntOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2IntOpenHashMap.java
@@ -430,68 +430,78 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
@Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
return newValue;
}
+
+ @Override
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2LongOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2LongOpenHashMap.java
index af187491..a3c51427 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2LongOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2LongOpenHashMap.java
@@ -430,68 +430,78 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
@Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
return newValue;
}
+
+ @Override
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ObjectOpenHashMap.java
index 4770dbbf..2a26e1a0 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ObjectOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ObjectOpenHashMap.java
@@ -401,26 +401,7 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
+
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -440,25 +421,6 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
return newValue;
}
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -477,26 +439,7 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
}
return newValue;
}
-
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -511,20 +454,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ShortOpenHashMap.java
index fbe3a98b..261a7d09 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ShortOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/hash/Byte2ShortOpenHashMap.java
@@ -430,68 +430,78 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
@Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
return newValue;
}
+
+ @Override
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2BooleanOpenHashMap.java
index eddec887..65c0ff90 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2BooleanOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2BooleanOpenHashMap.java
@@ -413,20 +413,19 @@ public void forEach(ByteBooleanConsumer action) {
@Override
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public boolean mergeBoolean(byte key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ByteOpenHashMap.java
index 716ca350..efe0c01f 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ByteOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ByteOpenHashMap.java
@@ -409,20 +409,19 @@ public void forEach(ByteByteConsumer action) {
@Override
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public byte mergeByte(byte key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2CharOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2CharOpenHashMap.java
index e2f1b626..779b272c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2CharOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2CharOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteCharConsumer action) {
@Override
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public char mergeChar(byte key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2DoubleOpenHashMap.java
index edcb48e3..cdf07d95 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2DoubleOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2DoubleOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteDoubleConsumer action) {
@Override
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public double mergeDouble(byte key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2FloatOpenHashMap.java
index 2b30c54a..af6bb16c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2FloatOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2FloatOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteFloatConsumer action) {
@Override
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public float mergeFloat(byte key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2IntOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2IntOpenHashMap.java
index a8079202..91d46ecf 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2IntOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2IntOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteIntConsumer action) {
@Override
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public int mergeInt(byte key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2LongOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2LongOpenHashMap.java
index 46284693..d7385a98 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2LongOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2LongOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteLongConsumer action) {
@Override
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public long mergeLong(byte key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ObjectOpenHashMap.java
index 6c92f626..8a655ddf 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ObjectOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ObjectOpenHashMap.java
@@ -397,20 +397,11 @@ public void forEach(ByteObjectConsumer action) {
@Override
public V compute(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ShortOpenHashMap.java
index 5bfd8953..b79011b4 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ShortOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/immutable/ImmutableByte2ShortOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(ByteShortConsumer action) {
@Override
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public short mergeShort(byte key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2BooleanArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2BooleanArrayMap.java
index bbfb3504..3e4e630d 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2BooleanArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2BooleanArrayMap.java
@@ -420,66 +420,76 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insertIndex(size++, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
-
+
@Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insertIndex(size++, key, newValue);
return newValue;
}
boolean newValue = values[index];
return newValue;
}
+
+ @Override
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -502,16 +512,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ByteArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ByteArrayMap.java
index 5c9cc355..de0e62f3 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ByteArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ByteArrayMap.java
@@ -436,66 +436,76 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insertIndex(size++, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
-
+
@Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
return newValue;
}
+
+ @Override
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -504,30 +514,20 @@ public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2CharArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2CharArrayMap.java
index a1228f93..bfecf909 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2CharArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2CharArrayMap.java
@@ -443,66 +443,76 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insertIndex(size++, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
-
+
@Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
return newValue;
}
+
+ @Override
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -511,30 +521,20 @@ public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2DoubleArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2DoubleArrayMap.java
index ba3549f1..87e4db59 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2DoubleArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2DoubleArrayMap.java
@@ -443,66 +443,76 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insertIndex(size++, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
-
+
@Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insertIndex(size++, key, newValue);
return newValue;
}
double newValue = values[index];
return newValue;
}
+
+ @Override
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2FloatArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2FloatArrayMap.java
index 0ebe48bd..8ca091e3 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2FloatArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2FloatArrayMap.java
@@ -443,66 +443,76 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insertIndex(size++, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
-
+
@Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
return newValue;
}
+
+ @Override
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -511,30 +521,20 @@ public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2IntArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2IntArrayMap.java
index b0320eca..2ab28490 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2IntArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2IntArrayMap.java
@@ -443,66 +443,76 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insertIndex(size++, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
-
+
@Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insertIndex(size++, key, newValue);
return newValue;
}
int newValue = values[index];
return newValue;
}
+
+ @Override
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2LongArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2LongArrayMap.java
index e52bb50f..390700b0 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2LongArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2LongArrayMap.java
@@ -443,66 +443,76 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insertIndex(size++, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
-
+
@Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insertIndex(size++, key, newValue);
return newValue;
}
long newValue = values[index];
return newValue;
}
+
+ @Override
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ObjectArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ObjectArrayMap.java
index 0d4eea7f..a4d6a6ac 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ObjectArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ObjectArrayMap.java
@@ -415,25 +415,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insertIndex(size++, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -452,26 +433,7 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
}
return newValue;
}
-
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insertIndex(size++, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -490,26 +452,7 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
}
return newValue;
}
-
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int index = findIndex(key);
- if(index == -1) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insertIndex(size++, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -524,20 +467,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ShortArrayMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ShortArrayMap.java
index adcf2916..3ccd8ab2 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ShortArrayMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/misc/Byte2ShortArrayMap.java
@@ -443,66 +443,76 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
}
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insertIndex(size++, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
-
+
@Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insertIndex(size++, key, newValue);
return newValue;
}
short newValue = values[index];
return newValue;
}
+
+ @Override
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -511,30 +521,20 @@ public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanAVLTreeMap.java
index 9b3a2564..5e0621d0 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanAVLTreeMap.java
@@ -396,34 +396,56 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
put(key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ boolean newValue = valueProvider.getAsBoolean();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -444,18 +466,6 @@ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingF
return entry.value;
}
- @Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- boolean newValue = valueProvider.getAsBoolean();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -474,16 +484,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return entry.value;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1487,14 +1487,9 @@ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappin
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- boolean newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanRBTreeMap.java
index 43e7c629..5e9799e4 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2BooleanRBTreeMap.java
@@ -395,34 +395,56 @@ public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
put(key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ boolean newValue = valueProvider.getAsBoolean();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -443,18 +465,6 @@ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingF
return entry.value;
}
- @Override
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- boolean newValue = valueProvider.getAsBoolean();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -473,16 +483,6 @@ public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valuePr
return entry.value;
}
- @Override
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1550,14 +1550,9 @@ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappin
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- boolean newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteAVLTreeMap.java
index f732da1f..b4fd9985 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteAVLTreeMap.java
@@ -447,34 +447,56 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
put(key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ byte newValue = valueProvider.getAsByte();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ byte newValue = mappingFunction.applyAsByte(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -495,46 +517,24 @@ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFun
return entry.value;
}
- @Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- byte newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1550,14 +1550,9 @@ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- byte newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteRBTreeMap.java
index 608f3ed6..309d5acb 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ByteRBTreeMap.java
@@ -446,34 +446,56 @@ public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
put(key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ byte newValue = valueProvider.getAsByte();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ byte newValue = mappingFunction.applyAsByte(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -494,46 +516,24 @@ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFun
return entry.value;
}
- @Override
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- byte newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1613,14 +1613,9 @@ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- byte newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharAVLTreeMap.java
index 84846f68..f7c4e657 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharAVLTreeMap.java
@@ -455,34 +455,56 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
put(key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ char newValue = valueProvider.getAsChar();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ char newValue = mappingFunction.applyAsChar(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,46 +525,24 @@ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFun
return entry.value;
}
- @Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- char newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- char newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharRBTreeMap.java
index 280ebc2f..11f0caa3 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2CharRBTreeMap.java
@@ -454,34 +454,56 @@ public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
put(key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ char newValue = valueProvider.getAsChar();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) {
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ char newValue = mappingFunction.applyAsChar(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,46 +524,24 @@ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFun
return entry.value;
}
- @Override
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- char newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- char newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleAVLTreeMap.java
index 36ad54c0..438ec1f4 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleAVLTreeMap.java
@@ -455,34 +455,56 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
put(key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, entry.value);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ double newValue = valueProvider.getAsDouble();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ double newValue = mappingFunction.applyAsDouble(key, entry.value);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,18 +525,6 @@ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mapp
return entry.value;
}
- @Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- double newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -533,16 +543,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return entry.value;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFu
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || Double.doubleToLongBits(entry.value) == Double.doubleToLongBits(getDefaultReturnValue())) return getDefaultReturnValue();
- double newValue = mappingFunction.apply(key, entry.value);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleRBTreeMap.java
index f2b41130..c72f3a35 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2DoubleRBTreeMap.java
@@ -454,34 +454,56 @@ public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
put(key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, entry.value);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ double newValue = valueProvider.getAsDouble();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ double newValue = mappingFunction.applyAsDouble(key, entry.value);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,18 +524,6 @@ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mapp
return entry.value;
}
- @Override
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- double newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -532,16 +542,6 @@ public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvi
return entry.value;
}
- @Override
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFu
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || Double.doubleToLongBits(entry.value) == Double.doubleToLongBits(getDefaultReturnValue())) return getDefaultReturnValue();
- double newValue = mappingFunction.apply(key, entry.value);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatAVLTreeMap.java
index 7c5e38f1..22d69d43 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatAVLTreeMap.java
@@ -455,34 +455,56 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
put(key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, entry.value);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ float newValue = valueProvider.getAsFloat();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ float newValue = mappingFunction.applyAsFloat(key, entry.value);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,46 +525,24 @@ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mapping
return entry.value;
}
- @Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- float newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
if(Float.floatToIntBits(entry.value) == Float.floatToIntBits(getDefaultReturnValue())) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunct
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || Float.floatToIntBits(entry.value) == Float.floatToIntBits(getDefaultReturnValue())) return getDefaultReturnValue();
- float newValue = mappingFunction.apply(key, entry.value);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatRBTreeMap.java
index 08c207c1..54ba4ea1 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2FloatRBTreeMap.java
@@ -454,34 +454,56 @@ public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
put(key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, entry.value);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ float newValue = valueProvider.getAsFloat();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ float newValue = mappingFunction.applyAsFloat(key, entry.value);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,46 +524,24 @@ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mapping
return entry.value;
}
- @Override
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- float newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
put(key, newValue);
return newValue;
}
if(Float.floatToIntBits(entry.value) == Float.floatToIntBits(getDefaultReturnValue())) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunct
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || Float.floatToIntBits(entry.value) == Float.floatToIntBits(getDefaultReturnValue())) return getDefaultReturnValue();
- float newValue = mappingFunction.apply(key, entry.value);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntAVLTreeMap.java
index f489a425..533b7662 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntAVLTreeMap.java
@@ -455,34 +455,56 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
put(key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ int newValue = valueProvider.getAsInt();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ int newValue = mappingFunction.applyAsInt(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,18 +525,6 @@ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFuncti
return entry.value;
}
- @Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- int newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -533,16 +543,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return entry.value;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- int newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntRBTreeMap.java
index e3422924..5cfbedab 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2IntRBTreeMap.java
@@ -454,34 +454,56 @@ public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
put(key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ int newValue = valueProvider.getAsInt();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) {
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ int newValue = mappingFunction.applyAsInt(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,18 +524,6 @@ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFuncti
return entry.value;
}
- @Override
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- int newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -532,16 +542,6 @@ public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) {
return entry.value;
}
- @Override
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- int newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongAVLTreeMap.java
index c4149663..ee198d56 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongAVLTreeMap.java
@@ -455,34 +455,56 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
put(key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ long newValue = valueProvider.getAsLong();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ long newValue = mappingFunction.applyAsLong(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,18 +525,6 @@ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFun
return entry.value;
}
- @Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- long newValue = valueProvider.getAsLong();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -533,16 +543,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return entry.value;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- long newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongRBTreeMap.java
index 5a16c4e9..7355d9ce 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2LongRBTreeMap.java
@@ -454,34 +454,56 @@ public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
put(key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ long newValue = valueProvider.getAsLong();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) {
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ long newValue = mappingFunction.applyAsLong(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,18 +524,6 @@ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFun
return entry.value;
}
- @Override
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- long newValue = valueProvider.getAsLong();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -532,16 +542,6 @@ public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) {
return entry.value;
}
- @Override
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- long newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectAVLTreeMap.java
index 0b886dca..2cd9c397 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectAVLTreeMap.java
@@ -395,25 +395,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, entry.value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -432,24 +413,6 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
return entry.value;
}
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- if(Objects.equals(entry.value, getDefaultReturnValue())) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- entry.value = newValue;
- }
- return entry.value;
- }
-
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -468,24 +431,6 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
return entry.value;
}
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- if(Objects.equals(entry.value, getDefaultReturnValue())) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- entry.value = newValue;
- }
- return entry.value;
- }
-
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -500,20 +445,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null || Objects.equals(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, entry.value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectRBTreeMap.java
index ce7a338d..62844db5 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ObjectRBTreeMap.java
@@ -394,25 +394,6 @@ public V compute(byte key, ByteObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, entry.value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -431,24 +412,6 @@ public V computeIfAbsent(byte key, ByteFunction mappingFunction) {
return entry.value;
}
- @Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- if(Objects.equals(entry.value, getDefaultReturnValue())) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- entry.value = newValue;
- }
- return entry.value;
- }
-
@Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -467,24 +430,6 @@ public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) {
return entry.value;
}
- @Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- put(key, newValue);
- return newValue;
- }
- if(Objects.equals(entry.value, getDefaultReturnValue())) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- entry.value = newValue;
- }
- return entry.value;
- }
-
@Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -499,20 +444,6 @@ public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null || Objects.equals(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, entry.value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
- }
-
@Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortAVLTreeMap.java
index 6565e914..6d262bec 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortAVLTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortAVLTreeMap.java
@@ -455,34 +455,56 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
}
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
put(key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ short newValue = valueProvider.getAsShort();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ short newValue = mappingFunction.applyAsShort(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -503,46 +525,24 @@ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mapping
return entry.value;
}
- @Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- short newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1558,14 +1558,9 @@ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunct
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- short newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortRBTreeMap.java
index ffc1042b..03215894 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortRBTreeMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/impl/tree/Byte2ShortRBTreeMap.java
@@ -454,34 +454,56 @@ public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) {
}
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
put(key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- removeNode(entry);
+ return entry.value;
+ }
+
+ @Override
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ Node entry = findNode(key);
+ if(entry == null) {
+ short newValue = valueProvider.getAsShort();
+ put(key, newValue);
return newValue;
}
+ return entry.value;
+ }
+
+ @Override
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ Node entry = findNode(key);
+ if(entry == null) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, entry.value);
entry.value = newValue;
return newValue;
}
@Override
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) {
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
Node entry = findNode(key);
if(entry == null) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
- return entry.value;
+ short newValue = mappingFunction.applyAsShort(key, entry.value);
+ if(newValue == getDefaultReturnValue()) {
+ removeNode(entry);
+ return newValue;
+ }
+ entry.value = newValue;
+ return newValue;
}
@Override
@@ -502,46 +524,24 @@ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mapping
return entry.value;
}
- @Override
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- Node entry = findNode(key);
- if(entry == null) {
- short newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return entry.value;
- }
-
@Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
Node entry = findNode(key);
if(entry == null) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
put(key, newValue);
return newValue;
}
if(entry.value == getDefaultReturnValue()) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
entry.value = newValue;
}
return entry.value;
}
- @Override
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- Node entry = findNode(key);
- if(entry == null) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, entry.value);
- entry.value = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -1621,14 +1621,9 @@ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunct
Objects.requireNonNull(mappingFunction);
if(!inRange(key)) return getDefaultReturnValue();
Node entry = map.findNode(key);
- if(entry == null || entry.value == getDefaultReturnValue()) return getDefaultReturnValue();
- short newValue = mappingFunction.apply(key, entry.value);
- if(newValue == getDefaultReturnValue()) {
- map.removeNode(entry);
- return newValue;
- }
- entry.value = newValue;
- return newValue;
+ if(entry == null) return getDefaultReturnValue();
+ entry.value = mappingFunction.apply(key, entry.value);
+ return entry.value;
}
@Override
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2BooleanMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2BooleanMap.java
index 4b24bfc8..d8ddccc8 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2BooleanMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2BooleanMap.java
@@ -284,41 +284,51 @@ public default boolean remove(Object key, Object value) {
*/
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction);
+ public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction);
+ public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction);
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider);
+ */
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -328,16 +338,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ByteMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ByteMap.java
index 8bd81c2a..74acdd0c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ByteMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ByteMap.java
@@ -308,41 +308,51 @@ public default boolean remove(Object key, Object value) {
*/
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction);
+ public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction);
+ public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction);
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider);
+ */
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -352,16 +362,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2CharMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2CharMap.java
index f4886028..986a2e2a 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2CharMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2CharMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction);
+ public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public char supplyCharIfAbsent(byte key, CharSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction);
+ public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction);
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public char supplyCharIfAbsent(byte key, CharSupplier valueProvider);
+ */
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2DoubleMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2DoubleMap.java
index 91fa0ef9..95fe7684 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2DoubleMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2DoubleMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction);
+ public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction);
+ public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction);
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider);
+ */
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2FloatMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2FloatMap.java
index 096cb368..4c7cee87 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2FloatMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2FloatMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction);
+ public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction);
+ public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction);
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider);
+ */
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2IntMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2IntMap.java
index 7e383c2c..75be994c 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2IntMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2IntMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction);
+ public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public int supplyIntIfAbsent(byte key, IntSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction);
+ public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction);
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public int supplyIntIfAbsent(byte key, IntSupplier valueProvider);
+ */
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2LongMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2LongMap.java
index 35441a4c..88930203 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2LongMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2LongMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction);
+ public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public long supplyLongIfAbsent(byte key, LongSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction);
+ public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction);
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public long supplyLongIfAbsent(byte key, LongSupplier valueProvider);
+ */
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ObjectMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ObjectMap.java
index c7641c69..f1145bd0 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ObjectMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ObjectMap.java
@@ -266,15 +266,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computation
*/
public V compute(byte key, ByteObjectUnaryOperator mappingFunction);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
- */
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction);
/**
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -284,15 +275,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public V computeIfAbsent(byte key, ByteFunction mappingFunction);
- /**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
- */
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -302,15 +284,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider);
- /**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param valueProvider the value if not present
- * @return the result of the computed value or present value
- */
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -321,16 +294,6 @@ public default boolean remove(Object key, Object value) {
* @note if not present then compute is not executed
*/
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction);
/**
* A Type Specific merge method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ShortMap.java b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ShortMap.java
index 7bdac5d8..88225d11 100644
--- a/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ShortMap.java
+++ b/src/main/java/speiger/src/collections/bytes/maps/interfaces/Byte2ShortMap.java
@@ -309,41 +309,51 @@ public default boolean remove(Object key, Object value) {
*/
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction);
/**
- * A Type Specific compute method to reduce boxing/unboxing
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value
- * @return the result of the computation
+ * @param mappingFunction the operator that should generate the value if not present
+ * @return the result of the computed value or present value
*/
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction);
+ public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
+ * @param valueProvider the value if not present
* @return the result of the computed value or present value
+ */
+ public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider);
+ /**
+ * A Type Specific compute method to reduce boxing/unboxing
+ * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
+ * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
+ * @param key the key that should be computed
+ * @param mappingFunction the operator that should generate the value if present
+ * @return the result of the default return value or present value
+ * @note if not present then compute is not executed
*/
- public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction);
+ public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction);
/**
- * A Type Specific computeIfAbsent method to reduce boxing/unboxing
+ * A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if not present
- * @return the result of the computed value or present value
+ * @param mappingFunction the operator that should generate the value
+ * @return the result of the computation
*/
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction);
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction);
/**
- * A Supplier based computeIfAbsent function to fill the most used usecase of this function
+ * A Type Specific computeIfAbsent method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
* @param key the key that should be computed
- * @param valueProvider the value if not present
+ * @param mappingFunction the operator that should generate the value if not present
* @return the result of the computed value or present value
- */
- public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider);
+ */
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction);
/**
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
@@ -353,16 +363,6 @@ public default boolean remove(Object key, Object value) {
* @return the result of the computed value or present value
*/
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider);
- /**
- * A Type Specific compute method to reduce boxing/unboxing
- * If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
- * A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
- * @param key the key that should be computed
- * @param mappingFunction the operator that should generate the value if present
- * @return the result of the default return value or present value
- * @note if not present then compute is not executed
- */
- public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction);
/**
* A Type Specific compute method to reduce boxing/unboxing
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
diff --git a/src/main/java/speiger/src/collections/bytes/queues/ByteArrayFIFOQueue.java b/src/main/java/speiger/src/collections/bytes/queues/ByteArrayFIFOQueue.java
index 9812bd7a..41d89bed 100644
--- a/src/main/java/speiger/src/collections/bytes/queues/ByteArrayFIFOQueue.java
+++ b/src/main/java/speiger/src/collections/bytes/queues/ByteArrayFIFOQueue.java
@@ -146,6 +146,15 @@ public byte peek(int index) {
return index >= array.length ? array[index-array.length] : array[index];
}
+ @Override
+ public boolean contains(byte e) {
+ if(first == last) return false;
+ for(int i = 0,m=size();i iterator, int repeats
return new RepeatingIterator(wrap(iterator), repeats);
}
+ /**
+ * A Helper function that creates a infinitely looping iterator
+ * @param iterator that should be looping infinitely
+ * @return a infinitely looping iterator
+ */
+ public static ByteIterator infinite(ByteIterator iterator) {
+ return new InfiniteIterator(iterator);
+ }
+
+ /**
+ * A Helper function that creates a infinitely looping iterator from a Java Iterator
+ * @param iterator that should be looping infinitely
+ * @return a infinitely looping iterator
+ */
+ public static ByteIterator infinite(Iterator extends Byte> iterator) {
+ return new InfiniteIterator(wrap(iterator));
+ }
+
/**
* A Helper function that hard limits the Iterator to a specific size
* @param iterator that should be limited
@@ -841,6 +862,40 @@ public T next() {
}
}
+ private static class InfiniteIterator implements ByteIterator
+ {
+ ByteIterator iter;
+ CollectionWrapper looper = ByteCollections.wrapper();
+ int index = 0;
+
+ public InfiniteIterator(ByteIterator iter) {
+ this.iter = iter;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return true;
+ }
+
+ @Override
+ public byte nextByte() {
+ if(iter != null) {
+ if(iter.hasNext()) {
+ byte value = iter.nextByte();
+ looper.add(value);
+ return value;
+ }
+ else iter = null;
+ }
+ return looper.getByte((index++) % looper.size());
+ }
+
+ @Override
+ public void forEachRemaining(ByteConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ public void forEachRemaining(Consumer super Byte> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ public void forEachRemaining(E input, ObjectByteConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
+ }
+
private static class RepeatingIterator implements ByteIterator
{
final int repeats;
diff --git a/src/main/java/speiger/src/collections/bytes/utils/ByteLists.java b/src/main/java/speiger/src/collections/bytes/utils/ByteLists.java
index 3d52d57c..29f3c317 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/ByteLists.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/ByteLists.java
@@ -12,6 +12,7 @@
import speiger.src.collections.bytes.functions.ByteConsumer;
import speiger.src.collections.bytes.lists.AbstractByteList;
import speiger.src.collections.bytes.lists.ByteList;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.bytes.lists.ByteListIterator;
import speiger.src.collections.utils.SanityChecks;
@@ -317,6 +318,16 @@ public ByteListIterator listIterator(int index) {
return l.listIterator(index);
}
+ @Override
+ public ByteListIterator indexedIterator(int...indecies) {
+ return l.indexedIterator(indecies);
+ }
+
+ @Override
+ public ByteListIterator indexedIterator(IntList indecies) {
+ return l.indexedIterator(indecies);
+ }
+
@Override
public ByteList subList(int from, int to) {
return ByteLists.synchronize(l.subList(from, to));
@@ -426,6 +437,16 @@ public ByteListIterator listIterator(int index) {
return ByteIterators.unmodifiable(l.listIterator(index));
}
+ @Override
+ public ByteListIterator indexedIterator(int...indecies) {
+ return ByteIterators.unmodifiable(l.indexedIterator(indecies));
+ }
+
+ @Override
+ public ByteListIterator indexedIterator(IntList indecies) {
+ return ByteIterators.unmodifiable(l.indexedIterator(indecies));
+ }
+
@Override
public ByteList subList(int from, int to) {
return ByteLists.unmodifiable(l.subList(from, to));
@@ -514,6 +535,16 @@ public ByteListIterator listIterator(int index) {
return ByteIterators.empty();
}
+ @Override
+ public ByteListIterator indexedIterator(int...indecies) {
+ return ByteIterators.empty();
+ }
+
+ @Override
+ public ByteListIterator indexedIterator(IntList indecies) {
+ return ByteIterators.empty();
+ }
+
@Override
public int hashCode() { return 1; }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/BytePriorityQueues.java b/src/main/java/speiger/src/collections/bytes/utils/BytePriorityQueues.java
index 0663d197..67d9603e 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/BytePriorityQueues.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/BytePriorityQueues.java
@@ -89,6 +89,8 @@ protected SynchronizedPriorityQueue(BytePriorityQueue queue, Object mutex) {
@Override
public byte peek(int index) { synchronized(mutex) { return queue.peek(index); } }
@Override
+ public boolean contains(byte e) { synchronized(mutex) { return queue.contains(e); } }
+ @Override
public boolean removeFirst(byte e) { synchronized(mutex) { return queue.removeFirst(e); } }
@Override
public boolean removeLast(byte e) { synchronized(mutex) { return queue.removeLast(e); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2BooleanMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2BooleanMaps.java
index 3e63491b..42442f23 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2BooleanMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2BooleanMaps.java
@@ -246,18 +246,18 @@ public static class SingletonMap extends AbstractByte2BooleanMap {
@Override
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public boolean mergeBoolean(byte key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -304,18 +304,18 @@ public static class EmptyMap extends AbstractByte2BooleanMap {
@Override
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public boolean mergeBoolean(byte key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -535,18 +535,18 @@ public boolean get(byte key) {
@Override
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public boolean mergeBoolean(byte key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -938,18 +938,18 @@ public AbstractByte2BooleanMap setDefaultReturnValue(boolean v) {
@Override
public boolean computeBoolean(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } }
@Override
- public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } }
- @Override
public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } }
@Override
- public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } }
@Override
- public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } }
- @Override
public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } }
@Override
+ public boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } }
@Override
public boolean mergeBoolean(byte key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ByteMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ByteMaps.java
index a4c19371..8bb6a3f4 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ByteMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ByteMaps.java
@@ -249,18 +249,18 @@ public static class SingletonMap extends AbstractByte2ByteMap {
@Override
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public byte mergeByte(byte key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -311,18 +311,18 @@ public static class EmptyMap extends AbstractByte2ByteMap {
@Override
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public byte mergeByte(byte key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -546,18 +546,18 @@ public byte get(byte key) {
@Override
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public byte mergeByte(byte key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -954,18 +954,18 @@ public AbstractByte2ByteMap setDefaultReturnValue(byte v) {
@Override
public byte computeByte(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } }
@Override
- public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } }
- @Override
public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } }
@Override
- public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } }
@Override
- public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } }
- @Override
public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } }
@Override
+ public byte computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } }
+ @Override
+ public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } }
@Override
public byte mergeByte(byte key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2CharMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2CharMaps.java
index 53b74b2d..3a92fc41 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2CharMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2CharMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2CharMap {
@Override
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public char mergeChar(byte key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2CharMap {
@Override
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public char mergeChar(byte key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public char get(byte key) {
@Override
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public char mergeChar(byte key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2CharMap setDefaultReturnValue(char v) {
@Override
public char computeChar(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } }
@Override
- public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } }
- @Override
public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } }
@Override
- public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } }
@Override
- public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } }
- @Override
public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } }
@Override
+ public char computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } }
+ @Override
+ public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } }
@Override
public char mergeChar(byte key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2DoubleMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2DoubleMaps.java
index 17c4c912..30233700 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2DoubleMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2DoubleMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2DoubleMap {
@Override
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public double mergeDouble(byte key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2DoubleMap {
@Override
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public double mergeDouble(byte key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public double get(byte key) {
@Override
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public double mergeDouble(byte key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2DoubleMap setDefaultReturnValue(double v) {
@Override
public double computeDouble(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } }
@Override
- public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } }
- @Override
public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } }
@Override
- public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } }
@Override
- public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } }
- @Override
public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } }
@Override
+ public double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } }
@Override
public double mergeDouble(byte key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2FloatMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2FloatMaps.java
index bc2bff1f..4bfd042f 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2FloatMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2FloatMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2FloatMap {
@Override
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public float mergeFloat(byte key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2FloatMap {
@Override
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public float mergeFloat(byte key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public float get(byte key) {
@Override
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public float mergeFloat(byte key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2FloatMap setDefaultReturnValue(float v) {
@Override
public float computeFloat(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } }
@Override
- public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } }
- @Override
public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } }
@Override
- public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } }
@Override
- public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } }
- @Override
public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } }
@Override
+ public float computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } }
+ @Override
+ public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } }
@Override
public float mergeFloat(byte key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2IntMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2IntMaps.java
index 13ab6576..78a456a6 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2IntMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2IntMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2IntMap {
@Override
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public int mergeInt(byte key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2IntMap {
@Override
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public int mergeInt(byte key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public int get(byte key) {
@Override
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public int mergeInt(byte key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2IntMap setDefaultReturnValue(int v) {
@Override
public int computeInt(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } }
@Override
- public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } }
- @Override
public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } }
@Override
- public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } }
@Override
- public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } }
- @Override
public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } }
@Override
+ public int computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } }
+ @Override
+ public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } }
@Override
public int mergeInt(byte key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2LongMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2LongMaps.java
index 7367968b..2dcde038 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2LongMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2LongMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2LongMap {
@Override
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public long mergeLong(byte key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2LongMap {
@Override
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public long mergeLong(byte key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public long get(byte key) {
@Override
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public long mergeLong(byte key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2LongMap setDefaultReturnValue(long v) {
@Override
public long computeLong(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } }
@Override
- public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } }
- @Override
public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } }
@Override
- public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } }
@Override
- public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } }
- @Override
public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } }
@Override
+ public long computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } }
+ @Override
+ public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } }
@Override
public long mergeLong(byte key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ObjectMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ObjectMaps.java
index 39b484c5..d926d88e 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ObjectMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ObjectMaps.java
@@ -266,20 +266,12 @@ public static class SingletonMap extends AbstractByte2ObjectMap {
@Override
public V compute(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
public void mergeAll(Byte2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -325,20 +317,12 @@ public static class EmptyMap extends AbstractByte2ObjectMap {
@Override
public V compute(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
public void mergeAll(Byte2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -561,20 +545,12 @@ public V get(byte key) {
@Override
public V compute(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
public void mergeAll(Byte2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -968,20 +944,12 @@ public AbstractByte2ObjectMap setDefaultReturnValue(V v) {
@Override
public V compute(byte key, ByteObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } }
@Override
- public V computeNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } }
- @Override
public V computeIfAbsent(byte key, ByteFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } }
@Override
- public V computeIfAbsentNonDefault(byte key, ByteFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public V computeIfPresent(byte key, ByteObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } }
@Override
- public V computeIfPresentNonDefault(byte key, ByteObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } }
- @Override
public V supplyIfAbsent(byte key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } }
@Override
- public V supplyIfAbsentNonDefault(byte key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } }
- @Override
public V merge(byte key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } }
@Override
public void mergeAll(Byte2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ShortMaps.java b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ShortMaps.java
index cf3e17a5..0c73b7e3 100644
--- a/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ShortMaps.java
+++ b/src/main/java/speiger/src/collections/bytes/utils/maps/Byte2ShortMaps.java
@@ -250,18 +250,18 @@ public static class SingletonMap extends AbstractByte2ShortMap {
@Override
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public short mergeShort(byte key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -312,18 +312,18 @@ public static class EmptyMap extends AbstractByte2ShortMap {
@Override
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public short mergeShort(byte key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -547,18 +547,18 @@ public short get(byte key) {
@Override
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
public short mergeShort(byte key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@@ -955,18 +955,18 @@ public AbstractByte2ShortMap setDefaultReturnValue(short v) {
@Override
public short computeShort(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } }
@Override
- public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } }
- @Override
public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } }
@Override
- public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } }
- @Override
public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } }
@Override
- public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } }
- @Override
public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } }
@Override
+ public short computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } }
+ @Override
+ public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } }
+ @Override
+ public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } }
+ @Override
public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } }
@Override
public short mergeShort(byte key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } }
diff --git a/src/main/java/speiger/src/collections/chars/functions/CharSupplier.java b/src/main/java/speiger/src/collections/chars/functions/CharSupplier.java
index 8d675dce..e4c6c66c 100644
--- a/src/main/java/speiger/src/collections/chars/functions/CharSupplier.java
+++ b/src/main/java/speiger/src/collections/chars/functions/CharSupplier.java
@@ -8,5 +8,5 @@ public interface CharSupplier
/**
* @return the supplied value
*/
- public char getAsInt();
+ public char getAsChar();
}
\ No newline at end of file
diff --git a/src/main/java/speiger/src/collections/chars/lists/AbstractCharList.java b/src/main/java/speiger/src/collections/chars/lists/AbstractCharList.java
index ad1ffd82..db993971 100644
--- a/src/main/java/speiger/src/collections/chars/lists/AbstractCharList.java
+++ b/src/main/java/speiger/src/collections/chars/lists/AbstractCharList.java
@@ -12,6 +12,7 @@
import speiger.src.collections.chars.collections.CharCollection;
import speiger.src.collections.chars.collections.CharIterator;
import speiger.src.collections.chars.collections.CharSplititerator;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.chars.utils.CharSplititerators;
import speiger.src.collections.utils.SanityChecks;
@@ -205,13 +206,23 @@ public CharIterator iterator() {
public CharListIterator listIterator() {
return listIterator(0);
}
-
+
@Override
public CharListIterator listIterator(int index) {
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
return new CharListIter(index);
}
+ @Override
+ public CharListIterator indexedIterator(int...indecies) {
+ return new IndexedIterator(indecies);
+ }
+
+ @Override
+ public CharListIterator indexedIterator(IntList indecies) {
+ return new ListIndexedIterator(indecies);
+ }
+
@Override
public void size(int size) {
while(size > size()) add((char)0);
@@ -566,7 +577,153 @@ public int back(int amount) {
}
}
}
+
+ private class ListIndexedIterator implements CharListIterator {
+ IntList indecies;
+ int index;
+ int lastReturned = -1;
+
+ ListIndexedIterator(IntList indecies) {
+ this.indecies = indecies;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return index < indecies.size();
+ }
+
+ @Override
+ public char nextChar() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getChar((lastReturned = indecies.getInt(i)));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public char previousChar() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getChar((lastReturned = indecies.getInt(index)));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(char e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(char e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractCharList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.size() - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
+ private class IndexedIterator implements CharListIterator {
+ int[] indecies;
+ int index;
+ int lastReturned = -1;
+
+ IndexedIterator(int[] indecies) {
+ this.indecies = indecies;
+ }
+ @Override
+ public boolean hasNext() {
+ return index < indecies.length;
+ }
+
+ @Override
+ public char nextChar() {
+ if(!hasNext()) throw new NoSuchElementException();
+ int i = index++;
+ return getChar((lastReturned = indecies[i]));
+ }
+
+ @Override
+ public boolean hasPrevious() {
+ return index > 0;
+ }
+
+ @Override
+ public char previousChar() {
+ if(!hasPrevious()) throw new NoSuchElementException();
+ index--;
+ return getChar((lastReturned = indecies[index]));
+ }
+
+ @Override
+ public int nextIndex() {
+ return index;
+ }
+
+ @Override
+ public int previousIndex() {
+ return index-1;
+ }
+
+ @Override
+ public void remove() { throw new UnsupportedOperationException(); }
+ @Override
+ public void add(char e) { throw new UnsupportedOperationException(); }
+
+ @Override
+ public void set(char e) {
+ if(lastReturned == -1) throw new IllegalStateException();
+ AbstractCharList.this.set(lastReturned, e);
+ }
+
+ @Override
+ public int skip(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, indecies.length - index);
+ index += steps;
+ if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
+ return steps;
+ }
+
+ @Override
+ public int back(int amount) {
+ if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
+ int steps = Math.min(amount, index);
+ index -= steps;
+ if(steps > 0) lastReturned = Math.max(index, 0);
+ return steps;
+ }
+ }
+
private class CharListIter implements CharListIterator {
int index;
int lastReturned = -1;
@@ -644,7 +801,7 @@ public int back(int amount) {
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
int steps = Math.min(amount, index);
index -= steps;
- if(steps > 0) lastReturned = Math.min(index, size()-1);
+ if(steps > 0) lastReturned = Math.max(index, 0);
return steps;
}
}
diff --git a/src/main/java/speiger/src/collections/chars/lists/CharList.java b/src/main/java/speiger/src/collections/chars/lists/CharList.java
index b2781896..6d86715c 100644
--- a/src/main/java/speiger/src/collections/chars/lists/CharList.java
+++ b/src/main/java/speiger/src/collections/chars/lists/CharList.java
@@ -14,6 +14,7 @@
import speiger.src.collections.chars.functions.CharComparator;
import speiger.src.collections.chars.utils.CharArrays;
import speiger.src.collections.chars.utils.CharLists;
+import speiger.src.collections.ints.lists.IntList;
import speiger.src.collections.chars.utils.CharSplititerators;
import speiger.src.collections.utils.SanityChecks;
@@ -342,6 +343,24 @@ public default void forEachIndexed(IntCharConsumer action) {
@Override
public CharListIterator listIterator(int index);
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public CharListIterator indexedIterator(int...indecies);
+
+ /**
+ * Creates a Iterator that follows the indecies provided.
+ * For example if the Lists Contents is:
-1, 0 1
and the indecies are:
0, 1, 2, 2, 1, 0
+ * then the iterator will return the following values:
-1, 0, 1, 1, 0, -1
+ * @param indecies that should be used for the iteration.
+ * @return a custom indexed iterator
+ */
+ public CharListIterator indexedIterator(IntList indecies);
+
/**
* A Type-Specific List of subList
* @see java.util.List#subList(int, int)
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2BooleanMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2BooleanMap.java
index 441bfa8a..f1df3557 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2BooleanMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2BooleanMap.java
@@ -151,6 +151,39 @@ public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction
return newValue;
}
+ @Override
+ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ boolean newValue = mappingFunction.test(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ boolean newValue = valueProvider.getAsBoolean();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ boolean newValue = mappingFunction.applyAsBoolean(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -167,17 +200,6 @@ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappi
return newValue;
}
- @Override
- public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- boolean newValue = mappingFunction.test(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -192,17 +214,6 @@ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingF
return value;
}
- @Override
- public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- boolean newValue = valueProvider.getAsBoolean();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -217,17 +228,6 @@ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valuePr
return value;
}
- @Override
- public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- boolean newValue = mappingFunction.applyAsBoolean(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ByteMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ByteMap.java
index 11751864..7e7e4bca 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ByteMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ByteMap.java
@@ -157,6 +157,39 @@ public byte computeByte(char key, CharByteUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ byte newValue = mappingFunction.applyAsByte(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ byte newValue = valueProvider.getAsByte();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ byte newValue = mappingFunction.applyAsByte(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- byte newValue = mappingFunction.applyAsByte(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFun
return value;
}
- @Override
- public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- byte newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
byte value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
return value;
}
- @Override
- public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- byte newValue = mappingFunction.applyAsByte(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2CharMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2CharMap.java
index b676f32b..9d6a53d2 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2CharMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2CharMap.java
@@ -155,6 +155,39 @@ public char computeChar(char key, CharCharUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ char newValue = mappingFunction.applyAsChar(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ char newValue = valueProvider.getAsChar();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ char newValue = mappingFunction.applyAsChar(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -171,17 +204,6 @@ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- char newValue = mappingFunction.applyAsChar(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -196,23 +218,12 @@ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFun
return value;
}
- @Override
- public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- char newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
char value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -221,17 +232,6 @@ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
return value;
}
- @Override
- public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- char newValue = mappingFunction.applyAsChar(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2DoubleMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2DoubleMap.java
index 8a365291..acc6d857 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2DoubleMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2DoubleMap.java
@@ -157,6 +157,39 @@ public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ double newValue = mappingFunction.applyAsDouble(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ double newValue = valueProvider.getAsDouble();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ double newValue = mappingFunction.applyAsDouble(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingF
return newValue;
}
- @Override
- public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- double newValue = mappingFunction.applyAsDouble(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mapp
return value;
}
- @Override
- public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- double newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvi
return value;
}
- @Override
- public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- double newValue = mappingFunction.applyAsDouble(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2FloatMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2FloatMap.java
index 87cea2e6..358202b7 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2FloatMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2FloatMap.java
@@ -157,6 +157,39 @@ public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ float newValue = mappingFunction.applyAsFloat(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ float newValue = valueProvider.getAsFloat();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ float newValue = mappingFunction.applyAsFloat(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunc
return newValue;
}
- @Override
- public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- float newValue = mappingFunction.applyAsFloat(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mapping
return value;
}
- @Override
- public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- float newValue = valueProvider.getAsDouble();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
float value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) != Float.floatToIntBits(getDefaultReturnValue())) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider
return value;
}
- @Override
- public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- float newValue = mappingFunction.applyAsFloat(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2IntMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2IntMap.java
index 941b3e49..34c7a3f2 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2IntMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2IntMap.java
@@ -157,6 +157,39 @@ public int computeInt(char key, CharIntUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ int newValue = mappingFunction.applyAsInt(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ int newValue = valueProvider.getAsInt();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ int newValue = mappingFunction.applyAsInt(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- int newValue = mappingFunction.applyAsInt(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFuncti
return value;
}
- @Override
- public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- int newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
return value;
}
- @Override
- public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- int newValue = mappingFunction.applyAsInt(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2LongMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2LongMap.java
index ca1ea4a7..b6013f65 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2LongMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2LongMap.java
@@ -157,6 +157,39 @@ public long computeLong(char key, CharLongUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ long newValue = mappingFunction.applyAsLong(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ long newValue = valueProvider.getAsLong();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ long newValue = mappingFunction.applyAsLong(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunctio
return newValue;
}
- @Override
- public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- long newValue = mappingFunction.applyAsLong(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,17 +220,6 @@ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFun
return value;
}
- @Override
- public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- long newValue = valueProvider.getAsLong();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -223,17 +234,6 @@ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
return value;
}
- @Override
- public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- long newValue = mappingFunction.applyAsLong(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ObjectMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ObjectMap.java
index 75ad7840..97b3cdce 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ObjectMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ObjectMap.java
@@ -159,22 +159,6 @@ public V compute(char key, CharObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value = get(key);
- V newValue = mappingFunction.apply(key, value);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- if(!Objects.equals(value, getDefaultReturnValue()) || containsKey(key)) {
- remove(key);
- return getDefaultReturnValue();
- }
- return getDefaultReturnValue();
- }
- put(key, newValue);
- return newValue;
- }
-
@Override
public V computeIfAbsent(char key, CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -189,20 +173,6 @@ public V computeIfAbsent(char key, CharFunction mappingFunction) {
return value;
}
- @Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value;
- if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- V newValue = mappingFunction.apply(key);
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- }
- return value;
- }
-
@Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -217,20 +187,6 @@ public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
return value;
}
- @Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- V value;
- if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- V newValue = valueProvider.get();
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- }
- return value;
- }
-
@Override
public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -246,21 +202,6 @@ public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction)
return getDefaultReturnValue();
}
- @Override
- public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- V value;
- if(!Objects.equals((value = get(key)), getDefaultReturnValue()) || containsKey(key)) {
- V newValue = mappingFunction.apply(key, value);
- if(!Objects.equals(newValue, getDefaultReturnValue())) {
- put(key, newValue);
- return newValue;
- }
- remove(key);
- }
- return getDefaultReturnValue();
- }
-
@Override
public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ShortMap.java b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ShortMap.java
index 7c506bbe..56518fcd 100644
--- a/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ShortMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/abstracts/AbstractChar2ShortMap.java
@@ -157,6 +157,39 @@ public short computeShort(char key, CharShortUnaryOperator mappingFunction) {
return newValue;
}
+ @Override
+ public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(!containsKey(key)) {
+ short newValue = mappingFunction.applyAsShort(key);
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ if(!containsKey(key)) {
+ short newValue = valueProvider.getAsShort();
+ put(key, newValue);
+ return newValue;
+ }
+ return get(key);
+ }
+
+ @Override
+ public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ if(containsKey(key)) {
+ short newValue = mappingFunction.applyAsShort(key, get(key));
+ put(key, newValue);
+ return newValue;
+ }
+ return getDefaultReturnValue();
+ }
+
@Override
public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -173,17 +206,6 @@ public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunc
return newValue;
}
- @Override
- public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(!containsKey(key)) {
- short newValue = mappingFunction.applyAsShort(key);
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -198,23 +220,12 @@ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mapping
return value;
}
- @Override
- public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- if(!containsKey(key)) {
- short newValue = valueProvider.getAsInt();
- put(key, newValue);
- return newValue;
- }
- return get(key);
- }
-
@Override
public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
short value;
if((value = get(key)) == getDefaultReturnValue() || !containsKey(key)) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue != getDefaultReturnValue()) {
put(key, newValue);
return newValue;
@@ -223,17 +234,6 @@ public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider
return value;
}
- @Override
- public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- if(containsKey(key)) {
- short newValue = mappingFunction.applyAsShort(key, get(key));
- put(key, newValue);
- return newValue;
- }
- return getDefaultReturnValue();
- }
-
@Override
public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2BooleanConcurrentOpenHashMap.java
index 4a691a34..5695aa30 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2BooleanConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2BooleanConcurrentOpenHashMap.java
@@ -438,13 +438,6 @@ public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -452,13 +445,6 @@ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -467,17 +453,31 @@ public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
}
@Override
- public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2032,35 +2032,29 @@ protected boolean compute(int hash, char key, CharBooleanUnaryOperator mappingFu
}
}
- protected boolean computeNonDefault(int hash, char key, CharBooleanUnaryOperator mappingFunction) {
+ protected boolean computeIfAbsent(int hash, char key, CharPredicate mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected boolean computeIfAbsent(int hash, char key, CharPredicate mappingFunction) {
+
+ protected boolean supplyIfAbsent(int hash, char key, BooleanSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2071,23 +2065,37 @@ protected boolean computeIfAbsent(int hash, char key, CharPredicate mappingFunct
unlockWrite(stamp);
}
}
+
+ protected boolean computeIfPresent(int hash, char key, CharBooleanUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected boolean computeIfAbsentNonDefault(int hash, char key, CharPredicate mappingFunction) {
+ protected boolean computeNonDefault(int hash, char key, CharBooleanUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2095,16 +2103,22 @@ protected boolean computeIfAbsentNonDefault(int hash, char key, CharPredicate ma
}
}
- protected boolean supplyIfAbsent(int hash, char key, BooleanSupplier valueProvider) {
+ protected boolean computeIfAbsentNonDefault(int hash, char key, CharPredicate mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2135,20 +2149,6 @@ protected boolean supplyIfAbsentNonDefault(int hash, char key, BooleanSupplier v
}
}
- protected boolean computeIfPresent(int hash, char key, CharBooleanUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected boolean computeIfPresentNonDefault(int hash, char key, CharBooleanUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ByteConcurrentOpenHashMap.java
index 5c905f21..b468f5a9 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ByteConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ByteConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public byte computeByte(char key, CharByteUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
}
@Override
- public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected byte compute(int hash, char key, CharByteUnaryOperator mappingFunction
}
}
- protected byte computeNonDefault(int hash, char key, CharByteUnaryOperator mappingFunction) {
+ protected byte computeIfAbsent(int hash, char key, Char2ByteFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected byte computeIfAbsent(int hash, char key, Char2ByteFunction mappingFunction) {
+
+ protected byte supplyIfAbsent(int hash, char key, ByteSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected byte computeIfAbsent(int hash, char key, Char2ByteFunction mappingFunc
unlockWrite(stamp);
}
}
-
- protected byte computeIfAbsentNonDefault(int hash, char key, Char2ByteFunction mappingFunction) {
+
+ protected byte computeIfPresent(int hash, char key, CharByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- byte newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected byte computeIfAbsentNonDefault(int hash, char key, Char2ByteFunction m
}
}
- protected byte supplyIfAbsent(int hash, char key, ByteSupplier valueProvider) {
+ protected byte computeNonDefault(int hash, char key, CharByteUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected byte supplyIfAbsent(int hash, char key, ByteSupplier valueProvider) {
}
}
- protected byte supplyIfAbsentNonDefault(int hash, char key, ByteSupplier valueProvider) {
+ protected byte computeIfAbsentNonDefault(int hash, char key, Char2ByteFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsByte(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected byte supplyIfAbsentNonDefault(int hash, char key, ByteSupplier valuePr
}
}
- protected byte computeIfPresent(int hash, char key, CharByteUnaryOperator mappingFunction) {
+ protected byte supplyIfAbsentNonDefault(int hash, char key, ByteSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ byte newValue = valueProvider.getAsByte();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsByte();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2CharConcurrentOpenHashMap.java
index d333fd0b..f47e2278 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2CharConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2CharConcurrentOpenHashMap.java
@@ -444,13 +444,6 @@ public char computeChar(char key, CharCharUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -458,13 +451,6 @@ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -473,17 +459,31 @@ public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
}
@Override
- public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2069,35 +2069,29 @@ protected char compute(int hash, char key, CharCharUnaryOperator mappingFunction
}
}
- protected char computeNonDefault(int hash, char key, CharCharUnaryOperator mappingFunction) {
+ protected char computeIfAbsent(int hash, char key, CharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected char computeIfAbsent(int hash, char key, CharUnaryOperator mappingFunction) {
+
+ protected char supplyIfAbsent(int hash, char key, CharSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2108,23 +2102,14 @@ protected char computeIfAbsent(int hash, char key, CharUnaryOperator mappingFunc
unlockWrite(stamp);
}
}
-
- protected char computeIfAbsentNonDefault(int hash, char key, CharUnaryOperator mappingFunction) {
+
+ protected char computeIfPresent(int hash, char key, CharCharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- char newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2132,16 +2117,22 @@ protected char computeIfAbsentNonDefault(int hash, char key, CharUnaryOperator m
}
}
- protected char supplyIfAbsent(int hash, char key, CharSupplier valueProvider) {
+ protected char computeNonDefault(int hash, char key, CharCharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2149,19 +2140,19 @@ protected char supplyIfAbsent(int hash, char key, CharSupplier valueProvider) {
}
}
- protected char supplyIfAbsentNonDefault(int hash, char key, CharSupplier valueProvider) {
+ protected char computeIfAbsentNonDefault(int hash, char key, CharUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsChar(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2172,13 +2163,22 @@ protected char supplyIfAbsentNonDefault(int hash, char key, CharSupplier valuePr
}
}
- protected char computeIfPresent(int hash, char key, CharCharUnaryOperator mappingFunction) {
+ protected char supplyIfAbsentNonDefault(int hash, char key, CharSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ char newValue = valueProvider.getAsChar();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsChar();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2DoubleConcurrentOpenHashMap.java
index bc2a54c5..c1b9b909 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2DoubleConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2DoubleConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunctio
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
}
@Override
- public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected double compute(int hash, char key, CharDoubleUnaryOperator mappingFunc
}
}
- protected double computeNonDefault(int hash, char key, CharDoubleUnaryOperator mappingFunction) {
+ protected double computeIfAbsent(int hash, char key, Char2DoubleFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected double computeIfAbsent(int hash, char key, Char2DoubleFunction mappingFunction) {
+
+ protected double supplyIfAbsent(int hash, char key, DoubleSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected double computeIfAbsent(int hash, char key, Char2DoubleFunction mapping
unlockWrite(stamp);
}
}
+
+ protected double computeIfPresent(int hash, char key, CharDoubleUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected double computeIfAbsentNonDefault(int hash, char key, Char2DoubleFunction mappingFunction) {
+ protected double computeNonDefault(int hash, char key, CharDoubleUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected double computeIfAbsentNonDefault(int hash, char key, Char2DoubleFuncti
}
}
- protected double supplyIfAbsent(int hash, char key, DoubleSupplier valueProvider) {
+ protected double computeIfAbsentNonDefault(int hash, char key, Char2DoubleFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected double supplyIfAbsentNonDefault(int hash, char key, DoubleSupplier val
}
}
- protected double computeIfPresent(int hash, char key, CharDoubleUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected double computeIfPresentNonDefault(int hash, char key, CharDoubleUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2FloatConcurrentOpenHashMap.java
index 0b718f45..a7cd51c5 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2FloatConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2FloatConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction)
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
}
@Override
- public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected float compute(int hash, char key, CharFloatUnaryOperator mappingFuncti
}
}
- protected float computeNonDefault(int hash, char key, CharFloatUnaryOperator mappingFunction) {
+ protected float computeIfAbsent(int hash, char key, Char2FloatFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected float computeIfAbsent(int hash, char key, Char2FloatFunction mappingFunction) {
+
+ protected float supplyIfAbsent(int hash, char key, FloatSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected float computeIfAbsent(int hash, char key, Char2FloatFunction mappingFu
unlockWrite(stamp);
}
}
-
- protected float computeIfAbsentNonDefault(int hash, char key, Char2FloatFunction mappingFunction) {
+
+ protected float computeIfPresent(int hash, char key, CharFloatUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- float newValue = values[index];
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected float computeIfAbsentNonDefault(int hash, char key, Char2FloatFunction
}
}
- protected float supplyIfAbsent(int hash, char key, FloatSupplier valueProvider) {
+ protected float computeNonDefault(int hash, char key, CharFloatUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected float supplyIfAbsent(int hash, char key, FloatSupplier valueProvider)
}
}
- protected float supplyIfAbsentNonDefault(int hash, char key, FloatSupplier valueProvider) {
+ protected float computeIfAbsentNonDefault(int hash, char key, Char2FloatFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = mappingFunction.applyAsFloat(key);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected float supplyIfAbsentNonDefault(int hash, char key, FloatSupplier value
}
}
- protected float computeIfPresent(int hash, char key, CharFloatUnaryOperator mappingFunction) {
+ protected float supplyIfAbsentNonDefault(int hash, char key, FloatSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ float newValue = valueProvider.getAsFloat();
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = valueProvider.getAsFloat();
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2IntConcurrentOpenHashMap.java
index d22322a3..2dab4017 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2IntConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2IntConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public int computeInt(char key, CharIntUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
}
@Override
- public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected int compute(int hash, char key, CharIntUnaryOperator mappingFunction)
}
}
- protected int computeNonDefault(int hash, char key, CharIntUnaryOperator mappingFunction) {
+ protected int computeIfAbsent(int hash, char key, Char2IntFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected int computeIfAbsent(int hash, char key, Char2IntFunction mappingFunction) {
+
+ protected int supplyIfAbsent(int hash, char key, IntSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected int computeIfAbsent(int hash, char key, Char2IntFunction mappingFuncti
unlockWrite(stamp);
}
}
+
+ protected int computeIfPresent(int hash, char key, CharIntUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected int computeIfAbsentNonDefault(int hash, char key, Char2IntFunction mappingFunction) {
+ protected int computeNonDefault(int hash, char key, CharIntUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected int computeIfAbsentNonDefault(int hash, char key, Char2IntFunction map
}
}
- protected int supplyIfAbsent(int hash, char key, IntSupplier valueProvider) {
+ protected int computeIfAbsentNonDefault(int hash, char key, Char2IntFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected int supplyIfAbsentNonDefault(int hash, char key, IntSupplier valueProv
}
}
- protected int computeIfPresent(int hash, char key, CharIntUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected int computeIfPresentNonDefault(int hash, char key, CharIntUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2LongConcurrentOpenHashMap.java
index c14a127a..ad35d955 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2LongConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2LongConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public long computeLong(char key, CharLongUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
}
@Override
- public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected long compute(int hash, char key, CharLongUnaryOperator mappingFunction
}
}
- protected long computeNonDefault(int hash, char key, CharLongUnaryOperator mappingFunction) {
+ protected long computeIfAbsent(int hash, char key, Char2LongFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected long computeIfAbsent(int hash, char key, Char2LongFunction mappingFunction) {
+
+ protected long supplyIfAbsent(int hash, char key, LongSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,37 @@ protected long computeIfAbsent(int hash, char key, Char2LongFunction mappingFunc
unlockWrite(stamp);
}
}
+
+ protected long computeIfPresent(int hash, char key, CharLongUnaryOperator mappingFunction) {
+ long stamp = writeLock();
+ try {
+ int index = findIndex(hash, key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+ finally {
+ unlockWrite(stamp);
+ }
+ }
- protected long computeIfAbsentNonDefault(int hash, char key, Char2LongFunction mappingFunction) {
+ protected long computeNonDefault(int hash, char key, CharLongUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2147,22 @@ protected long computeIfAbsentNonDefault(int hash, char key, Char2LongFunction m
}
}
- protected long supplyIfAbsent(int hash, char key, LongSupplier valueProvider) {
+ protected long computeIfAbsentNonDefault(int hash, char key, Char2LongFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
@@ -2179,20 +2193,6 @@ protected long supplyIfAbsentNonDefault(int hash, char key, LongSupplier valuePr
}
}
- protected long computeIfPresent(int hash, char key, CharLongUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected long computeIfPresentNonDefault(int hash, char key, CharLongUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ObjectConcurrentOpenHashMap.java
index e3ef131f..82087e1e 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ObjectConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ObjectConcurrentOpenHashMap.java
@@ -426,13 +426,6 @@ public V compute(char key, CharObjectUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V computeIfAbsent(char key, CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -440,13 +433,6 @@ public V computeIfAbsent(char key, CharFunction mappingFunction) {
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -454,13 +440,6 @@ public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
}
- @Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
- }
-
@Override
public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -468,13 +447,6 @@ public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction)
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
- @Override
- public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -2011,29 +1983,6 @@ protected V compute(int hash, char key, CharObjectUnaryOperator mappingFuncti
}
}
- protected V computeNonDefault(int hash, char key, CharObjectUnaryOperator mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
protected V computeIfAbsent(int hash, char key, CharFunction mappingFunction) {
long stamp = writeLock();
try {
@@ -2056,30 +2005,7 @@ protected V computeIfAbsent(int hash, char key, CharFunction mappingFunction)
unlockWrite(stamp);
}
}
-
- protected V computeIfAbsentNonDefault(int hash, char key, CharFunction mappingFunction) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
+
protected V supplyIfAbsent(int hash, char key, ObjectSupplier valueProvider) {
long stamp = writeLock();
try {
@@ -2102,30 +2028,7 @@ protected V supplyIfAbsent(int hash, char key, ObjectSupplier valueProvider)
unlockWrite(stamp);
}
}
-
- protected V supplyIfAbsentNonDefault(int hash, char key, ObjectSupplier valueProvider) {
- long stamp = writeLock();
- try {
- int index = findIndex(hash, key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
- finally {
- unlockWrite(stamp);
- }
- }
-
+
protected V computeIfPresent(int hash, char key, CharObjectUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
@@ -2144,11 +2047,16 @@ protected V computeIfPresent(int hash, char key, CharObjectUnaryOperator mapp
}
}
- protected V computeIfPresentNonDefault(int hash, char key, CharObjectUnaryOperator mappingFunction) {
+ protected V computeNonDefault(int hash, char key, CharObjectUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
+ if(index < 0) {
+ V newValue = mappingFunction.apply(key, getDefaultReturnValue());
+ if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
V newValue = mappingFunction.apply(key, values[index]);
if(Objects.equals(newValue, getDefaultReturnValue())) {
removeIndex(index);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ShortConcurrentOpenHashMap.java
index f7f6a316..0742c01c 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ShortConcurrentOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/concurrent/Char2ShortConcurrentOpenHashMap.java
@@ -451,13 +451,6 @@ public short computeShort(char key, CharShortUnaryOperator mappingFunction) {
return getSegment(hash).compute(hash, key, mappingFunction);
}
- @Override
- public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
- }
-
@Override
public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -465,13 +458,6 @@ public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction)
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
}
- @Override
- public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int hash = getHashCode(key);
- return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
- }
-
@Override
public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -480,17 +466,31 @@ public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
}
@Override
- public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
+ return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
}
@Override
- public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
+ public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int hash = getHashCode(key);
- return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
+ return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int hash = getHashCode(key);
+ return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
+ }
+
+ @Override
+ public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
+ int hash = getHashCode(key);
+ return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
}
@Override
@@ -2076,35 +2076,29 @@ protected short compute(int hash, char key, CharShortUnaryOperator mappingFuncti
}
}
- protected short computeNonDefault(int hash, char key, CharShortUnaryOperator mappingFunction) {
+ protected short computeIfAbsent(int hash, char key, Char2ShortFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
finally {
unlockWrite(stamp);
}
}
-
- protected short computeIfAbsent(int hash, char key, Char2ShortFunction mappingFunction) {
+
+ protected short supplyIfAbsent(int hash, char key, ShortSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
@@ -2115,23 +2109,14 @@ protected short computeIfAbsent(int hash, char key, Char2ShortFunction mappingFu
unlockWrite(stamp);
}
}
-
- protected short computeIfAbsentNonDefault(int hash, char key, Char2ShortFunction mappingFunction) {
+
+ protected short computeIfPresent(int hash, char key, CharShortUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- short newValue = values[index];
- if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
- }
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2139,16 +2124,22 @@ protected short computeIfAbsentNonDefault(int hash, char key, Char2ShortFunction
}
}
- protected short supplyIfAbsent(int hash, char key, ShortSupplier valueProvider) {
+ protected short computeNonDefault(int hash, char key, CharShortUnaryOperator mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ if(newValue == getDefaultReturnValue()) {
+ removeIndex(index);
+ return newValue;
+ }
+ values[index] = newValue;
return newValue;
}
finally {
@@ -2156,19 +2147,19 @@ protected short supplyIfAbsent(int hash, char key, ShortSupplier valueProvider)
}
}
- protected short supplyIfAbsentNonDefault(int hash, char key, ShortSupplier valueProvider) {
+ protected short computeIfAbsentNonDefault(int hash, char key, Char2ShortFunction mappingFunction) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = mappingFunction.applyAsShort(key);
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
@@ -2179,13 +2170,22 @@ protected short supplyIfAbsentNonDefault(int hash, char key, ShortSupplier value
}
}
- protected short computeIfPresent(int hash, char key, CharShortUnaryOperator mappingFunction) {
+ protected short supplyIfAbsentNonDefault(int hash, char key, ShortSupplier valueProvider) {
long stamp = writeLock();
try {
int index = findIndex(hash, key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
+ if(index < 0) {
+ short newValue = valueProvider.getAsShort();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ insert(-index-1, key, newValue);
+ return newValue;
+ }
+ short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = valueProvider.getAsShort();
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
finally {
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2BooleanOpenCustomHashMap.java
index 294e799f..33a755cb 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2BooleanOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2BooleanOpenCustomHashMap.java
@@ -441,30 +441,24 @@ public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
-
+
@Override
- public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
@@ -473,34 +467,50 @@ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
}
@Override
- public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -523,16 +533,6 @@ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ByteOpenCustomHashMap.java
index b88ea935..d24f11d7 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ByteOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ByteOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public byte computeByte(char key, CharByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
-
+
@Override
- public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
}
@Override
- public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2CharOpenCustomHashMap.java
index 600e09b5..202a6953 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2CharOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2CharOpenCustomHashMap.java
@@ -455,30 +455,24 @@ public char computeChar(char key, CharCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
-
+
@Override
- public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
@@ -487,34 +481,50 @@ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -523,30 +533,20 @@ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2DoubleOpenCustomHashMap.java
index f920ea75..2827a379 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2DoubleOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2DoubleOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
-
+
@Override
- public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunctio
}
@Override
- public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2FloatOpenCustomHashMap.java
index 4c50118e..fefed7da 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2FloatOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2FloatOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
-
+
@Override
- public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction)
}
@Override
- public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2IntOpenCustomHashMap.java
index ec8f3fa8..4f483fe9 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2IntOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2IntOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public int computeInt(char key, CharIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
-
+
@Override
- public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
}
@Override
- public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2LongOpenCustomHashMap.java
index 6f263cd9..3a531d9e 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2LongOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2LongOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public long computeLong(char key, CharLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
-
+
@Override
- public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
}
@Override
- public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -545,16 +555,6 @@ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ObjectOpenCustomHashMap.java
index 0c7fe745..b72f1502 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ObjectOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ObjectOpenCustomHashMap.java
@@ -432,25 +432,6 @@ public V compute(char key, CharObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(char key, CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -469,26 +450,7 @@ public V computeIfAbsent(char key, CharFunction mappingFunction) {
}
return newValue;
}
-
- @Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -508,25 +470,6 @@ public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
return newValue;
}
- @Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
@Override
public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -541,20 +484,6 @@ public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ShortOpenCustomHashMap.java
index d4866f64..0b1bc66f 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ShortOpenCustomHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/customHash/Char2ShortOpenCustomHashMap.java
@@ -463,30 +463,24 @@ public short computeShort(char key, CharShortUnaryOperator mappingFunction) {
}
@Override
- public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
-
+
@Override
- public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
@@ -495,34 +489,50 @@ public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction)
}
@Override
- public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
+ public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
+
+ @Override
+ public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -531,30 +541,20 @@ public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2BooleanOpenHashMap.java
index 148c9bdf..2c2a74c0 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2BooleanOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2BooleanOpenHashMap.java
@@ -408,68 +408,78 @@ public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction
values[index] = newValue;
return newValue;
}
-
+
@Override
- public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
@Override
- public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
return newValue;
}
+
+ @Override
+ public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -492,16 +502,6 @@ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ByteOpenHashMap.java
index eb2c38d0..0dc979bf 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ByteOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ByteOpenHashMap.java
@@ -430,68 +430,78 @@ public byte computeByte(char key, CharByteUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
@Override
- public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
return newValue;
}
+
+ @Override
+ public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2CharOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2CharOpenHashMap.java
index dd8c9687..04202627 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2CharOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2CharOpenHashMap.java
@@ -424,68 +424,78 @@ public char computeChar(char key, CharCharUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
@Override
- public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
return newValue;
}
+
+ @Override
+ public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -494,30 +504,20 @@ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2DoubleOpenHashMap.java
index 7b1ee796..7020e0fd 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2DoubleOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2DoubleOpenHashMap.java
@@ -430,68 +430,78 @@ public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
@Override
- public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
return newValue;
}
+
+ @Override
+ public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2FloatOpenHashMap.java
index 1e494b23..49b036d6 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2FloatOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2FloatOpenHashMap.java
@@ -430,68 +430,78 @@ public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
@Override
- public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
return newValue;
}
+
+ @Override
+ public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2IntOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2IntOpenHashMap.java
index 160d4cc6..eea889c4 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2IntOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2IntOpenHashMap.java
@@ -430,68 +430,78 @@ public int computeInt(char key, CharIntUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
@Override
- public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
return newValue;
}
+
+ @Override
+ public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2LongOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2LongOpenHashMap.java
index f8b54e06..52348d18 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2LongOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2LongOpenHashMap.java
@@ -430,68 +430,78 @@ public long computeLong(char key, CharLongUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
@Override
- public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
return newValue;
}
+
+ @Override
+ public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -514,16 +524,6 @@ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ObjectOpenHashMap.java
index 6e4a1b29..5b2ea01f 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ObjectOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ObjectOpenHashMap.java
@@ -401,26 +401,7 @@ public V compute(char key, CharObjectUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
- @Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
+
@Override
public V computeIfAbsent(char key, CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -440,25 +421,6 @@ public V computeIfAbsent(char key, CharFunction mappingFunction) {
return newValue;
}
- @Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
@Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -477,26 +439,7 @@ public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
}
return newValue;
}
-
- @Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
- int index = findIndex(key);
- if(index < 0) {
- V newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insert(-index-1, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = valueProvider.get();
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -511,20 +454,6 @@ public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction)
return newValue;
}
- @Override
- public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0 || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ShortOpenHashMap.java
index 0f7221fc..26674468 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ShortOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/hash/Char2ShortOpenHashMap.java
@@ -430,68 +430,78 @@ public short computeShort(char key, CharShortUnaryOperator mappingFunction) {
values[index] = newValue;
return newValue;
}
-
+
@Override
- public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
+ public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ short newValue = mappingFunction.applyAsShort(key);
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ short newValue = values[index];
return newValue;
}
@Override
- public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = valueProvider.getAsShort();
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
return newValue;
}
+
+ @Override
+ public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index < 0) return getDefaultReturnValue();
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
+ public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = mappingFunction.applyAsShort(key);
+ short newValue = mappingFunction.applyAsShort(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
- short newValue = values[index];
+ short newValue = mappingFunction.applyAsShort(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsShort(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsShort(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -500,30 +510,20 @@ public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index < 0) {
- short newValue = valueProvider.getAsInt();
+ short newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
insert(-index-1, key, newValue);
return newValue;
}
short newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsShort();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index < 0) return getDefaultReturnValue();
- short newValue = mappingFunction.applyAsShort(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2BooleanOpenHashMap.java
index ab255f9d..5609e591 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2BooleanOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2BooleanOpenHashMap.java
@@ -413,20 +413,19 @@ public void forEach(CharBooleanConsumer action) {
@Override
public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public boolean mergeBoolean(char key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ByteOpenHashMap.java
index 261cf102..7e2c5022 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ByteOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ByteOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharByteConsumer action) {
@Override
public byte computeByte(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public byte mergeByte(char key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2CharOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2CharOpenHashMap.java
index 6fe5a534..48e2675a 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2CharOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2CharOpenHashMap.java
@@ -409,20 +409,19 @@ public void forEach(CharCharConsumer action) {
@Override
public char computeChar(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public char mergeChar(char key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2DoubleOpenHashMap.java
index 9b043016..ac400e2d 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2DoubleOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2DoubleOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharDoubleConsumer action) {
@Override
public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public double mergeDouble(char key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2FloatOpenHashMap.java
index 09d8592d..33af531a 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2FloatOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2FloatOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharFloatConsumer action) {
@Override
public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public float mergeFloat(char key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2IntOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2IntOpenHashMap.java
index 5da1a673..5376a770 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2IntOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2IntOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharIntConsumer action) {
@Override
public int computeInt(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public int mergeInt(char key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2LongOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2LongOpenHashMap.java
index 39a64e00..73052944 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2LongOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2LongOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharLongConsumer action) {
@Override
public long computeLong(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public long mergeLong(char key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ObjectOpenHashMap.java
index d9f3efe7..fb2ea5a1 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ObjectOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ObjectOpenHashMap.java
@@ -397,20 +397,11 @@ public void forEach(CharObjectConsumer action) {
@Override
public V compute(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfAbsent(char key, CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
- public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ShortOpenHashMap.java
index 35ef8a0d..8cd06ff1 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ShortOpenHashMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/immutable/ImmutableChar2ShortOpenHashMap.java
@@ -418,20 +418,19 @@ public void forEach(CharShortConsumer action) {
@Override
public short computeShort(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
@Override
- public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
- @Override
public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
@Override
- public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
- @Override
public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
@Override
+ public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); }
+ @Override
+ public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); }
+ @Override
public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
-
@Override
public short mergeShort(char key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); }
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2BooleanArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2BooleanArrayMap.java
index 319024c8..b31f12cd 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2BooleanArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2BooleanArrayMap.java
@@ -420,66 +420,76 @@ public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction
}
@Override
- public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
+ public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ boolean newValue = mappingFunction.test(key);
insertIndex(size++, key, newValue);
return newValue;
}
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ boolean newValue = values[index];
return newValue;
}
-
+
@Override
- public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = valueProvider.getAsBoolean();
insertIndex(size++, key, newValue);
return newValue;
}
boolean newValue = values[index];
return newValue;
}
+
+ @Override
+ public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = mappingFunction.test(key);
+ boolean newValue = mappingFunction.applyAsBoolean(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- boolean newValue = values[index];
+ boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.test(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- boolean newValue = valueProvider.getAsBoolean();
+ boolean newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
boolean newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.test(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -502,16 +512,6 @@ public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valuePr
return newValue;
}
- @Override
- public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- boolean newValue = mappingFunction.applyAsBoolean(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ByteArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ByteArrayMap.java
index 11cc422f..88731b86 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ByteArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ByteArrayMap.java
@@ -443,66 +443,76 @@ public byte computeByte(char key, CharByteUnaryOperator mappingFunction) {
}
@Override
- public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
+ public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ byte newValue = mappingFunction.applyAsByte(key);
insertIndex(size++, key, newValue);
return newValue;
}
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ byte newValue = values[index];
return newValue;
}
-
+
@Override
- public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = valueProvider.getAsByte();
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
return newValue;
}
+
+ @Override
+ public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = mappingFunction.applyAsByte(key);
+ byte newValue = mappingFunction.applyAsByte(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- byte newValue = values[index];
+ byte newValue = mappingFunction.applyAsByte(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsByte(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsByte(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -511,30 +521,20 @@ public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- byte newValue = valueProvider.getAsInt();
+ byte newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
byte newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsByte();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- byte newValue = mappingFunction.applyAsByte(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2CharArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2CharArrayMap.java
index e08dfd5b..67daf627 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2CharArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2CharArrayMap.java
@@ -436,66 +436,76 @@ public char computeChar(char key, CharCharUnaryOperator mappingFunction) {
}
@Override
- public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
+ public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ char newValue = mappingFunction.applyAsChar(key);
insertIndex(size++, key, newValue);
return newValue;
}
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ char newValue = values[index];
return newValue;
}
-
+
@Override
- public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = valueProvider.getAsChar();
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
return newValue;
}
+
+ @Override
+ public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = mappingFunction.applyAsChar(key);
+ char newValue = mappingFunction.applyAsChar(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- char newValue = values[index];
+ char newValue = mappingFunction.applyAsChar(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsChar(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public char supplyCharIfAbsent(char key, CharSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- char newValue = valueProvider.getAsInt();
+ char newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsChar(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -504,30 +514,20 @@ public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- char newValue = valueProvider.getAsInt();
+ char newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
char newValue = values[index];
if(newValue == getDefaultReturnValue()) {
- newValue = valueProvider.getAsInt();
+ newValue = valueProvider.getAsChar();
if(newValue == getDefaultReturnValue()) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- char newValue = mappingFunction.applyAsChar(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2DoubleArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2DoubleArrayMap.java
index 645ab293..0b828e95 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2DoubleArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2DoubleArrayMap.java
@@ -443,66 +443,76 @@ public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) {
}
@Override
- public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
+ public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ double newValue = mappingFunction.applyAsDouble(key);
insertIndex(size++, key, newValue);
return newValue;
}
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ double newValue = values[index];
return newValue;
}
-
+
@Override
- public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = valueProvider.getAsDouble();
insertIndex(size++, key, newValue);
return newValue;
}
double newValue = values[index];
return newValue;
}
+
+ @Override
+ public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = mappingFunction.applyAsDouble(key);
+ double newValue = mappingFunction.applyAsDouble(key, getDefaultReturnValue());
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- double newValue = values[index];
+ double newValue = mappingFunction.applyAsDouble(key, values[index]);
if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsDouble(key);
- if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- double newValue = valueProvider.getAsDouble();
+ double newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
double newValue = values[index];
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsDouble(key);
+ if(Double.doubleToLongBits(newValue) == Double.doubleToLongBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvi
return newValue;
}
- @Override
- public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- double newValue = mappingFunction.applyAsDouble(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2FloatArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2FloatArrayMap.java
index 74b1cb10..5fab7109 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2FloatArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2FloatArrayMap.java
@@ -443,66 +443,76 @@ public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) {
}
@Override
- public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
+ public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ float newValue = mappingFunction.applyAsFloat(key);
insertIndex(size++, key, newValue);
return newValue;
}
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ float newValue = values[index];
return newValue;
}
-
+
@Override
- public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = valueProvider.getAsFloat();
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
return newValue;
}
+
+ @Override
+ public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = mappingFunction.applyAsFloat(key);
+ float newValue = mappingFunction.applyAsFloat(key, getDefaultReturnValue());
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- float newValue = values[index];
+ float newValue = mappingFunction.applyAsFloat(key, values[index]);
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = mappingFunction.applyAsFloat(key);
- if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
+ newValue = mappingFunction.applyAsFloat(key);
+ if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -511,30 +521,20 @@ public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider
Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- float newValue = valueProvider.getAsDouble();
+ float newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
float newValue = values[index];
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) {
- newValue = valueProvider.getAsDouble();
+ newValue = valueProvider.getAsFloat();
if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue;
values[index] = newValue;
}
return newValue;
}
- @Override
- public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- float newValue = mappingFunction.applyAsFloat(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2IntArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2IntArrayMap.java
index 4965fd78..21a88051 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2IntArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2IntArrayMap.java
@@ -443,66 +443,76 @@ public int computeInt(char key, CharIntUnaryOperator mappingFunction) {
}
@Override
- public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
+ public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ int newValue = mappingFunction.applyAsInt(key);
insertIndex(size++, key, newValue);
return newValue;
}
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ int newValue = values[index];
return newValue;
}
-
+
@Override
- public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = valueProvider.getAsInt();
insertIndex(size++, key, newValue);
return newValue;
}
int newValue = values[index];
return newValue;
}
+
+ @Override
+ public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = mappingFunction.applyAsInt(key);
+ int newValue = mappingFunction.applyAsInt(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- int newValue = values[index];
+ int newValue = mappingFunction.applyAsInt(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsInt(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public int supplyIntIfAbsent(char key, IntSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- int newValue = valueProvider.getAsInt();
+ int newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
int newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsInt(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) {
return newValue;
}
- @Override
- public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- int newValue = mappingFunction.applyAsInt(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2LongArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2LongArrayMap.java
index 37b87ad7..a42f724b 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2LongArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2LongArrayMap.java
@@ -443,66 +443,76 @@ public long computeLong(char key, CharLongUnaryOperator mappingFunction) {
}
@Override
- public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
+ public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
- if(newValue == getDefaultReturnValue()) return newValue;
+ long newValue = mappingFunction.applyAsLong(key);
insertIndex(size++, key, newValue);
return newValue;
}
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- if(newValue == getDefaultReturnValue()) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
+ long newValue = values[index];
return newValue;
}
-
+
@Override
- public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
+ public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
+ Objects.requireNonNull(valueProvider);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = valueProvider.getAsLong();
insertIndex(size++, key, newValue);
return newValue;
}
long newValue = values[index];
return newValue;
}
+
+ @Override
+ public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
+ int index = findIndex(key);
+ if(index == -1) return getDefaultReturnValue();
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
+ values[index] = newValue;
+ return newValue;
+ }
@Override
- public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = mappingFunction.applyAsLong(key);
+ long newValue = mappingFunction.applyAsLong(key, getDefaultReturnValue());
if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
- long newValue = values[index];
+ long newValue = mappingFunction.applyAsLong(key, values[index]);
if(newValue == getDefaultReturnValue()) {
- newValue = mappingFunction.applyAsLong(key);
- if(newValue == getDefaultReturnValue()) return newValue;
- values[index] = newValue;
+ removeIndex(index);
+ return newValue;
}
+ values[index] = newValue;
return newValue;
}
@Override
- public long supplyLongIfAbsent(char key, LongSupplier valueProvider) {
- Objects.requireNonNull(valueProvider);
+ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) {
+ Objects.requireNonNull(mappingFunction);
int index = findIndex(key);
if(index == -1) {
- long newValue = valueProvider.getAsLong();
+ long newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
insertIndex(size++, key, newValue);
return newValue;
}
long newValue = values[index];
+ if(newValue == getDefaultReturnValue()) {
+ newValue = mappingFunction.applyAsLong(key);
+ if(newValue == getDefaultReturnValue()) return newValue;
+ values[index] = newValue;
+ }
return newValue;
}
@@ -525,16 +535,6 @@ public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) {
return newValue;
}
- @Override
- public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) return getDefaultReturnValue();
- long newValue = mappingFunction.applyAsLong(key, values[index]);
- values[index] = newValue;
- return newValue;
- }
-
@Override
public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) {
Objects.requireNonNull(mappingFunction);
diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ObjectArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ObjectArrayMap.java
index 6d747dd6..82ec8a99 100644
--- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ObjectArrayMap.java
+++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ObjectArrayMap.java
@@ -415,25 +415,6 @@ public V compute(char key, CharObjectUnaryOperator mappingFunction) {
return newValue;
}
- @Override
- public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) {
- V newValue = mappingFunction.apply(key, getDefaultReturnValue());
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insertIndex(size++, key, newValue);
- return newValue;
- }
- V newValue = mappingFunction.apply(key, values[index]);
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- removeIndex(index);
- return newValue;
- }
- values[index] = newValue;
- return newValue;
- }
-
@Override
public V computeIfAbsent(char key, CharFunction mappingFunction) {
Objects.requireNonNull(mappingFunction);
@@ -452,26 +433,7 @@ public V computeIfAbsent(char key, CharFunction mappingFunction) {
}
return newValue;
}
-
- @Override
- public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) {
- Objects.requireNonNull(mappingFunction);
- int index = findIndex(key);
- if(index == -1) {
- V newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- insertIndex(size++, key, newValue);
- return newValue;
- }
- V newValue = values[index];
- if(Objects.equals(newValue, getDefaultReturnValue())) {
- newValue = mappingFunction.apply(key);
- if(Objects.equals(newValue, getDefaultReturnValue())) return newValue;
- values[index] = newValue;
- }
- return newValue;
- }
-
+
@Override
public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
Objects.requireNonNull(valueProvider);
@@ -490,26 +452,7 @@ public V supplyIfAbsent(char key, ObjectSupplier valueProvider) {
}
return newValue;
}
-
- @Override
- public V supplyIfAbsentNonDefault(char key, ObjectSupplier