From 2a2d9e8d953d3097ba2e9d7fc1514ddc4898b37a Mon Sep 17 00:00:00 2001 From: Speiger Date: Thu, 29 Jun 2023 22:59:18 +0200 Subject: [PATCH] Updated to 0.9.0 src --- .../booleans/lists/AbstractBooleanList.java | 161 ++++++- .../booleans/lists/BooleanList.java | 19 + .../queues/BooleanArrayFIFOQueue.java | 9 + .../queues/BooleanArrayPriorityQueue.java | 7 + .../queues/BooleanHeapPriorityQueue.java | 7 + .../booleans/queues/BooleanPriorityQueue.java | 7 + .../booleans/utils/BooleanAsyncBuilder.java | 3 +- .../booleans/utils/BooleanIterators.java | 55 +++ .../booleans/utils/BooleanLists.java | 31 ++ .../booleans/utils/BooleanPriorityQueues.java | 2 + .../bytes/functions/ByteSupplier.java | 2 +- .../bytes/lists/AbstractByteList.java | 161 ++++++- .../src/collections/bytes/lists/ByteList.java | 19 + .../abstracts/AbstractByte2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractByte2ByteMap.java | 68 +-- .../maps/abstracts/AbstractByte2CharMap.java | 68 +-- .../abstracts/AbstractByte2DoubleMap.java | 66 +-- .../maps/abstracts/AbstractByte2FloatMap.java | 68 +-- .../maps/abstracts/AbstractByte2IntMap.java | 66 +-- .../maps/abstracts/AbstractByte2LongMap.java | 66 +-- .../abstracts/AbstractByte2ObjectMap.java | 59 --- .../maps/abstracts/AbstractByte2ShortMap.java | 68 +-- .../Byte2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Byte2ByteConcurrentOpenHashMap.java | 142 +++--- .../Byte2CharConcurrentOpenHashMap.java | 142 +++--- .../Byte2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Byte2FloatConcurrentOpenHashMap.java | 142 +++--- .../Byte2IntConcurrentOpenHashMap.java | 138 +++--- .../Byte2LongConcurrentOpenHashMap.java | 138 +++--- .../Byte2ObjectConcurrentOpenHashMap.java | 110 +---- .../Byte2ShortConcurrentOpenHashMap.java | 142 +++--- .../Byte2BooleanOpenCustomHashMap.java | 72 ++-- .../Byte2ByteOpenCustomHashMap.java | 76 ++-- .../Byte2CharOpenCustomHashMap.java | 76 ++-- .../Byte2DoubleOpenCustomHashMap.java | 72 ++-- .../Byte2FloatOpenCustomHashMap.java | 76 ++-- .../customHash/Byte2IntOpenCustomHashMap.java | 72 ++-- .../Byte2LongOpenCustomHashMap.java | 72 ++-- .../Byte2ObjectOpenCustomHashMap.java | 73 +--- .../Byte2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Byte2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Byte2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Byte2CharOpenHashMap.java | 76 ++-- .../impl/hash/Byte2DoubleOpenHashMap.java | 72 ++-- .../maps/impl/hash/Byte2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Byte2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Byte2LongOpenHashMap.java | 72 ++-- .../impl/hash/Byte2ObjectOpenHashMap.java | 75 +--- .../maps/impl/hash/Byte2ShortOpenHashMap.java | 76 ++-- .../ImmutableByte2BooleanOpenHashMap.java | 13 +- .../ImmutableByte2ByteOpenHashMap.java | 13 +- .../ImmutableByte2CharOpenHashMap.java | 13 +- .../ImmutableByte2DoubleOpenHashMap.java | 13 +- .../ImmutableByte2FloatOpenHashMap.java | 13 +- .../ImmutableByte2IntOpenHashMap.java | 13 +- .../ImmutableByte2LongOpenHashMap.java | 13 +- .../ImmutableByte2ObjectOpenHashMap.java | 9 - .../ImmutableByte2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Byte2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Byte2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Byte2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Byte2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Byte2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Byte2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Byte2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Byte2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Byte2ShortArrayMap.java | 76 ++-- .../impl/tree/Byte2BooleanAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2CharRBTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2LongRBTreeMap.java | 79 ++-- .../maps/impl/tree/Byte2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Byte2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Byte2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Byte2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Byte2BooleanMap.java | 56 +-- .../bytes/maps/interfaces/Byte2ByteMap.java | 56 +-- .../bytes/maps/interfaces/Byte2CharMap.java | 56 +-- .../bytes/maps/interfaces/Byte2DoubleMap.java | 56 +-- .../bytes/maps/interfaces/Byte2FloatMap.java | 56 +-- .../bytes/maps/interfaces/Byte2IntMap.java | 56 +-- .../bytes/maps/interfaces/Byte2LongMap.java | 56 +-- .../bytes/maps/interfaces/Byte2ObjectMap.java | 37 -- .../bytes/maps/interfaces/Byte2ShortMap.java | 56 +-- .../bytes/queues/ByteArrayFIFOQueue.java | 9 + .../bytes/queues/ByteArrayPriorityQueue.java | 7 + .../bytes/queues/ByteHeapPriorityQueue.java | 7 + .../bytes/queues/BytePriorityQueue.java | 7 + .../bytes/utils/ByteAsyncBuilder.java | 6 +- .../bytes/utils/ByteIterators.java | 55 +++ .../collections/bytes/utils/ByteLists.java | 31 ++ .../bytes/utils/BytePriorityQueues.java | 2 + .../bytes/utils/maps/Byte2BooleanMaps.java | 48 +-- .../bytes/utils/maps/Byte2ByteMaps.java | 48 +-- .../bytes/utils/maps/Byte2CharMaps.java | 48 +-- .../bytes/utils/maps/Byte2DoubleMaps.java | 48 +-- .../bytes/utils/maps/Byte2FloatMaps.java | 48 +-- .../bytes/utils/maps/Byte2IntMaps.java | 48 +-- .../bytes/utils/maps/Byte2LongMaps.java | 48 +-- .../bytes/utils/maps/Byte2ObjectMaps.java | 32 -- .../bytes/utils/maps/Byte2ShortMaps.java | 48 +-- .../chars/functions/CharSupplier.java | 2 +- .../chars/lists/AbstractCharList.java | 161 ++++++- .../src/collections/chars/lists/CharList.java | 19 + .../abstracts/AbstractChar2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractChar2ByteMap.java | 68 +-- .../maps/abstracts/AbstractChar2CharMap.java | 68 +-- .../abstracts/AbstractChar2DoubleMap.java | 66 +-- .../maps/abstracts/AbstractChar2FloatMap.java | 68 +-- .../maps/abstracts/AbstractChar2IntMap.java | 66 +-- .../maps/abstracts/AbstractChar2LongMap.java | 66 +-- .../abstracts/AbstractChar2ObjectMap.java | 59 --- .../maps/abstracts/AbstractChar2ShortMap.java | 68 +-- .../Char2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Char2ByteConcurrentOpenHashMap.java | 142 +++--- .../Char2CharConcurrentOpenHashMap.java | 142 +++--- .../Char2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Char2FloatConcurrentOpenHashMap.java | 142 +++--- .../Char2IntConcurrentOpenHashMap.java | 138 +++--- .../Char2LongConcurrentOpenHashMap.java | 138 +++--- .../Char2ObjectConcurrentOpenHashMap.java | 110 +---- .../Char2ShortConcurrentOpenHashMap.java | 142 +++--- .../Char2BooleanOpenCustomHashMap.java | 72 ++-- .../Char2ByteOpenCustomHashMap.java | 76 ++-- .../Char2CharOpenCustomHashMap.java | 76 ++-- .../Char2DoubleOpenCustomHashMap.java | 72 ++-- .../Char2FloatOpenCustomHashMap.java | 76 ++-- .../customHash/Char2IntOpenCustomHashMap.java | 72 ++-- .../Char2LongOpenCustomHashMap.java | 72 ++-- .../Char2ObjectOpenCustomHashMap.java | 73 +--- .../Char2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Char2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Char2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Char2CharOpenHashMap.java | 76 ++-- .../impl/hash/Char2DoubleOpenHashMap.java | 72 ++-- .../maps/impl/hash/Char2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Char2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Char2LongOpenHashMap.java | 72 ++-- .../impl/hash/Char2ObjectOpenHashMap.java | 75 +--- .../maps/impl/hash/Char2ShortOpenHashMap.java | 76 ++-- .../ImmutableChar2BooleanOpenHashMap.java | 13 +- .../ImmutableChar2ByteOpenHashMap.java | 13 +- .../ImmutableChar2CharOpenHashMap.java | 13 +- .../ImmutableChar2DoubleOpenHashMap.java | 13 +- .../ImmutableChar2FloatOpenHashMap.java | 13 +- .../ImmutableChar2IntOpenHashMap.java | 13 +- .../ImmutableChar2LongOpenHashMap.java | 13 +- .../ImmutableChar2ObjectOpenHashMap.java | 9 - .../ImmutableChar2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Char2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Char2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Char2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Char2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Char2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Char2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Char2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Char2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Char2ShortArrayMap.java | 76 ++-- .../impl/tree/Char2BooleanAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Char2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Char2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Char2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Char2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Char2CharRBTreeMap.java | 83 ++-- .../maps/impl/tree/Char2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Char2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Char2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Char2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Char2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Char2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Char2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Char2LongRBTreeMap.java | 79 ++-- .../maps/impl/tree/Char2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Char2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Char2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Char2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Char2BooleanMap.java | 56 +-- .../chars/maps/interfaces/Char2ByteMap.java | 56 +-- .../chars/maps/interfaces/Char2CharMap.java | 56 +-- .../chars/maps/interfaces/Char2DoubleMap.java | 56 +-- .../chars/maps/interfaces/Char2FloatMap.java | 56 +-- .../chars/maps/interfaces/Char2IntMap.java | 56 +-- .../chars/maps/interfaces/Char2LongMap.java | 56 +-- .../chars/maps/interfaces/Char2ObjectMap.java | 37 -- .../chars/maps/interfaces/Char2ShortMap.java | 56 +-- .../chars/queues/CharArrayFIFOQueue.java | 9 + .../chars/queues/CharArrayPriorityQueue.java | 7 + .../chars/queues/CharHeapPriorityQueue.java | 7 + .../chars/queues/CharPriorityQueue.java | 7 + .../chars/utils/CharAsyncBuilder.java | 6 +- .../chars/utils/CharIterators.java | 55 +++ .../collections/chars/utils/CharLists.java | 31 ++ .../chars/utils/CharPriorityQueues.java | 2 + .../chars/utils/maps/Char2BooleanMaps.java | 48 +-- .../chars/utils/maps/Char2ByteMaps.java | 48 +-- .../chars/utils/maps/Char2CharMaps.java | 48 +-- .../chars/utils/maps/Char2DoubleMaps.java | 48 +-- .../chars/utils/maps/Char2FloatMaps.java | 48 +-- .../chars/utils/maps/Char2IntMaps.java | 48 +-- .../chars/utils/maps/Char2LongMaps.java | 48 +-- .../chars/utils/maps/Char2ObjectMaps.java | 32 -- .../chars/utils/maps/Char2ShortMaps.java | 48 +-- .../doubles/lists/AbstractDoubleList.java | 161 ++++++- .../collections/doubles/lists/DoubleList.java | 19 + .../abstracts/AbstractDouble2BooleanMap.java | 66 +-- .../abstracts/AbstractDouble2ByteMap.java | 68 +-- .../abstracts/AbstractDouble2CharMap.java | 68 +-- .../abstracts/AbstractDouble2DoubleMap.java | 66 +-- .../abstracts/AbstractDouble2FloatMap.java | 68 +-- .../maps/abstracts/AbstractDouble2IntMap.java | 66 +-- .../abstracts/AbstractDouble2LongMap.java | 66 +-- .../abstracts/AbstractDouble2ObjectMap.java | 59 --- .../abstracts/AbstractDouble2ShortMap.java | 68 +-- .../Double2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Double2ByteConcurrentOpenHashMap.java | 142 +++--- .../Double2CharConcurrentOpenHashMap.java | 142 +++--- .../Double2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Double2FloatConcurrentOpenHashMap.java | 142 +++--- .../Double2IntConcurrentOpenHashMap.java | 138 +++--- .../Double2LongConcurrentOpenHashMap.java | 138 +++--- .../Double2ObjectConcurrentOpenHashMap.java | 110 +---- .../Double2ShortConcurrentOpenHashMap.java | 142 +++--- .../Double2BooleanOpenCustomHashMap.java | 72 ++-- .../Double2ByteOpenCustomHashMap.java | 76 ++-- .../Double2CharOpenCustomHashMap.java | 76 ++-- .../Double2DoubleOpenCustomHashMap.java | 72 ++-- .../Double2FloatOpenCustomHashMap.java | 76 ++-- .../Double2IntOpenCustomHashMap.java | 72 ++-- .../Double2LongOpenCustomHashMap.java | 72 ++-- .../Double2ObjectOpenCustomHashMap.java | 73 +--- .../Double2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Double2BooleanOpenHashMap.java | 72 ++-- .../impl/hash/Double2ByteOpenHashMap.java | 76 ++-- .../impl/hash/Double2CharOpenHashMap.java | 76 ++-- .../impl/hash/Double2DoubleOpenHashMap.java | 72 ++-- .../impl/hash/Double2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Double2IntOpenHashMap.java | 72 ++-- .../impl/hash/Double2LongOpenHashMap.java | 72 ++-- .../impl/hash/Double2ObjectOpenHashMap.java | 75 +--- .../impl/hash/Double2ShortOpenHashMap.java | 76 ++-- .../ImmutableDouble2BooleanOpenHashMap.java | 13 +- .../ImmutableDouble2ByteOpenHashMap.java | 13 +- .../ImmutableDouble2CharOpenHashMap.java | 13 +- .../ImmutableDouble2DoubleOpenHashMap.java | 13 +- .../ImmutableDouble2FloatOpenHashMap.java | 13 +- .../ImmutableDouble2IntOpenHashMap.java | 13 +- .../ImmutableDouble2LongOpenHashMap.java | 13 +- .../ImmutableDouble2ObjectOpenHashMap.java | 9 - .../ImmutableDouble2ShortOpenHashMap.java | 13 +- .../impl/misc/Double2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Double2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Double2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Double2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Double2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Double2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Double2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Double2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Double2ShortArrayMap.java | 76 ++-- .../impl/tree/Double2BooleanAVLTreeMap.java | 79 ++-- .../impl/tree/Double2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Double2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Double2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Double2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Double2CharRBTreeMap.java | 83 ++-- .../impl/tree/Double2DoubleAVLTreeMap.java | 79 ++-- .../impl/tree/Double2DoubleRBTreeMap.java | 79 ++-- .../impl/tree/Double2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Double2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Double2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Double2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Double2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Double2LongRBTreeMap.java | 79 ++-- .../impl/tree/Double2ObjectAVLTreeMap.java | 69 --- .../impl/tree/Double2ObjectRBTreeMap.java | 69 --- .../impl/tree/Double2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Double2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Double2BooleanMap.java | 56 +-- .../maps/interfaces/Double2ByteMap.java | 56 +-- .../maps/interfaces/Double2CharMap.java | 56 +-- .../maps/interfaces/Double2DoubleMap.java | 56 +-- .../maps/interfaces/Double2FloatMap.java | 56 +-- .../maps/interfaces/Double2IntMap.java | 56 +-- .../maps/interfaces/Double2LongMap.java | 56 +-- .../maps/interfaces/Double2ObjectMap.java | 37 -- .../maps/interfaces/Double2ShortMap.java | 56 +-- .../doubles/queues/DoubleArrayFIFOQueue.java | 9 + .../queues/DoubleArrayPriorityQueue.java | 7 + .../queues/DoubleHeapPriorityQueue.java | 7 + .../doubles/queues/DoublePriorityQueue.java | 7 + .../doubles/utils/DoubleAsyncBuilder.java | 6 +- .../doubles/utils/DoubleIterators.java | 55 +++ .../doubles/utils/DoubleLists.java | 31 ++ .../doubles/utils/DoublePriorityQueues.java | 2 + .../utils/maps/Double2BooleanMaps.java | 48 +-- .../doubles/utils/maps/Double2ByteMaps.java | 48 +-- .../doubles/utils/maps/Double2CharMaps.java | 48 +-- .../doubles/utils/maps/Double2DoubleMaps.java | 48 +-- .../doubles/utils/maps/Double2FloatMaps.java | 48 +-- .../doubles/utils/maps/Double2IntMaps.java | 48 +-- .../doubles/utils/maps/Double2LongMaps.java | 48 +-- .../doubles/utils/maps/Double2ObjectMaps.java | 32 -- .../doubles/utils/maps/Double2ShortMaps.java | 48 +-- .../floats/functions/FloatSupplier.java | 2 +- .../floats/lists/AbstractFloatList.java | 161 ++++++- .../collections/floats/lists/FloatList.java | 19 + .../abstracts/AbstractFloat2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractFloat2ByteMap.java | 68 +-- .../maps/abstracts/AbstractFloat2CharMap.java | 68 +-- .../abstracts/AbstractFloat2DoubleMap.java | 66 +-- .../abstracts/AbstractFloat2FloatMap.java | 68 +-- .../maps/abstracts/AbstractFloat2IntMap.java | 66 +-- .../maps/abstracts/AbstractFloat2LongMap.java | 66 +-- .../abstracts/AbstractFloat2ObjectMap.java | 59 --- .../abstracts/AbstractFloat2ShortMap.java | 68 +-- .../Float2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Float2ByteConcurrentOpenHashMap.java | 142 +++--- .../Float2CharConcurrentOpenHashMap.java | 142 +++--- .../Float2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Float2FloatConcurrentOpenHashMap.java | 142 +++--- .../Float2IntConcurrentOpenHashMap.java | 138 +++--- .../Float2LongConcurrentOpenHashMap.java | 138 +++--- .../Float2ObjectConcurrentOpenHashMap.java | 110 +---- .../Float2ShortConcurrentOpenHashMap.java | 142 +++--- .../Float2BooleanOpenCustomHashMap.java | 72 ++-- .../Float2ByteOpenCustomHashMap.java | 76 ++-- .../Float2CharOpenCustomHashMap.java | 76 ++-- .../Float2DoubleOpenCustomHashMap.java | 72 ++-- .../Float2FloatOpenCustomHashMap.java | 76 ++-- .../Float2IntOpenCustomHashMap.java | 72 ++-- .../Float2LongOpenCustomHashMap.java | 72 ++-- .../Float2ObjectOpenCustomHashMap.java | 73 +--- .../Float2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Float2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Float2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Float2CharOpenHashMap.java | 76 ++-- .../impl/hash/Float2DoubleOpenHashMap.java | 72 ++-- .../impl/hash/Float2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Float2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Float2LongOpenHashMap.java | 72 ++-- .../impl/hash/Float2ObjectOpenHashMap.java | 75 +--- .../impl/hash/Float2ShortOpenHashMap.java | 76 ++-- .../ImmutableFloat2BooleanOpenHashMap.java | 13 +- .../ImmutableFloat2ByteOpenHashMap.java | 13 +- .../ImmutableFloat2CharOpenHashMap.java | 13 +- .../ImmutableFloat2DoubleOpenHashMap.java | 13 +- .../ImmutableFloat2FloatOpenHashMap.java | 13 +- .../ImmutableFloat2IntOpenHashMap.java | 13 +- .../ImmutableFloat2LongOpenHashMap.java | 13 +- .../ImmutableFloat2ObjectOpenHashMap.java | 9 - .../ImmutableFloat2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Float2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Float2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Float2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Float2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Float2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Float2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Float2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Float2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Float2ShortArrayMap.java | 76 ++-- .../impl/tree/Float2BooleanAVLTreeMap.java | 79 ++-- .../impl/tree/Float2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Float2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Float2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Float2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Float2CharRBTreeMap.java | 83 ++-- .../impl/tree/Float2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Float2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Float2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Float2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Float2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Float2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Float2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Float2LongRBTreeMap.java | 79 ++-- .../impl/tree/Float2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Float2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Float2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Float2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Float2BooleanMap.java | 56 +-- .../floats/maps/interfaces/Float2ByteMap.java | 56 +-- .../floats/maps/interfaces/Float2CharMap.java | 56 +-- .../maps/interfaces/Float2DoubleMap.java | 56 +-- .../maps/interfaces/Float2FloatMap.java | 56 +-- .../floats/maps/interfaces/Float2IntMap.java | 56 +-- .../floats/maps/interfaces/Float2LongMap.java | 56 +-- .../maps/interfaces/Float2ObjectMap.java | 37 -- .../maps/interfaces/Float2ShortMap.java | 56 +-- .../floats/queues/FloatArrayFIFOQueue.java | 9 + .../queues/FloatArrayPriorityQueue.java | 7 + .../floats/queues/FloatHeapPriorityQueue.java | 7 + .../floats/queues/FloatPriorityQueue.java | 7 + .../floats/utils/FloatAsyncBuilder.java | 6 +- .../floats/utils/FloatIterators.java | 55 +++ .../collections/floats/utils/FloatLists.java | 31 ++ .../floats/utils/FloatPriorityQueues.java | 2 + .../floats/utils/maps/Float2BooleanMaps.java | 48 +-- .../floats/utils/maps/Float2ByteMaps.java | 48 +-- .../floats/utils/maps/Float2CharMaps.java | 48 +-- .../floats/utils/maps/Float2DoubleMaps.java | 48 +-- .../floats/utils/maps/Float2FloatMaps.java | 48 +-- .../floats/utils/maps/Float2IntMaps.java | 48 +-- .../floats/utils/maps/Float2LongMaps.java | 48 +-- .../floats/utils/maps/Float2ObjectMaps.java | 32 -- .../floats/utils/maps/Float2ShortMaps.java | 48 +-- .../ints/lists/AbstractIntList.java | 160 ++++++- .../src/collections/ints/lists/IntList.java | 18 + .../abstracts/AbstractInt2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractInt2ByteMap.java | 68 +-- .../maps/abstracts/AbstractInt2CharMap.java | 68 +-- .../maps/abstracts/AbstractInt2DoubleMap.java | 66 +-- .../maps/abstracts/AbstractInt2FloatMap.java | 68 +-- .../maps/abstracts/AbstractInt2IntMap.java | 66 +-- .../maps/abstracts/AbstractInt2LongMap.java | 66 +-- .../maps/abstracts/AbstractInt2ObjectMap.java | 59 --- .../maps/abstracts/AbstractInt2ShortMap.java | 68 +-- .../Int2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Int2ByteConcurrentOpenHashMap.java | 142 +++--- .../Int2CharConcurrentOpenHashMap.java | 142 +++--- .../Int2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Int2FloatConcurrentOpenHashMap.java | 142 +++--- .../Int2IntConcurrentOpenHashMap.java | 138 +++--- .../Int2LongConcurrentOpenHashMap.java | 138 +++--- .../Int2ObjectConcurrentOpenHashMap.java | 110 +---- .../Int2ShortConcurrentOpenHashMap.java | 142 +++--- .../Int2BooleanOpenCustomHashMap.java | 72 ++-- .../customHash/Int2ByteOpenCustomHashMap.java | 76 ++-- .../customHash/Int2CharOpenCustomHashMap.java | 76 ++-- .../Int2DoubleOpenCustomHashMap.java | 72 ++-- .../Int2FloatOpenCustomHashMap.java | 76 ++-- .../customHash/Int2IntOpenCustomHashMap.java | 72 ++-- .../customHash/Int2LongOpenCustomHashMap.java | 72 ++-- .../Int2ObjectOpenCustomHashMap.java | 73 +--- .../Int2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Int2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Int2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Int2CharOpenHashMap.java | 76 ++-- .../maps/impl/hash/Int2DoubleOpenHashMap.java | 72 ++-- .../maps/impl/hash/Int2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Int2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Int2LongOpenHashMap.java | 72 ++-- .../maps/impl/hash/Int2ObjectOpenHashMap.java | 75 +--- .../maps/impl/hash/Int2ShortOpenHashMap.java | 76 ++-- .../ImmutableInt2BooleanOpenHashMap.java | 13 +- .../ImmutableInt2ByteOpenHashMap.java | 13 +- .../ImmutableInt2CharOpenHashMap.java | 13 +- .../ImmutableInt2DoubleOpenHashMap.java | 13 +- .../ImmutableInt2FloatOpenHashMap.java | 13 +- .../ImmutableInt2IntOpenHashMap.java | 13 +- .../ImmutableInt2LongOpenHashMap.java | 13 +- .../ImmutableInt2ObjectOpenHashMap.java | 9 - .../ImmutableInt2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Int2BooleanArrayMap.java | 72 ++-- .../ints/maps/impl/misc/Int2ByteArrayMap.java | 76 ++-- .../ints/maps/impl/misc/Int2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Int2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Int2FloatArrayMap.java | 76 ++-- .../ints/maps/impl/misc/Int2IntArrayMap.java | 72 ++-- .../ints/maps/impl/misc/Int2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Int2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Int2ShortArrayMap.java | 76 ++-- .../maps/impl/tree/Int2BooleanAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Int2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Int2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Int2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Int2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Int2CharRBTreeMap.java | 83 ++-- .../maps/impl/tree/Int2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Int2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Int2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Int2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Int2IntAVLTreeMap.java | 79 ++-- .../ints/maps/impl/tree/Int2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Int2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Int2LongRBTreeMap.java | 79 ++-- .../maps/impl/tree/Int2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Int2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Int2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Int2ShortRBTreeMap.java | 83 ++-- .../ints/maps/interfaces/Int2BooleanMap.java | 56 +-- .../ints/maps/interfaces/Int2ByteMap.java | 56 +-- .../ints/maps/interfaces/Int2CharMap.java | 56 +-- .../ints/maps/interfaces/Int2DoubleMap.java | 56 +-- .../ints/maps/interfaces/Int2FloatMap.java | 56 +-- .../ints/maps/interfaces/Int2IntMap.java | 56 +-- .../ints/maps/interfaces/Int2LongMap.java | 56 +-- .../ints/maps/interfaces/Int2ObjectMap.java | 37 -- .../ints/maps/interfaces/Int2ShortMap.java | 56 +-- .../ints/queues/IntArrayFIFOQueue.java | 9 + .../ints/queues/IntArrayPriorityQueue.java | 7 + .../ints/queues/IntHeapPriorityQueue.java | 7 + .../ints/queues/IntPriorityQueue.java | 7 + .../ints/utils/IntAsyncBuilder.java | 3 +- .../collections/ints/utils/IntIterators.java | 55 +++ .../src/collections/ints/utils/IntLists.java | 30 ++ .../ints/utils/IntPriorityQueues.java | 2 + .../ints/utils/maps/Int2BooleanMaps.java | 48 +-- .../ints/utils/maps/Int2ByteMaps.java | 48 +-- .../ints/utils/maps/Int2CharMaps.java | 48 +-- .../ints/utils/maps/Int2DoubleMaps.java | 48 +-- .../ints/utils/maps/Int2FloatMaps.java | 48 +-- .../ints/utils/maps/Int2IntMaps.java | 48 +-- .../ints/utils/maps/Int2LongMaps.java | 48 +-- .../ints/utils/maps/Int2ObjectMaps.java | 32 -- .../ints/utils/maps/Int2ShortMaps.java | 48 +-- .../longs/lists/AbstractLongList.java | 161 ++++++- .../src/collections/longs/lists/LongList.java | 19 + .../abstracts/AbstractLong2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractLong2ByteMap.java | 68 +-- .../maps/abstracts/AbstractLong2CharMap.java | 68 +-- .../abstracts/AbstractLong2DoubleMap.java | 66 +-- .../maps/abstracts/AbstractLong2FloatMap.java | 68 +-- .../maps/abstracts/AbstractLong2IntMap.java | 66 +-- .../maps/abstracts/AbstractLong2LongMap.java | 66 +-- .../abstracts/AbstractLong2ObjectMap.java | 59 --- .../maps/abstracts/AbstractLong2ShortMap.java | 68 +-- .../Long2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Long2ByteConcurrentOpenHashMap.java | 142 +++--- .../Long2CharConcurrentOpenHashMap.java | 142 +++--- .../Long2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Long2FloatConcurrentOpenHashMap.java | 142 +++--- .../Long2IntConcurrentOpenHashMap.java | 138 +++--- .../Long2LongConcurrentOpenHashMap.java | 138 +++--- .../Long2ObjectConcurrentOpenHashMap.java | 110 +---- .../Long2ShortConcurrentOpenHashMap.java | 142 +++--- .../Long2BooleanOpenCustomHashMap.java | 72 ++-- .../Long2ByteOpenCustomHashMap.java | 76 ++-- .../Long2CharOpenCustomHashMap.java | 76 ++-- .../Long2DoubleOpenCustomHashMap.java | 72 ++-- .../Long2FloatOpenCustomHashMap.java | 76 ++-- .../customHash/Long2IntOpenCustomHashMap.java | 72 ++-- .../Long2LongOpenCustomHashMap.java | 72 ++-- .../Long2ObjectOpenCustomHashMap.java | 73 +--- .../Long2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Long2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Long2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Long2CharOpenHashMap.java | 76 ++-- .../impl/hash/Long2DoubleOpenHashMap.java | 72 ++-- .../maps/impl/hash/Long2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Long2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Long2LongOpenHashMap.java | 72 ++-- .../impl/hash/Long2ObjectOpenHashMap.java | 75 +--- .../maps/impl/hash/Long2ShortOpenHashMap.java | 76 ++-- .../ImmutableLong2BooleanOpenHashMap.java | 13 +- .../ImmutableLong2ByteOpenHashMap.java | 13 +- .../ImmutableLong2CharOpenHashMap.java | 13 +- .../ImmutableLong2DoubleOpenHashMap.java | 13 +- .../ImmutableLong2FloatOpenHashMap.java | 13 +- .../ImmutableLong2IntOpenHashMap.java | 13 +- .../ImmutableLong2LongOpenHashMap.java | 13 +- .../ImmutableLong2ObjectOpenHashMap.java | 9 - .../ImmutableLong2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Long2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Long2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Long2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Long2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Long2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Long2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Long2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Long2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Long2ShortArrayMap.java | 76 ++-- .../impl/tree/Long2BooleanAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Long2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Long2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Long2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Long2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Long2CharRBTreeMap.java | 83 ++-- .../maps/impl/tree/Long2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Long2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Long2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Long2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Long2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Long2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Long2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Long2LongRBTreeMap.java | 79 ++-- .../maps/impl/tree/Long2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Long2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Long2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Long2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Long2BooleanMap.java | 56 +-- .../longs/maps/interfaces/Long2ByteMap.java | 56 +-- .../longs/maps/interfaces/Long2CharMap.java | 56 +-- .../longs/maps/interfaces/Long2DoubleMap.java | 56 +-- .../longs/maps/interfaces/Long2FloatMap.java | 56 +-- .../longs/maps/interfaces/Long2IntMap.java | 56 +-- .../longs/maps/interfaces/Long2LongMap.java | 56 +-- .../longs/maps/interfaces/Long2ObjectMap.java | 37 -- .../longs/maps/interfaces/Long2ShortMap.java | 56 +-- .../longs/queues/LongArrayFIFOQueue.java | 9 + .../longs/queues/LongArrayPriorityQueue.java | 7 + .../longs/queues/LongHeapPriorityQueue.java | 7 + .../longs/queues/LongPriorityQueue.java | 7 + .../longs/utils/LongAsyncBuilder.java | 6 +- .../longs/utils/LongIterators.java | 55 +++ .../collections/longs/utils/LongLists.java | 31 ++ .../longs/utils/LongPriorityQueues.java | 2 + .../longs/utils/maps/Long2BooleanMaps.java | 48 +-- .../longs/utils/maps/Long2ByteMaps.java | 48 +-- .../longs/utils/maps/Long2CharMaps.java | 48 +-- .../longs/utils/maps/Long2DoubleMaps.java | 48 +-- .../longs/utils/maps/Long2FloatMaps.java | 48 +-- .../longs/utils/maps/Long2IntMaps.java | 48 +-- .../longs/utils/maps/Long2LongMaps.java | 48 +-- .../longs/utils/maps/Long2ObjectMaps.java | 32 -- .../longs/utils/maps/Long2ShortMaps.java | 48 +-- .../objects/collections/ObjectIterable.java | 76 ++++ .../objects/lists/AbstractObjectList.java | 161 ++++++- .../collections/objects/lists/ObjectList.java | 19 + .../abstracts/AbstractObject2BooleanMap.java | 66 +-- .../abstracts/AbstractObject2ByteMap.java | 68 +-- .../abstracts/AbstractObject2CharMap.java | 68 +-- .../abstracts/AbstractObject2DoubleMap.java | 66 +-- .../abstracts/AbstractObject2FloatMap.java | 68 +-- .../maps/abstracts/AbstractObject2IntMap.java | 66 +-- .../abstracts/AbstractObject2LongMap.java | 66 +-- .../abstracts/AbstractObject2ObjectMap.java | 59 --- .../abstracts/AbstractObject2ShortMap.java | 68 +-- .../Object2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Object2ByteConcurrentOpenHashMap.java | 142 +++--- .../Object2CharConcurrentOpenHashMap.java | 142 +++--- .../Object2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Object2FloatConcurrentOpenHashMap.java | 142 +++--- .../Object2IntConcurrentOpenHashMap.java | 138 +++--- .../Object2LongConcurrentOpenHashMap.java | 138 +++--- .../Object2ObjectConcurrentOpenHashMap.java | 110 +---- .../Object2ShortConcurrentOpenHashMap.java | 142 +++--- .../Object2BooleanOpenCustomHashMap.java | 72 ++-- .../Object2ByteOpenCustomHashMap.java | 76 ++-- .../Object2CharOpenCustomHashMap.java | 76 ++-- .../Object2DoubleOpenCustomHashMap.java | 72 ++-- .../Object2FloatOpenCustomHashMap.java | 76 ++-- .../Object2IntOpenCustomHashMap.java | 72 ++-- .../Object2LongOpenCustomHashMap.java | 72 ++-- .../Object2ObjectOpenCustomHashMap.java | 73 +--- .../Object2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Object2BooleanOpenHashMap.java | 72 ++-- .../impl/hash/Object2ByteOpenHashMap.java | 76 ++-- .../impl/hash/Object2CharOpenHashMap.java | 76 ++-- .../impl/hash/Object2DoubleOpenHashMap.java | 72 ++-- .../impl/hash/Object2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Object2IntOpenHashMap.java | 72 ++-- .../impl/hash/Object2LongOpenHashMap.java | 72 ++-- .../impl/hash/Object2ObjectOpenHashMap.java | 75 +--- .../impl/hash/Object2ShortOpenHashMap.java | 76 ++-- .../ImmutableObject2BooleanOpenHashMap.java | 13 +- .../ImmutableObject2ByteOpenHashMap.java | 13 +- .../ImmutableObject2CharOpenHashMap.java | 13 +- .../ImmutableObject2DoubleOpenHashMap.java | 13 +- .../ImmutableObject2FloatOpenHashMap.java | 13 +- .../ImmutableObject2IntOpenHashMap.java | 13 +- .../ImmutableObject2LongOpenHashMap.java | 13 +- .../ImmutableObject2ObjectOpenHashMap.java | 9 - .../ImmutableObject2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Enum2BooleanMap.java | 70 +-- .../objects/maps/impl/misc/Enum2ByteMap.java | 74 ++-- .../objects/maps/impl/misc/Enum2CharMap.java | 74 ++-- .../maps/impl/misc/Enum2DoubleMap.java | 70 +-- .../objects/maps/impl/misc/Enum2FloatMap.java | 74 ++-- .../objects/maps/impl/misc/Enum2IntMap.java | 70 +-- .../objects/maps/impl/misc/Enum2LongMap.java | 70 +-- .../maps/impl/misc/Enum2ObjectMap.java | 74 +--- .../objects/maps/impl/misc/Enum2ShortMap.java | 74 ++-- .../impl/misc/Object2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Object2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Object2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Object2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Object2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Object2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Object2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Object2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Object2ShortArrayMap.java | 76 ++-- .../impl/tree/Object2BooleanAVLTreeMap.java | 85 ++-- .../impl/tree/Object2BooleanRBTreeMap.java | 85 ++-- .../maps/impl/tree/Object2ByteAVLTreeMap.java | 89 ++-- .../maps/impl/tree/Object2ByteRBTreeMap.java | 89 ++-- .../maps/impl/tree/Object2CharAVLTreeMap.java | 89 ++-- .../maps/impl/tree/Object2CharRBTreeMap.java | 89 ++-- .../impl/tree/Object2DoubleAVLTreeMap.java | 85 ++-- .../impl/tree/Object2DoubleRBTreeMap.java | 85 ++-- .../impl/tree/Object2FloatAVLTreeMap.java | 89 ++-- .../maps/impl/tree/Object2FloatRBTreeMap.java | 89 ++-- .../maps/impl/tree/Object2IntAVLTreeMap.java | 85 ++-- .../maps/impl/tree/Object2IntRBTreeMap.java | 85 ++-- .../maps/impl/tree/Object2LongAVLTreeMap.java | 85 ++-- .../maps/impl/tree/Object2LongRBTreeMap.java | 85 ++-- .../impl/tree/Object2ObjectAVLTreeMap.java | 73 ---- .../impl/tree/Object2ObjectRBTreeMap.java | 73 ---- .../impl/tree/Object2ShortAVLTreeMap.java | 89 ++-- .../maps/impl/tree/Object2ShortRBTreeMap.java | 89 ++-- .../maps/interfaces/Object2BooleanMap.java | 56 +-- .../maps/interfaces/Object2ByteMap.java | 56 +-- .../maps/interfaces/Object2CharMap.java | 56 +-- .../maps/interfaces/Object2DoubleMap.java | 56 +-- .../maps/interfaces/Object2FloatMap.java | 56 +-- .../maps/interfaces/Object2IntMap.java | 56 +-- .../maps/interfaces/Object2LongMap.java | 56 +-- .../maps/interfaces/Object2ObjectMap.java | 37 -- .../maps/interfaces/Object2ShortMap.java | 56 +-- .../objects/queues/ObjectArrayFIFOQueue.java | 9 + .../queues/ObjectArrayPriorityQueue.java | 7 + .../queues/ObjectHeapPriorityQueue.java | 7 + .../objects/queues/ObjectPriorityQueue.java | 7 + .../objects/utils/ObjectAsyncBuilder.java | 80 +++- .../objects/utils/ObjectIterables.java | 370 ++++++++++++++++ .../objects/utils/ObjectIterators.java | 403 ++++++++++++++++++ .../objects/utils/ObjectLists.java | 31 ++ .../objects/utils/ObjectPriorityQueues.java | 2 + .../utils/maps/Object2BooleanMaps.java | 48 +-- .../objects/utils/maps/Object2ByteMaps.java | 48 +-- .../objects/utils/maps/Object2CharMaps.java | 48 +-- .../objects/utils/maps/Object2DoubleMaps.java | 48 +-- .../objects/utils/maps/Object2FloatMaps.java | 48 +-- .../objects/utils/maps/Object2IntMaps.java | 48 +-- .../objects/utils/maps/Object2LongMaps.java | 48 +-- .../objects/utils/maps/Object2ObjectMaps.java | 32 -- .../objects/utils/maps/Object2ShortMaps.java | 48 +-- .../shorts/functions/ShortSupplier.java | 2 +- .../shorts/lists/AbstractShortList.java | 161 ++++++- .../collections/shorts/lists/ShortList.java | 19 + .../abstracts/AbstractShort2BooleanMap.java | 66 +-- .../maps/abstracts/AbstractShort2ByteMap.java | 68 +-- .../maps/abstracts/AbstractShort2CharMap.java | 68 +-- .../abstracts/AbstractShort2DoubleMap.java | 66 +-- .../abstracts/AbstractShort2FloatMap.java | 68 +-- .../maps/abstracts/AbstractShort2IntMap.java | 66 +-- .../maps/abstracts/AbstractShort2LongMap.java | 66 +-- .../abstracts/AbstractShort2ObjectMap.java | 59 --- .../abstracts/AbstractShort2ShortMap.java | 68 +-- .../Short2BooleanConcurrentOpenHashMap.java | 138 +++--- .../Short2ByteConcurrentOpenHashMap.java | 142 +++--- .../Short2CharConcurrentOpenHashMap.java | 142 +++--- .../Short2DoubleConcurrentOpenHashMap.java | 138 +++--- .../Short2FloatConcurrentOpenHashMap.java | 142 +++--- .../Short2IntConcurrentOpenHashMap.java | 138 +++--- .../Short2LongConcurrentOpenHashMap.java | 138 +++--- .../Short2ObjectConcurrentOpenHashMap.java | 110 +---- .../Short2ShortConcurrentOpenHashMap.java | 142 +++--- .../Short2BooleanOpenCustomHashMap.java | 72 ++-- .../Short2ByteOpenCustomHashMap.java | 76 ++-- .../Short2CharOpenCustomHashMap.java | 76 ++-- .../Short2DoubleOpenCustomHashMap.java | 72 ++-- .../Short2FloatOpenCustomHashMap.java | 76 ++-- .../Short2IntOpenCustomHashMap.java | 72 ++-- .../Short2LongOpenCustomHashMap.java | 72 ++-- .../Short2ObjectOpenCustomHashMap.java | 73 +--- .../Short2ShortOpenCustomHashMap.java | 76 ++-- .../impl/hash/Short2BooleanOpenHashMap.java | 72 ++-- .../maps/impl/hash/Short2ByteOpenHashMap.java | 76 ++-- .../maps/impl/hash/Short2CharOpenHashMap.java | 76 ++-- .../impl/hash/Short2DoubleOpenHashMap.java | 72 ++-- .../impl/hash/Short2FloatOpenHashMap.java | 76 ++-- .../maps/impl/hash/Short2IntOpenHashMap.java | 72 ++-- .../maps/impl/hash/Short2LongOpenHashMap.java | 72 ++-- .../impl/hash/Short2ObjectOpenHashMap.java | 75 +--- .../impl/hash/Short2ShortOpenHashMap.java | 76 ++-- .../ImmutableShort2BooleanOpenHashMap.java | 13 +- .../ImmutableShort2ByteOpenHashMap.java | 13 +- .../ImmutableShort2CharOpenHashMap.java | 13 +- .../ImmutableShort2DoubleOpenHashMap.java | 13 +- .../ImmutableShort2FloatOpenHashMap.java | 13 +- .../ImmutableShort2IntOpenHashMap.java | 13 +- .../ImmutableShort2LongOpenHashMap.java | 13 +- .../ImmutableShort2ObjectOpenHashMap.java | 9 - .../ImmutableShort2ShortOpenHashMap.java | 13 +- .../maps/impl/misc/Short2BooleanArrayMap.java | 72 ++-- .../maps/impl/misc/Short2ByteArrayMap.java | 76 ++-- .../maps/impl/misc/Short2CharArrayMap.java | 76 ++-- .../maps/impl/misc/Short2DoubleArrayMap.java | 72 ++-- .../maps/impl/misc/Short2FloatArrayMap.java | 76 ++-- .../maps/impl/misc/Short2IntArrayMap.java | 72 ++-- .../maps/impl/misc/Short2LongArrayMap.java | 72 ++-- .../maps/impl/misc/Short2ObjectArrayMap.java | 75 +--- .../maps/impl/misc/Short2ShortArrayMap.java | 76 ++-- .../impl/tree/Short2BooleanAVLTreeMap.java | 79 ++-- .../impl/tree/Short2BooleanRBTreeMap.java | 79 ++-- .../maps/impl/tree/Short2ByteAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Short2ByteRBTreeMap.java | 83 ++-- .../maps/impl/tree/Short2CharAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Short2CharRBTreeMap.java | 83 ++-- .../impl/tree/Short2DoubleAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Short2DoubleRBTreeMap.java | 79 ++-- .../maps/impl/tree/Short2FloatAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Short2FloatRBTreeMap.java | 83 ++-- .../maps/impl/tree/Short2IntAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Short2IntRBTreeMap.java | 79 ++-- .../maps/impl/tree/Short2LongAVLTreeMap.java | 79 ++-- .../maps/impl/tree/Short2LongRBTreeMap.java | 79 ++-- .../impl/tree/Short2ObjectAVLTreeMap.java | 69 --- .../maps/impl/tree/Short2ObjectRBTreeMap.java | 69 --- .../maps/impl/tree/Short2ShortAVLTreeMap.java | 83 ++-- .../maps/impl/tree/Short2ShortRBTreeMap.java | 83 ++-- .../maps/interfaces/Short2BooleanMap.java | 56 +-- .../shorts/maps/interfaces/Short2ByteMap.java | 56 +-- .../shorts/maps/interfaces/Short2CharMap.java | 56 +-- .../maps/interfaces/Short2DoubleMap.java | 56 +-- .../maps/interfaces/Short2FloatMap.java | 56 +-- .../shorts/maps/interfaces/Short2IntMap.java | 56 +-- .../shorts/maps/interfaces/Short2LongMap.java | 56 +-- .../maps/interfaces/Short2ObjectMap.java | 37 -- .../maps/interfaces/Short2ShortMap.java | 56 +-- .../shorts/queues/ShortArrayFIFOQueue.java | 9 + .../queues/ShortArrayPriorityQueue.java | 7 + .../shorts/queues/ShortHeapPriorityQueue.java | 7 + .../shorts/queues/ShortPriorityQueue.java | 7 + .../shorts/utils/ShortAsyncBuilder.java | 6 +- .../shorts/utils/ShortIterators.java | 55 +++ .../collections/shorts/utils/ShortLists.java | 31 ++ .../shorts/utils/ShortPriorityQueues.java | 2 + .../shorts/utils/maps/Short2BooleanMaps.java | 48 +-- .../shorts/utils/maps/Short2ByteMaps.java | 48 +-- .../shorts/utils/maps/Short2CharMaps.java | 48 +-- .../shorts/utils/maps/Short2DoubleMaps.java | 48 +-- .../shorts/utils/maps/Short2FloatMaps.java | 48 +-- .../shorts/utils/maps/Short2IntMaps.java | 48 +-- .../shorts/utils/maps/Short2LongMaps.java | 48 +-- .../shorts/utils/maps/Short2ObjectMaps.java | 32 -- .../shorts/utils/maps/Short2ShortMaps.java | 48 +-- 825 files changed, 26303 insertions(+), 28230 deletions(-) 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 f0d9e8f..7d47bc4 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.AbstractBooleanCollection; 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 abstract class AbstractBooleanList extends AbstractBooleanCollection impl 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 abstract class AbstractBooleanList extends AbstractBooleanCollection impl } } } + + 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 abstract class AbstractBooleanList extends AbstractBooleanCollection impl 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 a28cd9f..d31cb4d 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.ints.functions.consumer.IntBooleanConsumer; 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 interface BooleanList extends BooleanCollection, List @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 77967c6..1c7d010 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 class BooleanArrayFIFOQueue extends AbstractBooleanPriorityQueue implemen 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) { + 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 class BooleanIterators } } + 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 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 75ffdc7..c05f576 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.collections.BooleanCollection; 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 class BooleanLists 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 class BooleanLists 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 class BooleanLists 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 fd8011e..6fda575 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 @@ public class BooleanPriorityQueues @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 de0e3f6..5436774 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 52aeb21..360803f 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.AbstractByteCollection; 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 abstract class AbstractByteList extends AbstractByteCollection implements 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 abstract class AbstractByteList extends AbstractByteCollection implements } } } + + 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 abstract class AbstractByteList extends AbstractByteCollection implements 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 459044e..b47b05a 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.ints.functions.consumer.IntByteConsumer; 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 interface ByteList extends ByteCollection, List @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 6b2eaf7..5d930b7 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 abstract class AbstractByte2BooleanMap extends AbstractMap 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 abstract class AbstractByte2BooleanMap extends AbstractMap 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 abstract class AbstractByte2BooleanMap extends AbstractMap 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 abstract class AbstractByte2BooleanMap extends AbstractMap 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 cf08f10..62847fc 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 abstract class AbstractByte2ByteMap extends AbstractMap imple 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 abstract class AbstractByte2ByteMap extends AbstractMap imple 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 abstract class AbstractByte2ByteMap extends AbstractMap imple 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 abstract class AbstractByte2ByteMap extends AbstractMap imple 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 8a6190f..97f5398 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 abstract class AbstractByte2CharMap extends AbstractMap 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 abstract class AbstractByte2CharMap extends AbstractMap 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 abstract class AbstractByte2CharMap extends AbstractMap 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 abstract class AbstractByte2CharMap extends AbstractMap 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 7518101..0e3db33 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 abstract class AbstractByte2DoubleMap extends AbstractMap i 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 abstract class AbstractByte2DoubleMap extends AbstractMap i 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 abstract class AbstractByte2DoubleMap extends AbstractMap i 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 abstract class AbstractByte2DoubleMap extends AbstractMap i 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 585d364..9d8c6bb 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 abstract class AbstractByte2FloatMap extends AbstractMap imp 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 abstract class AbstractByte2FloatMap extends AbstractMap imp 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 abstract class AbstractByte2FloatMap extends AbstractMap imp 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 abstract class AbstractByte2FloatMap extends AbstractMap imp 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 8ca1f7a..f2b7195 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 abstract class AbstractByte2IntMap extends AbstractMap imp 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 abstract class AbstractByte2IntMap extends AbstractMap imp 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 abstract class AbstractByte2IntMap extends AbstractMap imp 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 abstract class AbstractByte2IntMap extends AbstractMap imp 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 9c89cce..8d55117 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 abstract class AbstractByte2LongMap extends AbstractMap imple 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 abstract class AbstractByte2LongMap extends AbstractMap imple 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 abstract class AbstractByte2LongMap extends AbstractMap imple 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 abstract class AbstractByte2LongMap extends AbstractMap imple 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 4568239..e258494 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 abstract class AbstractByte2ObjectMap extends AbstractMap imp 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 abstract class AbstractByte2ObjectMap extends AbstractMap imp 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 abstract class AbstractByte2ObjectMap extends AbstractMap imp 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 abstract class AbstractByte2ObjectMap extends AbstractMap imp 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 64b0ebc..3922aa3 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 abstract class AbstractByte2ShortMap extends AbstractMap imp 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 abstract class AbstractByte2ShortMap extends AbstractMap imp 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 abstract class AbstractByte2ShortMap extends AbstractMap imp 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 abstract class AbstractByte2ShortMap extends AbstractMap imp 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 856c9eb..866147a 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 class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i 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,6 +445,27 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,13 +473,6 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,13 +480,6 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(byte key, ByteBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2032,6 +2032,54 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i } } + protected boolean computeIfAbsent(int hash, byte key, BytePredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, byte key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + 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 computeNonDefault(int hash, byte key, ByteBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2055,23 +2103,6 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i } } - protected boolean computeIfAbsent(int hash, byte key, BytePredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, byte key, BytePredicate mappingFunction) { long stamp = writeLock(); try { @@ -2095,23 +2126,6 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i } } - protected boolean supplyIfAbsent(int hash, byte key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, byte key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2135,20 +2149,6 @@ public class Byte2BooleanConcurrentOpenHashMap extends AbstractByte2BooleanMap i } } - 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 1f020df..1c24085 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 class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme 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,6 +451,27 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,13 +479,6 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(byte key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -479,13 +486,6 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(byte key, ByteByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2069,6 +2069,54 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, byte key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, byte key, ByteByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, byte key, ByteByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2092,23 +2140,6 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, byte key, ByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2132,36 +2163,19 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme } } - protected byte supplyIfAbsent(int hash, byte key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, byte key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2172,20 +2186,6 @@ public class Byte2ByteConcurrentOpenHashMap extends AbstractByte2ByteMap impleme } } - protected byte computeIfPresent(int hash, byte key, ByteByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, byte key, ByteByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { 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 c27fcbd..98ca658 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 class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme 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,6 +458,27 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(byte key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(byte key, ByteCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, byte key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, byte key, ByteCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, byte key, ByteCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, byte key, Byte2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme } } - protected char supplyIfAbsent(int hash, byte key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, byte key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Byte2CharConcurrentOpenHashMap extends AbstractByte2CharMap impleme } } - protected char computeIfPresent(int hash, byte key, ByteCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, byte key, ByteCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { 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 5eb8cf6..2ddbfc7 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 class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp 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,6 +458,27 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(byte key, ByteDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, byte key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + 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 computeNonDefault(int hash, byte key, ByteDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, byte key, Byte2DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp } } - protected double supplyIfAbsent(int hash, byte key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, byte key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Byte2DoubleConcurrentOpenHashMap extends AbstractByte2DoubleMap imp } } - 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 239fdbc..179dffb 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 class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple 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,6 +458,27 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(byte key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(byte key, ByteFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, byte key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, byte key, ByteFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, byte key, ByteFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, byte key, Byte2FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple } } - protected float supplyIfAbsent(int hash, byte key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, byte key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Byte2FloatConcurrentOpenHashMap extends AbstractByte2FloatMap imple } } - protected float computeIfPresent(int hash, byte key, ByteFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, byte key, ByteFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { 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 d4af8ac..cf35fa1 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 class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement 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,6 +458,27 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(byte key, ByteIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, byte key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + 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 computeNonDefault(int hash, byte key, ByteIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, byte key, Byte2IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement } } - protected int supplyIfAbsent(int hash, byte key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, byte key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Byte2IntConcurrentOpenHashMap extends AbstractByte2IntMap implement } } - 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 7185e27..f350730 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 class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme 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,6 +458,27 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(byte key, ByteLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, byte key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + 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 computeNonDefault(int hash, byte key, ByteLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, byte key, Byte2LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme } } - protected long supplyIfAbsent(int hash, byte key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, byte key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Byte2LongConcurrentOpenHashMap extends AbstractByte2LongMap impleme } } - 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 4ab870a..bf4042e 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 class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 @@ public class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< } } - 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 @@ public class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 @@ public class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< 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 @@ public class Byte2ObjectConcurrentOpenHashMap extends AbstractByte2ObjectMap< } } - 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 5f30105..8ea1dd6 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 class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple 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,6 +458,27 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(byte key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(byte key, ByteShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, byte key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, byte key, ByteShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, byte key, ByteShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, byte key, Byte2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple } } - protected short supplyIfAbsent(int hash, byte key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, byte key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Byte2ShortConcurrentOpenHashMap extends AbstractByte2ShortMap imple } } - protected short computeIfPresent(int hash, byte key, ByteShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, byte key, ByteShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { 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 b09b252..fb5bfb6 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 @@ -440,6 +440,42 @@ public class Byte2BooleanOpenCustomHashMap extends AbstractByte2BooleanMap imple return newValue; } + @Override + public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Byte2BooleanOpenCustomHashMap extends AbstractByte2BooleanMap imple return newValue; } - @Override - public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Byte2BooleanOpenCustomHashMap extends AbstractByte2BooleanMap imple return newValue; } - @Override - public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Byte2BooleanOpenCustomHashMap extends AbstractByte2BooleanMap imple 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 4a2322a..616f06d 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 @@ -454,6 +454,42 @@ public class Byte2ByteOpenCustomHashMap extends AbstractByte2ByteMap implements return newValue; } + @Override + public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Byte2ByteOpenCustomHashMap extends AbstractByte2ByteMap implements return newValue; } - @Override - public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,48 +528,25 @@ public class Byte2ByteOpenCustomHashMap extends AbstractByte2ByteMap implements return newValue; } - @Override - public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 f7dda8e..f0db65c 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 @@ -462,6 +462,42 @@ public class Byte2CharOpenCustomHashMap extends AbstractByte2CharMap implements return newValue; } + @Override + public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2CharOpenCustomHashMap extends AbstractByte2CharMap implements return newValue; } - @Override - public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Byte2CharOpenCustomHashMap extends AbstractByte2CharMap implements return newValue; } - @Override - public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 2d5d7f3..96a025b 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 @@ -462,6 +462,42 @@ public class Byte2DoubleOpenCustomHashMap extends AbstractByte2DoubleMap impleme return newValue; } + @Override + public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2DoubleOpenCustomHashMap extends AbstractByte2DoubleMap impleme return newValue; } - @Override - public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Byte2DoubleOpenCustomHashMap extends AbstractByte2DoubleMap impleme return newValue; } - @Override - public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Byte2DoubleOpenCustomHashMap extends AbstractByte2DoubleMap impleme 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 9f71328..452bc6d 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 @@ -462,6 +462,42 @@ public class Byte2FloatOpenCustomHashMap extends AbstractByte2FloatMap implement return newValue; } + @Override + public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2FloatOpenCustomHashMap extends AbstractByte2FloatMap implement return newValue; } - @Override - public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Byte2FloatOpenCustomHashMap extends AbstractByte2FloatMap implement return newValue; } - @Override - public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 164803f..b8ac58f 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 @@ -462,6 +462,42 @@ public class Byte2IntOpenCustomHashMap extends AbstractByte2IntMap implements IT return newValue; } + @Override + public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2IntOpenCustomHashMap extends AbstractByte2IntMap implements IT return newValue; } - @Override - public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Byte2IntOpenCustomHashMap extends AbstractByte2IntMap implements IT return newValue; } - @Override - public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Byte2IntOpenCustomHashMap extends AbstractByte2IntMap implements IT 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 98280eb..6b68b2d 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 @@ -462,6 +462,42 @@ public class Byte2LongOpenCustomHashMap extends AbstractByte2LongMap implements return newValue; } + @Override + public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2LongOpenCustomHashMap extends AbstractByte2LongMap implements return newValue; } - @Override - public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Byte2LongOpenCustomHashMap extends AbstractByte2LongMap implements return newValue; } - @Override - public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Byte2LongOpenCustomHashMap extends AbstractByte2LongMap implements 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 b1c1bd4..0e3d8ab 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 class Byte2ObjectOpenCustomHashMap extends AbstractByte2ObjectMap i 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 class Byte2ObjectOpenCustomHashMap extends AbstractByte2ObjectMap i } 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 class Byte2ObjectOpenCustomHashMap extends AbstractByte2ObjectMap i 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 class Byte2ObjectOpenCustomHashMap extends AbstractByte2ObjectMap i 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 4942d14..d27135f 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 @@ -462,6 +462,42 @@ public class Byte2ShortOpenCustomHashMap extends AbstractByte2ShortMap implement return newValue; } + @Override + public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Byte2ShortOpenCustomHashMap extends AbstractByte2ShortMap implement return newValue; } - @Override - public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Byte2ShortOpenCustomHashMap extends AbstractByte2ShortMap implement return newValue; } - @Override - public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override 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 24f196f..ba5debd 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,6 +408,42 @@ public class Byte2BooleanOpenHashMap extends AbstractByte2BooleanMap implements values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Byte2BooleanOpenHashMap extends AbstractByte2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Byte2BooleanOpenHashMap extends AbstractByte2BooleanMap implements return newValue; } - @Override - public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Byte2BooleanOpenHashMap extends AbstractByte2BooleanMap implements 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 f69eb93..90ff012 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,6 +424,42 @@ public class Byte2ByteOpenHashMap extends AbstractByte2ByteMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Byte2ByteOpenHashMap extends AbstractByte2ByteMap implements ITrimm return newValue; } - @Override - public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,48 +499,25 @@ public class Byte2ByteOpenHashMap extends AbstractByte2ByteMap implements ITrimm return newValue; } - @Override - public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 977f676..bf4e02a 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,6 +430,42 @@ public class Byte2CharOpenHashMap extends AbstractByte2CharMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2CharOpenHashMap extends AbstractByte2CharMap implements ITrimm return newValue; } - @Override - public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Byte2CharOpenHashMap extends AbstractByte2CharMap implements ITrimm return newValue; } - @Override - public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 179487f..1d8a415 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,6 +430,42 @@ public class Byte2DoubleOpenHashMap extends AbstractByte2DoubleMap implements IT values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2DoubleOpenHashMap extends AbstractByte2DoubleMap implements IT return newValue; } - @Override - public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Byte2DoubleOpenHashMap extends AbstractByte2DoubleMap implements IT return newValue; } - @Override - public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Byte2DoubleOpenHashMap extends AbstractByte2DoubleMap implements IT 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 3ec3f76..4aae440 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,6 +430,42 @@ public class Byte2FloatOpenHashMap extends AbstractByte2FloatMap implements ITri values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2FloatOpenHashMap extends AbstractByte2FloatMap implements ITri return newValue; } - @Override - public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Byte2FloatOpenHashMap extends AbstractByte2FloatMap implements ITri return newValue; } - @Override - public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 d0be51a..42b872a 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,6 +430,42 @@ public class Byte2IntOpenHashMap extends AbstractByte2IntMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2IntOpenHashMap extends AbstractByte2IntMap implements ITrimmab return newValue; } - @Override - public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Byte2IntOpenHashMap extends AbstractByte2IntMap implements ITrimmab return newValue; } - @Override - public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Byte2IntOpenHashMap extends AbstractByte2IntMap implements ITrimmab 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 af18749..a3c5142 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,6 +430,42 @@ public class Byte2LongOpenHashMap extends AbstractByte2LongMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2LongOpenHashMap extends AbstractByte2LongMap implements ITrimm return newValue; } - @Override - public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Byte2LongOpenHashMap extends AbstractByte2LongMap implements ITrimm return newValue; } - @Override - public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Byte2LongOpenHashMap extends AbstractByte2LongMap implements ITrimm 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 4770dbb..2a26e1a 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 class Byte2ObjectOpenHashMap extends AbstractByte2ObjectMap impleme 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 class Byte2ObjectOpenHashMap extends AbstractByte2ObjectMap impleme 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 class Byte2ObjectOpenHashMap extends AbstractByte2ObjectMap impleme } 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 class Byte2ObjectOpenHashMap extends AbstractByte2ObjectMap impleme 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 fbe3a98..261a7d0 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,6 +430,42 @@ public class Byte2ShortOpenHashMap extends AbstractByte2ShortMap implements ITri values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Byte2ShortOpenHashMap extends AbstractByte2ShortMap implements ITri return newValue; } - @Override - public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Byte2ShortOpenHashMap extends AbstractByte2ShortMap implements ITri return newValue; } - @Override - public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override 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 eddec88..65c0ff9 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 class ImmutableByte2BooleanOpenHashMap extends AbstractByte2BooleanMap im @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 716ca35..efe0c01 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 class ImmutableByte2ByteOpenHashMap extends AbstractByte2ByteMap implemen @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 e2f1b62..779b272 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 class ImmutableByte2CharOpenHashMap extends AbstractByte2CharMap implemen @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 edcb48e..cdf07d9 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 class ImmutableByte2DoubleOpenHashMap extends AbstractByte2DoubleMap impl @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 2b30c54..af6bb16 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 class ImmutableByte2FloatOpenHashMap extends AbstractByte2FloatMap implem @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 a807920..91d46ec 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 class ImmutableByte2IntOpenHashMap extends AbstractByte2IntMap implements @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 4628469..d7385a9 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 class ImmutableByte2LongOpenHashMap extends AbstractByte2LongMap implemen @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 6c92f62..8a655dd 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 class ImmutableByte2ObjectOpenHashMap extends AbstractByte2ObjectMap 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 5bfd895..b79011b 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 class ImmutableByte2ShortOpenHashMap extends AbstractByte2ShortMap implem @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 bbfb350..3e4e630 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 @@ -419,6 +419,42 @@ public class Byte2BooleanArrayMap extends AbstractByte2BooleanMap implements Byt return newValue; } + @Override + public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Byte2BooleanArrayMap extends AbstractByte2BooleanMap implements Byt return newValue; } - @Override - public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Byte2BooleanArrayMap extends AbstractByte2BooleanMap implements Byt return newValue; } - @Override - public boolean supplyBooleanIfAbsent(byte key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(byte key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Byte2BooleanArrayMap extends AbstractByte2BooleanMap implements Byt 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 5c9cc35..de0e62f 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 @@ -435,6 +435,42 @@ public class Byte2ByteArrayMap extends AbstractByte2ByteMap implements Byte2Byte return newValue; } + @Override + public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Byte2ByteArrayMap extends AbstractByte2ByteMap implements Byte2Byte return newValue; } - @Override - public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,48 +509,25 @@ public class Byte2ByteArrayMap extends AbstractByte2ByteMap implements Byte2Byte return newValue; } - @Override - public byte supplyByteIfAbsent(byte key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 a1228f9..bfecf90 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 @@ -442,6 +442,42 @@ public class Byte2CharArrayMap extends AbstractByte2CharMap implements Byte2Char return newValue; } + @Override + public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2CharArrayMap extends AbstractByte2CharMap implements Byte2Char return newValue; } - @Override - public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Byte2CharArrayMap extends AbstractByte2CharMap implements Byte2Char return newValue; } - @Override - public char supplyCharIfAbsent(byte key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 ba3549f..87e4db5 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 @@ -442,6 +442,42 @@ public class Byte2DoubleArrayMap extends AbstractByte2DoubleMap implements Byte2 return newValue; } + @Override + public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2DoubleArrayMap extends AbstractByte2DoubleMap implements Byte2 return newValue; } - @Override - public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Byte2DoubleArrayMap extends AbstractByte2DoubleMap implements Byte2 return newValue; } - @Override - public double supplyDoubleIfAbsent(byte key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(byte key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Byte2DoubleArrayMap extends AbstractByte2DoubleMap implements Byte2 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 0ebe48b..8ca091e 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 @@ -442,6 +442,42 @@ public class Byte2FloatArrayMap extends AbstractByte2FloatMap implements Byte2Fl return newValue; } + @Override + public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2FloatArrayMap extends AbstractByte2FloatMap implements Byte2Fl return newValue; } - @Override - public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Byte2FloatArrayMap extends AbstractByte2FloatMap implements Byte2Fl return newValue; } - @Override - public float supplyFloatIfAbsent(byte key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 b0320ec..2ab2849 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 @@ -442,6 +442,42 @@ public class Byte2IntArrayMap extends AbstractByte2IntMap implements Byte2IntOrd return newValue; } + @Override + public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2IntArrayMap extends AbstractByte2IntMap implements Byte2IntOrd return newValue; } - @Override - public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Byte2IntArrayMap extends AbstractByte2IntMap implements Byte2IntOrd return newValue; } - @Override - public int supplyIntIfAbsent(byte key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(byte key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Byte2IntArrayMap extends AbstractByte2IntMap implements Byte2IntOrd 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 e52bb50..390700b 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 @@ -442,6 +442,42 @@ public class Byte2LongArrayMap extends AbstractByte2LongMap implements Byte2Long return newValue; } + @Override + public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2LongArrayMap extends AbstractByte2LongMap implements Byte2Long return newValue; } - @Override - public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Byte2LongArrayMap extends AbstractByte2LongMap implements Byte2Long return newValue; } - @Override - public long supplyLongIfAbsent(byte key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(byte key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Byte2LongArrayMap extends AbstractByte2LongMap implements Byte2Long 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 0d4eea7..a4d6a6a 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 class Byte2ObjectArrayMap extends AbstractByte2ObjectMap implements 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 class Byte2ObjectArrayMap extends AbstractByte2ObjectMap implements } 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 class Byte2ObjectArrayMap extends AbstractByte2ObjectMap implements } 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 class Byte2ObjectArrayMap extends AbstractByte2ObjectMap implements 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 adcf291..3ccd8ab 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 @@ -442,6 +442,42 @@ public class Byte2ShortArrayMap extends AbstractByte2ShortMap implements Byte2Sh return newValue; } + @Override + public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Byte2ShortArrayMap extends AbstractByte2ShortMap implements Byte2Sh return newValue; } - @Override - public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Byte2ShortArrayMap extends AbstractByte2ShortMap implements Byte2Sh return newValue; } - @Override - public short supplyShortIfAbsent(byte key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override 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 9b3a256..5e0621d 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 @@ -395,6 +395,40 @@ public class Byte2BooleanAVLTreeMap extends AbstractByte2BooleanMap implements B return newValue; } + @Override + public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + 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 computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Byte2BooleanAVLTreeMap extends AbstractByte2BooleanMap implements B return newValue; } - @Override - public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Byte2BooleanAVLTreeMap extends AbstractByte2BooleanMap implements B 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 class Byte2BooleanAVLTreeMap extends AbstractByte2BooleanMap implements B 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 class Byte2BooleanAVLTreeMap extends AbstractByte2BooleanMap implements B 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 43e7c62..5e9799e 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 @@ -394,6 +394,40 @@ public class Byte2BooleanRBTreeMap extends AbstractByte2BooleanMap implements By return newValue; } + @Override + public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + 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 computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Byte2BooleanRBTreeMap extends AbstractByte2BooleanMap implements By return newValue; } - @Override - public boolean computeBooleanIfAbsent(byte key, BytePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(byte key, BytePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Byte2BooleanRBTreeMap extends AbstractByte2BooleanMap implements By 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 class Byte2BooleanRBTreeMap extends AbstractByte2BooleanMap implements By 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 class Byte2BooleanRBTreeMap extends AbstractByte2BooleanMap implements By 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 f732da1..b4fd998 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 @@ -446,6 +446,40 @@ public class Byte2ByteAVLTreeMap extends AbstractByte2ByteMap implements Byte2By return newValue; } + @Override + public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + 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 computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Byte2ByteAVLTreeMap extends AbstractByte2ByteMap implements Byte2By return newValue; } - @Override - public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,46 +517,24 @@ public class Byte2ByteAVLTreeMap extends AbstractByte2ByteMap implements Byte2By 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 class Byte2ByteAVLTreeMap extends AbstractByte2ByteMap implements Byte2By 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 608f3ed..309d5ac 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 @@ -445,6 +445,40 @@ public class Byte2ByteRBTreeMap extends AbstractByte2ByteMap implements Byte2Byt return newValue; } + @Override + public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + 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 computeByteNonDefault(byte key, ByteByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Byte2ByteRBTreeMap extends AbstractByte2ByteMap implements Byte2Byt return newValue; } - @Override - public byte computeByteIfAbsent(byte key, ByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(byte key, ByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,46 +516,24 @@ public class Byte2ByteRBTreeMap extends AbstractByte2ByteMap implements Byte2Byt 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 class Byte2ByteRBTreeMap extends AbstractByte2ByteMap implements Byte2Byt 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 84846f6..f7c4e65 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 @@ -454,6 +454,40 @@ public class Byte2CharAVLTreeMap extends AbstractByte2CharMap implements Byte2Ch return newValue; } + @Override + public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + 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 computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2CharAVLTreeMap extends AbstractByte2CharMap implements Byte2Ch return newValue; } - @Override - public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Byte2CharAVLTreeMap extends AbstractByte2CharMap implements Byte2Ch 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 class Byte2CharAVLTreeMap extends AbstractByte2CharMap implements Byte2Ch 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 280ebc2..11f0caa 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 @@ -453,6 +453,40 @@ public class Byte2CharRBTreeMap extends AbstractByte2CharMap implements Byte2Cha return newValue; } + @Override + public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + 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 computeCharNonDefault(byte key, ByteCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2CharRBTreeMap extends AbstractByte2CharMap implements Byte2Cha return newValue; } - @Override - public char computeCharIfAbsent(byte key, Byte2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(byte key, Byte2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Byte2CharRBTreeMap extends AbstractByte2CharMap implements Byte2Cha 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 class Byte2CharRBTreeMap extends AbstractByte2CharMap implements Byte2Cha 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 36ad54c..438ec1f 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 @@ -454,6 +454,40 @@ public class Byte2DoubleAVLTreeMap extends AbstractByte2DoubleMap implements Byt return newValue; } + @Override + public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + 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 computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2DoubleAVLTreeMap extends AbstractByte2DoubleMap implements Byt return newValue; } - @Override - public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Byte2DoubleAVLTreeMap extends AbstractByte2DoubleMap implements Byt 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 class Byte2DoubleAVLTreeMap extends AbstractByte2DoubleMap implements Byt 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 class Byte2DoubleAVLTreeMap extends AbstractByte2DoubleMap implements Byt 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 f2b4113..c72f3a3 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 @@ -453,6 +453,40 @@ public class Byte2DoubleRBTreeMap extends AbstractByte2DoubleMap implements Byte return newValue; } + @Override + public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + 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 computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2DoubleRBTreeMap extends AbstractByte2DoubleMap implements Byte return newValue; } - @Override - public double computeDoubleIfAbsent(byte key, Byte2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(byte key, Byte2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Byte2DoubleRBTreeMap extends AbstractByte2DoubleMap implements Byte 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 class Byte2DoubleRBTreeMap extends AbstractByte2DoubleMap implements Byte 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 class Byte2DoubleRBTreeMap extends AbstractByte2DoubleMap implements Byte 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 7c5e38f..22d69d4 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 @@ -454,6 +454,40 @@ public class Byte2FloatAVLTreeMap extends AbstractByte2FloatMap implements Byte2 return newValue; } + @Override + public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + 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 computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2FloatAVLTreeMap extends AbstractByte2FloatMap implements Byte2 return newValue; } - @Override - public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Byte2FloatAVLTreeMap extends AbstractByte2FloatMap implements Byte2 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 class Byte2FloatAVLTreeMap extends AbstractByte2FloatMap implements Byte2 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 08c207c..54ba4ea 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 @@ -453,6 +453,40 @@ public class Byte2FloatRBTreeMap extends AbstractByte2FloatMap implements Byte2F return newValue; } + @Override + public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + 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 computeFloatNonDefault(byte key, ByteFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2FloatRBTreeMap extends AbstractByte2FloatMap implements Byte2F return newValue; } - @Override - public float computeFloatIfAbsent(byte key, Byte2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(byte key, Byte2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Byte2FloatRBTreeMap extends AbstractByte2FloatMap implements Byte2F 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 class Byte2FloatRBTreeMap extends AbstractByte2FloatMap implements Byte2F 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 f489a42..533b766 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 @@ -454,6 +454,40 @@ public class Byte2IntAVLTreeMap extends AbstractByte2IntMap implements Byte2IntN return newValue; } + @Override + public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + 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 computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2IntAVLTreeMap extends AbstractByte2IntMap implements Byte2IntN return newValue; } - @Override - public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Byte2IntAVLTreeMap extends AbstractByte2IntMap implements Byte2IntN 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 class Byte2IntAVLTreeMap extends AbstractByte2IntMap implements Byte2IntN 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 class Byte2IntAVLTreeMap extends AbstractByte2IntMap implements Byte2IntN 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 e342292..5cfbeda 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 @@ -453,6 +453,40 @@ public class Byte2IntRBTreeMap extends AbstractByte2IntMap implements Byte2IntNa return newValue; } + @Override + public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + 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 computeIntNonDefault(byte key, ByteIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2IntRBTreeMap extends AbstractByte2IntMap implements Byte2IntNa return newValue; } - @Override - public int computeIntIfAbsent(byte key, Byte2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(byte key, Byte2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Byte2IntRBTreeMap extends AbstractByte2IntMap implements Byte2IntNa 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 class Byte2IntRBTreeMap extends AbstractByte2IntMap implements Byte2IntNa 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 class Byte2IntRBTreeMap extends AbstractByte2IntMap implements Byte2IntNa 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 c414966..ee198d5 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 @@ -454,6 +454,40 @@ public class Byte2LongAVLTreeMap extends AbstractByte2LongMap implements Byte2Lo return newValue; } + @Override + public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + 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 computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2LongAVLTreeMap extends AbstractByte2LongMap implements Byte2Lo return newValue; } - @Override - public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Byte2LongAVLTreeMap extends AbstractByte2LongMap implements Byte2Lo 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 class Byte2LongAVLTreeMap extends AbstractByte2LongMap implements Byte2Lo 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 class Byte2LongAVLTreeMap extends AbstractByte2LongMap implements Byte2Lo 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 5a16c4e..7355d9c 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 @@ -453,6 +453,40 @@ public class Byte2LongRBTreeMap extends AbstractByte2LongMap implements Byte2Lon return newValue; } + @Override + public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + 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 computeLongNonDefault(byte key, ByteLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2LongRBTreeMap extends AbstractByte2LongMap implements Byte2Lon return newValue; } - @Override - public long computeLongIfAbsent(byte key, Byte2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(byte key, Byte2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Byte2LongRBTreeMap extends AbstractByte2LongMap implements Byte2Lon 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 class Byte2LongRBTreeMap extends AbstractByte2LongMap implements Byte2Lon 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 class Byte2LongRBTreeMap extends AbstractByte2LongMap implements Byte2Lon 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 0b886dc..2cd9c39 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 class Byte2ObjectAVLTreeMap extends AbstractByte2ObjectMap implemen 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 class Byte2ObjectAVLTreeMap extends AbstractByte2ObjectMap implemen 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 class Byte2ObjectAVLTreeMap extends AbstractByte2ObjectMap implemen 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 class Byte2ObjectAVLTreeMap extends AbstractByte2ObjectMap implemen 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 ce7a338..62844db 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 class Byte2ObjectRBTreeMap extends AbstractByte2ObjectMap implement 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 class Byte2ObjectRBTreeMap extends AbstractByte2ObjectMap implement 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 class Byte2ObjectRBTreeMap extends AbstractByte2ObjectMap implement 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 class Byte2ObjectRBTreeMap extends AbstractByte2ObjectMap implement 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 6565e91..6d262be 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 @@ -454,6 +454,40 @@ public class Byte2ShortAVLTreeMap extends AbstractByte2ShortMap implements Byte2 return newValue; } + @Override + public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + 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 computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Byte2ShortAVLTreeMap extends AbstractByte2ShortMap implements Byte2 return newValue; } - @Override - public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Byte2ShortAVLTreeMap extends AbstractByte2ShortMap implements Byte2 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 class Byte2ShortAVLTreeMap extends AbstractByte2ShortMap implements Byte2 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 ffc1042..0321589 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 @@ -453,6 +453,40 @@ public class Byte2ShortRBTreeMap extends AbstractByte2ShortMap implements Byte2S return newValue; } + @Override + public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + 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 computeShortNonDefault(byte key, ByteShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Byte2ShortRBTreeMap extends AbstractByte2ShortMap implements Byte2S return newValue; } - @Override - public short computeShortIfAbsent(byte key, Byte2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(byte key, Byte2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Byte2ShortRBTreeMap extends AbstractByte2ShortMap implements Byte2S 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 class Byte2ShortRBTreeMap extends AbstractByte2ShortMap implements Byte2S 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 4b24bfc..d8ddccc 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 @@ -283,15 +283,6 @@ public interface Byte2BooleanMap extends Map, BytePredicate * @return the result of the computation */ public boolean computeBoolean(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". - * 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 boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Byte2BooleanMap extends Map, BytePredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(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". + * 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 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 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". + * 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 boolean computeBooleanNonDefault(byte key, ByteBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Byte2BooleanMap extends Map, BytePredicate * @return the result of the computed value or present value */ 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". - * 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 boolean supplyBooleanIfAbsent(byte key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Byte2BooleanMap extends Map, BytePredicate * @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 8bd81c2..74acdd0 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 @@ -307,15 +307,6 @@ public interface Byte2ByteMap extends Map, ByteUnaryOperator * @return the result of the computation */ public byte computeByte(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". - * 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 byte computeByteNonDefault(byte key, ByteByteUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Byte2ByteMap extends Map, ByteUnaryOperator * @return the result of the computed value or present value */ public byte computeByteIfAbsent(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". + * 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 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 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". + * 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 byte computeByteNonDefault(byte key, ByteByteUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Byte2ByteMap extends Map, ByteUnaryOperator * @return the result of the computed value or present value */ 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". - * 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 byte supplyByteIfAbsent(byte key, ByteSupplier 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". @@ -352,16 +362,6 @@ public interface Byte2ByteMap extends Map, ByteUnaryOperator * @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 f488602..986a2e2 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 @@ -308,15 +308,6 @@ public interface Byte2CharMap extends Map, Byte2CharFunction * @return the result of the computation */ public char computeChar(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". - * 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 char computeCharNonDefault(byte key, ByteCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2CharMap extends Map, Byte2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(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". + * 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 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 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". + * 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 char computeCharNonDefault(byte key, ByteCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2CharMap extends Map, Byte2CharFunction * @return the result of the computed value or present value */ 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". - * 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 char supplyCharIfAbsent(byte key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2CharMap extends Map, Byte2CharFunction * @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 91fa0ef..95fe768 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 @@ -308,15 +308,6 @@ public interface Byte2DoubleMap extends Map, Byte2DoubleFunction * @return the result of the computation */ public double computeDouble(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". - * 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 double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2DoubleMap extends Map, Byte2DoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(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". + * 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 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 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". + * 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 double computeDoubleNonDefault(byte key, ByteDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2DoubleMap extends Map, Byte2DoubleFunction * @return the result of the computed value or present value */ 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". - * 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 double supplyDoubleIfAbsent(byte key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2DoubleMap extends Map, Byte2DoubleFunction * @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 096cb36..4c7cee8 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 @@ -308,15 +308,6 @@ public interface Byte2FloatMap extends Map, Byte2FloatFunction * @return the result of the computation */ public float computeFloat(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". - * 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 float computeFloatNonDefault(byte key, ByteFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2FloatMap extends Map, Byte2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(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". + * 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 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 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". + * 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 float computeFloatNonDefault(byte key, ByteFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2FloatMap extends Map, Byte2FloatFunction * @return the result of the computed value or present value */ 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". - * 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 float supplyFloatIfAbsent(byte key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2FloatMap extends Map, Byte2FloatFunction * @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 7e383c2..75be994 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 @@ -308,15 +308,6 @@ public interface Byte2IntMap extends Map, Byte2IntFunction * @return the result of the computation */ public int computeInt(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". - * 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 int computeIntNonDefault(byte key, ByteIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2IntMap extends Map, Byte2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(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". + * 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 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 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". + * 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 int computeIntNonDefault(byte key, ByteIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2IntMap extends Map, Byte2IntFunction * @return the result of the computed value or present value */ 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". - * 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 int supplyIntIfAbsent(byte key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2IntMap extends Map, Byte2IntFunction * @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 35441a4..8893020 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 @@ -308,15 +308,6 @@ public interface Byte2LongMap extends Map, Byte2LongFunction * @return the result of the computation */ public long computeLong(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". - * 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 long computeLongNonDefault(byte key, ByteLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2LongMap extends Map, Byte2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(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". + * 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 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 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". + * 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 long computeLongNonDefault(byte key, ByteLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2LongMap extends Map, Byte2LongFunction * @return the result of the computed value or present value */ 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". - * 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 long supplyLongIfAbsent(byte key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2LongMap extends Map, Byte2LongFunction * @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 c7641c6..f1145bd 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 interface Byte2ObjectMap extends Map, ByteFunction * @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 interface Byte2ObjectMap extends Map, ByteFunction * @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 interface Byte2ObjectMap extends Map, ByteFunction * @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 interface Byte2ObjectMap extends Map, ByteFunction * @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 7bdac5d..88225d1 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 @@ -308,15 +308,6 @@ public interface Byte2ShortMap extends Map, Byte2ShortFunction * @return the result of the computation */ public short computeShort(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". - * 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 short computeShortNonDefault(byte key, ByteShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Byte2ShortMap extends Map, Byte2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(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". + * 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 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 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". + * 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 short computeShortNonDefault(byte key, ByteShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Byte2ShortMap extends Map, Byte2ShortFunction * @return the result of the computed value or present value */ 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". - * 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 short supplyShortIfAbsent(byte key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Byte2ShortMap extends Map, Byte2ShortFunction * @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 9812bd7..41d89be 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 class ByteArrayFIFOQueue extends AbstractBytePriorityQueue implements Byt 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) { + 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 class ByteIterators } } + 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 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 3d52d57..29f3c31 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.collections.ByteCollection; 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 class ByteLists 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 class ByteLists 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 class ByteLists 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 0663d19..67d9603 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 @@ public class BytePriorityQueues @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 3e63491..42442f2 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 class Byte2BooleanMaps @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 class Byte2BooleanMaps @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 class Byte2BooleanMaps @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 class Byte2BooleanMaps @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 a4c1937..8bb6a3f 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 class Byte2ByteMaps @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 class Byte2ByteMaps @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 class Byte2ByteMaps @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 class Byte2ByteMaps @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 53b74b2..3a92fc4 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 class Byte2CharMaps @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 class Byte2CharMaps @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 class Byte2CharMaps @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 class Byte2CharMaps @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 17c4c91..3023370 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 class Byte2DoubleMaps @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 class Byte2DoubleMaps @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 class Byte2DoubleMaps @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 class Byte2DoubleMaps @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 bc2bff1..4bfd042 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 class Byte2FloatMaps @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 class Byte2FloatMaps @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 class Byte2FloatMaps @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 class Byte2FloatMaps @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 13ab657..78a456a 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 class Byte2IntMaps @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 class Byte2IntMaps @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 class Byte2IntMaps @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 class Byte2IntMaps @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 7367968..2dcde03 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 class Byte2LongMaps @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 class Byte2LongMaps @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 class Byte2LongMaps @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 class Byte2LongMaps @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 39b484c..d926d88 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 class Byte2ObjectMaps @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 class Byte2ObjectMaps @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 class Byte2ObjectMaps @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 class Byte2ObjectMaps @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 cf3e17a..0c73b7e 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 class Byte2ShortMaps @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 class Byte2ShortMaps @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 class Byte2ShortMaps @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 class Byte2ShortMaps @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 8d675dc..e4c6c66 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 ad1ffd8..db99397 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.AbstractCharCollection; 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 abstract class AbstractCharList extends AbstractCharCollection implements 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 abstract class AbstractCharList extends AbstractCharCollection implements } } } + + 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 abstract class AbstractCharList extends AbstractCharCollection implements 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 b278189..6d86715 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.ints.functions.consumer.IntCharConsumer; 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 interface CharList extends CharCollection, List @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 441bfa8..f1df355 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 abstract class AbstractChar2BooleanMap extends AbstractMap 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 abstract class AbstractChar2ByteMap extends AbstractMap 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 abstract class AbstractChar2ByteMap extends AbstractMap 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 abstract class AbstractChar2ByteMap extends AbstractMap 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 b676f32..9d6a53d 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 abstract class AbstractChar2CharMap extends AbstractMap 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 abstract class AbstractChar2LongMap extends AbstractMap 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 abstract class AbstractChar2LongMap extends AbstractMap 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 abstract class AbstractChar2LongMap extends AbstractMap 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 75ad784..97b3cdc 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 abstract class AbstractChar2ObjectMap extends AbstractMap 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 abstract class AbstractChar2ObjectMap extends AbstractMap 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 abstract class AbstractChar2ObjectMap extends AbstractMap 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 abstract class AbstractChar2ObjectMap extends AbstractMap 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 7c506bb..56518fc 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 abstract class AbstractChar2ShortMap extends AbstractMap extends AbstractChar2ObjectMap< 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 class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< 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 class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< 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 class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< 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 @@ public class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< } } - 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 @@ public class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< 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 @@ public class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< 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 @@ public class Char2ObjectConcurrentOpenHashMap extends AbstractChar2ObjectMap< } } - 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 f7f6a31..0742c01 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 class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple 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,6 +458,27 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(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 computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple } } + 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); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, char key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, char key, CharShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, char key, CharShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple } } - 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); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, char key, Char2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple } } - protected short supplyIfAbsent(int hash, char key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, char key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Char2ShortConcurrentOpenHashMap extends AbstractChar2ShortMap imple } } - protected short computeIfPresent(int hash, char key, CharShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, char key, CharShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { 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 294e799..33a755c 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 @@ -440,6 +440,42 @@ public class Char2BooleanOpenCustomHashMap extends AbstractChar2BooleanMap imple return newValue; } + @Override + public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Char2BooleanOpenCustomHashMap extends AbstractChar2BooleanMap imple return newValue; } - @Override - public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Char2BooleanOpenCustomHashMap extends AbstractChar2BooleanMap imple return newValue; } - @Override - public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Char2BooleanOpenCustomHashMap extends AbstractChar2BooleanMap imple 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 b88ea93..d24f11d 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 @@ -462,6 +462,42 @@ public class Char2ByteOpenCustomHashMap extends AbstractChar2ByteMap implements return newValue; } + @Override + public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2ByteOpenCustomHashMap extends AbstractChar2ByteMap implements return newValue; } - @Override - public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Char2ByteOpenCustomHashMap extends AbstractChar2ByteMap implements return newValue; } - @Override - public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 600e09b..202a695 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 @@ -454,6 +454,42 @@ public class Char2CharOpenCustomHashMap extends AbstractChar2CharMap implements return newValue; } + @Override + public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Char2CharOpenCustomHashMap extends AbstractChar2CharMap implements return newValue; } - @Override - public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,48 +528,25 @@ public class Char2CharOpenCustomHashMap extends AbstractChar2CharMap implements return newValue; } - @Override - public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 f920ea7..2827a37 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 @@ -462,6 +462,42 @@ public class Char2DoubleOpenCustomHashMap extends AbstractChar2DoubleMap impleme return newValue; } + @Override + public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2DoubleOpenCustomHashMap extends AbstractChar2DoubleMap impleme return newValue; } - @Override - public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Char2DoubleOpenCustomHashMap extends AbstractChar2DoubleMap impleme return newValue; } - @Override - public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Char2DoubleOpenCustomHashMap extends AbstractChar2DoubleMap impleme 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 4c50118..fefed7d 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 @@ -462,6 +462,42 @@ public class Char2FloatOpenCustomHashMap extends AbstractChar2FloatMap implement return newValue; } + @Override + public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2FloatOpenCustomHashMap extends AbstractChar2FloatMap implement return newValue; } - @Override - public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Char2FloatOpenCustomHashMap extends AbstractChar2FloatMap implement return newValue; } - @Override - public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 ec8f3fa..4f483fe 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 @@ -462,6 +462,42 @@ public class Char2IntOpenCustomHashMap extends AbstractChar2IntMap implements IT return newValue; } + @Override + public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2IntOpenCustomHashMap extends AbstractChar2IntMap implements IT return newValue; } - @Override - public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Char2IntOpenCustomHashMap extends AbstractChar2IntMap implements IT return newValue; } - @Override - public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Char2IntOpenCustomHashMap extends AbstractChar2IntMap implements IT 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 6f263cd..3a531d9 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 @@ -462,6 +462,42 @@ public class Char2LongOpenCustomHashMap extends AbstractChar2LongMap implements return newValue; } + @Override + public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2LongOpenCustomHashMap extends AbstractChar2LongMap implements return newValue; } - @Override - public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Char2LongOpenCustomHashMap extends AbstractChar2LongMap implements return newValue; } - @Override - public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Char2LongOpenCustomHashMap extends AbstractChar2LongMap implements 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 0c7fe74..b72f150 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 class Char2ObjectOpenCustomHashMap extends AbstractChar2ObjectMap i 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 class Char2ObjectOpenCustomHashMap extends AbstractChar2ObjectMap i } 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 class Char2ObjectOpenCustomHashMap extends AbstractChar2ObjectMap i 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 class Char2ObjectOpenCustomHashMap extends AbstractChar2ObjectMap i 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 d4866f6..0b1bc66 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 @@ -462,6 +462,42 @@ public class Char2ShortOpenCustomHashMap extends AbstractChar2ShortMap implement return newValue; } + @Override + public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Char2ShortOpenCustomHashMap extends AbstractChar2ShortMap implement return newValue; } - @Override - public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Char2ShortOpenCustomHashMap extends AbstractChar2ShortMap implement return newValue; } - @Override - public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override 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 148c9bd..2c2a74c 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,6 +408,42 @@ public class Char2BooleanOpenHashMap extends AbstractChar2BooleanMap implements values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Char2BooleanOpenHashMap extends AbstractChar2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Char2BooleanOpenHashMap extends AbstractChar2BooleanMap implements return newValue; } - @Override - public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Char2BooleanOpenHashMap extends AbstractChar2BooleanMap implements 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 eb2c38d..0dc979b 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,6 +430,42 @@ public class Char2ByteOpenHashMap extends AbstractChar2ByteMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2ByteOpenHashMap extends AbstractChar2ByteMap implements ITrimm return newValue; } - @Override - public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Char2ByteOpenHashMap extends AbstractChar2ByteMap implements ITrimm return newValue; } - @Override - public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 dd8c968..0420262 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,6 +424,42 @@ public class Char2CharOpenHashMap extends AbstractChar2CharMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Char2CharOpenHashMap extends AbstractChar2CharMap implements ITrimm return newValue; } - @Override - public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,48 +499,25 @@ public class Char2CharOpenHashMap extends AbstractChar2CharMap implements ITrimm return newValue; } - @Override - public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 7b1ee79..7020e0f 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,6 +430,42 @@ public class Char2DoubleOpenHashMap extends AbstractChar2DoubleMap implements IT values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2DoubleOpenHashMap extends AbstractChar2DoubleMap implements IT return newValue; } - @Override - public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Char2DoubleOpenHashMap extends AbstractChar2DoubleMap implements IT return newValue; } - @Override - public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Char2DoubleOpenHashMap extends AbstractChar2DoubleMap implements IT 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 1e494b2..49b036d 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,6 +430,42 @@ public class Char2FloatOpenHashMap extends AbstractChar2FloatMap implements ITri values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2FloatOpenHashMap extends AbstractChar2FloatMap implements ITri return newValue; } - @Override - public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Char2FloatOpenHashMap extends AbstractChar2FloatMap implements ITri return newValue; } - @Override - public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 160d4cc..eea889c 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,6 +430,42 @@ public class Char2IntOpenHashMap extends AbstractChar2IntMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2IntOpenHashMap extends AbstractChar2IntMap implements ITrimmab return newValue; } - @Override - public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Char2IntOpenHashMap extends AbstractChar2IntMap implements ITrimmab return newValue; } - @Override - public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Char2IntOpenHashMap extends AbstractChar2IntMap implements ITrimmab 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 f8b54e0..52348d1 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,6 +430,42 @@ public class Char2LongOpenHashMap extends AbstractChar2LongMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2LongOpenHashMap extends AbstractChar2LongMap implements ITrimm return newValue; } - @Override - public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Char2LongOpenHashMap extends AbstractChar2LongMap implements ITrimm return newValue; } - @Override - public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Char2LongOpenHashMap extends AbstractChar2LongMap implements ITrimm 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 6e4a1b2..5b2ea01 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 class Char2ObjectOpenHashMap extends AbstractChar2ObjectMap impleme 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 class Char2ObjectOpenHashMap extends AbstractChar2ObjectMap impleme 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 class Char2ObjectOpenHashMap extends AbstractChar2ObjectMap impleme } 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 class Char2ObjectOpenHashMap extends AbstractChar2ObjectMap impleme 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 0f7221f..2667446 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,6 +430,42 @@ public class Char2ShortOpenHashMap extends AbstractChar2ShortMap implements ITri values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + 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 computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Char2ShortOpenHashMap extends AbstractChar2ShortMap implements ITri return newValue; } - @Override - public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Char2ShortOpenHashMap extends AbstractChar2ShortMap implements ITri return newValue; } - @Override - public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override 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 ab255f9..5609e59 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 class ImmutableChar2BooleanOpenHashMap extends AbstractChar2BooleanMap im @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 261cf10..7e2c502 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 class ImmutableChar2ByteOpenHashMap extends AbstractChar2ByteMap implemen @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 6fe5a53..48e2675 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 class ImmutableChar2CharOpenHashMap extends AbstractChar2CharMap implemen @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 9b04301..ac400e2 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 class ImmutableChar2DoubleOpenHashMap extends AbstractChar2DoubleMap impl @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 09d8592..33af531 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 class ImmutableChar2FloatOpenHashMap extends AbstractChar2FloatMap implem @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 5da1a67..5376a77 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 class ImmutableChar2IntOpenHashMap extends AbstractChar2IntMap implements @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 39a64e0..7305294 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 class ImmutableChar2LongOpenHashMap extends AbstractChar2LongMap implemen @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 d9f3efe..fb2ea5a 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 class ImmutableChar2ObjectOpenHashMap extends AbstractChar2ObjectMap 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 35ef8a0..8cd06ff 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 class ImmutableChar2ShortOpenHashMap extends AbstractChar2ShortMap implem @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 319024c..b31f12c 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 @@ -419,6 +419,42 @@ public class Char2BooleanArrayMap extends AbstractChar2BooleanMap implements Cha return newValue; } + @Override + public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Char2BooleanArrayMap extends AbstractChar2BooleanMap implements Cha return newValue; } - @Override - public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Char2BooleanArrayMap extends AbstractChar2BooleanMap implements Cha return newValue; } - @Override - public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Char2BooleanArrayMap extends AbstractChar2BooleanMap implements Cha 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 11cc422..88731b8 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 @@ -442,6 +442,42 @@ public class Char2ByteArrayMap extends AbstractChar2ByteMap implements Char2Byte return newValue; } + @Override + public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Char2ByteArrayMap extends AbstractChar2ByteMap implements Char2Byte return newValue; } - @Override - public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Char2ByteArrayMap extends AbstractChar2ByteMap implements Char2Byte return newValue; } - @Override - public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override 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 e08dfd5..67daf62 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 @@ -435,6 +435,42 @@ public class Char2CharArrayMap extends AbstractChar2CharMap implements Char2Char return newValue; } + @Override + public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Char2CharArrayMap extends AbstractChar2CharMap implements Char2Char return newValue; } - @Override - public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,48 +509,25 @@ public class Char2CharArrayMap extends AbstractChar2CharMap implements Char2Char return newValue; } - @Override - public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override 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 645ab29..0b828e9 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 @@ -442,6 +442,42 @@ public class Char2DoubleArrayMap extends AbstractChar2DoubleMap implements Char2 return newValue; } + @Override + public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Char2DoubleArrayMap extends AbstractChar2DoubleMap implements Char2 return newValue; } - @Override - public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Char2DoubleArrayMap extends AbstractChar2DoubleMap implements Char2 return newValue; } - @Override - public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Char2DoubleArrayMap extends AbstractChar2DoubleMap implements Char2 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 74b1cb1..5fab710 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 @@ -442,6 +442,42 @@ public class Char2FloatArrayMap extends AbstractChar2FloatMap implements Char2Fl return newValue; } + @Override + public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Char2FloatArrayMap extends AbstractChar2FloatMap implements Char2Fl return newValue; } - @Override - public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Char2FloatArrayMap extends AbstractChar2FloatMap implements Char2Fl return newValue; } - @Override - public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override 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 4965fd7..21a8805 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 @@ -442,6 +442,42 @@ public class Char2IntArrayMap extends AbstractChar2IntMap implements Char2IntOrd return newValue; } + @Override + public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Char2IntArrayMap extends AbstractChar2IntMap implements Char2IntOrd return newValue; } - @Override - public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Char2IntArrayMap extends AbstractChar2IntMap implements Char2IntOrd return newValue; } - @Override - public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Char2IntArrayMap extends AbstractChar2IntMap implements Char2IntOrd 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 37b87ad..a42f724 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 @@ -442,6 +442,42 @@ public class Char2LongArrayMap extends AbstractChar2LongMap implements Char2Long return newValue; } + @Override + public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + 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 computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Char2LongArrayMap extends AbstractChar2LongMap implements Char2Long return newValue; } - @Override - public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Char2LongArrayMap extends AbstractChar2LongMap implements Char2Long return newValue; } - @Override - public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Char2LongArrayMap extends AbstractChar2LongMap implements Char2Long 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 6d747dd..82ec8a9 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 class Char2ObjectArrayMap extends AbstractChar2ObjectMap implements 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 class Char2ObjectArrayMap extends AbstractChar2ObjectMap implements } 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 class Char2ObjectArrayMap extends AbstractChar2ObjectMap implements } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(char 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(char key, CharObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -524,20 +467,6 @@ public class Char2ObjectArrayMap extends AbstractChar2ObjectMap implements return newValue; } - @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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(char key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ShortArrayMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ShortArrayMap.java index 6af5d8a..8278650 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/misc/Char2ShortArrayMap.java @@ -442,6 +442,42 @@ public class Char2ShortArrayMap extends AbstractChar2ShortMap implements Char2Sh return newValue; } + @Override + public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, 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 == -1) 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); @@ -461,19 +497,6 @@ public class Char2ShortArrayMap extends AbstractChar2ShortMap implements Char2Sh return newValue; } - @Override - public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Char2ShortArrayMap extends AbstractChar2ShortMap implements Char2Sh return newValue; } - @Override - public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(char 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(char key, CharShortUnaryOperator 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(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanAVLTreeMap.java index 8946dd0..cab1062 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanAVLTreeMap.java @@ -395,6 +395,40 @@ public class Char2BooleanAVLTreeMap extends AbstractChar2BooleanMap implements C return newValue; } + @Override + public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(char 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(char key, CharBooleanUnaryOperator 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 computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Char2BooleanAVLTreeMap extends AbstractChar2BooleanMap implements C return newValue; } - @Override - public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Char2BooleanAVLTreeMap extends AbstractChar2BooleanMap implements C return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(char 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(char key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,16 +484,6 @@ public class Char2BooleanAVLTreeMap extends AbstractChar2BooleanMap implements C return entry.value; } - @Override - public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator 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(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1487,14 +1487,9 @@ public class Char2BooleanAVLTreeMap extends AbstractChar2BooleanMap implements C 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/chars/maps/impl/tree/Char2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanRBTreeMap.java index c721108..4621948 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2BooleanRBTreeMap.java @@ -394,6 +394,40 @@ public class Char2BooleanRBTreeMap extends AbstractChar2BooleanMap implements Ch return newValue; } + @Override + public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(char 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(char key, CharBooleanUnaryOperator 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 computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Char2BooleanRBTreeMap extends AbstractChar2BooleanMap implements Ch return newValue; } - @Override - public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Char2BooleanRBTreeMap extends AbstractChar2BooleanMap implements Ch return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(char 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(char key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Char2BooleanRBTreeMap extends AbstractChar2BooleanMap implements Ch return entry.value; } - @Override - public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator 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(char key, CharBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Char2BooleanRBTreeMap extends AbstractChar2BooleanMap implements Ch 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/chars/maps/impl/tree/Char2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteAVLTreeMap.java index 6d7895a..c1ffbf4 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2ByteAVLTreeMap extends AbstractChar2ByteMap implements Char2By return newValue; } + @Override + public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(char 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(char key, CharByteUnaryOperator 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 computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2ByteAVLTreeMap extends AbstractChar2ByteMap implements Char2By return newValue; } - @Override - public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Char2ByteAVLTreeMap extends AbstractChar2ByteMap implements Char2By return entry.value; } - @Override - public byte supplyByteIfAbsent(char 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(char 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(char key, CharByteUnaryOperator 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(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2ByteAVLTreeMap extends AbstractChar2ByteMap implements Char2By 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/chars/maps/impl/tree/Char2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteRBTreeMap.java index c4d2dc2..b2abf89 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ByteRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2ByteRBTreeMap extends AbstractChar2ByteMap implements Char2Byt return newValue; } + @Override + public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(char 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(char key, CharByteUnaryOperator 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 computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2ByteRBTreeMap extends AbstractChar2ByteMap implements Char2Byt return newValue; } - @Override - public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Char2ByteRBTreeMap extends AbstractChar2ByteMap implements Char2Byt return entry.value; } - @Override - public byte supplyByteIfAbsent(char 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(char 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(char key, CharByteUnaryOperator 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(char key, CharByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2ByteRBTreeMap extends AbstractChar2ByteMap implements Char2Byt 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/chars/maps/impl/tree/Char2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharAVLTreeMap.java index 99d7324..ce036f2 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharAVLTreeMap.java @@ -446,6 +446,40 @@ public class Char2CharAVLTreeMap extends AbstractChar2CharMap implements Char2Ch return newValue; } + @Override + public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(char 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(char key, CharCharUnaryOperator 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 computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Char2CharAVLTreeMap extends AbstractChar2CharMap implements Char2Ch return newValue; } - @Override - public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,46 +517,24 @@ public class Char2CharAVLTreeMap extends AbstractChar2CharMap implements Char2Ch return entry.value; } - @Override - public char supplyCharIfAbsent(char 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(char 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(char key, CharCharUnaryOperator 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(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Char2CharAVLTreeMap extends AbstractChar2CharMap implements Char2Ch 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/chars/maps/impl/tree/Char2CharRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharRBTreeMap.java index 71ec201..d24412e 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2CharRBTreeMap.java @@ -445,6 +445,40 @@ public class Char2CharRBTreeMap extends AbstractChar2CharMap implements Char2Cha return newValue; } + @Override + public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(char 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(char key, CharCharUnaryOperator 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 computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Char2CharRBTreeMap extends AbstractChar2CharMap implements Char2Cha return newValue; } - @Override - public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,46 +516,24 @@ public class Char2CharRBTreeMap extends AbstractChar2CharMap implements Char2Cha return entry.value; } - @Override - public char supplyCharIfAbsent(char 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(char 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(char key, CharCharUnaryOperator 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(char key, CharCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1613,14 +1613,9 @@ public class Char2CharRBTreeMap extends AbstractChar2CharMap implements Char2Cha 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/chars/maps/impl/tree/Char2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleAVLTreeMap.java index 9affb84..200f4df 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2DoubleAVLTreeMap extends AbstractChar2DoubleMap implements Cha return newValue; } + @Override + public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(char 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(char key, CharDoubleUnaryOperator 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 computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2DoubleAVLTreeMap extends AbstractChar2DoubleMap implements Cha return newValue; } - @Override - public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Char2DoubleAVLTreeMap extends AbstractChar2DoubleMap implements Cha return entry.value; } - @Override - public double supplyDoubleIfAbsent(char 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(char key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Char2DoubleAVLTreeMap extends AbstractChar2DoubleMap implements Cha return entry.value; } - @Override - public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator 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(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2DoubleAVLTreeMap extends AbstractChar2DoubleMap implements Cha 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/chars/maps/impl/tree/Char2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleRBTreeMap.java index da4d21d..d62da56 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2DoubleRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2DoubleRBTreeMap extends AbstractChar2DoubleMap implements Char return newValue; } + @Override + public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(char 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(char key, CharDoubleUnaryOperator 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 computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2DoubleRBTreeMap extends AbstractChar2DoubleMap implements Char return newValue; } - @Override - public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Char2DoubleRBTreeMap extends AbstractChar2DoubleMap implements Char return entry.value; } - @Override - public double supplyDoubleIfAbsent(char 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(char key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Char2DoubleRBTreeMap extends AbstractChar2DoubleMap implements Char return entry.value; } - @Override - public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator 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(char key, CharDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2DoubleRBTreeMap extends AbstractChar2DoubleMap implements Char 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/chars/maps/impl/tree/Char2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatAVLTreeMap.java index 36c88e4..fba16b8 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2FloatAVLTreeMap extends AbstractChar2FloatMap implements Char2 return newValue; } + @Override + public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(char 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(char key, CharFloatUnaryOperator 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 computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2FloatAVLTreeMap extends AbstractChar2FloatMap implements Char2 return newValue; } - @Override - public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Char2FloatAVLTreeMap extends AbstractChar2FloatMap implements Char2 return entry.value; } - @Override - public float supplyFloatIfAbsent(char 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(char 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(char key, CharFloatUnaryOperator 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(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2FloatAVLTreeMap extends AbstractChar2FloatMap implements Char2 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/chars/maps/impl/tree/Char2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatRBTreeMap.java index b3a5e74..b439296 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2FloatRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2FloatRBTreeMap extends AbstractChar2FloatMap implements Char2F return newValue; } + @Override + public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(char 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(char key, CharFloatUnaryOperator 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 computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2FloatRBTreeMap extends AbstractChar2FloatMap implements Char2F return newValue; } - @Override - public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Char2FloatRBTreeMap extends AbstractChar2FloatMap implements Char2F return entry.value; } - @Override - public float supplyFloatIfAbsent(char 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(char 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(char key, CharFloatUnaryOperator 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(char key, CharFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2FloatRBTreeMap extends AbstractChar2FloatMap implements Char2F 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/chars/maps/impl/tree/Char2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntAVLTreeMap.java index 34d3937..0e4c487 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2IntAVLTreeMap extends AbstractChar2IntMap implements Char2IntN return newValue; } + @Override + public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(char 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(char key, CharIntUnaryOperator 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 computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2IntAVLTreeMap extends AbstractChar2IntMap implements Char2IntN return newValue; } - @Override - public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Char2IntAVLTreeMap extends AbstractChar2IntMap implements Char2IntN return entry.value; } - @Override - public int supplyIntIfAbsent(char 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(char key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Char2IntAVLTreeMap extends AbstractChar2IntMap implements Char2IntN return entry.value; } - @Override - public int computeIntIfPresent(char key, CharIntUnaryOperator 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(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2IntAVLTreeMap extends AbstractChar2IntMap implements Char2IntN 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/chars/maps/impl/tree/Char2IntRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntRBTreeMap.java index 5179222..c5581d6 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2IntRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2IntRBTreeMap extends AbstractChar2IntMap implements Char2IntNa return newValue; } + @Override + public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(char 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(char key, CharIntUnaryOperator 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 computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2IntRBTreeMap extends AbstractChar2IntMap implements Char2IntNa return newValue; } - @Override - public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Char2IntRBTreeMap extends AbstractChar2IntMap implements Char2IntNa return entry.value; } - @Override - public int supplyIntIfAbsent(char 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(char key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Char2IntRBTreeMap extends AbstractChar2IntMap implements Char2IntNa return entry.value; } - @Override - public int computeIntIfPresent(char key, CharIntUnaryOperator 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(char key, CharIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2IntRBTreeMap extends AbstractChar2IntMap implements Char2IntNa 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/chars/maps/impl/tree/Char2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongAVLTreeMap.java index a1fff5a..233d69f 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2LongAVLTreeMap extends AbstractChar2LongMap implements Char2Lo return newValue; } + @Override + public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(char 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(char key, CharLongUnaryOperator 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 computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2LongAVLTreeMap extends AbstractChar2LongMap implements Char2Lo return newValue; } - @Override - public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Char2LongAVLTreeMap extends AbstractChar2LongMap implements Char2Lo return entry.value; } - @Override - public long supplyLongIfAbsent(char 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(char key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Char2LongAVLTreeMap extends AbstractChar2LongMap implements Char2Lo return entry.value; } - @Override - public long computeLongIfPresent(char key, CharLongUnaryOperator 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(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2LongAVLTreeMap extends AbstractChar2LongMap implements Char2Lo 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/chars/maps/impl/tree/Char2LongRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongRBTreeMap.java index 4198f88..f2cd6e6 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2LongRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2LongRBTreeMap extends AbstractChar2LongMap implements Char2Lon return newValue; } + @Override + public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(char 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(char key, CharLongUnaryOperator 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 computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2LongRBTreeMap extends AbstractChar2LongMap implements Char2Lon return newValue; } - @Override - public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Char2LongRBTreeMap extends AbstractChar2LongMap implements Char2Lon return entry.value; } - @Override - public long supplyLongIfAbsent(char 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(char key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Char2LongRBTreeMap extends AbstractChar2LongMap implements Char2Lon return entry.value; } - @Override - public long computeLongIfPresent(char key, CharLongUnaryOperator 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(char key, CharLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2LongRBTreeMap extends AbstractChar2LongMap implements Char2Lon 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/chars/maps/impl/tree/Char2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectAVLTreeMap.java index 3036935..d6ec056 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectAVLTreeMap.java @@ -395,25 +395,6 @@ public class Char2ObjectAVLTreeMap extends AbstractChar2ObjectMap implemen return newValue; } - @Override - public V computeNonDefault(char key, CharObjectUnaryOperator 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(char key, CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -432,24 +413,6 @@ public class Char2ObjectAVLTreeMap extends AbstractChar2ObjectMap implemen return entry.value; } - @Override - public V computeIfAbsentNonDefault(char key, CharFunction 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(char key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -468,24 +431,6 @@ public class Char2ObjectAVLTreeMap extends AbstractChar2ObjectMap implemen return entry.value; } - @Override - public V supplyIfAbsentNonDefault(char 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(char key, CharObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -500,20 +445,6 @@ public class Char2ObjectAVLTreeMap extends AbstractChar2ObjectMap implemen return newValue; } - @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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(char key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectRBTreeMap.java index 4093277..c4d94cf 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ObjectRBTreeMap.java @@ -394,25 +394,6 @@ public class Char2ObjectRBTreeMap extends AbstractChar2ObjectMap implement return newValue; } - @Override - public V computeNonDefault(char key, CharObjectUnaryOperator 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(char key, CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Char2ObjectRBTreeMap extends AbstractChar2ObjectMap implement return entry.value; } - @Override - public V computeIfAbsentNonDefault(char key, CharFunction 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(char key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Char2ObjectRBTreeMap extends AbstractChar2ObjectMap implement return entry.value; } - @Override - public V supplyIfAbsentNonDefault(char 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(char key, CharObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Char2ObjectRBTreeMap extends AbstractChar2ObjectMap implement return newValue; } - @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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(char key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortAVLTreeMap.java index 55570ca..4ad1975 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortAVLTreeMap.java @@ -454,6 +454,40 @@ public class Char2ShortAVLTreeMap extends AbstractChar2ShortMap implements Char2 return newValue; } + @Override + public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(char 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(char key, CharShortUnaryOperator 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 computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Char2ShortAVLTreeMap extends AbstractChar2ShortMap implements Char2 return newValue; } - @Override - public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Char2ShortAVLTreeMap extends AbstractChar2ShortMap implements Char2 return entry.value; } - @Override - public short supplyShortIfAbsent(char 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(char 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(char key, CharShortUnaryOperator 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(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Char2ShortAVLTreeMap extends AbstractChar2ShortMap implements Char2 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/chars/maps/impl/tree/Char2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortRBTreeMap.java index ec4944a..7edd274 100644 --- a/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/impl/tree/Char2ShortRBTreeMap.java @@ -453,6 +453,40 @@ public class Char2ShortRBTreeMap extends AbstractChar2ShortMap implements Char2S return newValue; } + @Override + public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(char 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(char key, CharShortUnaryOperator 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 computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Char2ShortRBTreeMap extends AbstractChar2ShortMap implements Char2S return newValue; } - @Override - public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Char2ShortRBTreeMap extends AbstractChar2ShortMap implements Char2S return entry.value; } - @Override - public short supplyShortIfAbsent(char 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(char 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(char key, CharShortUnaryOperator 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(char key, CharShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Char2ShortRBTreeMap extends AbstractChar2ShortMap implements Char2S 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/chars/maps/interfaces/Char2BooleanMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2BooleanMap.java index 0e9c4ee..6c89a5c 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2BooleanMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2BooleanMap.java @@ -283,15 +283,6 @@ public interface Char2BooleanMap extends Map, CharPredicate * @return the result of the computation */ public boolean computeBoolean(char key, CharBooleanUnaryOperator 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 boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Char2BooleanMap extends Map, CharPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(char key, CharPredicate 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". + * 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 boolean supplyBooleanIfAbsent(char 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(char key, CharBooleanUnaryOperator 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 boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Char2BooleanMap extends Map, CharPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate 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". - * 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 boolean supplyBooleanIfAbsent(char key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Char2BooleanMap extends Map, CharPredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(char 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(char key, CharBooleanUnaryOperator 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/chars/maps/interfaces/Char2ByteMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ByteMap.java index eeb5e62..8ca7198 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ByteMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ByteMap.java @@ -308,15 +308,6 @@ public interface Char2ByteMap extends Map, Char2ByteFunction * @return the result of the computation */ public byte computeByte(char key, CharByteUnaryOperator 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 byte computeByteNonDefault(char key, CharByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2ByteMap extends Map, Char2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(char key, Char2ByteFunction 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". + * 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 byte supplyByteIfAbsent(char 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(char key, CharByteUnaryOperator 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 byte computeByteNonDefault(char key, CharByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2ByteMap extends Map, Char2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction 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". - * 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 byte supplyByteIfAbsent(char key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Char2ByteMap extends Map, Char2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(char 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(char key, CharByteUnaryOperator 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/chars/maps/interfaces/Char2CharMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2CharMap.java index c2d970a..91294f6 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2CharMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2CharMap.java @@ -307,15 +307,6 @@ public interface Char2CharMap extends Map, CharUnaryOperat * @return the result of the computation */ public char computeChar(char key, CharCharUnaryOperator 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 char computeCharNonDefault(char key, CharCharUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Char2CharMap extends Map, CharUnaryOperat * @return the result of the computed value or present value */ public char computeCharIfAbsent(char key, CharUnaryOperator 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". + * 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 char supplyCharIfAbsent(char 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(char key, CharCharUnaryOperator 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 char computeCharNonDefault(char key, CharCharUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Char2CharMap extends Map, CharUnaryOperat * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator 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". - * 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 char supplyCharIfAbsent(char key, CharSupplier 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". @@ -352,16 +362,6 @@ public interface Char2CharMap extends Map, CharUnaryOperat * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(char 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(char key, CharCharUnaryOperator 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/chars/maps/interfaces/Char2DoubleMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2DoubleMap.java index a4f6dc7..9e748a7 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2DoubleMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2DoubleMap.java @@ -308,15 +308,6 @@ public interface Char2DoubleMap extends Map, Char2DoubleFunct * @return the result of the computation */ public double computeDouble(char key, CharDoubleUnaryOperator 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 double computeDoubleNonDefault(char key, CharDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2DoubleMap extends Map, Char2DoubleFunct * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(char key, Char2DoubleFunction 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". + * 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 double supplyDoubleIfAbsent(char 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(char key, CharDoubleUnaryOperator 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 double computeDoubleNonDefault(char key, CharDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2DoubleMap extends Map, Char2DoubleFunct * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction 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". - * 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 double supplyDoubleIfAbsent(char key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Char2DoubleMap extends Map, Char2DoubleFunct * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(char 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(char key, CharDoubleUnaryOperator 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/chars/maps/interfaces/Char2FloatMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2FloatMap.java index f7e6f27..51e1922 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2FloatMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2FloatMap.java @@ -308,15 +308,6 @@ public interface Char2FloatMap extends Map, Char2FloatFunction * @return the result of the computation */ public float computeFloat(char key, CharFloatUnaryOperator 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 float computeFloatNonDefault(char key, CharFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2FloatMap extends Map, Char2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(char key, Char2FloatFunction 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". + * 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 float supplyFloatIfAbsent(char 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(char key, CharFloatUnaryOperator 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 float computeFloatNonDefault(char key, CharFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2FloatMap extends Map, Char2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction 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". - * 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 float supplyFloatIfAbsent(char key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Char2FloatMap extends Map, Char2FloatFunction * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(char 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(char key, CharFloatUnaryOperator 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/chars/maps/interfaces/Char2IntMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2IntMap.java index e782a7b..11f4f8e 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2IntMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2IntMap.java @@ -308,15 +308,6 @@ public interface Char2IntMap extends Map, Char2IntFunction * @return the result of the computation */ public int computeInt(char key, CharIntUnaryOperator 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 int computeIntNonDefault(char key, CharIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2IntMap extends Map, Char2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(char key, Char2IntFunction 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". + * 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 int supplyIntIfAbsent(char 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(char key, CharIntUnaryOperator 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 int computeIntNonDefault(char key, CharIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2IntMap extends Map, Char2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(char key, Char2IntFunction 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". - * 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 int supplyIntIfAbsent(char key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Char2IntMap extends Map, Char2IntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(char 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(char key, CharIntUnaryOperator 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/chars/maps/interfaces/Char2LongMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2LongMap.java index 7c8a61a..597a9f1 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2LongMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2LongMap.java @@ -308,15 +308,6 @@ public interface Char2LongMap extends Map, Char2LongFunction * @return the result of the computation */ public long computeLong(char key, CharLongUnaryOperator 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 long computeLongNonDefault(char key, CharLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2LongMap extends Map, Char2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(char key, Char2LongFunction 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". + * 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 long supplyLongIfAbsent(char 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(char key, CharLongUnaryOperator 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 long computeLongNonDefault(char key, CharLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2LongMap extends Map, Char2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(char key, Char2LongFunction 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". - * 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 long supplyLongIfAbsent(char key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Char2LongMap extends Map, Char2LongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(char 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(char key, CharLongUnaryOperator 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/chars/maps/interfaces/Char2ObjectMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ObjectMap.java index df3fe69..6f8ad97 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ObjectMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ObjectMap.java @@ -266,15 +266,6 @@ public interface Char2ObjectMap extends Map, CharFunction * @return the result of the computation */ public V compute(char key, CharObjectUnaryOperator 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(char key, CharObjectUnaryOperator 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 interface Char2ObjectMap extends Map, CharFunction * @return the result of the computed value or present value */ public V computeIfAbsent(char key, CharFunction 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(char key, CharFunction 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 interface Char2ObjectMap extends Map, CharFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(char 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(char 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 interface Char2ObjectMap extends Map, CharFunction * @note if not present then compute is not executed */ public V computeIfPresent(char key, CharObjectUnaryOperator 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(char key, CharObjectUnaryOperator 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/chars/maps/interfaces/Char2ShortMap.java b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ShortMap.java index bff9e4f..36cf1c0 100644 --- a/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ShortMap.java +++ b/src/main/java/speiger/src/collections/chars/maps/interfaces/Char2ShortMap.java @@ -308,15 +308,6 @@ public interface Char2ShortMap extends Map, Char2ShortFunction * @return the result of the computation */ public short computeShort(char key, CharShortUnaryOperator 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 short computeShortNonDefault(char key, CharShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Char2ShortMap extends Map, Char2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(char key, Char2ShortFunction 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". + * 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 short supplyShortIfAbsent(char 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(char key, CharShortUnaryOperator 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 short computeShortNonDefault(char key, CharShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Char2ShortMap extends Map, Char2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction 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". - * 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 short supplyShortIfAbsent(char key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Char2ShortMap extends Map, Char2ShortFunction * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(char 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(char key, CharShortUnaryOperator 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/chars/queues/CharArrayFIFOQueue.java b/src/main/java/speiger/src/collections/chars/queues/CharArrayFIFOQueue.java index 9343567..fbd78a4 100644 --- a/src/main/java/speiger/src/collections/chars/queues/CharArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/chars/queues/CharArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class CharArrayFIFOQueue extends AbstractCharPriorityQueue implements Cha return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(char e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class CharIterators } } + private static class InfiniteIterator implements CharIterator + { + CharIterator iter; + CollectionWrapper looper = CharCollections.wrapper(); + int index = 0; + + public InfiniteIterator(CharIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public char nextChar() { + if(iter != null) { + if(iter.hasNext()) { + char value = iter.nextChar(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getChar((index++) % looper.size()); + } + + @Override + public void forEachRemaining(CharConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectCharConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements CharIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/chars/utils/CharLists.java b/src/main/java/speiger/src/collections/chars/utils/CharLists.java index 5123b67..f83a514 100644 --- a/src/main/java/speiger/src/collections/chars/utils/CharLists.java +++ b/src/main/java/speiger/src/collections/chars/utils/CharLists.java @@ -12,6 +12,7 @@ import speiger.src.collections.chars.collections.CharCollection; import speiger.src.collections.chars.functions.CharConsumer; import speiger.src.collections.chars.lists.AbstractCharList; import speiger.src.collections.chars.lists.CharList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.chars.lists.CharListIterator; import speiger.src.collections.utils.SanityChecks; @@ -317,6 +318,16 @@ public class CharLists return l.listIterator(index); } + @Override + public CharListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public CharListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public CharList subList(int from, int to) { return CharLists.synchronize(l.subList(from, to)); @@ -426,6 +437,16 @@ public class CharLists return CharIterators.unmodifiable(l.listIterator(index)); } + @Override + public CharListIterator indexedIterator(int...indecies) { + return CharIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public CharListIterator indexedIterator(IntList indecies) { + return CharIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public CharList subList(int from, int to) { return CharLists.unmodifiable(l.subList(from, to)); @@ -514,6 +535,16 @@ public class CharLists return CharIterators.empty(); } + @Override + public CharListIterator indexedIterator(int...indecies) { + return CharIterators.empty(); + } + + @Override + public CharListIterator indexedIterator(IntList indecies) { + return CharIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/chars/utils/CharPriorityQueues.java b/src/main/java/speiger/src/collections/chars/utils/CharPriorityQueues.java index 9247083..f3bfa68 100644 --- a/src/main/java/speiger/src/collections/chars/utils/CharPriorityQueues.java +++ b/src/main/java/speiger/src/collections/chars/utils/CharPriorityQueues.java @@ -89,6 +89,8 @@ public class CharPriorityQueues @Override public char peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(char e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(char e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(char e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2BooleanMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2BooleanMaps.java index b2343a4..fb7b871 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2BooleanMaps.java @@ -246,18 +246,18 @@ public class Char2BooleanMaps @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 computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { 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 computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(char key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Char2BooleanMaps @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 computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { 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 computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(char key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Char2BooleanMaps @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 computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { 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 computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(char key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Char2BooleanMaps @Override public boolean computeBoolean(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(char key, CharPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(char key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(char key, CharPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(char key, CharBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(char key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(char key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ByteMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ByteMaps.java index 796aea3..df14315 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ByteMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ByteMaps.java @@ -250,18 +250,18 @@ public class Char2ByteMaps @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 computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { 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 computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(char key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2ByteMaps @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 computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { 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 computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(char key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2ByteMaps @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 computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { 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 computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(char key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2ByteMaps @Override public byte computeByte(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(char key, Char2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(char key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(char key, Char2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(char key, CharByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(char key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(char key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2CharMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2CharMaps.java index 307550d..33ae0c7 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2CharMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2CharMaps.java @@ -249,18 +249,18 @@ public class Char2CharMaps @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 computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { 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 computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(char key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Char2CharMaps @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 computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { 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 computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(char key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Char2CharMaps @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 computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { 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 computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(char key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Char2CharMaps @Override public char computeChar(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(char key, CharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(char key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(char key, CharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(char key, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(char key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(char key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2DoubleMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2DoubleMaps.java index 60b77a0..89eac95 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2DoubleMaps.java @@ -250,18 +250,18 @@ public class Char2DoubleMaps @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 computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { 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 computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(char key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2DoubleMaps @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 computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { 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 computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(char key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2DoubleMaps @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 computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { 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 computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(char key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2DoubleMaps @Override public double computeDouble(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(char key, Char2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(char key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(char key, Char2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(char key, CharDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(char key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(char key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2FloatMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2FloatMaps.java index 49b5be4..87cbee7 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2FloatMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2FloatMaps.java @@ -250,18 +250,18 @@ public class Char2FloatMaps @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 computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { 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 computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(char key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2FloatMaps @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 computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { 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 computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(char key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2FloatMaps @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 computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { 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 computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(char key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2FloatMaps @Override public float computeFloat(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(char key, Char2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(char key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(char key, Char2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(char key, CharFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(char key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(char key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2IntMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2IntMaps.java index abda506..1ce34c3 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2IntMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2IntMaps.java @@ -250,18 +250,18 @@ public class Char2IntMaps @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 computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { 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 computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(char key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2IntMaps @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 computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { 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 computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(char key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2IntMaps @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 computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { 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 computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(char key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2IntMaps @Override public int computeInt(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(char key, Char2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(char key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(char key, Char2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(char key, CharIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(char key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(char key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2LongMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2LongMaps.java index 7c4944c..9c4be5b 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2LongMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2LongMaps.java @@ -250,18 +250,18 @@ public class Char2LongMaps @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 computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { 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 computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(char key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2LongMaps @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 computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { 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 computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(char key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2LongMaps @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 computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { 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 computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(char key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2LongMaps @Override public long computeLong(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(char key, Char2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(char key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(char key, Char2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(char key, CharLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(char key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(char key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ObjectMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ObjectMaps.java index b985de6..fc30692 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ObjectMaps.java @@ -266,20 +266,12 @@ public class Char2ObjectMaps @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 computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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 merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Char2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Char2ObjectMaps @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 computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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 merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Char2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Char2ObjectMaps @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 computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator 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 merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Char2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Char2ObjectMaps @Override public V compute(char key, CharObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(char key, CharObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(char key, CharFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(char key, CharFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(char key, CharObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(char key, CharObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(char key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(char key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(char key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Char2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ShortMaps.java b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ShortMaps.java index fa69134..ef65cc8 100644 --- a/src/main/java/speiger/src/collections/chars/utils/maps/Char2ShortMaps.java +++ b/src/main/java/speiger/src/collections/chars/utils/maps/Char2ShortMaps.java @@ -250,18 +250,18 @@ public class Char2ShortMaps @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 computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { 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 computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(char key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Char2ShortMaps @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 computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { 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 computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(char key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Char2ShortMaps @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 computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { 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 computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(char key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Char2ShortMaps @Override public short computeShort(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(char key, Char2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(char key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(char key, Char2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(char key, CharShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(char key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(char key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/lists/AbstractDoubleList.java b/src/main/java/speiger/src/collections/doubles/lists/AbstractDoubleList.java index e866815..a1ec7fe 100644 --- a/src/main/java/speiger/src/collections/doubles/lists/AbstractDoubleList.java +++ b/src/main/java/speiger/src/collections/doubles/lists/AbstractDoubleList.java @@ -12,6 +12,7 @@ import speiger.src.collections.doubles.collections.AbstractDoubleCollection; import speiger.src.collections.doubles.collections.DoubleCollection; import speiger.src.collections.doubles.collections.DoubleIterator; import speiger.src.collections.doubles.collections.DoubleSplititerator; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.doubles.utils.DoubleSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -205,13 +206,23 @@ public abstract class AbstractDoubleList extends AbstractDoubleCollection implem public DoubleListIterator listIterator() { return listIterator(0); } - + @Override public DoubleListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new DoubleListIter(index); } + @Override + public DoubleListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public DoubleListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add(0D); @@ -566,7 +577,153 @@ public abstract class AbstractDoubleList extends AbstractDoubleCollection implem } } } + + private class ListIndexedIterator implements DoubleListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public double nextDouble() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getDouble((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public double previousDouble() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getDouble((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(double e) { throw new UnsupportedOperationException(); } + + @Override + public void set(double e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractDoubleList.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 DoubleListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public double nextDouble() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getDouble((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public double previousDouble() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getDouble((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(double e) { throw new UnsupportedOperationException(); } + + @Override + public void set(double e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractDoubleList.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 DoubleListIter implements DoubleListIterator { int index; int lastReturned = -1; @@ -644,7 +801,7 @@ public abstract class AbstractDoubleList extends AbstractDoubleCollection implem 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/doubles/lists/DoubleList.java b/src/main/java/speiger/src/collections/doubles/lists/DoubleList.java index efdc5cc..8e209f5 100644 --- a/src/main/java/speiger/src/collections/doubles/lists/DoubleList.java +++ b/src/main/java/speiger/src/collections/doubles/lists/DoubleList.java @@ -14,6 +14,7 @@ import speiger.src.collections.ints.functions.consumer.IntDoubleConsumer; import speiger.src.collections.doubles.functions.DoubleComparator; import speiger.src.collections.doubles.utils.DoubleArrays; import speiger.src.collections.doubles.utils.DoubleLists; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.doubles.utils.DoubleSplititerators; /** @@ -341,6 +342,24 @@ public interface DoubleList extends DoubleCollection, List @Override public DoubleListIterator 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 DoubleListIterator 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 DoubleListIterator 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/doubles/maps/abstracts/AbstractDouble2BooleanMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2BooleanMap.java index 032c6d6..d9ac97e 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2BooleanMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2BooleanMap.java @@ -151,6 +151,39 @@ public abstract class AbstractDouble2BooleanMap extends AbstractMap i return newValue; } + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractDouble2ByteMap extends AbstractMap i return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractDouble2ByteMap extends AbstractMap i return value; } - @Override - public byte supplyByteIfAbsent(double 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(double 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 abstract class AbstractDouble2ByteMap extends AbstractMap i return value; } - @Override - public byte computeByteIfPresent(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2CharMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2CharMap.java index efadc09..d3f9d26 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2CharMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2CharMap.java @@ -157,6 +157,39 @@ public abstract class AbstractDouble2CharMap extends AbstractMap return newValue; } + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractDouble2FloatMap extends AbstractMap return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractDouble2FloatMap extends AbstractMap return value; } - @Override - public float supplyFloatIfAbsent(double 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(double 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 abstract class AbstractDouble2FloatMap extends AbstractMap return value; } - @Override - public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2IntMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2IntMap.java index 6af6370..944e121 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2IntMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2IntMap.java @@ -157,6 +157,39 @@ public abstract class AbstractDouble2IntMap extends AbstractMap return newValue; } + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(double 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(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractDouble2IntMap extends AbstractMap return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractDouble2IntMap extends AbstractMap return value; } - @Override - public int supplyIntIfAbsent(double 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(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractDouble2IntMap extends AbstractMap return value; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2LongMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2LongMap.java index 7825251..abdbc5e 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2LongMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2LongMap.java @@ -157,6 +157,39 @@ public abstract class AbstractDouble2LongMap extends AbstractMap i return newValue; } + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(double 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(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractDouble2LongMap extends AbstractMap i return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractDouble2LongMap extends AbstractMap i return value; } - @Override - public long supplyLongIfAbsent(double 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(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractDouble2LongMap extends AbstractMap i return value; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ObjectMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ObjectMap.java index 9265ea0..7cc1df0 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ObjectMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ObjectMap.java @@ -159,22 +159,6 @@ public abstract class AbstractDouble2ObjectMap extends AbstractMap return newValue; } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -189,20 +173,6 @@ public abstract class AbstractDouble2ObjectMap extends AbstractMap return value; } - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,20 +187,6 @@ public abstract class AbstractDouble2ObjectMap extends AbstractMap return value; } - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -246,21 +202,6 @@ public abstract class AbstractDouble2ObjectMap extends AbstractMap return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ShortMap.java b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ShortMap.java index 51d2585..7aa3bb7 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ShortMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/abstracts/AbstractDouble2ShortMap.java @@ -157,6 +157,39 @@ public abstract class AbstractDouble2ShortMap extends AbstractMap return newValue; } + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractDouble2ShortMap extends AbstractMap return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractDouble2ShortMap extends AbstractMap return value; } - @Override - public short supplyShortIfAbsent(double 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(double 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 abstract class AbstractDouble2ShortMap extends AbstractMap return value; } - @Override - public short computeShortIfPresent(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2BooleanConcurrentOpenHashMap.java index 941cc28..06286dc 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2BooleanConcurrentOpenHashMap.java @@ -438,13 +438,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,6 +445,27 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,13 +473,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,13 +480,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2032,6 +2032,54 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM } } + protected boolean computeIfAbsent(int hash, double key, DoublePredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, double key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, double key, DoubleBooleanUnaryOperator 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 computeNonDefault(int hash, double key, DoubleBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2055,23 +2103,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM } } - protected boolean computeIfAbsent(int hash, double key, DoublePredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, double key, DoublePredicate mappingFunction) { long stamp = writeLock(); try { @@ -2095,23 +2126,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM } } - protected boolean supplyIfAbsent(int hash, double key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, double key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2135,20 +2149,6 @@ public class Double2BooleanConcurrentOpenHashMap extends AbstractDouble2BooleanM } } - protected boolean computeIfPresent(int hash, double key, DoubleBooleanUnaryOperator 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, double key, DoubleBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ByteConcurrentOpenHashMap.java index 54cae6f..cff0945 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ByteConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp } } + protected byte computeIfAbsent(int hash, double key, Double2ByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, double key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, double key, DoubleByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, double key, DoubleByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp } } - protected byte computeIfAbsent(int hash, double key, Double2ByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, double key, Double2ByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp } } - protected byte supplyIfAbsent(int hash, double key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, double key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Double2ByteConcurrentOpenHashMap extends AbstractDouble2ByteMap imp } } - protected byte computeIfPresent(int hash, double key, DoubleByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, double key, DoubleByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2CharConcurrentOpenHashMap.java index 198ea3e..bd56d34 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2CharConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp } } + protected char computeIfAbsent(int hash, double key, Double2CharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, double key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, double key, DoubleCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, double key, DoubleCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp } } - protected char computeIfAbsent(int hash, double key, Double2CharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, double key, Double2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp } } - protected char supplyIfAbsent(int hash, double key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, double key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Double2CharConcurrentOpenHashMap extends AbstractDouble2CharMap imp } } - protected char computeIfPresent(int hash, double key, DoubleCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, double key, DoubleCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2DoubleConcurrentOpenHashMap.java index d5d5ad0..b9b91f4 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2DoubleConcurrentOpenHashMap.java @@ -444,13 +444,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,6 +451,27 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,13 +479,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -479,13 +486,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2069,6 +2069,54 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap } } + protected double computeIfAbsent(int hash, double key, DoubleUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, double key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, double key, DoubleDoubleUnaryOperator 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 computeNonDefault(int hash, double key, DoubleDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2092,23 +2140,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap } } - protected double computeIfAbsent(int hash, double key, DoubleUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, double key, DoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2132,23 +2163,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap } } - protected double supplyIfAbsent(int hash, double key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, double key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2172,20 +2186,6 @@ public class Double2DoubleConcurrentOpenHashMap extends AbstractDouble2DoubleMap } } - protected double computeIfPresent(int hash, double key, DoubleDoubleUnaryOperator 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, double key, DoubleDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2FloatConcurrentOpenHashMap.java index aa37c30..d3d912e 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2FloatConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i } } + protected float computeIfAbsent(int hash, double key, Double2FloatFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, double key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, double key, DoubleFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, double key, DoubleFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i } } - protected float computeIfAbsent(int hash, double key, Double2FloatFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, double key, Double2FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i } } - protected float supplyIfAbsent(int hash, double key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, double key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Double2FloatConcurrentOpenHashMap extends AbstractDouble2FloatMap i } } - protected float computeIfPresent(int hash, double key, DoubleFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, double key, DoubleFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2IntConcurrentOpenHashMap.java index 6281ac6..33c3b4a 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2IntConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple } } + protected int computeIfAbsent(int hash, double key, Double2IntFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, double key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, double key, DoubleIntUnaryOperator 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 computeNonDefault(int hash, double key, DoubleIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple } } - protected int computeIfAbsent(int hash, double key, Double2IntFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, double key, Double2IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple } } - protected int supplyIfAbsent(int hash, double key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, double key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Double2IntConcurrentOpenHashMap extends AbstractDouble2IntMap imple } } - protected int computeIfPresent(int hash, double key, DoubleIntUnaryOperator 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, double key, DoubleIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2LongConcurrentOpenHashMap.java index 7d2cb49..cd7442f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2LongConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp } } + protected long computeIfAbsent(int hash, double key, Double2LongFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, double key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, double key, DoubleLongUnaryOperator 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 computeNonDefault(int hash, double key, DoubleLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp } } - protected long computeIfAbsent(int hash, double key, Double2LongFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, double key, Double2LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp } } - protected long supplyIfAbsent(int hash, double key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, double key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Double2LongConcurrentOpenHashMap extends AbstractDouble2LongMap imp } } - protected long computeIfPresent(int hash, double key, DoubleLongUnaryOperator 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, double key, DoubleLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ObjectConcurrentOpenHashMap.java index 15a112a..4beff51 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ObjectConcurrentOpenHashMap.java @@ -426,13 +426,6 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,13 +433,6 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -454,13 +440,6 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,13 +447,6 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2011,29 +1983,6 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object } } - protected V computeNonDefault(int hash, double key, DoubleObjectUnaryOperator 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, double key, DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2056,30 +2005,7 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, double key, DoubleFunction 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, double key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -2102,30 +2028,7 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, double 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, double key, DoubleObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2144,11 +2047,16 @@ public class Double2ObjectConcurrentOpenHashMap extends AbstractDouble2Object } } - protected V computeIfPresentNonDefault(int hash, double key, DoubleObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, double key, DoubleObjectUnaryOperator 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/doubles/maps/impl/concurrent/Double2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ShortConcurrentOpenHashMap.java index 956bb6e..745f24f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/concurrent/Double2ShortConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i } } + protected short computeIfAbsent(int hash, double key, Double2ShortFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, double key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, double key, DoubleShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, double key, DoubleShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i } } - protected short computeIfAbsent(int hash, double key, Double2ShortFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, double key, Double2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i } } - protected short supplyIfAbsent(int hash, double key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, double key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Double2ShortConcurrentOpenHashMap extends AbstractDouble2ShortMap i } } - protected short computeIfPresent(int hash, double key, DoubleShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, double key, DoubleShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2BooleanOpenCustomHashMap.java index 9a8063c..07cd964 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2BooleanOpenCustomHashMap.java @@ -440,6 +440,42 @@ public class Double2BooleanOpenCustomHashMap extends AbstractDouble2BooleanMap i return newValue; } + @Override + public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Double2BooleanOpenCustomHashMap extends AbstractDouble2BooleanMap i return newValue; } - @Override - public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Double2BooleanOpenCustomHashMap extends AbstractDouble2BooleanMap i return newValue; } - @Override - public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Double2BooleanOpenCustomHashMap extends AbstractDouble2BooleanMap i return newValue; } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ByteOpenCustomHashMap.java index 29218b6..0d94dd4 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ByteOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2ByteOpenCustomHashMap extends AbstractDouble2ByteMap impleme return newValue; } + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2ByteOpenCustomHashMap extends AbstractDouble2ByteMap impleme return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Double2ByteOpenCustomHashMap extends AbstractDouble2ByteMap impleme return newValue; } - @Override - public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2CharOpenCustomHashMap.java index ea641d8..abd4083 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2CharOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2CharOpenCustomHashMap extends AbstractDouble2CharMap impleme return newValue; } + @Override + public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2CharOpenCustomHashMap extends AbstractDouble2CharMap impleme return newValue; } - @Override - public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Double2CharOpenCustomHashMap extends AbstractDouble2CharMap impleme return newValue; } - @Override - public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(double 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(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2DoubleOpenCustomHashMap.java index b1d2b5d..e127a3c 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2DoubleOpenCustomHashMap.java @@ -454,6 +454,42 @@ public class Double2DoubleOpenCustomHashMap extends AbstractDouble2DoubleMap imp return newValue; } + @Override + public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Double2DoubleOpenCustomHashMap extends AbstractDouble2DoubleMap imp return newValue; } - @Override - public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,19 +528,6 @@ public class Double2DoubleOpenCustomHashMap extends AbstractDouble2DoubleMap imp return newValue; } - @Override - public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -537,16 +547,6 @@ public class Double2DoubleOpenCustomHashMap extends AbstractDouble2DoubleMap imp return newValue; } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2FloatOpenCustomHashMap.java index e368dc8..b1a1f2a 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2FloatOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2FloatOpenCustomHashMap extends AbstractDouble2FloatMap imple return newValue; } + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2FloatOpenCustomHashMap extends AbstractDouble2FloatMap imple return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Double2FloatOpenCustomHashMap extends AbstractDouble2FloatMap imple return newValue; } - @Override - public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2IntOpenCustomHashMap.java index 35370bf..c05505e 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2IntOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2IntOpenCustomHashMap extends AbstractDouble2IntMap implement return newValue; } + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2IntOpenCustomHashMap extends AbstractDouble2IntMap implement return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Double2IntOpenCustomHashMap extends AbstractDouble2IntMap implement return newValue; } - @Override - public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Double2IntOpenCustomHashMap extends AbstractDouble2IntMap implement return newValue; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2LongOpenCustomHashMap.java index 5d1a2a7..993e742 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2LongOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2LongOpenCustomHashMap extends AbstractDouble2LongMap impleme return newValue; } + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2LongOpenCustomHashMap extends AbstractDouble2LongMap impleme return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Double2LongOpenCustomHashMap extends AbstractDouble2LongMap impleme return newValue; } - @Override - public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Double2LongOpenCustomHashMap extends AbstractDouble2LongMap impleme return newValue; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ObjectOpenCustomHashMap.java index 0f64a01..0b5d7e7 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ObjectOpenCustomHashMap.java @@ -432,25 +432,6 @@ public class Double2ObjectOpenCustomHashMap extends AbstractDouble2ObjectMap< return newValue; } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -469,26 +450,7 @@ public class Double2ObjectOpenCustomHashMap extends AbstractDouble2ObjectMap< } return newValue; } - - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,25 +470,6 @@ public class Double2ObjectOpenCustomHashMap extends AbstractDouble2ObjectMap< return newValue; } - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -541,20 +484,6 @@ public class Double2ObjectOpenCustomHashMap extends AbstractDouble2ObjectMap< return newValue; } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ShortOpenCustomHashMap.java index 932e483..de38908 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/customHash/Double2ShortOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Double2ShortOpenCustomHashMap extends AbstractDouble2ShortMap imple return newValue; } + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Double2ShortOpenCustomHashMap extends AbstractDouble2ShortMap imple return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Double2ShortOpenCustomHashMap extends AbstractDouble2ShortMap imple return newValue; } - @Override - public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2BooleanOpenHashMap.java index a8afb4e..9bb6588 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2BooleanOpenHashMap.java @@ -408,6 +408,42 @@ public class Double2BooleanOpenHashMap extends AbstractDouble2BooleanMap impleme values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Double2BooleanOpenHashMap extends AbstractDouble2BooleanMap impleme return newValue; } - @Override - public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Double2BooleanOpenHashMap extends AbstractDouble2BooleanMap impleme return newValue; } - @Override - public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Double2BooleanOpenHashMap extends AbstractDouble2BooleanMap impleme return newValue; } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ByteOpenHashMap.java index 62aafcf..2d8c579 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ByteOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2ByteOpenHashMap extends AbstractDouble2ByteMap implements IT values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2ByteOpenHashMap extends AbstractDouble2ByteMap implements IT return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Double2ByteOpenHashMap extends AbstractDouble2ByteMap implements IT return newValue; } - @Override - public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2CharOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2CharOpenHashMap.java index 692bfab..fb8d46b 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2CharOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2CharOpenHashMap extends AbstractDouble2CharMap implements IT values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2CharOpenHashMap extends AbstractDouble2CharMap implements IT return newValue; } - @Override - public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Double2CharOpenHashMap extends AbstractDouble2CharMap implements IT return newValue; } - @Override - public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(double 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(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2DoubleOpenHashMap.java index 9ed1e1d..d84466d 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2DoubleOpenHashMap.java @@ -424,6 +424,42 @@ public class Double2DoubleOpenHashMap extends AbstractDouble2DoubleMap implement values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Double2DoubleOpenHashMap extends AbstractDouble2DoubleMap implement return newValue; } - @Override - public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,19 +499,6 @@ public class Double2DoubleOpenHashMap extends AbstractDouble2DoubleMap implement return newValue; } - @Override - public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,16 +518,6 @@ public class Double2DoubleOpenHashMap extends AbstractDouble2DoubleMap implement return newValue; } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2FloatOpenHashMap.java index cb14331..481ba54 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2FloatOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2FloatOpenHashMap extends AbstractDouble2FloatMap implements values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2FloatOpenHashMap extends AbstractDouble2FloatMap implements return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Double2FloatOpenHashMap extends AbstractDouble2FloatMap implements return newValue; } - @Override - public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2IntOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2IntOpenHashMap.java index 0b82696..4678e7b 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2IntOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2IntOpenHashMap extends AbstractDouble2IntMap implements ITri values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2IntOpenHashMap extends AbstractDouble2IntMap implements ITri return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Double2IntOpenHashMap extends AbstractDouble2IntMap implements ITri return newValue; } - @Override - public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Double2IntOpenHashMap extends AbstractDouble2IntMap implements ITri return newValue; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2LongOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2LongOpenHashMap.java index a793263..5b3cbaa 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2LongOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2LongOpenHashMap extends AbstractDouble2LongMap implements IT values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2LongOpenHashMap extends AbstractDouble2LongMap implements IT return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Double2LongOpenHashMap extends AbstractDouble2LongMap implements IT return newValue; } - @Override - public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Double2LongOpenHashMap extends AbstractDouble2LongMap implements IT return newValue; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ObjectOpenHashMap.java index 9a74c8f..5fd9897 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ObjectOpenHashMap.java @@ -401,26 +401,7 @@ public class Double2ObjectOpenHashMap extends AbstractDouble2ObjectMap imp values[index] = newValue; return newValue; } - - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,25 +421,6 @@ public class Double2ObjectOpenHashMap extends AbstractDouble2ObjectMap imp return newValue; } - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -477,26 +439,7 @@ public class Double2ObjectOpenHashMap extends AbstractDouble2ObjectMap imp } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -511,20 +454,6 @@ public class Double2ObjectOpenHashMap extends AbstractDouble2ObjectMap imp return newValue; } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ShortOpenHashMap.java index e0d401d..321957e 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/hash/Double2ShortOpenHashMap.java @@ -430,6 +430,42 @@ public class Double2ShortOpenHashMap extends AbstractDouble2ShortMap implements values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Double2ShortOpenHashMap extends AbstractDouble2ShortMap implements return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Double2ShortOpenHashMap extends AbstractDouble2ShortMap implements return newValue; } - @Override - public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2BooleanOpenHashMap.java index 11f3e57..bb78289 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2BooleanOpenHashMap.java @@ -413,20 +413,19 @@ public class ImmutableDouble2BooleanOpenHashMap extends AbstractDouble2BooleanMa @Override public boolean computeBoolean(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(double key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ByteOpenHashMap.java index 85f7535..20c5d0b 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ByteOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2ByteOpenHashMap extends AbstractDouble2ByteMap impl @Override public byte computeByte(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(double key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2CharOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2CharOpenHashMap.java index 8ef4ed6..71ef200 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2CharOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2CharOpenHashMap extends AbstractDouble2CharMap impl @Override public char computeChar(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(double key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2DoubleOpenHashMap.java index 6c23258..ed25c4a 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2DoubleOpenHashMap.java @@ -409,20 +409,19 @@ public class ImmutableDouble2DoubleOpenHashMap extends AbstractDouble2DoubleMap @Override public double computeDouble(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(double key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2FloatOpenHashMap.java index 6563d7c..4a52f97 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2FloatOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2FloatOpenHashMap extends AbstractDouble2FloatMap im @Override public float computeFloat(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(double key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2IntOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2IntOpenHashMap.java index 27a3bb8..a402acb 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2IntOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2IntOpenHashMap extends AbstractDouble2IntMap implem @Override public int computeInt(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(double key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2LongOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2LongOpenHashMap.java index 14dd6d0..9557acc 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2LongOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2LongOpenHashMap extends AbstractDouble2LongMap impl @Override public long computeLong(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(double key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ObjectOpenHashMap.java index fa2cdf6..090beaa 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ObjectOpenHashMap.java @@ -397,20 +397,11 @@ public class ImmutableDouble2ObjectOpenHashMap extends AbstractDouble2ObjectM @Override public V compute(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ShortOpenHashMap.java index c7067e7..5a03438 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/immutable/ImmutableDouble2ShortOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableDouble2ShortOpenHashMap extends AbstractDouble2ShortMap im @Override public short computeShort(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(double key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2BooleanArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2BooleanArrayMap.java index 03bf947..4484085 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2BooleanArrayMap.java @@ -419,6 +419,42 @@ public class Double2BooleanArrayMap extends AbstractDouble2BooleanMap implements return newValue; } + @Override + public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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 computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Double2BooleanArrayMap extends AbstractDouble2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Double2BooleanArrayMap extends AbstractDouble2BooleanMap implements return newValue; } - @Override - public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Double2BooleanArrayMap extends AbstractDouble2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ByteArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ByteArrayMap.java index 3415178..3f204f7 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ByteArrayMap.java @@ -442,6 +442,42 @@ public class Double2ByteArrayMap extends AbstractDouble2ByteMap implements Doubl return newValue; } + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(double key, DoubleByteUnaryOperator 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 computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2ByteArrayMap extends AbstractDouble2ByteMap implements Doubl return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Double2ByteArrayMap extends AbstractDouble2ByteMap implements Doubl return newValue; } - @Override - public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2CharArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2CharArrayMap.java index 65fad45..453105f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2CharArrayMap.java @@ -442,6 +442,42 @@ public class Double2CharArrayMap extends AbstractDouble2CharMap implements Doubl return newValue; } + @Override + public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(double key, DoubleCharUnaryOperator 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 computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2CharArrayMap extends AbstractDouble2CharMap implements Doubl return newValue; } - @Override - public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Double2CharArrayMap extends AbstractDouble2CharMap implements Doubl return newValue; } - @Override - public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(double 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(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2DoubleArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2DoubleArrayMap.java index 9081fc0..0f09fa0 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2DoubleArrayMap.java @@ -435,6 +435,42 @@ public class Double2DoubleArrayMap extends AbstractDouble2DoubleMap implements D return newValue; } + @Override + public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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 computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Double2DoubleArrayMap extends AbstractDouble2DoubleMap implements D return newValue; } - @Override - public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,19 +509,6 @@ public class Double2DoubleArrayMap extends AbstractDouble2DoubleMap implements D return newValue; } - @Override - public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -518,16 +528,6 @@ public class Double2DoubleArrayMap extends AbstractDouble2DoubleMap implements D return newValue; } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2FloatArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2FloatArrayMap.java index 54fd7d8..d5fdacc 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2FloatArrayMap.java @@ -442,6 +442,42 @@ public class Double2FloatArrayMap extends AbstractDouble2FloatMap implements Dou return newValue; } + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator 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 computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2FloatArrayMap extends AbstractDouble2FloatMap implements Dou return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Double2FloatArrayMap extends AbstractDouble2FloatMap implements Dou return newValue; } - @Override - public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2IntArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2IntArrayMap.java index 43fd893..b97624c 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2IntArrayMap.java @@ -442,6 +442,42 @@ public class Double2IntArrayMap extends AbstractDouble2IntMap implements Double2 return newValue; } + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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 computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2IntArrayMap extends AbstractDouble2IntMap implements Double2 return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Double2IntArrayMap extends AbstractDouble2IntMap implements Double2 return newValue; } - @Override - public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Double2IntArrayMap extends AbstractDouble2IntMap implements Double2 return newValue; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2LongArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2LongArrayMap.java index b023e64..ed949e9 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2LongArrayMap.java @@ -442,6 +442,42 @@ public class Double2LongArrayMap extends AbstractDouble2LongMap implements Doubl return newValue; } + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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 computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2LongArrayMap extends AbstractDouble2LongMap implements Doubl return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Double2LongArrayMap extends AbstractDouble2LongMap implements Doubl return newValue; } - @Override - public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Double2LongArrayMap extends AbstractDouble2LongMap implements Doubl return newValue; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ObjectArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ObjectArrayMap.java index 44cc9f1..383824f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ObjectArrayMap.java @@ -415,25 +415,6 @@ public class Double2ObjectArrayMap extends AbstractDouble2ObjectMap implem return newValue; } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,26 +433,7 @@ public class Double2ObjectArrayMap extends AbstractDouble2ObjectMap implem } return newValue; } - - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -490,26 +452,7 @@ public class Double2ObjectArrayMap extends AbstractDouble2ObjectMap implem } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -524,20 +467,6 @@ public class Double2ObjectArrayMap extends AbstractDouble2ObjectMap implem return newValue; } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ShortArrayMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ShortArrayMap.java index b5fd846..1c45eb9 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/misc/Double2ShortArrayMap.java @@ -442,6 +442,42 @@ public class Double2ShortArrayMap extends AbstractDouble2ShortMap implements Dou return newValue; } + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(double key, DoubleShortUnaryOperator 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 computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Double2ShortArrayMap extends AbstractDouble2ShortMap implements Dou return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Double2ShortArrayMap extends AbstractDouble2ShortMap implements Dou return newValue; } - @Override - public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanAVLTreeMap.java index eff5cec..ac6e582 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanAVLTreeMap.java @@ -395,6 +395,40 @@ public class Double2BooleanAVLTreeMap extends AbstractDouble2BooleanMap implemen return newValue; } + @Override + public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(double 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(double key, DoubleBooleanUnaryOperator 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 computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Double2BooleanAVLTreeMap extends AbstractDouble2BooleanMap implemen return newValue; } - @Override - public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Double2BooleanAVLTreeMap extends AbstractDouble2BooleanMap implemen return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(double 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(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,16 +484,6 @@ public class Double2BooleanAVLTreeMap extends AbstractDouble2BooleanMap implemen return entry.value; } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1487,14 +1487,9 @@ public class Double2BooleanAVLTreeMap extends AbstractDouble2BooleanMap implemen 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/doubles/maps/impl/tree/Double2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanRBTreeMap.java index 2339aa9..4142677 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2BooleanRBTreeMap.java @@ -394,6 +394,40 @@ public class Double2BooleanRBTreeMap extends AbstractDouble2BooleanMap implement return newValue; } + @Override + public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(double 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(double key, DoubleBooleanUnaryOperator 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 computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Double2BooleanRBTreeMap extends AbstractDouble2BooleanMap implement return newValue; } - @Override - public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Double2BooleanRBTreeMap extends AbstractDouble2BooleanMap implement return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(double 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(double key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Double2BooleanRBTreeMap extends AbstractDouble2BooleanMap implement return entry.value; } - @Override - public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator 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(double key, DoubleBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Double2BooleanRBTreeMap extends AbstractDouble2BooleanMap implement 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/doubles/maps/impl/tree/Double2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteAVLTreeMap.java index d4f51bd..bd4f3e8 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2ByteAVLTreeMap extends AbstractDouble2ByteMap implements Dou return newValue; } + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(double 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(double key, DoubleByteUnaryOperator 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 computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2ByteAVLTreeMap extends AbstractDouble2ByteMap implements Dou return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Double2ByteAVLTreeMap extends AbstractDouble2ByteMap implements Dou return entry.value; } - @Override - public byte supplyByteIfAbsent(double 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(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2ByteAVLTreeMap extends AbstractDouble2ByteMap implements Dou 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/doubles/maps/impl/tree/Double2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteRBTreeMap.java index 640bb3e..9af6023 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ByteRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2ByteRBTreeMap extends AbstractDouble2ByteMap implements Doub return newValue; } + @Override + public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(double 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(double key, DoubleByteUnaryOperator 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 computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2ByteRBTreeMap extends AbstractDouble2ByteMap implements Doub return newValue; } - @Override - public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Double2ByteRBTreeMap extends AbstractDouble2ByteMap implements Doub return entry.value; } - @Override - public byte supplyByteIfAbsent(double 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(double 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(double key, DoubleByteUnaryOperator 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(double key, DoubleByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2ByteRBTreeMap extends AbstractDouble2ByteMap implements Doub 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/doubles/maps/impl/tree/Double2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharAVLTreeMap.java index 2c1caed..af5a99c 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2CharAVLTreeMap extends AbstractDouble2CharMap implements Dou return newValue; } + @Override + public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(double 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(double key, DoubleCharUnaryOperator 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 computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2CharAVLTreeMap extends AbstractDouble2CharMap implements Dou return newValue; } - @Override - public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Double2CharAVLTreeMap extends AbstractDouble2CharMap implements Dou return entry.value; } - @Override - public char supplyCharIfAbsent(double 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(double 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(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2CharAVLTreeMap extends AbstractDouble2CharMap implements Dou 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/doubles/maps/impl/tree/Double2CharRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharRBTreeMap.java index 76ce3e0..905f2bf 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2CharRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2CharRBTreeMap extends AbstractDouble2CharMap implements Doub return newValue; } + @Override + public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(double 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(double key, DoubleCharUnaryOperator 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 computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2CharRBTreeMap extends AbstractDouble2CharMap implements Doub return newValue; } - @Override - public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Double2CharRBTreeMap extends AbstractDouble2CharMap implements Doub return entry.value; } - @Override - public char supplyCharIfAbsent(double 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(double 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(double key, DoubleCharUnaryOperator 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(double key, DoubleCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2CharRBTreeMap extends AbstractDouble2CharMap implements Doub 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/doubles/maps/impl/tree/Double2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleAVLTreeMap.java index cade7f4..2c312fe 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleAVLTreeMap.java @@ -446,6 +446,40 @@ public class Double2DoubleAVLTreeMap extends AbstractDouble2DoubleMap implements return newValue; } + @Override + public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(double 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(double key, DoubleDoubleUnaryOperator 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 computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Double2DoubleAVLTreeMap extends AbstractDouble2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,18 +517,6 @@ public class Double2DoubleAVLTreeMap extends AbstractDouble2DoubleMap implements return entry.value; } - @Override - public double supplyDoubleIfAbsent(double 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(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Double2DoubleAVLTreeMap extends AbstractDouble2DoubleMap implements return entry.value; } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Double2DoubleAVLTreeMap extends AbstractDouble2DoubleMap implements 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/doubles/maps/impl/tree/Double2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleRBTreeMap.java index f02200d..676ce58 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2DoubleRBTreeMap.java @@ -445,6 +445,40 @@ public class Double2DoubleRBTreeMap extends AbstractDouble2DoubleMap implements return newValue; } + @Override + public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(double 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(double key, DoubleDoubleUnaryOperator 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 computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Double2DoubleRBTreeMap extends AbstractDouble2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,18 +516,6 @@ public class Double2DoubleRBTreeMap extends AbstractDouble2DoubleMap implements return entry.value; } - @Override - public double supplyDoubleIfAbsent(double 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(double key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -524,16 +534,6 @@ public class Double2DoubleRBTreeMap extends AbstractDouble2DoubleMap implements return entry.value; } - @Override - public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator 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(double key, DoubleDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1613,14 +1613,9 @@ public class Double2DoubleRBTreeMap extends AbstractDouble2DoubleMap implements 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/doubles/maps/impl/tree/Double2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatAVLTreeMap.java index 38351e0..80c41b0 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2FloatAVLTreeMap extends AbstractDouble2FloatMap implements D return newValue; } + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(double 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(double key, DoubleFloatUnaryOperator 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 computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2FloatAVLTreeMap extends AbstractDouble2FloatMap implements D return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Double2FloatAVLTreeMap extends AbstractDouble2FloatMap implements D return entry.value; } - @Override - public float supplyFloatIfAbsent(double 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(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2FloatAVLTreeMap extends AbstractDouble2FloatMap implements D 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/doubles/maps/impl/tree/Double2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatRBTreeMap.java index acd4ee0..a21dc4f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2FloatRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2FloatRBTreeMap extends AbstractDouble2FloatMap implements Do return newValue; } + @Override + public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(double 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(double key, DoubleFloatUnaryOperator 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 computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2FloatRBTreeMap extends AbstractDouble2FloatMap implements Do return newValue; } - @Override - public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Double2FloatRBTreeMap extends AbstractDouble2FloatMap implements Do return entry.value; } - @Override - public float supplyFloatIfAbsent(double 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(double 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(double key, DoubleFloatUnaryOperator 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(double key, DoubleFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2FloatRBTreeMap extends AbstractDouble2FloatMap implements Do 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/doubles/maps/impl/tree/Double2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntAVLTreeMap.java index e4d3162..5e34797 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2IntAVLTreeMap extends AbstractDouble2IntMap implements Doubl return newValue; } + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(double 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(double key, DoubleIntUnaryOperator 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 computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2IntAVLTreeMap extends AbstractDouble2IntMap implements Doubl return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Double2IntAVLTreeMap extends AbstractDouble2IntMap implements Doubl return entry.value; } - @Override - public int supplyIntIfAbsent(double 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(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Double2IntAVLTreeMap extends AbstractDouble2IntMap implements Doubl return entry.value; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2IntAVLTreeMap extends AbstractDouble2IntMap implements Doubl 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/doubles/maps/impl/tree/Double2IntRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntRBTreeMap.java index fa20ce7..6897e52 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2IntRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2IntRBTreeMap extends AbstractDouble2IntMap implements Double return newValue; } + @Override + public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(double 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(double key, DoubleIntUnaryOperator 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 computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2IntRBTreeMap extends AbstractDouble2IntMap implements Double return newValue; } - @Override - public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Double2IntRBTreeMap extends AbstractDouble2IntMap implements Double return entry.value; } - @Override - public int supplyIntIfAbsent(double 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(double key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Double2IntRBTreeMap extends AbstractDouble2IntMap implements Double return entry.value; } - @Override - public int computeIntIfPresent(double key, DoubleIntUnaryOperator 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(double key, DoubleIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2IntRBTreeMap extends AbstractDouble2IntMap implements Double 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/doubles/maps/impl/tree/Double2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongAVLTreeMap.java index b9001bd..96e966f 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2LongAVLTreeMap extends AbstractDouble2LongMap implements Dou return newValue; } + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(double 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(double key, DoubleLongUnaryOperator 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 computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2LongAVLTreeMap extends AbstractDouble2LongMap implements Dou return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Double2LongAVLTreeMap extends AbstractDouble2LongMap implements Dou return entry.value; } - @Override - public long supplyLongIfAbsent(double 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(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Double2LongAVLTreeMap extends AbstractDouble2LongMap implements Dou return entry.value; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2LongAVLTreeMap extends AbstractDouble2LongMap implements Dou 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/doubles/maps/impl/tree/Double2LongRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongRBTreeMap.java index 872019d..3ee5cd0 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2LongRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2LongRBTreeMap extends AbstractDouble2LongMap implements Doub return newValue; } + @Override + public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(double 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(double key, DoubleLongUnaryOperator 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 computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2LongRBTreeMap extends AbstractDouble2LongMap implements Doub return newValue; } - @Override - public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Double2LongRBTreeMap extends AbstractDouble2LongMap implements Doub return entry.value; } - @Override - public long supplyLongIfAbsent(double 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(double key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Double2LongRBTreeMap extends AbstractDouble2LongMap implements Doub return entry.value; } - @Override - public long computeLongIfPresent(double key, DoubleLongUnaryOperator 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(double key, DoubleLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2LongRBTreeMap extends AbstractDouble2LongMap implements Doub 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/doubles/maps/impl/tree/Double2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectAVLTreeMap.java index f7e3b5d..ec5151d 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectAVLTreeMap.java @@ -395,25 +395,6 @@ public class Double2ObjectAVLTreeMap extends AbstractDouble2ObjectMap impl return newValue; } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -432,24 +413,6 @@ public class Double2ObjectAVLTreeMap extends AbstractDouble2ObjectMap impl return entry.value; } - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -468,24 +431,6 @@ public class Double2ObjectAVLTreeMap extends AbstractDouble2ObjectMap impl return entry.value; } - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -500,20 +445,6 @@ public class Double2ObjectAVLTreeMap extends AbstractDouble2ObjectMap impl return newValue; } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectRBTreeMap.java index 76a91d0..bd1b93b 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ObjectRBTreeMap.java @@ -394,25 +394,6 @@ public class Double2ObjectRBTreeMap extends AbstractDouble2ObjectMap imple return newValue; } - @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator 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(double key, DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Double2ObjectRBTreeMap extends AbstractDouble2ObjectMap imple return entry.value; } - @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction 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(double key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Double2ObjectRBTreeMap extends AbstractDouble2ObjectMap imple return entry.value; } - @Override - public V supplyIfAbsentNonDefault(double 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(double key, DoubleObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Double2ObjectRBTreeMap extends AbstractDouble2ObjectMap imple return newValue; } - @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator 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(double key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortAVLTreeMap.java index ff433d0..f58e437 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortAVLTreeMap.java @@ -454,6 +454,40 @@ public class Double2ShortAVLTreeMap extends AbstractDouble2ShortMap implements D return newValue; } + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(double 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(double key, DoubleShortUnaryOperator 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 computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Double2ShortAVLTreeMap extends AbstractDouble2ShortMap implements D return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Double2ShortAVLTreeMap extends AbstractDouble2ShortMap implements D return entry.value; } - @Override - public short supplyShortIfAbsent(double 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(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Double2ShortAVLTreeMap extends AbstractDouble2ShortMap implements D 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/doubles/maps/impl/tree/Double2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortRBTreeMap.java index e012677..419f430 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/impl/tree/Double2ShortRBTreeMap.java @@ -453,6 +453,40 @@ public class Double2ShortRBTreeMap extends AbstractDouble2ShortMap implements Do return newValue; } + @Override + public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(double 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(double key, DoubleShortUnaryOperator 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 computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Double2ShortRBTreeMap extends AbstractDouble2ShortMap implements Do return newValue; } - @Override - public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Double2ShortRBTreeMap extends AbstractDouble2ShortMap implements Do return entry.value; } - @Override - public short supplyShortIfAbsent(double 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(double 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(double key, DoubleShortUnaryOperator 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(double key, DoubleShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Double2ShortRBTreeMap extends AbstractDouble2ShortMap implements Do 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/doubles/maps/interfaces/Double2BooleanMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2BooleanMap.java index 039c840..7a5dc21 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2BooleanMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2BooleanMap.java @@ -283,15 +283,6 @@ public interface Double2BooleanMap extends Map, DoublePredicate * @return the result of the computation */ public boolean computeBoolean(double key, DoubleBooleanUnaryOperator 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 boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Double2BooleanMap extends Map, DoublePredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(double key, DoublePredicate 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". + * 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 boolean supplyBooleanIfAbsent(double 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(double key, DoubleBooleanUnaryOperator 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 boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Double2BooleanMap extends Map, DoublePredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate 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". - * 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 boolean supplyBooleanIfAbsent(double key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Double2BooleanMap extends Map, DoublePredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(double 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(double key, DoubleBooleanUnaryOperator 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/doubles/maps/interfaces/Double2ByteMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ByteMap.java index f040787..91dbf28 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ByteMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ByteMap.java @@ -308,15 +308,6 @@ public interface Double2ByteMap extends Map, Double2ByteFunction * @return the result of the computation */ public byte computeByte(double key, DoubleByteUnaryOperator 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 byte computeByteNonDefault(double key, DoubleByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2ByteMap extends Map, Double2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(double key, Double2ByteFunction 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". + * 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 byte supplyByteIfAbsent(double 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(double key, DoubleByteUnaryOperator 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 byte computeByteNonDefault(double key, DoubleByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2ByteMap extends Map, Double2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction 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". - * 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 byte supplyByteIfAbsent(double key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Double2ByteMap extends Map, Double2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(double 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(double key, DoubleByteUnaryOperator 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/doubles/maps/interfaces/Double2CharMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2CharMap.java index 3fcae9f..97d15e3 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2CharMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2CharMap.java @@ -308,15 +308,6 @@ public interface Double2CharMap extends Map, Double2CharFunct * @return the result of the computation */ public char computeChar(double key, DoubleCharUnaryOperator 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 char computeCharNonDefault(double key, DoubleCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2CharMap extends Map, Double2CharFunct * @return the result of the computed value or present value */ public char computeCharIfAbsent(double key, Double2CharFunction 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". + * 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 char supplyCharIfAbsent(double 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(double key, DoubleCharUnaryOperator 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 char computeCharNonDefault(double key, DoubleCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2CharMap extends Map, Double2CharFunct * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(double key, Double2CharFunction 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". - * 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 char supplyCharIfAbsent(double key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Double2CharMap extends Map, Double2CharFunct * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(double 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(double key, DoubleCharUnaryOperator 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/doubles/maps/interfaces/Double2DoubleMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2DoubleMap.java index 15f5cb3..f35a531 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2DoubleMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2DoubleMap.java @@ -307,15 +307,6 @@ public interface Double2DoubleMap extends Map, DoubleUnaryOperat * @return the result of the computation */ public double computeDouble(double key, DoubleDoubleUnaryOperator 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 double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Double2DoubleMap extends Map, DoubleUnaryOperat * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(double key, DoubleUnaryOperator 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". + * 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 double supplyDoubleIfAbsent(double 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(double key, DoubleDoubleUnaryOperator 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 double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Double2DoubleMap extends Map, DoubleUnaryOperat * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator 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". - * 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 double supplyDoubleIfAbsent(double key, DoubleSupplier 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". @@ -352,16 +362,6 @@ public interface Double2DoubleMap extends Map, DoubleUnaryOperat * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(double 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(double key, DoubleDoubleUnaryOperator 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/doubles/maps/interfaces/Double2FloatMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2FloatMap.java index a657739..8c6f502 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2FloatMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2FloatMap.java @@ -308,15 +308,6 @@ public interface Double2FloatMap extends Map, Double2FloatFunctio * @return the result of the computation */ public float computeFloat(double key, DoubleFloatUnaryOperator 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 float computeFloatNonDefault(double key, DoubleFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2FloatMap extends Map, Double2FloatFunctio * @return the result of the computed value or present value */ public float computeFloatIfAbsent(double key, Double2FloatFunction 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". + * 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 float supplyFloatIfAbsent(double 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(double key, DoubleFloatUnaryOperator 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 float computeFloatNonDefault(double key, DoubleFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2FloatMap extends Map, Double2FloatFunctio * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction 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". - * 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 float supplyFloatIfAbsent(double key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Double2FloatMap extends Map, Double2FloatFunctio * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(double 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(double key, DoubleFloatUnaryOperator 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/doubles/maps/interfaces/Double2IntMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2IntMap.java index 61039ef..1a79d67 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2IntMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2IntMap.java @@ -308,15 +308,6 @@ public interface Double2IntMap extends Map, Double2IntFunction * @return the result of the computation */ public int computeInt(double key, DoubleIntUnaryOperator 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 int computeIntNonDefault(double key, DoubleIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2IntMap extends Map, Double2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(double key, Double2IntFunction 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". + * 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 int supplyIntIfAbsent(double 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(double key, DoubleIntUnaryOperator 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 int computeIntNonDefault(double key, DoubleIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2IntMap extends Map, Double2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(double key, Double2IntFunction 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". - * 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 int supplyIntIfAbsent(double key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Double2IntMap extends Map, Double2IntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(double 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(double key, DoubleIntUnaryOperator 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/doubles/maps/interfaces/Double2LongMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2LongMap.java index 80924de..9db6cb3 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2LongMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2LongMap.java @@ -308,15 +308,6 @@ public interface Double2LongMap extends Map, Double2LongFunction * @return the result of the computation */ public long computeLong(double key, DoubleLongUnaryOperator 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 long computeLongNonDefault(double key, DoubleLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2LongMap extends Map, Double2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(double key, Double2LongFunction 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". + * 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 long supplyLongIfAbsent(double 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(double key, DoubleLongUnaryOperator 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 long computeLongNonDefault(double key, DoubleLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2LongMap extends Map, Double2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(double key, Double2LongFunction 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". - * 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 long supplyLongIfAbsent(double key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Double2LongMap extends Map, Double2LongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(double 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(double key, DoubleLongUnaryOperator 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/doubles/maps/interfaces/Double2ObjectMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ObjectMap.java index e4cb80c..52ff5d0 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ObjectMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ObjectMap.java @@ -266,15 +266,6 @@ public interface Double2ObjectMap extends Map, DoubleFunction * @return the result of the computation */ public V compute(double key, DoubleObjectUnaryOperator 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(double key, DoubleObjectUnaryOperator 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 interface Double2ObjectMap extends Map, DoubleFunction * @return the result of the computed value or present value */ public V computeIfAbsent(double key, DoubleFunction 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(double key, DoubleFunction 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 interface Double2ObjectMap extends Map, DoubleFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(double 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(double 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 interface Double2ObjectMap extends Map, DoubleFunction * @note if not present then compute is not executed */ public V computeIfPresent(double key, DoubleObjectUnaryOperator 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(double key, DoubleObjectUnaryOperator 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/doubles/maps/interfaces/Double2ShortMap.java b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ShortMap.java index f4a3cd5..e196423 100644 --- a/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ShortMap.java +++ b/src/main/java/speiger/src/collections/doubles/maps/interfaces/Double2ShortMap.java @@ -308,15 +308,6 @@ public interface Double2ShortMap extends Map, Double2ShortFunctio * @return the result of the computation */ public short computeShort(double key, DoubleShortUnaryOperator 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 short computeShortNonDefault(double key, DoubleShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Double2ShortMap extends Map, Double2ShortFunctio * @return the result of the computed value or present value */ public short computeShortIfAbsent(double key, Double2ShortFunction 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". + * 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 short supplyShortIfAbsent(double 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(double key, DoubleShortUnaryOperator 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 short computeShortNonDefault(double key, DoubleShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Double2ShortMap extends Map, Double2ShortFunctio * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction 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". - * 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 short supplyShortIfAbsent(double key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Double2ShortMap extends Map, Double2ShortFunctio * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(double 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(double key, DoubleShortUnaryOperator 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/doubles/queues/DoubleArrayFIFOQueue.java b/src/main/java/speiger/src/collections/doubles/queues/DoubleArrayFIFOQueue.java index 8d60339..f9ba1b3 100644 --- a/src/main/java/speiger/src/collections/doubles/queues/DoubleArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/doubles/queues/DoubleArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class DoubleArrayFIFOQueue extends AbstractDoublePriorityQueue implements return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(double e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class DoubleIterators } } + private static class InfiniteIterator implements DoubleIterator + { + DoubleIterator iter; + CollectionWrapper looper = DoubleCollections.wrapper(); + int index = 0; + + public InfiniteIterator(DoubleIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public double nextDouble() { + if(iter != null) { + if(iter.hasNext()) { + double value = iter.nextDouble(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getDouble((index++) % looper.size()); + } + + @Override + public void forEachRemaining(DoubleConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectDoubleConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements DoubleIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/doubles/utils/DoubleLists.java b/src/main/java/speiger/src/collections/doubles/utils/DoubleLists.java index 0361ba0..78e9432 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/DoubleLists.java +++ b/src/main/java/speiger/src/collections/doubles/utils/DoubleLists.java @@ -12,6 +12,7 @@ import speiger.src.collections.doubles.collections.DoubleCollection; import speiger.src.collections.doubles.functions.DoubleConsumer; import speiger.src.collections.doubles.lists.AbstractDoubleList; import speiger.src.collections.doubles.lists.DoubleList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.doubles.lists.DoubleListIterator; import speiger.src.collections.utils.SanityChecks; @@ -317,6 +318,16 @@ public class DoubleLists return l.listIterator(index); } + @Override + public DoubleListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public DoubleListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public DoubleList subList(int from, int to) { return DoubleLists.synchronize(l.subList(from, to)); @@ -426,6 +437,16 @@ public class DoubleLists return DoubleIterators.unmodifiable(l.listIterator(index)); } + @Override + public DoubleListIterator indexedIterator(int...indecies) { + return DoubleIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public DoubleListIterator indexedIterator(IntList indecies) { + return DoubleIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public DoubleList subList(int from, int to) { return DoubleLists.unmodifiable(l.subList(from, to)); @@ -514,6 +535,16 @@ public class DoubleLists return DoubleIterators.empty(); } + @Override + public DoubleListIterator indexedIterator(int...indecies) { + return DoubleIterators.empty(); + } + + @Override + public DoubleListIterator indexedIterator(IntList indecies) { + return DoubleIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/doubles/utils/DoublePriorityQueues.java b/src/main/java/speiger/src/collections/doubles/utils/DoublePriorityQueues.java index 6ecde3b..3bdba4b 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/DoublePriorityQueues.java +++ b/src/main/java/speiger/src/collections/doubles/utils/DoublePriorityQueues.java @@ -89,6 +89,8 @@ public class DoublePriorityQueues @Override public double peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(double e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(double e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(double e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2BooleanMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2BooleanMaps.java index 23bf6a0..541ec03 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2BooleanMaps.java @@ -246,18 +246,18 @@ public class Double2BooleanMaps @Override public boolean computeBoolean(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(double key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Double2BooleanMaps @Override public boolean computeBoolean(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(double key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Double2BooleanMaps @Override public boolean computeBoolean(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(double key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Double2BooleanMaps @Override public boolean computeBoolean(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(double key, DoublePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(double key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(double key, DoublePredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(double key, DoubleBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(double key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(double key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ByteMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ByteMaps.java index 1b5ca62..e47407f 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ByteMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ByteMaps.java @@ -250,18 +250,18 @@ public class Double2ByteMaps @Override public byte computeByte(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(double key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2ByteMaps @Override public byte computeByte(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(double key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2ByteMaps @Override public byte computeByte(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(double key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2ByteMaps @Override public byte computeByte(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(double key, Double2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(double key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(double key, Double2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(double key, DoubleByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(double key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(double key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2CharMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2CharMaps.java index 5ffbf67..d6c61ae 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2CharMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2CharMaps.java @@ -250,18 +250,18 @@ public class Double2CharMaps @Override public char computeChar(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(double key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2CharMaps @Override public char computeChar(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(double key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2CharMaps @Override public char computeChar(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(double key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2CharMaps @Override public char computeChar(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(double key, Double2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(double key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(double key, Double2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(double key, DoubleCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(double key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(double key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2DoubleMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2DoubleMaps.java index 11b8652..90d05d8 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2DoubleMaps.java @@ -249,18 +249,18 @@ public class Double2DoubleMaps @Override public double computeDouble(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(double key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Double2DoubleMaps @Override public double computeDouble(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(double key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Double2DoubleMaps @Override public double computeDouble(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(double key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Double2DoubleMaps @Override public double computeDouble(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(double key, DoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(double key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(double key, DoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(double key, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(double key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(double key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2FloatMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2FloatMaps.java index bbf1a7b..4f8821c 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2FloatMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2FloatMaps.java @@ -250,18 +250,18 @@ public class Double2FloatMaps @Override public float computeFloat(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(double key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2FloatMaps @Override public float computeFloat(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(double key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2FloatMaps @Override public float computeFloat(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(double key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2FloatMaps @Override public float computeFloat(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(double key, Double2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(double key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(double key, Double2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(double key, DoubleFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(double key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(double key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2IntMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2IntMaps.java index d178518..6f5496b 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2IntMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2IntMaps.java @@ -250,18 +250,18 @@ public class Double2IntMaps @Override public int computeInt(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(double key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2IntMaps @Override public int computeInt(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(double key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2IntMaps @Override public int computeInt(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(double key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2IntMaps @Override public int computeInt(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(double key, Double2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(double key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(double key, Double2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(double key, DoubleIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(double key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(double key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2LongMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2LongMaps.java index 208dcd4..909dc12 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2LongMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2LongMaps.java @@ -250,18 +250,18 @@ public class Double2LongMaps @Override public long computeLong(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(double key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2LongMaps @Override public long computeLong(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(double key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2LongMaps @Override public long computeLong(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(double key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2LongMaps @Override public long computeLong(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(double key, Double2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(double key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(double key, Double2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(double key, DoubleLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(double key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(double key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ObjectMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ObjectMaps.java index 7b2f237..d28ecf1 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ObjectMaps.java @@ -266,20 +266,12 @@ public class Double2ObjectMaps @Override public V compute(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Double2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Double2ObjectMaps @Override public V compute(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Double2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Double2ObjectMaps @Override public V compute(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Double2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Double2ObjectMaps @Override public V compute(double key, DoubleObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(double key, DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(double key, DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(double key, DoubleObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(double key, DoubleObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(double key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(double key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(double key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Double2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ShortMaps.java b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ShortMaps.java index fc2945b..f77709a 100644 --- a/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ShortMaps.java +++ b/src/main/java/speiger/src/collections/doubles/utils/maps/Double2ShortMaps.java @@ -250,18 +250,18 @@ public class Double2ShortMaps @Override public short computeShort(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(double key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Double2ShortMaps @Override public short computeShort(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(double key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Double2ShortMaps @Override public short computeShort(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(double key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Double2ShortMaps @Override public short computeShort(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(double key, Double2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(double key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(double key, Double2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(double key, DoubleShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(double key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(double key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/functions/FloatSupplier.java b/src/main/java/speiger/src/collections/floats/functions/FloatSupplier.java index f0009ae..561e246 100644 --- a/src/main/java/speiger/src/collections/floats/functions/FloatSupplier.java +++ b/src/main/java/speiger/src/collections/floats/functions/FloatSupplier.java @@ -8,5 +8,5 @@ public interface FloatSupplier /** * @return the supplied value */ - public float getAsDouble(); + public float getAsFloat(); } \ No newline at end of file diff --git a/src/main/java/speiger/src/collections/floats/lists/AbstractFloatList.java b/src/main/java/speiger/src/collections/floats/lists/AbstractFloatList.java index dd68f29..6a64c29 100644 --- a/src/main/java/speiger/src/collections/floats/lists/AbstractFloatList.java +++ b/src/main/java/speiger/src/collections/floats/lists/AbstractFloatList.java @@ -12,6 +12,7 @@ import speiger.src.collections.floats.collections.AbstractFloatCollection; import speiger.src.collections.floats.collections.FloatCollection; import speiger.src.collections.floats.collections.FloatIterator; import speiger.src.collections.floats.collections.FloatSplititerator; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.floats.utils.FloatSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -205,13 +206,23 @@ public abstract class AbstractFloatList extends AbstractFloatCollection implemen public FloatListIterator listIterator() { return listIterator(0); } - + @Override public FloatListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new FloatListIter(index); } + @Override + public FloatListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public FloatListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add(0F); @@ -566,7 +577,153 @@ public abstract class AbstractFloatList extends AbstractFloatCollection implemen } } } + + private class ListIndexedIterator implements FloatListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public float nextFloat() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getFloat((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public float previousFloat() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getFloat((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(float e) { throw new UnsupportedOperationException(); } + + @Override + public void set(float e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractFloatList.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 FloatListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public float nextFloat() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getFloat((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public float previousFloat() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getFloat((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(float e) { throw new UnsupportedOperationException(); } + + @Override + public void set(float e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractFloatList.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 FloatListIter implements FloatListIterator { int index; int lastReturned = -1; @@ -644,7 +801,7 @@ public abstract class AbstractFloatList extends AbstractFloatCollection implemen 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/floats/lists/FloatList.java b/src/main/java/speiger/src/collections/floats/lists/FloatList.java index b1f7323..fa9ba2e 100644 --- a/src/main/java/speiger/src/collections/floats/lists/FloatList.java +++ b/src/main/java/speiger/src/collections/floats/lists/FloatList.java @@ -14,6 +14,7 @@ import speiger.src.collections.ints.functions.consumer.IntFloatConsumer; import speiger.src.collections.floats.functions.FloatComparator; import speiger.src.collections.floats.utils.FloatArrays; import speiger.src.collections.floats.utils.FloatLists; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.floats.utils.FloatSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -342,6 +343,24 @@ public interface FloatList extends FloatCollection, List @Override public FloatListIterator 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 FloatListIterator 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 FloatListIterator 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/floats/maps/abstracts/AbstractFloat2BooleanMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2BooleanMap.java index 5c32f19..49b3646 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2BooleanMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2BooleanMap.java @@ -151,6 +151,39 @@ public abstract class AbstractFloat2BooleanMap extends AbstractMap imp return newValue; } + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractFloat2ByteMap extends AbstractMap imp return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractFloat2ByteMap extends AbstractMap imp return value; } - @Override - public byte supplyByteIfAbsent(float 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(float 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 abstract class AbstractFloat2ByteMap extends AbstractMap imp return value; } - @Override - public byte computeByteIfPresent(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2CharMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2CharMap.java index 7b06b00..4bff55f 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2CharMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2CharMap.java @@ -157,6 +157,39 @@ public abstract class AbstractFloat2CharMap extends AbstractMap return newValue; } + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public double supplyDoubleIfAbsent(float 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(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractFloat2DoubleMap extends AbstractMap return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractFloat2DoubleMap extends AbstractMap return value; } - @Override - public double supplyDoubleIfAbsent(float 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(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractFloat2DoubleMap extends AbstractMap return value; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2FloatMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2FloatMap.java index 339beb1..5080405 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2FloatMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2FloatMap.java @@ -155,6 +155,39 @@ public abstract class AbstractFloat2FloatMap extends AbstractMap i return newValue; } + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -171,17 +204,6 @@ public abstract class AbstractFloat2FloatMap extends AbstractMap i return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -196,23 +218,12 @@ public abstract class AbstractFloat2FloatMap extends AbstractMap i return value; } - @Override - public float supplyFloatIfAbsent(float 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(float 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; @@ -221,17 +232,6 @@ public abstract class AbstractFloat2FloatMap extends AbstractMap i return value; } - @Override - public float computeFloatIfPresent(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2IntMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2IntMap.java index 465ae9e..5e409ed 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2IntMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2IntMap.java @@ -157,6 +157,39 @@ public abstract class AbstractFloat2IntMap extends AbstractMap i return newValue; } + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(float 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(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractFloat2IntMap extends AbstractMap i return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractFloat2IntMap extends AbstractMap i return value; } - @Override - public int supplyIntIfAbsent(float 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(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractFloat2IntMap extends AbstractMap i return value; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2LongMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2LongMap.java index 75d1a69..4207688 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2LongMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2LongMap.java @@ -157,6 +157,39 @@ public abstract class AbstractFloat2LongMap extends AbstractMap imp return newValue; } + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(float 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(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractFloat2LongMap extends AbstractMap imp return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractFloat2LongMap extends AbstractMap imp return value; } - @Override - public long supplyLongIfAbsent(float 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(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractFloat2LongMap extends AbstractMap imp return value; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ObjectMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ObjectMap.java index 66e3569..35af092 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ObjectMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ObjectMap.java @@ -159,22 +159,6 @@ public abstract class AbstractFloat2ObjectMap extends AbstractMap i return newValue; } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -189,20 +173,6 @@ public abstract class AbstractFloat2ObjectMap extends AbstractMap i return value; } - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,20 +187,6 @@ public abstract class AbstractFloat2ObjectMap extends AbstractMap i return value; } - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -246,21 +202,6 @@ public abstract class AbstractFloat2ObjectMap extends AbstractMap i return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ShortMap.java b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ShortMap.java index 16a3b80..0ea44ce 100644 --- a/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ShortMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/abstracts/AbstractFloat2ShortMap.java @@ -157,6 +157,39 @@ public abstract class AbstractFloat2ShortMap extends AbstractMap i return newValue; } + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractFloat2ShortMap extends AbstractMap i return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractFloat2ShortMap extends AbstractMap i return value; } - @Override - public short supplyShortIfAbsent(float 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(float 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 abstract class AbstractFloat2ShortMap extends AbstractMap i return value; } - @Override - public short computeShortIfPresent(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2BooleanConcurrentOpenHashMap.java index e217464..4d78c90 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2BooleanConcurrentOpenHashMap.java @@ -438,13 +438,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,6 +445,27 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,13 +473,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,13 +480,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2032,6 +2032,54 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap } } + protected boolean computeIfAbsent(int hash, float key, FloatPredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, float key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, float key, FloatBooleanUnaryOperator 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 computeNonDefault(int hash, float key, FloatBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2055,23 +2103,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap } } - protected boolean computeIfAbsent(int hash, float key, FloatPredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, float key, FloatPredicate mappingFunction) { long stamp = writeLock(); try { @@ -2095,23 +2126,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap } } - protected boolean supplyIfAbsent(int hash, float key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, float key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2135,20 +2149,6 @@ public class Float2BooleanConcurrentOpenHashMap extends AbstractFloat2BooleanMap } } - protected boolean computeIfPresent(int hash, float key, FloatBooleanUnaryOperator 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, float key, FloatBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ByteConcurrentOpenHashMap.java index 435419c..50f4f6c 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ByteConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple } } + protected byte computeIfAbsent(int hash, float key, Float2ByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, float key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, float key, FloatByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, float key, FloatByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple } } - protected byte computeIfAbsent(int hash, float key, Float2ByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, float key, Float2ByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple } } - protected byte supplyIfAbsent(int hash, float key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, float key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Float2ByteConcurrentOpenHashMap extends AbstractFloat2ByteMap imple } } - protected byte computeIfPresent(int hash, float key, FloatByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, float key, FloatByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2CharConcurrentOpenHashMap.java index ed9a535..768998d 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2CharConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple } } + protected char computeIfAbsent(int hash, float key, Float2CharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, float key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, float key, FloatCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, float key, FloatCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple } } - protected char computeIfAbsent(int hash, float key, Float2CharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, float key, Float2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple } } - protected char supplyIfAbsent(int hash, float key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, float key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Float2CharConcurrentOpenHashMap extends AbstractFloat2CharMap imple } } - protected char computeIfPresent(int hash, float key, FloatCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, float key, FloatCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2DoubleConcurrentOpenHashMap.java index d7ecf97..fb173fa 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2DoubleConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i } } + protected double computeIfAbsent(int hash, float key, Float2DoubleFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, float key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, float key, FloatDoubleUnaryOperator 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 computeNonDefault(int hash, float key, FloatDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i } } - protected double computeIfAbsent(int hash, float key, Float2DoubleFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, float key, Float2DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i } } - protected double supplyIfAbsent(int hash, float key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, float key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Float2DoubleConcurrentOpenHashMap extends AbstractFloat2DoubleMap i } } - protected double computeIfPresent(int hash, float key, FloatDoubleUnaryOperator 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, float key, FloatDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2FloatConcurrentOpenHashMap.java index 615a828..fe5126c 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2FloatConcurrentOpenHashMap.java @@ -444,13 +444,6 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,6 +451,27 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,13 +479,6 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -479,13 +486,6 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2069,6 +2069,54 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp } } + protected float computeIfAbsent(int hash, float key, FloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, float key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, float key, FloatFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, float key, FloatFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2092,23 +2140,6 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp } } - protected float computeIfAbsent(int hash, float key, FloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, float key, FloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2132,36 +2163,19 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp } } - protected float supplyIfAbsent(int hash, float key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, float key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2172,20 +2186,6 @@ public class Float2FloatConcurrentOpenHashMap extends AbstractFloat2FloatMap imp } } - protected float computeIfPresent(int hash, float key, FloatFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, float key, FloatFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2IntConcurrentOpenHashMap.java index 85cf4ba..f8f33c1 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2IntConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme } } + protected int computeIfAbsent(int hash, float key, Float2IntFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, float key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, float key, FloatIntUnaryOperator 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 computeNonDefault(int hash, float key, FloatIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme } } - protected int computeIfAbsent(int hash, float key, Float2IntFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, float key, Float2IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme } } - protected int supplyIfAbsent(int hash, float key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, float key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Float2IntConcurrentOpenHashMap extends AbstractFloat2IntMap impleme } } - protected int computeIfPresent(int hash, float key, FloatIntUnaryOperator 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, float key, FloatIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2LongConcurrentOpenHashMap.java index 482186d..2add7a1 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2LongConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple } } + protected long computeIfAbsent(int hash, float key, Float2LongFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, float key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, float key, FloatLongUnaryOperator 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 computeNonDefault(int hash, float key, FloatLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple } } - protected long computeIfAbsent(int hash, float key, Float2LongFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, float key, Float2LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple } } - protected long supplyIfAbsent(int hash, float key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, float key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Float2LongConcurrentOpenHashMap extends AbstractFloat2LongMap imple } } - protected long computeIfPresent(int hash, float key, FloatLongUnaryOperator 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, float key, FloatLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ObjectConcurrentOpenHashMap.java index 94669f2..007122b 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ObjectConcurrentOpenHashMap.java @@ -426,13 +426,6 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,13 +433,6 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -454,13 +440,6 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,13 +447,6 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2011,29 +1983,6 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa } } - protected V computeNonDefault(int hash, float key, FloatObjectUnaryOperator 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, float key, FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2056,30 +2005,7 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, float key, FloatFunction 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, float key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -2102,30 +2028,7 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, float 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, float key, FloatObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2144,11 +2047,16 @@ public class Float2ObjectConcurrentOpenHashMap extends AbstractFloat2ObjectMa } } - protected V computeIfPresentNonDefault(int hash, float key, FloatObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, float key, FloatObjectUnaryOperator 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/floats/maps/impl/concurrent/Float2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ShortConcurrentOpenHashMap.java index e6a48c1..ce27739 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/concurrent/Float2ShortConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp } } + protected short computeIfAbsent(int hash, float key, Float2ShortFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, float key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, float key, FloatShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, float key, FloatShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp } } - protected short computeIfAbsent(int hash, float key, Float2ShortFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, float key, Float2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp } } - protected short supplyIfAbsent(int hash, float key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, float key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Float2ShortConcurrentOpenHashMap extends AbstractFloat2ShortMap imp } } - protected short computeIfPresent(int hash, float key, FloatShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, float key, FloatShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2BooleanOpenCustomHashMap.java index 9d9e05d..fcb2d01 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2BooleanOpenCustomHashMap.java @@ -440,6 +440,42 @@ public class Float2BooleanOpenCustomHashMap extends AbstractFloat2BooleanMap imp return newValue; } + @Override + public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Float2BooleanOpenCustomHashMap extends AbstractFloat2BooleanMap imp return newValue; } - @Override - public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Float2BooleanOpenCustomHashMap extends AbstractFloat2BooleanMap imp return newValue; } - @Override - public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Float2BooleanOpenCustomHashMap extends AbstractFloat2BooleanMap imp return newValue; } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ByteOpenCustomHashMap.java index c0a8e94..f0c1bdc 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ByteOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2ByteOpenCustomHashMap extends AbstractFloat2ByteMap implement return newValue; } + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2ByteOpenCustomHashMap extends AbstractFloat2ByteMap implement return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Float2ByteOpenCustomHashMap extends AbstractFloat2ByteMap implement return newValue; } - @Override - public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2CharOpenCustomHashMap.java index 941ac63..a84890e 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2CharOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2CharOpenCustomHashMap extends AbstractFloat2CharMap implement return newValue; } + @Override + public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2CharOpenCustomHashMap extends AbstractFloat2CharMap implement return newValue; } - @Override - public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Float2CharOpenCustomHashMap extends AbstractFloat2CharMap implement return newValue; } - @Override - public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(float 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(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2DoubleOpenCustomHashMap.java index 5579e87..8879ace 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2DoubleOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2DoubleOpenCustomHashMap extends AbstractFloat2DoubleMap imple return newValue; } + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2DoubleOpenCustomHashMap extends AbstractFloat2DoubleMap imple return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Float2DoubleOpenCustomHashMap extends AbstractFloat2DoubleMap imple return newValue; } - @Override - public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Float2DoubleOpenCustomHashMap extends AbstractFloat2DoubleMap imple return newValue; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2FloatOpenCustomHashMap.java index f2d63e1..36ab9ed 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2FloatOpenCustomHashMap.java @@ -454,6 +454,42 @@ public class Float2FloatOpenCustomHashMap extends AbstractFloat2FloatMap impleme return newValue; } + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Float2FloatOpenCustomHashMap extends AbstractFloat2FloatMap impleme return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,48 +528,25 @@ public class Float2FloatOpenCustomHashMap extends AbstractFloat2FloatMap impleme return newValue; } - @Override - public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2IntOpenCustomHashMap.java index e67196f..e149b2e 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2IntOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2IntOpenCustomHashMap extends AbstractFloat2IntMap implements return newValue; } + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2IntOpenCustomHashMap extends AbstractFloat2IntMap implements return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Float2IntOpenCustomHashMap extends AbstractFloat2IntMap implements return newValue; } - @Override - public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Float2IntOpenCustomHashMap extends AbstractFloat2IntMap implements return newValue; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2LongOpenCustomHashMap.java index a3fd9fc..1ade7ff 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2LongOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2LongOpenCustomHashMap extends AbstractFloat2LongMap implement return newValue; } + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2LongOpenCustomHashMap extends AbstractFloat2LongMap implement return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Float2LongOpenCustomHashMap extends AbstractFloat2LongMap implement return newValue; } - @Override - public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Float2LongOpenCustomHashMap extends AbstractFloat2LongMap implement return newValue; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ObjectOpenCustomHashMap.java index 64aff4e..3abe68e 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ObjectOpenCustomHashMap.java @@ -432,25 +432,6 @@ public class Float2ObjectOpenCustomHashMap extends AbstractFloat2ObjectMap return newValue; } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -469,26 +450,7 @@ public class Float2ObjectOpenCustomHashMap extends AbstractFloat2ObjectMap } return newValue; } - - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,25 +470,6 @@ public class Float2ObjectOpenCustomHashMap extends AbstractFloat2ObjectMap return newValue; } - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -541,20 +484,6 @@ public class Float2ObjectOpenCustomHashMap extends AbstractFloat2ObjectMap return newValue; } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ShortOpenCustomHashMap.java index 15a1300..5272af1 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/customHash/Float2ShortOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Float2ShortOpenCustomHashMap extends AbstractFloat2ShortMap impleme return newValue; } + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Float2ShortOpenCustomHashMap extends AbstractFloat2ShortMap impleme return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Float2ShortOpenCustomHashMap extends AbstractFloat2ShortMap impleme return newValue; } - @Override - public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2BooleanOpenHashMap.java index 65e8816..44cc712 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2BooleanOpenHashMap.java @@ -408,6 +408,42 @@ public class Float2BooleanOpenHashMap extends AbstractFloat2BooleanMap implement values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Float2BooleanOpenHashMap extends AbstractFloat2BooleanMap implement return newValue; } - @Override - public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Float2BooleanOpenHashMap extends AbstractFloat2BooleanMap implement return newValue; } - @Override - public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Float2BooleanOpenHashMap extends AbstractFloat2BooleanMap implement return newValue; } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ByteOpenHashMap.java index afabe21..136f26c 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ByteOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2ByteOpenHashMap extends AbstractFloat2ByteMap implements ITri values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2ByteOpenHashMap extends AbstractFloat2ByteMap implements ITri return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Float2ByteOpenHashMap extends AbstractFloat2ByteMap implements ITri return newValue; } - @Override - public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2CharOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2CharOpenHashMap.java index 291c536..998e9a4 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2CharOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2CharOpenHashMap extends AbstractFloat2CharMap implements ITri values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2CharOpenHashMap extends AbstractFloat2CharMap implements ITri return newValue; } - @Override - public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Float2CharOpenHashMap extends AbstractFloat2CharMap implements ITri return newValue; } - @Override - public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(float 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(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2DoubleOpenHashMap.java index b8c9500..32f9ab2 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2DoubleOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2DoubleOpenHashMap extends AbstractFloat2DoubleMap implements values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2DoubleOpenHashMap extends AbstractFloat2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Float2DoubleOpenHashMap extends AbstractFloat2DoubleMap implements return newValue; } - @Override - public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Float2DoubleOpenHashMap extends AbstractFloat2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2FloatOpenHashMap.java index 484e47c..5e27111 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2FloatOpenHashMap.java @@ -424,6 +424,42 @@ public class Float2FloatOpenHashMap extends AbstractFloat2FloatMap implements IT values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Float2FloatOpenHashMap extends AbstractFloat2FloatMap implements IT return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,48 +499,25 @@ public class Float2FloatOpenHashMap extends AbstractFloat2FloatMap implements IT return newValue; } - @Override - public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2IntOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2IntOpenHashMap.java index 23278fa..0191957 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2IntOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2IntOpenHashMap extends AbstractFloat2IntMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2IntOpenHashMap extends AbstractFloat2IntMap implements ITrimm return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Float2IntOpenHashMap extends AbstractFloat2IntMap implements ITrimm return newValue; } - @Override - public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Float2IntOpenHashMap extends AbstractFloat2IntMap implements ITrimm return newValue; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2LongOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2LongOpenHashMap.java index 4144e28..a55f915 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2LongOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2LongOpenHashMap extends AbstractFloat2LongMap implements ITri values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2LongOpenHashMap extends AbstractFloat2LongMap implements ITri return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Float2LongOpenHashMap extends AbstractFloat2LongMap implements ITri return newValue; } - @Override - public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Float2LongOpenHashMap extends AbstractFloat2LongMap implements ITri return newValue; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ObjectOpenHashMap.java index 97d2331..06b429a 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ObjectOpenHashMap.java @@ -401,26 +401,7 @@ public class Float2ObjectOpenHashMap extends AbstractFloat2ObjectMap imple values[index] = newValue; return newValue; } - - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,25 +421,6 @@ public class Float2ObjectOpenHashMap extends AbstractFloat2ObjectMap imple return newValue; } - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -477,26 +439,7 @@ public class Float2ObjectOpenHashMap extends AbstractFloat2ObjectMap imple } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -511,20 +454,6 @@ public class Float2ObjectOpenHashMap extends AbstractFloat2ObjectMap imple return newValue; } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ShortOpenHashMap.java index 4f508e1..6a9b71d 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/hash/Float2ShortOpenHashMap.java @@ -430,6 +430,42 @@ public class Float2ShortOpenHashMap extends AbstractFloat2ShortMap implements IT values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Float2ShortOpenHashMap extends AbstractFloat2ShortMap implements IT return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Float2ShortOpenHashMap extends AbstractFloat2ShortMap implements IT return newValue; } - @Override - public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2BooleanOpenHashMap.java index a6177b4..2c22869 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2BooleanOpenHashMap.java @@ -413,20 +413,19 @@ public class ImmutableFloat2BooleanOpenHashMap extends AbstractFloat2BooleanMap @Override public boolean computeBoolean(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(float key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ByteOpenHashMap.java index 982ec0e..3667992 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ByteOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2ByteOpenHashMap extends AbstractFloat2ByteMap implem @Override public byte computeByte(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(float key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2CharOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2CharOpenHashMap.java index b9667ed..b979575 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2CharOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2CharOpenHashMap extends AbstractFloat2CharMap implem @Override public char computeChar(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(float key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2DoubleOpenHashMap.java index 1057e40..0da6c77 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2DoubleOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2DoubleOpenHashMap extends AbstractFloat2DoubleMap im @Override public double computeDouble(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(float key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2FloatOpenHashMap.java index ce6209b..c6d3e74 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2FloatOpenHashMap.java @@ -409,20 +409,19 @@ public class ImmutableFloat2FloatOpenHashMap extends AbstractFloat2FloatMap impl @Override public float computeFloat(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(float key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2IntOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2IntOpenHashMap.java index 8d6eb85..6e65c50 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2IntOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2IntOpenHashMap extends AbstractFloat2IntMap implemen @Override public int computeInt(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(float key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2LongOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2LongOpenHashMap.java index 73f175c..38713bc 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2LongOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2LongOpenHashMap extends AbstractFloat2LongMap implem @Override public long computeLong(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(float key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ObjectOpenHashMap.java index 7f9844f..33524a9 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ObjectOpenHashMap.java @@ -397,20 +397,11 @@ public class ImmutableFloat2ObjectOpenHashMap extends AbstractFloat2ObjectMap @Override public V compute(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ShortOpenHashMap.java index 4dc3912..e7bc266 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/immutable/ImmutableFloat2ShortOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableFloat2ShortOpenHashMap extends AbstractFloat2ShortMap impl @Override public short computeShort(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(float key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2BooleanArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2BooleanArrayMap.java index 5403930..f5c1ef5 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2BooleanArrayMap.java @@ -419,6 +419,42 @@ public class Float2BooleanArrayMap extends AbstractFloat2BooleanMap implements F return newValue; } + @Override + public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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 computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Float2BooleanArrayMap extends AbstractFloat2BooleanMap implements F return newValue; } - @Override - public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Float2BooleanArrayMap extends AbstractFloat2BooleanMap implements F return newValue; } - @Override - public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Float2BooleanArrayMap extends AbstractFloat2BooleanMap implements F return newValue; } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ByteArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ByteArrayMap.java index 4fb6291..8071e26 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ByteArrayMap.java @@ -442,6 +442,42 @@ public class Float2ByteArrayMap extends AbstractFloat2ByteMap implements Float2B return newValue; } + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(float key, FloatByteUnaryOperator 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 computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2ByteArrayMap extends AbstractFloat2ByteMap implements Float2B return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Float2ByteArrayMap extends AbstractFloat2ByteMap implements Float2B return newValue; } - @Override - public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2CharArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2CharArrayMap.java index 986ae05..6beed7b 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2CharArrayMap.java @@ -442,6 +442,42 @@ public class Float2CharArrayMap extends AbstractFloat2CharMap implements Float2C return newValue; } + @Override + public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(float key, FloatCharUnaryOperator 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 computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2CharArrayMap extends AbstractFloat2CharMap implements Float2C return newValue; } - @Override - public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Float2CharArrayMap extends AbstractFloat2CharMap implements Float2C return newValue; } - @Override - public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(float 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(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2DoubleArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2DoubleArrayMap.java index 1aa408b..b020305 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2DoubleArrayMap.java @@ -442,6 +442,42 @@ public class Float2DoubleArrayMap extends AbstractFloat2DoubleMap implements Flo return newValue; } + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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 computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2DoubleArrayMap extends AbstractFloat2DoubleMap implements Flo return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Float2DoubleArrayMap extends AbstractFloat2DoubleMap implements Flo return newValue; } - @Override - public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Float2DoubleArrayMap extends AbstractFloat2DoubleMap implements Flo return newValue; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2FloatArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2FloatArrayMap.java index ca90a13..65aef8c 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2FloatArrayMap.java @@ -435,6 +435,42 @@ public class Float2FloatArrayMap extends AbstractFloat2FloatMap implements Float return newValue; } + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(float key, FloatFloatUnaryOperator 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 computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Float2FloatArrayMap extends AbstractFloat2FloatMap implements Float return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,48 +509,25 @@ public class Float2FloatArrayMap extends AbstractFloat2FloatMap implements Float return newValue; } - @Override - public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2IntArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2IntArrayMap.java index 81a54b4..c376196 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2IntArrayMap.java @@ -442,6 +442,42 @@ public class Float2IntArrayMap extends AbstractFloat2IntMap implements Float2Int return newValue; } + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(float key, FloatIntUnaryOperator 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 computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2IntArrayMap extends AbstractFloat2IntMap implements Float2Int return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Float2IntArrayMap extends AbstractFloat2IntMap implements Float2Int return newValue; } - @Override - public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Float2IntArrayMap extends AbstractFloat2IntMap implements Float2Int return newValue; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2LongArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2LongArrayMap.java index c78e244..ecdcaa2 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2LongArrayMap.java @@ -442,6 +442,42 @@ public class Float2LongArrayMap extends AbstractFloat2LongMap implements Float2L return newValue; } + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(float key, FloatLongUnaryOperator 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 computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2LongArrayMap extends AbstractFloat2LongMap implements Float2L return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Float2LongArrayMap extends AbstractFloat2LongMap implements Float2L return newValue; } - @Override - public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Float2LongArrayMap extends AbstractFloat2LongMap implements Float2L return newValue; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ObjectArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ObjectArrayMap.java index f41fcdd..1026f62 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ObjectArrayMap.java @@ -415,25 +415,6 @@ public class Float2ObjectArrayMap extends AbstractFloat2ObjectMap implemen return newValue; } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,26 +433,7 @@ public class Float2ObjectArrayMap extends AbstractFloat2ObjectMap implemen } return newValue; } - - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -490,26 +452,7 @@ public class Float2ObjectArrayMap extends AbstractFloat2ObjectMap implemen } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -524,20 +467,6 @@ public class Float2ObjectArrayMap extends AbstractFloat2ObjectMap implemen return newValue; } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ShortArrayMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ShortArrayMap.java index 34f6c20..1ce6913 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/misc/Float2ShortArrayMap.java @@ -442,6 +442,42 @@ public class Float2ShortArrayMap extends AbstractFloat2ShortMap implements Float return newValue; } + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(float key, FloatShortUnaryOperator 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 computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Float2ShortArrayMap extends AbstractFloat2ShortMap implements Float return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Float2ShortArrayMap extends AbstractFloat2ShortMap implements Float return newValue; } - @Override - public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanAVLTreeMap.java index 328a10c..86c2749 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanAVLTreeMap.java @@ -395,6 +395,40 @@ public class Float2BooleanAVLTreeMap extends AbstractFloat2BooleanMap implements return newValue; } + @Override + public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(float 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(float key, FloatBooleanUnaryOperator 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 computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Float2BooleanAVLTreeMap extends AbstractFloat2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Float2BooleanAVLTreeMap extends AbstractFloat2BooleanMap implements return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(float 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(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,16 +484,6 @@ public class Float2BooleanAVLTreeMap extends AbstractFloat2BooleanMap implements return entry.value; } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1487,14 +1487,9 @@ public class Float2BooleanAVLTreeMap extends AbstractFloat2BooleanMap implements 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/floats/maps/impl/tree/Float2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanRBTreeMap.java index 25b0d33..eb87c05 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2BooleanRBTreeMap.java @@ -394,6 +394,40 @@ public class Float2BooleanRBTreeMap extends AbstractFloat2BooleanMap implements return newValue; } + @Override + public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(float 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(float key, FloatBooleanUnaryOperator 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 computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Float2BooleanRBTreeMap extends AbstractFloat2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Float2BooleanRBTreeMap extends AbstractFloat2BooleanMap implements return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(float 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(float key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Float2BooleanRBTreeMap extends AbstractFloat2BooleanMap implements return entry.value; } - @Override - public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator 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(float key, FloatBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Float2BooleanRBTreeMap extends AbstractFloat2BooleanMap implements 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/floats/maps/impl/tree/Float2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteAVLTreeMap.java index 73e67ea..1d3c751 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2ByteAVLTreeMap extends AbstractFloat2ByteMap implements Float return newValue; } + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(float 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(float key, FloatByteUnaryOperator 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 computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2ByteAVLTreeMap extends AbstractFloat2ByteMap implements Float return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Float2ByteAVLTreeMap extends AbstractFloat2ByteMap implements Float return entry.value; } - @Override - public byte supplyByteIfAbsent(float 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(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2ByteAVLTreeMap extends AbstractFloat2ByteMap implements Float 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/floats/maps/impl/tree/Float2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteRBTreeMap.java index cc48a50..7f11a44 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ByteRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2ByteRBTreeMap extends AbstractFloat2ByteMap implements Float2 return newValue; } + @Override + public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(float 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(float key, FloatByteUnaryOperator 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 computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2ByteRBTreeMap extends AbstractFloat2ByteMap implements Float2 return newValue; } - @Override - public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Float2ByteRBTreeMap extends AbstractFloat2ByteMap implements Float2 return entry.value; } - @Override - public byte supplyByteIfAbsent(float 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(float 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(float key, FloatByteUnaryOperator 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(float key, FloatByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2ByteRBTreeMap extends AbstractFloat2ByteMap implements Float2 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/floats/maps/impl/tree/Float2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharAVLTreeMap.java index 4fac37c..9a2cc69 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2CharAVLTreeMap extends AbstractFloat2CharMap implements Float return newValue; } + @Override + public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(float 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(float key, FloatCharUnaryOperator 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 computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2CharAVLTreeMap extends AbstractFloat2CharMap implements Float return newValue; } - @Override - public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Float2CharAVLTreeMap extends AbstractFloat2CharMap implements Float return entry.value; } - @Override - public char supplyCharIfAbsent(float 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(float 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(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2CharAVLTreeMap extends AbstractFloat2CharMap implements Float 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/floats/maps/impl/tree/Float2CharRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharRBTreeMap.java index 2787a55..fa584f7 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2CharRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2CharRBTreeMap extends AbstractFloat2CharMap implements Float2 return newValue; } + @Override + public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(float 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(float key, FloatCharUnaryOperator 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 computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2CharRBTreeMap extends AbstractFloat2CharMap implements Float2 return newValue; } - @Override - public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Float2CharRBTreeMap extends AbstractFloat2CharMap implements Float2 return entry.value; } - @Override - public char supplyCharIfAbsent(float 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(float 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(float key, FloatCharUnaryOperator 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(float key, FloatCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2CharRBTreeMap extends AbstractFloat2CharMap implements Float2 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/floats/maps/impl/tree/Float2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleAVLTreeMap.java index c03db0d..1911638 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2DoubleAVLTreeMap extends AbstractFloat2DoubleMap implements F return newValue; } + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(float 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(float key, FloatDoubleUnaryOperator 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 computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2DoubleAVLTreeMap extends AbstractFloat2DoubleMap implements F return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Float2DoubleAVLTreeMap extends AbstractFloat2DoubleMap implements F return entry.value; } - @Override - public double supplyDoubleIfAbsent(float 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(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Float2DoubleAVLTreeMap extends AbstractFloat2DoubleMap implements F return entry.value; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2DoubleAVLTreeMap extends AbstractFloat2DoubleMap implements F 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/floats/maps/impl/tree/Float2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleRBTreeMap.java index 1586e89..41f64a0 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2DoubleRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2DoubleRBTreeMap extends AbstractFloat2DoubleMap implements Fl return newValue; } + @Override + public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(float 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(float key, FloatDoubleUnaryOperator 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 computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2DoubleRBTreeMap extends AbstractFloat2DoubleMap implements Fl return newValue; } - @Override - public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Float2DoubleRBTreeMap extends AbstractFloat2DoubleMap implements Fl return entry.value; } - @Override - public double supplyDoubleIfAbsent(float 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(float key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Float2DoubleRBTreeMap extends AbstractFloat2DoubleMap implements Fl return entry.value; } - @Override - public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator 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(float key, FloatDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2DoubleRBTreeMap extends AbstractFloat2DoubleMap implements Fl 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/floats/maps/impl/tree/Float2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatAVLTreeMap.java index 250796e..c6de83b 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatAVLTreeMap.java @@ -446,6 +446,40 @@ public class Float2FloatAVLTreeMap extends AbstractFloat2FloatMap implements Flo return newValue; } + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(float 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(float key, FloatFloatUnaryOperator 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 computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Float2FloatAVLTreeMap extends AbstractFloat2FloatMap implements Flo return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,46 +517,24 @@ public class Float2FloatAVLTreeMap extends AbstractFloat2FloatMap implements Flo return entry.value; } - @Override - public float supplyFloatIfAbsent(float 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(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Float2FloatAVLTreeMap extends AbstractFloat2FloatMap implements Flo 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/floats/maps/impl/tree/Float2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatRBTreeMap.java index 572b508..52665ce 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2FloatRBTreeMap.java @@ -445,6 +445,40 @@ public class Float2FloatRBTreeMap extends AbstractFloat2FloatMap implements Floa return newValue; } + @Override + public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(float 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(float key, FloatFloatUnaryOperator 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 computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Float2FloatRBTreeMap extends AbstractFloat2FloatMap implements Floa return newValue; } - @Override - public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,46 +516,24 @@ public class Float2FloatRBTreeMap extends AbstractFloat2FloatMap implements Floa return entry.value; } - @Override - public float supplyFloatIfAbsent(float 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(float 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(float key, FloatFloatUnaryOperator 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(float key, FloatFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1613,14 +1613,9 @@ public class Float2FloatRBTreeMap extends AbstractFloat2FloatMap implements Floa 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/floats/maps/impl/tree/Float2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntAVLTreeMap.java index bfc21ad..c764aec 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2IntAVLTreeMap extends AbstractFloat2IntMap implements Float2I return newValue; } + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(float 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(float key, FloatIntUnaryOperator 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 computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2IntAVLTreeMap extends AbstractFloat2IntMap implements Float2I return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Float2IntAVLTreeMap extends AbstractFloat2IntMap implements Float2I return entry.value; } - @Override - public int supplyIntIfAbsent(float 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(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Float2IntAVLTreeMap extends AbstractFloat2IntMap implements Float2I return entry.value; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2IntAVLTreeMap extends AbstractFloat2IntMap implements Float2I 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/floats/maps/impl/tree/Float2IntRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntRBTreeMap.java index efd945c..b260194 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2IntRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2IntRBTreeMap extends AbstractFloat2IntMap implements Float2In return newValue; } + @Override + public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(float 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(float key, FloatIntUnaryOperator 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 computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2IntRBTreeMap extends AbstractFloat2IntMap implements Float2In return newValue; } - @Override - public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Float2IntRBTreeMap extends AbstractFloat2IntMap implements Float2In return entry.value; } - @Override - public int supplyIntIfAbsent(float 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(float key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Float2IntRBTreeMap extends AbstractFloat2IntMap implements Float2In return entry.value; } - @Override - public int computeIntIfPresent(float key, FloatIntUnaryOperator 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(float key, FloatIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2IntRBTreeMap extends AbstractFloat2IntMap implements Float2In 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/floats/maps/impl/tree/Float2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongAVLTreeMap.java index f24a991..bd15c14 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2LongAVLTreeMap extends AbstractFloat2LongMap implements Float return newValue; } + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(float 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(float key, FloatLongUnaryOperator 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 computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2LongAVLTreeMap extends AbstractFloat2LongMap implements Float return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Float2LongAVLTreeMap extends AbstractFloat2LongMap implements Float return entry.value; } - @Override - public long supplyLongIfAbsent(float 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(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Float2LongAVLTreeMap extends AbstractFloat2LongMap implements Float return entry.value; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2LongAVLTreeMap extends AbstractFloat2LongMap implements Float 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/floats/maps/impl/tree/Float2LongRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongRBTreeMap.java index 49cb12a..2cf733e 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2LongRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2LongRBTreeMap extends AbstractFloat2LongMap implements Float2 return newValue; } + @Override + public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(float 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(float key, FloatLongUnaryOperator 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 computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2LongRBTreeMap extends AbstractFloat2LongMap implements Float2 return newValue; } - @Override - public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Float2LongRBTreeMap extends AbstractFloat2LongMap implements Float2 return entry.value; } - @Override - public long supplyLongIfAbsent(float 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(float key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Float2LongRBTreeMap extends AbstractFloat2LongMap implements Float2 return entry.value; } - @Override - public long computeLongIfPresent(float key, FloatLongUnaryOperator 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(float key, FloatLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2LongRBTreeMap extends AbstractFloat2LongMap implements Float2 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/floats/maps/impl/tree/Float2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectAVLTreeMap.java index 883d439..3fba480 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectAVLTreeMap.java @@ -395,25 +395,6 @@ public class Float2ObjectAVLTreeMap extends AbstractFloat2ObjectMap implem return newValue; } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -432,24 +413,6 @@ public class Float2ObjectAVLTreeMap extends AbstractFloat2ObjectMap implem return entry.value; } - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -468,24 +431,6 @@ public class Float2ObjectAVLTreeMap extends AbstractFloat2ObjectMap implem return entry.value; } - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -500,20 +445,6 @@ public class Float2ObjectAVLTreeMap extends AbstractFloat2ObjectMap implem return newValue; } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectRBTreeMap.java index b026f42..7ece5d8 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ObjectRBTreeMap.java @@ -394,25 +394,6 @@ public class Float2ObjectRBTreeMap extends AbstractFloat2ObjectMap impleme return newValue; } - @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator 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(float key, FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Float2ObjectRBTreeMap extends AbstractFloat2ObjectMap impleme return entry.value; } - @Override - public V computeIfAbsentNonDefault(float key, FloatFunction 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(float key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Float2ObjectRBTreeMap extends AbstractFloat2ObjectMap impleme return entry.value; } - @Override - public V supplyIfAbsentNonDefault(float 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(float key, FloatObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Float2ObjectRBTreeMap extends AbstractFloat2ObjectMap impleme return newValue; } - @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator 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(float key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortAVLTreeMap.java index f5be883..127187e 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortAVLTreeMap.java @@ -454,6 +454,40 @@ public class Float2ShortAVLTreeMap extends AbstractFloat2ShortMap implements Flo return newValue; } + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(float 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(float key, FloatShortUnaryOperator 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 computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Float2ShortAVLTreeMap extends AbstractFloat2ShortMap implements Flo return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Float2ShortAVLTreeMap extends AbstractFloat2ShortMap implements Flo return entry.value; } - @Override - public short supplyShortIfAbsent(float 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(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Float2ShortAVLTreeMap extends AbstractFloat2ShortMap implements Flo 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/floats/maps/impl/tree/Float2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortRBTreeMap.java index c8fe3d5..5da5d2c 100644 --- a/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/impl/tree/Float2ShortRBTreeMap.java @@ -453,6 +453,40 @@ public class Float2ShortRBTreeMap extends AbstractFloat2ShortMap implements Floa return newValue; } + @Override + public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(float 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(float key, FloatShortUnaryOperator 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 computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Float2ShortRBTreeMap extends AbstractFloat2ShortMap implements Floa return newValue; } - @Override - public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Float2ShortRBTreeMap extends AbstractFloat2ShortMap implements Floa return entry.value; } - @Override - public short supplyShortIfAbsent(float 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(float 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(float key, FloatShortUnaryOperator 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(float key, FloatShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Float2ShortRBTreeMap extends AbstractFloat2ShortMap implements Floa 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/floats/maps/interfaces/Float2BooleanMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2BooleanMap.java index d2fd0e6..8c515f8 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2BooleanMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2BooleanMap.java @@ -283,15 +283,6 @@ public interface Float2BooleanMap extends Map, FloatPredicate * @return the result of the computation */ public boolean computeBoolean(float key, FloatBooleanUnaryOperator 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 boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Float2BooleanMap extends Map, FloatPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(float key, FloatPredicate 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". + * 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 boolean supplyBooleanIfAbsent(float 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(float key, FloatBooleanUnaryOperator 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 boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Float2BooleanMap extends Map, FloatPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate 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". - * 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 boolean supplyBooleanIfAbsent(float key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Float2BooleanMap extends Map, FloatPredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(float 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(float key, FloatBooleanUnaryOperator 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/floats/maps/interfaces/Float2ByteMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ByteMap.java index 87fcbfd..ea55003 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ByteMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ByteMap.java @@ -308,15 +308,6 @@ public interface Float2ByteMap extends Map, Float2ByteFunction * @return the result of the computation */ public byte computeByte(float key, FloatByteUnaryOperator 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 byte computeByteNonDefault(float key, FloatByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2ByteMap extends Map, Float2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(float key, Float2ByteFunction 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". + * 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 byte supplyByteIfAbsent(float 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(float key, FloatByteUnaryOperator 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 byte computeByteNonDefault(float key, FloatByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2ByteMap extends Map, Float2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction 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". - * 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 byte supplyByteIfAbsent(float key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Float2ByteMap extends Map, Float2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(float 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(float key, FloatByteUnaryOperator 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/floats/maps/interfaces/Float2CharMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2CharMap.java index f39cbe1..711df79 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2CharMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2CharMap.java @@ -308,15 +308,6 @@ public interface Float2CharMap extends Map, Float2CharFunction * @return the result of the computation */ public char computeChar(float key, FloatCharUnaryOperator 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 char computeCharNonDefault(float key, FloatCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2CharMap extends Map, Float2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(float key, Float2CharFunction 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". + * 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 char supplyCharIfAbsent(float 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(float key, FloatCharUnaryOperator 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 char computeCharNonDefault(float key, FloatCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2CharMap extends Map, Float2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(float key, Float2CharFunction 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". - * 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 char supplyCharIfAbsent(float key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Float2CharMap extends Map, Float2CharFunction * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(float 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(float key, FloatCharUnaryOperator 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/floats/maps/interfaces/Float2DoubleMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2DoubleMap.java index a0b41e3..ccaa4ce 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2DoubleMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2DoubleMap.java @@ -308,15 +308,6 @@ public interface Float2DoubleMap extends Map, Float2DoubleFunctio * @return the result of the computation */ public double computeDouble(float key, FloatDoubleUnaryOperator 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 double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2DoubleMap extends Map, Float2DoubleFunctio * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(float key, Float2DoubleFunction 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". + * 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 double supplyDoubleIfAbsent(float 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(float key, FloatDoubleUnaryOperator 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 double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2DoubleMap extends Map, Float2DoubleFunctio * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction 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". - * 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 double supplyDoubleIfAbsent(float key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Float2DoubleMap extends Map, Float2DoubleFunctio * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(float 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(float key, FloatDoubleUnaryOperator 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/floats/maps/interfaces/Float2FloatMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2FloatMap.java index 0e6a403..586ef31 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2FloatMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2FloatMap.java @@ -307,15 +307,6 @@ public interface Float2FloatMap extends Map, FloatUnaryOperator * @return the result of the computation */ public float computeFloat(float key, FloatFloatUnaryOperator 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 float computeFloatNonDefault(float key, FloatFloatUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Float2FloatMap extends Map, FloatUnaryOperator * @return the result of the computed value or present value */ public float computeFloatIfAbsent(float key, FloatUnaryOperator 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". + * 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 float supplyFloatIfAbsent(float 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(float key, FloatFloatUnaryOperator 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 float computeFloatNonDefault(float key, FloatFloatUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Float2FloatMap extends Map, FloatUnaryOperator * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator 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". - * 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 float supplyFloatIfAbsent(float key, FloatSupplier 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". @@ -352,16 +362,6 @@ public interface Float2FloatMap extends Map, FloatUnaryOperator * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(float 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(float key, FloatFloatUnaryOperator 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/floats/maps/interfaces/Float2IntMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2IntMap.java index d762dc3..7239358 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2IntMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2IntMap.java @@ -308,15 +308,6 @@ public interface Float2IntMap extends Map, Float2IntFunction * @return the result of the computation */ public int computeInt(float key, FloatIntUnaryOperator 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 int computeIntNonDefault(float key, FloatIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2IntMap extends Map, Float2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(float key, Float2IntFunction 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". + * 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 int supplyIntIfAbsent(float 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(float key, FloatIntUnaryOperator 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 int computeIntNonDefault(float key, FloatIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2IntMap extends Map, Float2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(float key, Float2IntFunction 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". - * 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 int supplyIntIfAbsent(float key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Float2IntMap extends Map, Float2IntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(float 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(float key, FloatIntUnaryOperator 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/floats/maps/interfaces/Float2LongMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2LongMap.java index 0e81ae2..48042c9 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2LongMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2LongMap.java @@ -308,15 +308,6 @@ public interface Float2LongMap extends Map, Float2LongFunction * @return the result of the computation */ public long computeLong(float key, FloatLongUnaryOperator 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 long computeLongNonDefault(float key, FloatLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2LongMap extends Map, Float2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(float key, Float2LongFunction 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". + * 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 long supplyLongIfAbsent(float 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(float key, FloatLongUnaryOperator 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 long computeLongNonDefault(float key, FloatLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2LongMap extends Map, Float2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(float key, Float2LongFunction 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". - * 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 long supplyLongIfAbsent(float key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Float2LongMap extends Map, Float2LongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(float 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(float key, FloatLongUnaryOperator 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/floats/maps/interfaces/Float2ObjectMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ObjectMap.java index 137c02f..3206346 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ObjectMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ObjectMap.java @@ -266,15 +266,6 @@ public interface Float2ObjectMap extends Map, FloatFunction * @return the result of the computation */ public V compute(float key, FloatObjectUnaryOperator 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(float key, FloatObjectUnaryOperator 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 interface Float2ObjectMap extends Map, FloatFunction * @return the result of the computed value or present value */ public V computeIfAbsent(float key, FloatFunction 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(float key, FloatFunction 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 interface Float2ObjectMap extends Map, FloatFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(float 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(float 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 interface Float2ObjectMap extends Map, FloatFunction * @note if not present then compute is not executed */ public V computeIfPresent(float key, FloatObjectUnaryOperator 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(float key, FloatObjectUnaryOperator 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/floats/maps/interfaces/Float2ShortMap.java b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ShortMap.java index f623b7d..c6f8a04 100644 --- a/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ShortMap.java +++ b/src/main/java/speiger/src/collections/floats/maps/interfaces/Float2ShortMap.java @@ -308,15 +308,6 @@ public interface Float2ShortMap extends Map, Float2ShortFunction * @return the result of the computation */ public short computeShort(float key, FloatShortUnaryOperator 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 short computeShortNonDefault(float key, FloatShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Float2ShortMap extends Map, Float2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(float key, Float2ShortFunction 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". + * 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 short supplyShortIfAbsent(float 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(float key, FloatShortUnaryOperator 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 short computeShortNonDefault(float key, FloatShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Float2ShortMap extends Map, Float2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction 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". - * 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 short supplyShortIfAbsent(float key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Float2ShortMap extends Map, Float2ShortFunction * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(float 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(float key, FloatShortUnaryOperator 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/floats/queues/FloatArrayFIFOQueue.java b/src/main/java/speiger/src/collections/floats/queues/FloatArrayFIFOQueue.java index b041064..1cfb72d 100644 --- a/src/main/java/speiger/src/collections/floats/queues/FloatArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/floats/queues/FloatArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class FloatArrayFIFOQueue extends AbstractFloatPriorityQueue implements F return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(float e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class FloatIterators } } + private static class InfiniteIterator implements FloatIterator + { + FloatIterator iter; + CollectionWrapper looper = FloatCollections.wrapper(); + int index = 0; + + public InfiniteIterator(FloatIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public float nextFloat() { + if(iter != null) { + if(iter.hasNext()) { + float value = iter.nextFloat(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getFloat((index++) % looper.size()); + } + + @Override + public void forEachRemaining(FloatConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectFloatConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements FloatIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/floats/utils/FloatLists.java b/src/main/java/speiger/src/collections/floats/utils/FloatLists.java index 9ede258..fad29f8 100644 --- a/src/main/java/speiger/src/collections/floats/utils/FloatLists.java +++ b/src/main/java/speiger/src/collections/floats/utils/FloatLists.java @@ -12,6 +12,7 @@ import speiger.src.collections.floats.collections.FloatCollection; import speiger.src.collections.floats.functions.FloatConsumer; import speiger.src.collections.floats.lists.AbstractFloatList; import speiger.src.collections.floats.lists.FloatList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.floats.lists.FloatListIterator; import speiger.src.collections.utils.SanityChecks; @@ -317,6 +318,16 @@ public class FloatLists return l.listIterator(index); } + @Override + public FloatListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public FloatListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public FloatList subList(int from, int to) { return FloatLists.synchronize(l.subList(from, to)); @@ -426,6 +437,16 @@ public class FloatLists return FloatIterators.unmodifiable(l.listIterator(index)); } + @Override + public FloatListIterator indexedIterator(int...indecies) { + return FloatIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public FloatListIterator indexedIterator(IntList indecies) { + return FloatIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public FloatList subList(int from, int to) { return FloatLists.unmodifiable(l.subList(from, to)); @@ -514,6 +535,16 @@ public class FloatLists return FloatIterators.empty(); } + @Override + public FloatListIterator indexedIterator(int...indecies) { + return FloatIterators.empty(); + } + + @Override + public FloatListIterator indexedIterator(IntList indecies) { + return FloatIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/floats/utils/FloatPriorityQueues.java b/src/main/java/speiger/src/collections/floats/utils/FloatPriorityQueues.java index 8bf0629..c47e06f 100644 --- a/src/main/java/speiger/src/collections/floats/utils/FloatPriorityQueues.java +++ b/src/main/java/speiger/src/collections/floats/utils/FloatPriorityQueues.java @@ -89,6 +89,8 @@ public class FloatPriorityQueues @Override public float peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(float e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(float e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(float e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2BooleanMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2BooleanMaps.java index 52ec471..e2fc89c 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2BooleanMaps.java @@ -246,18 +246,18 @@ public class Float2BooleanMaps @Override public boolean computeBoolean(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(float key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Float2BooleanMaps @Override public boolean computeBoolean(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(float key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Float2BooleanMaps @Override public boolean computeBoolean(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(float key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Float2BooleanMaps @Override public boolean computeBoolean(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(float key, FloatPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(float key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(float key, FloatPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(float key, FloatBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(float key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(float key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ByteMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ByteMaps.java index 5b46cf1..4bef7b8 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ByteMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ByteMaps.java @@ -250,18 +250,18 @@ public class Float2ByteMaps @Override public byte computeByte(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(float key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2ByteMaps @Override public byte computeByte(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(float key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2ByteMaps @Override public byte computeByte(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(float key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2ByteMaps @Override public byte computeByte(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(float key, Float2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(float key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(float key, Float2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(float key, FloatByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(float key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(float key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2CharMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2CharMaps.java index f92eca6..29c60ed 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2CharMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2CharMaps.java @@ -250,18 +250,18 @@ public class Float2CharMaps @Override public char computeChar(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(float key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2CharMaps @Override public char computeChar(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(float key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2CharMaps @Override public char computeChar(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(float key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2CharMaps @Override public char computeChar(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(float key, Float2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(float key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(float key, Float2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(float key, FloatCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(float key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(float key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2DoubleMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2DoubleMaps.java index 4a3fe4b..ccfec8e 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2DoubleMaps.java @@ -250,18 +250,18 @@ public class Float2DoubleMaps @Override public double computeDouble(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(float key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2DoubleMaps @Override public double computeDouble(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(float key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2DoubleMaps @Override public double computeDouble(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(float key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2DoubleMaps @Override public double computeDouble(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(float key, Float2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(float key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(float key, Float2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(float key, FloatDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(float key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(float key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2FloatMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2FloatMaps.java index 9125dda..57de78c 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2FloatMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2FloatMaps.java @@ -249,18 +249,18 @@ public class Float2FloatMaps @Override public float computeFloat(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(float key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Float2FloatMaps @Override public float computeFloat(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(float key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Float2FloatMaps @Override public float computeFloat(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(float key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Float2FloatMaps @Override public float computeFloat(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(float key, FloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(float key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(float key, FloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(float key, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(float key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(float key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2IntMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2IntMaps.java index c6e388a..bb19810 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2IntMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2IntMaps.java @@ -250,18 +250,18 @@ public class Float2IntMaps @Override public int computeInt(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(float key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2IntMaps @Override public int computeInt(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(float key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2IntMaps @Override public int computeInt(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(float key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2IntMaps @Override public int computeInt(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(float key, Float2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(float key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(float key, Float2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(float key, FloatIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(float key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(float key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2LongMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2LongMaps.java index 90b59d6..32400c3 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2LongMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2LongMaps.java @@ -250,18 +250,18 @@ public class Float2LongMaps @Override public long computeLong(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(float key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2LongMaps @Override public long computeLong(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(float key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2LongMaps @Override public long computeLong(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(float key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2LongMaps @Override public long computeLong(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(float key, Float2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(float key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(float key, Float2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(float key, FloatLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(float key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(float key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ObjectMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ObjectMaps.java index 7f8dcc0..fc05b5a 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ObjectMaps.java @@ -266,20 +266,12 @@ public class Float2ObjectMaps @Override public V compute(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Float2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Float2ObjectMaps @Override public V compute(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Float2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Float2ObjectMaps @Override public V compute(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Float2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Float2ObjectMaps @Override public V compute(float key, FloatObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(float key, FloatFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(float key, FloatFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(float key, FloatObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(float key, FloatObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(float key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(float key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(float key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Float2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ShortMaps.java b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ShortMaps.java index 9fd0d8b..18ed15f 100644 --- a/src/main/java/speiger/src/collections/floats/utils/maps/Float2ShortMaps.java +++ b/src/main/java/speiger/src/collections/floats/utils/maps/Float2ShortMaps.java @@ -250,18 +250,18 @@ public class Float2ShortMaps @Override public short computeShort(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(float key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Float2ShortMaps @Override public short computeShort(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(float key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Float2ShortMaps @Override public short computeShort(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(float key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Float2ShortMaps @Override public short computeShort(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(float key, Float2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(float key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(float key, Float2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(float key, FloatShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(float key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(float key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/lists/AbstractIntList.java b/src/main/java/speiger/src/collections/ints/lists/AbstractIntList.java index 0c9e8ae..e3fbfec 100644 --- a/src/main/java/speiger/src/collections/ints/lists/AbstractIntList.java +++ b/src/main/java/speiger/src/collections/ints/lists/AbstractIntList.java @@ -205,13 +205,23 @@ public abstract class AbstractIntList extends AbstractIntCollection implements I public IntListIterator listIterator() { return listIterator(0); } - + @Override public IntListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new IntListIter(index); } + @Override + public IntListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public IntListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add(0); @@ -566,7 +576,153 @@ public abstract class AbstractIntList extends AbstractIntCollection implements I } } } + + private class ListIndexedIterator implements IntListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public int nextInt() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getInt((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public int previousInt() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getInt((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(int e) { throw new UnsupportedOperationException(); } + + @Override + public void set(int e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractIntList.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 IntListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public int nextInt() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getInt((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public int previousInt() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getInt((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(int e) { throw new UnsupportedOperationException(); } + + @Override + public void set(int e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractIntList.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 IntListIter implements IntListIterator { int index; int lastReturned = -1; @@ -644,7 +800,7 @@ public abstract class AbstractIntList extends AbstractIntCollection implements I 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/ints/lists/IntList.java b/src/main/java/speiger/src/collections/ints/lists/IntList.java index 8539d47..679ebfa 100644 --- a/src/main/java/speiger/src/collections/ints/lists/IntList.java +++ b/src/main/java/speiger/src/collections/ints/lists/IntList.java @@ -341,6 +341,24 @@ public interface IntList extends IntCollection, List @Override public IntListIterator 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 IntListIterator 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 IntListIterator 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/ints/maps/abstracts/AbstractInt2BooleanMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2BooleanMap.java index d973bbc..8bacde0 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2BooleanMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2BooleanMap.java @@ -151,6 +151,39 @@ public abstract class AbstractInt2BooleanMap extends AbstractMap imp return newValue; } + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractInt2ByteMap extends AbstractMap imp return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractInt2ByteMap extends AbstractMap imp return value; } - @Override - public byte supplyByteIfAbsent(int 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(int 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 abstract class AbstractInt2ByteMap extends AbstractMap imp return value; } - @Override - public byte computeByteIfPresent(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2CharMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2CharMap.java index 5cf14b6..7924b56 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2CharMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2CharMap.java @@ -157,6 +157,39 @@ public abstract class AbstractInt2CharMap extends AbstractMap return newValue; } + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public double supplyDoubleIfAbsent(int 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(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractInt2DoubleMap extends AbstractMap return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractInt2DoubleMap extends AbstractMap return value; } - @Override - public double supplyDoubleIfAbsent(int 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(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractInt2DoubleMap extends AbstractMap return value; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2FloatMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2FloatMap.java index bdb684f..cbe8cec 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2FloatMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2FloatMap.java @@ -157,6 +157,39 @@ public abstract class AbstractInt2FloatMap extends AbstractMap i return newValue; } + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractInt2FloatMap extends AbstractMap i return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractInt2FloatMap extends AbstractMap i return value; } - @Override - public float supplyFloatIfAbsent(int 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(int 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 abstract class AbstractInt2FloatMap extends AbstractMap i return value; } - @Override - public float computeFloatIfPresent(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2IntMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2IntMap.java index eea5a1a..f761c2d 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2IntMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2IntMap.java @@ -155,6 +155,39 @@ public abstract class AbstractInt2IntMap extends AbstractMap i return newValue; } + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(int 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(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -171,17 +204,6 @@ public abstract class AbstractInt2IntMap extends AbstractMap i return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -196,17 +218,6 @@ public abstract class AbstractInt2IntMap extends AbstractMap i return value; } - @Override - public int supplyIntIfAbsent(int 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(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -221,17 +232,6 @@ public abstract class AbstractInt2IntMap extends AbstractMap i return value; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2LongMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2LongMap.java index 58e7d91..da57cbe 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2LongMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2LongMap.java @@ -157,6 +157,39 @@ public abstract class AbstractInt2LongMap extends AbstractMap imp return newValue; } + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(int 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(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractInt2LongMap extends AbstractMap imp return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractInt2LongMap extends AbstractMap imp return value; } - @Override - public long supplyLongIfAbsent(int 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(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractInt2LongMap extends AbstractMap imp return value; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ObjectMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ObjectMap.java index d49fcae..9724824 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ObjectMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ObjectMap.java @@ -159,22 +159,6 @@ public abstract class AbstractInt2ObjectMap extends AbstractMap i return newValue; } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -189,20 +173,6 @@ public abstract class AbstractInt2ObjectMap extends AbstractMap i return value; } - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,20 +187,6 @@ public abstract class AbstractInt2ObjectMap extends AbstractMap i return value; } - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -246,21 +202,6 @@ public abstract class AbstractInt2ObjectMap extends AbstractMap i return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ShortMap.java b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ShortMap.java index e0511ed..c79dc49 100644 --- a/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ShortMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/abstracts/AbstractInt2ShortMap.java @@ -157,6 +157,39 @@ public abstract class AbstractInt2ShortMap extends AbstractMap i return newValue; } + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractInt2ShortMap extends AbstractMap i return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractInt2ShortMap extends AbstractMap i return value; } - @Override - public short supplyShortIfAbsent(int 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(int 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 abstract class AbstractInt2ShortMap extends AbstractMap i return value; } - @Override - public short computeShortIfPresent(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2BooleanConcurrentOpenHashMap.java index 8d4057f..adeb692 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2BooleanConcurrentOpenHashMap.java @@ -437,13 +437,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -451,6 +444,27 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,13 +472,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -472,13 +479,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2031,6 +2031,54 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp } } + protected boolean computeIfAbsent(int hash, int key, IntPredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, int key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, int key, IntBooleanUnaryOperator 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 computeNonDefault(int hash, int key, IntBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2054,23 +2102,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp } } - protected boolean computeIfAbsent(int hash, int key, IntPredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, int key, IntPredicate mappingFunction) { long stamp = writeLock(); try { @@ -2094,23 +2125,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp } } - protected boolean supplyIfAbsent(int hash, int key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, int key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2134,20 +2148,6 @@ public class Int2BooleanConcurrentOpenHashMap extends AbstractInt2BooleanMap imp } } - protected boolean computeIfPresent(int hash, int key, IntBooleanUnaryOperator 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, int key, IntBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ByteConcurrentOpenHashMap.java index 2b836cb..10c47fa 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ByteConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement } } + protected byte computeIfAbsent(int hash, int key, Int2ByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, int key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, int key, IntByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, int key, IntByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement } } - protected byte computeIfAbsent(int hash, int key, Int2ByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, int key, Int2ByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,36 +2169,19 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement } } - protected byte supplyIfAbsent(int hash, int key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, int key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2178,20 +2192,6 @@ public class Int2ByteConcurrentOpenHashMap extends AbstractInt2ByteMap implement } } - protected byte computeIfPresent(int hash, int key, IntByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, int key, IntByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2CharConcurrentOpenHashMap.java index eae7d76..5564eb4 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2CharConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement } } + protected char computeIfAbsent(int hash, int key, Int2CharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, int key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, int key, IntCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, int key, IntCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement } } - protected char computeIfAbsent(int hash, int key, Int2CharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, int key, Int2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,36 +2169,19 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement } } - protected char supplyIfAbsent(int hash, int key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, int key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2178,20 +2192,6 @@ public class Int2CharConcurrentOpenHashMap extends AbstractInt2CharMap implement } } - protected char computeIfPresent(int hash, int key, IntCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, int key, IntCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2DoubleConcurrentOpenHashMap.java index dfe0dfa..d33dd53 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2DoubleConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple } } + protected double computeIfAbsent(int hash, int key, Int2DoubleFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, int key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, int key, IntDoubleUnaryOperator 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 computeNonDefault(int hash, int key, IntDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple } } - protected double computeIfAbsent(int hash, int key, Int2DoubleFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, int key, Int2DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,23 +2169,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple } } - protected double supplyIfAbsent(int hash, int key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, int key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2178,20 +2192,6 @@ public class Int2DoubleConcurrentOpenHashMap extends AbstractInt2DoubleMap imple } } - protected double computeIfPresent(int hash, int key, IntDoubleUnaryOperator 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, int key, IntDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2FloatConcurrentOpenHashMap.java index 8cf4c3d..41badbf 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2FloatConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme } } + protected float computeIfAbsent(int hash, int key, Int2FloatFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, int key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, int key, IntFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, int key, IntFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme } } - protected float computeIfAbsent(int hash, int key, Int2FloatFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, int key, Int2FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,36 +2169,19 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme } } - protected float supplyIfAbsent(int hash, int key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, int key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2178,20 +2192,6 @@ public class Int2FloatConcurrentOpenHashMap extends AbstractInt2FloatMap impleme } } - protected float computeIfPresent(int hash, int key, IntFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, int key, IntFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2IntConcurrentOpenHashMap.java index c4cde2b..a481ecc 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2IntConcurrentOpenHashMap.java @@ -443,13 +443,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -457,6 +450,27 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,13 +478,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -478,13 +485,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2068,6 +2068,54 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements } } + protected int computeIfAbsent(int hash, int key, IntUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, int key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, int key, IntIntUnaryOperator 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 computeNonDefault(int hash, int key, IntIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2091,23 +2139,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements } } - protected int computeIfAbsent(int hash, int key, IntUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, int key, IntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2131,23 +2162,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements } } - protected int supplyIfAbsent(int hash, int key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, int key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2171,20 +2185,6 @@ public class Int2IntConcurrentOpenHashMap extends AbstractInt2IntMap implements } } - protected int computeIfPresent(int hash, int key, IntIntUnaryOperator 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, int key, IntIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2LongConcurrentOpenHashMap.java index 69eb157..f917674 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2LongConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement } } + protected long computeIfAbsent(int hash, int key, Int2LongFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, int key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, int key, IntLongUnaryOperator 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 computeNonDefault(int hash, int key, IntLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement } } - protected long computeIfAbsent(int hash, int key, Int2LongFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, int key, Int2LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,23 +2169,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement } } - protected long supplyIfAbsent(int hash, int key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, int key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2178,20 +2192,6 @@ public class Int2LongConcurrentOpenHashMap extends AbstractInt2LongMap implement } } - protected long computeIfPresent(int hash, int key, IntLongUnaryOperator 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, int key, IntLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ObjectConcurrentOpenHashMap.java index 5f624c7..7079dd7 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ObjectConcurrentOpenHashMap.java @@ -425,13 +425,6 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -439,13 +432,6 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -453,13 +439,6 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -467,13 +446,6 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2010,29 +1982,6 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap } } - protected V computeNonDefault(int hash, int key, IntObjectUnaryOperator 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, int key, IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2055,30 +2004,7 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, int key, IntFunction 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, int key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -2101,30 +2027,7 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, int 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, int key, IntObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2143,11 +2046,16 @@ public class Int2ObjectConcurrentOpenHashMap extends AbstractInt2ObjectMap } } - protected V computeIfPresentNonDefault(int hash, int key, IntObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, int key, IntObjectUnaryOperator 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/ints/maps/impl/concurrent/Int2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ShortConcurrentOpenHashMap.java index ff2371a..f507ab2 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/concurrent/Int2ShortConcurrentOpenHashMap.java @@ -450,13 +450,6 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,6 +457,27 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,13 +485,6 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -485,13 +492,6 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2075,6 +2075,54 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme } } + protected short computeIfAbsent(int hash, int key, Int2ShortFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, int key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, int key, IntShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, int key, IntShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2098,23 +2146,6 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme } } - protected short computeIfAbsent(int hash, int key, Int2ShortFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, int key, Int2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2138,36 +2169,19 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme } } - protected short supplyIfAbsent(int hash, int key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, int key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2178,20 +2192,6 @@ public class Int2ShortConcurrentOpenHashMap extends AbstractInt2ShortMap impleme } } - protected short computeIfPresent(int hash, int key, IntShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, int key, IntShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2BooleanOpenCustomHashMap.java index ba3c8c8..d22984b 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2BooleanOpenCustomHashMap.java @@ -439,6 +439,42 @@ public class Int2BooleanOpenCustomHashMap extends AbstractInt2BooleanMap impleme return newValue; } + @Override + public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,19 +494,6 @@ public class Int2BooleanOpenCustomHashMap extends AbstractInt2BooleanMap impleme return newValue; } - @Override - public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -490,19 +513,6 @@ public class Int2BooleanOpenCustomHashMap extends AbstractInt2BooleanMap impleme return newValue; } - @Override - public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -522,16 +532,6 @@ public class Int2BooleanOpenCustomHashMap extends AbstractInt2BooleanMap impleme return newValue; } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ByteOpenCustomHashMap.java index 1a67b0c..9a31c73 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ByteOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2ByteOpenCustomHashMap extends AbstractInt2ByteMap implements IT return newValue; } + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2ByteOpenCustomHashMap extends AbstractInt2ByteMap implements IT return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,48 +535,25 @@ public class Int2ByteOpenCustomHashMap extends AbstractInt2ByteMap implements IT return newValue; } - @Override - public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2CharOpenCustomHashMap.java index 0968c84..c41498e 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2CharOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2CharOpenCustomHashMap extends AbstractInt2CharMap implements IT return newValue; } + @Override + public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2CharOpenCustomHashMap extends AbstractInt2CharMap implements IT return newValue; } - @Override - public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,48 +535,25 @@ public class Int2CharOpenCustomHashMap extends AbstractInt2CharMap implements IT return newValue; } - @Override - public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(int 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(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2DoubleOpenCustomHashMap.java index b5fc27c..b5e8e24 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2DoubleOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2DoubleOpenCustomHashMap extends AbstractInt2DoubleMap implement return newValue; } + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2DoubleOpenCustomHashMap extends AbstractInt2DoubleMap implement return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,19 +535,6 @@ public class Int2DoubleOpenCustomHashMap extends AbstractInt2DoubleMap implement return newValue; } - @Override - public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -544,16 +554,6 @@ public class Int2DoubleOpenCustomHashMap extends AbstractInt2DoubleMap implement return newValue; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2FloatOpenCustomHashMap.java index 3fd3f32..d4542c2 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2FloatOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2FloatOpenCustomHashMap extends AbstractInt2FloatMap implements return newValue; } + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2FloatOpenCustomHashMap extends AbstractInt2FloatMap implements return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,48 +535,25 @@ public class Int2FloatOpenCustomHashMap extends AbstractInt2FloatMap implements return newValue; } - @Override - public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2IntOpenCustomHashMap.java index d816420..3e11e17 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2IntOpenCustomHashMap.java @@ -453,6 +453,42 @@ public class Int2IntOpenCustomHashMap extends AbstractInt2IntMap implements ITri return newValue; } + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,19 +508,6 @@ public class Int2IntOpenCustomHashMap extends AbstractInt2IntMap implements ITri return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -504,19 +527,6 @@ public class Int2IntOpenCustomHashMap extends AbstractInt2IntMap implements ITri return newValue; } - @Override - public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -536,16 +546,6 @@ public class Int2IntOpenCustomHashMap extends AbstractInt2IntMap implements ITri return newValue; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2LongOpenCustomHashMap.java index 82e7481..f813d92 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2LongOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2LongOpenCustomHashMap extends AbstractInt2LongMap implements IT return newValue; } + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2LongOpenCustomHashMap extends AbstractInt2LongMap implements IT return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,19 +535,6 @@ public class Int2LongOpenCustomHashMap extends AbstractInt2LongMap implements IT return newValue; } - @Override - public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -544,16 +554,6 @@ public class Int2LongOpenCustomHashMap extends AbstractInt2LongMap implements IT return newValue; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ObjectOpenCustomHashMap.java index b19a571..c09cb15 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ObjectOpenCustomHashMap.java @@ -431,25 +431,6 @@ public class Int2ObjectOpenCustomHashMap extends AbstractInt2ObjectMap imp return newValue; } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,26 +449,7 @@ public class Int2ObjectOpenCustomHashMap extends AbstractInt2ObjectMap imp } return newValue; } - - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -507,25 +469,6 @@ public class Int2ObjectOpenCustomHashMap extends AbstractInt2ObjectMap imp return newValue; } - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -540,20 +483,6 @@ public class Int2ObjectOpenCustomHashMap extends AbstractInt2ObjectMap imp return newValue; } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ShortOpenCustomHashMap.java index 0b7d519..2e1029d 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/customHash/Int2ShortOpenCustomHashMap.java @@ -461,6 +461,42 @@ public class Int2ShortOpenCustomHashMap extends AbstractInt2ShortMap implements return newValue; } + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +516,6 @@ public class Int2ShortOpenCustomHashMap extends AbstractInt2ShortMap implements return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -512,48 +535,25 @@ public class Int2ShortOpenCustomHashMap extends AbstractInt2ShortMap implements return newValue; } - @Override - public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2BooleanOpenHashMap.java index db27053..fec9234 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2BooleanOpenHashMap.java @@ -407,6 +407,42 @@ public class Int2BooleanOpenHashMap extends AbstractInt2BooleanMap implements IT values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { @@ -427,19 +463,6 @@ public class Int2BooleanOpenHashMap extends AbstractInt2BooleanMap implements IT return newValue; } - @Override - public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +482,6 @@ public class Int2BooleanOpenHashMap extends AbstractInt2BooleanMap implements IT return newValue; } - @Override - public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -491,16 +501,6 @@ public class Int2BooleanOpenHashMap extends AbstractInt2BooleanMap implements IT return newValue; } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ByteOpenHashMap.java index 4aaf17f..1b18c50 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ByteOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2ByteOpenHashMap extends AbstractInt2ByteMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2ByteOpenHashMap extends AbstractInt2ByteMap implements ITrimmab return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,48 +504,25 @@ public class Int2ByteOpenHashMap extends AbstractInt2ByteMap implements ITrimmab return newValue; } - @Override - public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2CharOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2CharOpenHashMap.java index f2ab45c..ac2e07c 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2CharOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2CharOpenHashMap extends AbstractInt2CharMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2CharOpenHashMap extends AbstractInt2CharMap implements ITrimmab return newValue; } - @Override - public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,48 +504,25 @@ public class Int2CharOpenHashMap extends AbstractInt2CharMap implements ITrimmab return newValue; } - @Override - public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(int 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(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2DoubleOpenHashMap.java index f6e49cb..268326a 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2DoubleOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2DoubleOpenHashMap extends AbstractInt2DoubleMap implements ITri values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2DoubleOpenHashMap extends AbstractInt2DoubleMap implements ITri return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +504,6 @@ public class Int2DoubleOpenHashMap extends AbstractInt2DoubleMap implements ITri return newValue; } - @Override - public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -513,16 +523,6 @@ public class Int2DoubleOpenHashMap extends AbstractInt2DoubleMap implements ITri return newValue; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2FloatOpenHashMap.java index 74c7ad2..ce2a763 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2FloatOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2FloatOpenHashMap extends AbstractInt2FloatMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2FloatOpenHashMap extends AbstractInt2FloatMap implements ITrimm return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,48 +504,25 @@ public class Int2FloatOpenHashMap extends AbstractInt2FloatMap implements ITrimm return newValue; } - @Override - public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2IntOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2IntOpenHashMap.java index 983efa3..cd235ce 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2IntOpenHashMap.java @@ -423,6 +423,42 @@ public class Int2IntOpenHashMap extends AbstractInt2IntMap implements ITrimmable values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { @@ -443,19 +479,6 @@ public class Int2IntOpenHashMap extends AbstractInt2IntMap implements ITrimmable return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -475,19 +498,6 @@ public class Int2IntOpenHashMap extends AbstractInt2IntMap implements ITrimmable return newValue; } - @Override - public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -507,16 +517,6 @@ public class Int2IntOpenHashMap extends AbstractInt2IntMap implements ITrimmable return newValue; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2LongOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2LongOpenHashMap.java index 6651d4f..b5d9524 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2LongOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2LongOpenHashMap extends AbstractInt2LongMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2LongOpenHashMap extends AbstractInt2LongMap implements ITrimmab return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +504,6 @@ public class Int2LongOpenHashMap extends AbstractInt2LongMap implements ITrimmab return newValue; } - @Override - public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -513,16 +523,6 @@ public class Int2LongOpenHashMap extends AbstractInt2LongMap implements ITrimmab return newValue; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ObjectOpenHashMap.java index 14582d6..17d07cf 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ObjectOpenHashMap.java @@ -400,26 +400,7 @@ public class Int2ObjectOpenHashMap extends AbstractInt2ObjectMap implement values[index] = newValue; return newValue; } - - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -439,25 +420,6 @@ public class Int2ObjectOpenHashMap extends AbstractInt2ObjectMap implement return newValue; } - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -476,26 +438,7 @@ public class Int2ObjectOpenHashMap extends AbstractInt2ObjectMap implement } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -510,20 +453,6 @@ public class Int2ObjectOpenHashMap extends AbstractInt2ObjectMap implement return newValue; } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ShortOpenHashMap.java index 8c6d265..50ac239 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/hash/Int2ShortOpenHashMap.java @@ -429,6 +429,42 @@ public class Int2ShortOpenHashMap extends AbstractInt2ShortMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { @@ -449,19 +485,6 @@ public class Int2ShortOpenHashMap extends AbstractInt2ShortMap implements ITrimm return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,48 +504,25 @@ public class Int2ShortOpenHashMap extends AbstractInt2ShortMap implements ITrimm return newValue; } - @Override - public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2BooleanOpenHashMap.java index c067786..a737fed 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2BooleanOpenHashMap.java @@ -412,20 +412,19 @@ public class ImmutableInt2BooleanOpenHashMap extends AbstractInt2BooleanMap impl @Override public boolean computeBoolean(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(int key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ByteOpenHashMap.java index fec320d..03acab0 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ByteOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2ByteOpenHashMap extends AbstractInt2ByteMap implements @Override public byte computeByte(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(int key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2CharOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2CharOpenHashMap.java index 4ecfb6f..c814033 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2CharOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2CharOpenHashMap extends AbstractInt2CharMap implements @Override public char computeChar(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(int key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2DoubleOpenHashMap.java index 372a2a0..518af42 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2DoubleOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2DoubleOpenHashMap extends AbstractInt2DoubleMap implem @Override public double computeDouble(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(int key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2FloatOpenHashMap.java index 7853a98..7edc2c2 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2FloatOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2FloatOpenHashMap extends AbstractInt2FloatMap implemen @Override public float computeFloat(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(int key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2IntOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2IntOpenHashMap.java index 2ceb368..a487b3f 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2IntOpenHashMap.java @@ -408,20 +408,19 @@ public class ImmutableInt2IntOpenHashMap extends AbstractInt2IntMap implements I @Override public int computeInt(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(int key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2LongOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2LongOpenHashMap.java index 89cf633..17a53a1 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2LongOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2LongOpenHashMap extends AbstractInt2LongMap implements @Override public long computeLong(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(int key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ObjectOpenHashMap.java index df61e10..5556e87 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ObjectOpenHashMap.java @@ -396,20 +396,11 @@ public class ImmutableInt2ObjectOpenHashMap extends AbstractInt2ObjectMap @Override public V compute(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ShortOpenHashMap.java index 5626046..60975d5 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/immutable/ImmutableInt2ShortOpenHashMap.java @@ -417,20 +417,19 @@ public class ImmutableInt2ShortOpenHashMap extends AbstractInt2ShortMap implemen @Override public short computeShort(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(int key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2BooleanArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2BooleanArrayMap.java index 11ed01b..1c1a14e 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2BooleanArrayMap.java @@ -418,6 +418,42 @@ public class Int2BooleanArrayMap extends AbstractInt2BooleanMap implements Int2B return newValue; } + @Override + public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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 computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -437,19 +473,6 @@ public class Int2BooleanArrayMap extends AbstractInt2BooleanMap implements Int2B return newValue; } - @Override - public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -469,19 +492,6 @@ public class Int2BooleanArrayMap extends AbstractInt2BooleanMap implements Int2B return newValue; } - @Override - public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -501,16 +511,6 @@ public class Int2BooleanArrayMap extends AbstractInt2BooleanMap implements Int2B return newValue; } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ByteArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ByteArrayMap.java index 4291257..7df3f1f 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ByteArrayMap.java @@ -441,6 +441,42 @@ public class Int2ByteArrayMap extends AbstractInt2ByteMap implements Int2ByteOrd return newValue; } + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(int key, IntByteUnaryOperator 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 computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2ByteArrayMap extends AbstractInt2ByteMap implements Int2ByteOrd return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,48 +515,25 @@ public class Int2ByteArrayMap extends AbstractInt2ByteMap implements Int2ByteOrd return newValue; } - @Override - public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2CharArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2CharArrayMap.java index b952c5a..9a42945 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2CharArrayMap.java @@ -441,6 +441,42 @@ public class Int2CharArrayMap extends AbstractInt2CharMap implements Int2CharOrd return newValue; } + @Override + public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(int key, IntCharUnaryOperator 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 computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2CharArrayMap extends AbstractInt2CharMap implements Int2CharOrd return newValue; } - @Override - public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,48 +515,25 @@ public class Int2CharArrayMap extends AbstractInt2CharMap implements Int2CharOrd return newValue; } - @Override - public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(int 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(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2DoubleArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2DoubleArrayMap.java index 88b96dd..61917f5 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2DoubleArrayMap.java @@ -441,6 +441,42 @@ public class Int2DoubleArrayMap extends AbstractInt2DoubleMap implements Int2Dou return newValue; } + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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 computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2DoubleArrayMap extends AbstractInt2DoubleMap implements Int2Dou return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,19 +515,6 @@ public class Int2DoubleArrayMap extends AbstractInt2DoubleMap implements Int2Dou return newValue; } - @Override - public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -524,16 +534,6 @@ public class Int2DoubleArrayMap extends AbstractInt2DoubleMap implements Int2Dou return newValue; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2FloatArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2FloatArrayMap.java index f05cf13..6beb9a9 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2FloatArrayMap.java @@ -441,6 +441,42 @@ public class Int2FloatArrayMap extends AbstractInt2FloatMap implements Int2Float return newValue; } + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(int key, IntFloatUnaryOperator 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 computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2FloatArrayMap extends AbstractInt2FloatMap implements Int2Float return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,48 +515,25 @@ public class Int2FloatArrayMap extends AbstractInt2FloatMap implements Int2Float return newValue; } - @Override - public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2IntArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2IntArrayMap.java index eadb227..ce199c7 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2IntArrayMap.java @@ -434,6 +434,42 @@ public class Int2IntArrayMap extends AbstractInt2IntMap implements Int2IntOrdere return newValue; } + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(int key, IntIntUnaryOperator 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 computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,19 +489,6 @@ public class Int2IntArrayMap extends AbstractInt2IntMap implements Int2IntOrdere return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -485,19 +508,6 @@ public class Int2IntArrayMap extends AbstractInt2IntMap implements Int2IntOrdere return newValue; } - @Override - public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -517,16 +527,6 @@ public class Int2IntArrayMap extends AbstractInt2IntMap implements Int2IntOrdere return newValue; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2LongArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2LongArrayMap.java index 5d3de12..679fb0c 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2LongArrayMap.java @@ -441,6 +441,42 @@ public class Int2LongArrayMap extends AbstractInt2LongMap implements Int2LongOrd return newValue; } + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(int key, IntLongUnaryOperator 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 computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2LongArrayMap extends AbstractInt2LongMap implements Int2LongOrd return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,19 +515,6 @@ public class Int2LongArrayMap extends AbstractInt2LongMap implements Int2LongOrd return newValue; } - @Override - public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -524,16 +534,6 @@ public class Int2LongArrayMap extends AbstractInt2LongMap implements Int2LongOrd return newValue; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ObjectArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ObjectArrayMap.java index 4b1e53d..2ab9da0 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ObjectArrayMap.java @@ -414,25 +414,6 @@ public class Int2ObjectArrayMap extends AbstractInt2ObjectMap implements I return newValue; } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -451,26 +432,7 @@ public class Int2ObjectArrayMap extends AbstractInt2ObjectMap implements I } return newValue; } - - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -489,26 +451,7 @@ public class Int2ObjectArrayMap extends AbstractInt2ObjectMap implements I } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -523,20 +466,6 @@ public class Int2ObjectArrayMap extends AbstractInt2ObjectMap implements I return newValue; } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ShortArrayMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ShortArrayMap.java index 58400ac..6045174 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/misc/Int2ShortArrayMap.java @@ -441,6 +441,42 @@ public class Int2ShortArrayMap extends AbstractInt2ShortMap implements Int2Short return newValue; } + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(int key, IntShortUnaryOperator 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 computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +496,6 @@ public class Int2ShortArrayMap extends AbstractInt2ShortMap implements Int2Short return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -492,48 +515,25 @@ public class Int2ShortArrayMap extends AbstractInt2ShortMap implements Int2Short return newValue; } - @Override - public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanAVLTreeMap.java index 51ba573..fd5f2d4 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanAVLTreeMap.java @@ -394,6 +394,40 @@ public class Int2BooleanAVLTreeMap extends AbstractInt2BooleanMap implements Int return newValue; } + @Override + public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(int 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(int key, IntBooleanUnaryOperator 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 computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Int2BooleanAVLTreeMap extends AbstractInt2BooleanMap implements Int return newValue; } - @Override - public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Int2BooleanAVLTreeMap extends AbstractInt2BooleanMap implements Int return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(int 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(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Int2BooleanAVLTreeMap extends AbstractInt2BooleanMap implements Int return entry.value; } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1486,14 +1486,9 @@ public class Int2BooleanAVLTreeMap extends AbstractInt2BooleanMap implements Int 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/ints/maps/impl/tree/Int2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanRBTreeMap.java index c45cb1e..b1c568b 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2BooleanRBTreeMap.java @@ -393,6 +393,40 @@ public class Int2BooleanRBTreeMap extends AbstractInt2BooleanMap implements Int2 return newValue; } + @Override + public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(int 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(int key, IntBooleanUnaryOperator 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 computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -412,18 +446,6 @@ public class Int2BooleanRBTreeMap extends AbstractInt2BooleanMap implements Int2 return newValue; } - @Override - public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -442,18 +464,6 @@ public class Int2BooleanRBTreeMap extends AbstractInt2BooleanMap implements Int2 return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(int 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(int key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -472,16 +482,6 @@ public class Int2BooleanRBTreeMap extends AbstractInt2BooleanMap implements Int2 return entry.value; } - @Override - public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator 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(int key, IntBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1549,14 +1549,9 @@ public class Int2BooleanRBTreeMap extends AbstractInt2BooleanMap implements Int2 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/ints/maps/impl/tree/Int2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteAVLTreeMap.java index fa73b2b..0e91dbf 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2ByteAVLTreeMap extends AbstractInt2ByteMap implements Int2ByteN return newValue; } + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(int 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(int key, IntByteUnaryOperator 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 computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2ByteAVLTreeMap extends AbstractInt2ByteMap implements Int2ByteN return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Int2ByteAVLTreeMap extends AbstractInt2ByteMap implements Int2ByteN return entry.value; } - @Override - public byte supplyByteIfAbsent(int 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(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2ByteAVLTreeMap extends AbstractInt2ByteMap implements Int2ByteN 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/ints/maps/impl/tree/Int2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteRBTreeMap.java index 7b4a365..fa84284 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ByteRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2ByteRBTreeMap extends AbstractInt2ByteMap implements Int2ByteNa return newValue; } + @Override + public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(int 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(int key, IntByteUnaryOperator 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 computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2ByteRBTreeMap extends AbstractInt2ByteMap implements Int2ByteNa return newValue; } - @Override - public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,46 +523,24 @@ public class Int2ByteRBTreeMap extends AbstractInt2ByteMap implements Int2ByteNa return entry.value; } - @Override - public byte supplyByteIfAbsent(int 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(int 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(int key, IntByteUnaryOperator 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(int key, IntByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2ByteRBTreeMap extends AbstractInt2ByteMap implements Int2ByteNa 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/ints/maps/impl/tree/Int2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharAVLTreeMap.java index 40ef7f9..1ed98d4 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2CharAVLTreeMap extends AbstractInt2CharMap implements Int2CharN return newValue; } + @Override + public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(int 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(int key, IntCharUnaryOperator 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 computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2CharAVLTreeMap extends AbstractInt2CharMap implements Int2CharN return newValue; } - @Override - public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Int2CharAVLTreeMap extends AbstractInt2CharMap implements Int2CharN return entry.value; } - @Override - public char supplyCharIfAbsent(int 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(int 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(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2CharAVLTreeMap extends AbstractInt2CharMap implements Int2CharN 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/ints/maps/impl/tree/Int2CharRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharRBTreeMap.java index 103b4aa..d595de7 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2CharRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2CharRBTreeMap extends AbstractInt2CharMap implements Int2CharNa return newValue; } + @Override + public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(int 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(int key, IntCharUnaryOperator 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 computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2CharRBTreeMap extends AbstractInt2CharMap implements Int2CharNa return newValue; } - @Override - public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,46 +523,24 @@ public class Int2CharRBTreeMap extends AbstractInt2CharMap implements Int2CharNa return entry.value; } - @Override - public char supplyCharIfAbsent(int 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(int 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(int key, IntCharUnaryOperator 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(int key, IntCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2CharRBTreeMap extends AbstractInt2CharMap implements Int2CharNa 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/ints/maps/impl/tree/Int2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleAVLTreeMap.java index c08415f..d2724dc 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2DoubleAVLTreeMap extends AbstractInt2DoubleMap implements Int2D return newValue; } + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(int 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(int key, IntDoubleUnaryOperator 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 computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2DoubleAVLTreeMap extends AbstractInt2DoubleMap implements Int2D return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Int2DoubleAVLTreeMap extends AbstractInt2DoubleMap implements Int2D return entry.value; } - @Override - public double supplyDoubleIfAbsent(int 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(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Int2DoubleAVLTreeMap extends AbstractInt2DoubleMap implements Int2D return entry.value; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2DoubleAVLTreeMap extends AbstractInt2DoubleMap implements Int2D 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/ints/maps/impl/tree/Int2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleRBTreeMap.java index a3dee17..4fdbc56 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2DoubleRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2DoubleRBTreeMap extends AbstractInt2DoubleMap implements Int2Do return newValue; } + @Override + public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(int 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(int key, IntDoubleUnaryOperator 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 computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2DoubleRBTreeMap extends AbstractInt2DoubleMap implements Int2Do return newValue; } - @Override - public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,18 +523,6 @@ public class Int2DoubleRBTreeMap extends AbstractInt2DoubleMap implements Int2Do return entry.value; } - @Override - public double supplyDoubleIfAbsent(int 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(int key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -531,16 +541,6 @@ public class Int2DoubleRBTreeMap extends AbstractInt2DoubleMap implements Int2Do return entry.value; } - @Override - public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator 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(int key, IntDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2DoubleRBTreeMap extends AbstractInt2DoubleMap implements Int2Do 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/ints/maps/impl/tree/Int2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatAVLTreeMap.java index 95c74a7..eb228e3 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2FloatAVLTreeMap extends AbstractInt2FloatMap implements Int2Flo return newValue; } + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(int 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(int key, IntFloatUnaryOperator 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 computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2FloatAVLTreeMap extends AbstractInt2FloatMap implements Int2Flo return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Int2FloatAVLTreeMap extends AbstractInt2FloatMap implements Int2Flo return entry.value; } - @Override - public float supplyFloatIfAbsent(int 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(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2FloatAVLTreeMap extends AbstractInt2FloatMap implements Int2Flo 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/ints/maps/impl/tree/Int2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatRBTreeMap.java index 0180ef8..084f78c 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2FloatRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2FloatRBTreeMap extends AbstractInt2FloatMap implements Int2Floa return newValue; } + @Override + public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(int 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(int key, IntFloatUnaryOperator 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 computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2FloatRBTreeMap extends AbstractInt2FloatMap implements Int2Floa return newValue; } - @Override - public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,46 +523,24 @@ public class Int2FloatRBTreeMap extends AbstractInt2FloatMap implements Int2Floa return entry.value; } - @Override - public float supplyFloatIfAbsent(int 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(int 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(int key, IntFloatUnaryOperator 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(int key, IntFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2FloatRBTreeMap extends AbstractInt2FloatMap implements Int2Floa 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/ints/maps/impl/tree/Int2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntAVLTreeMap.java index 902882e..ebcf788 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntAVLTreeMap.java @@ -445,6 +445,40 @@ public class Int2IntAVLTreeMap extends AbstractInt2IntMap implements Int2IntNavi return newValue; } + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(int 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(int key, IntIntUnaryOperator 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 computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Int2IntAVLTreeMap extends AbstractInt2IntMap implements Int2IntNavi return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,18 +516,6 @@ public class Int2IntAVLTreeMap extends AbstractInt2IntMap implements Int2IntNavi return entry.value; } - @Override - public int supplyIntIfAbsent(int 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(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -524,16 +534,6 @@ public class Int2IntAVLTreeMap extends AbstractInt2IntMap implements Int2IntNavi return entry.value; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1549,14 +1549,9 @@ public class Int2IntAVLTreeMap extends AbstractInt2IntMap implements Int2IntNavi 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/ints/maps/impl/tree/Int2IntRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntRBTreeMap.java index 8c2cd35..9dc7932 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2IntRBTreeMap.java @@ -444,6 +444,40 @@ public class Int2IntRBTreeMap extends AbstractInt2IntMap implements Int2IntNavig return newValue; } + @Override + public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(int 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(int key, IntIntUnaryOperator 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 computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -463,18 +497,6 @@ public class Int2IntRBTreeMap extends AbstractInt2IntMap implements Int2IntNavig return newValue; } - @Override - public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,18 +515,6 @@ public class Int2IntRBTreeMap extends AbstractInt2IntMap implements Int2IntNavig return entry.value; } - @Override - public int supplyIntIfAbsent(int 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(int key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Int2IntRBTreeMap extends AbstractInt2IntMap implements Int2IntNavig return entry.value; } - @Override - public int computeIntIfPresent(int key, IntIntUnaryOperator 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(int key, IntIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1612,14 +1612,9 @@ public class Int2IntRBTreeMap extends AbstractInt2IntMap implements Int2IntNavig 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/ints/maps/impl/tree/Int2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongAVLTreeMap.java index c48768b..48bbcfe 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2LongAVLTreeMap extends AbstractInt2LongMap implements Int2LongN return newValue; } + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(int 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(int key, IntLongUnaryOperator 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 computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2LongAVLTreeMap extends AbstractInt2LongMap implements Int2LongN return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Int2LongAVLTreeMap extends AbstractInt2LongMap implements Int2LongN return entry.value; } - @Override - public long supplyLongIfAbsent(int 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(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Int2LongAVLTreeMap extends AbstractInt2LongMap implements Int2LongN return entry.value; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2LongAVLTreeMap extends AbstractInt2LongMap implements Int2LongN 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/ints/maps/impl/tree/Int2LongRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongRBTreeMap.java index c1ab9a1..1fb48c8 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2LongRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2LongRBTreeMap extends AbstractInt2LongMap implements Int2LongNa return newValue; } + @Override + public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(int 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(int key, IntLongUnaryOperator 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 computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2LongRBTreeMap extends AbstractInt2LongMap implements Int2LongNa return newValue; } - @Override - public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,18 +523,6 @@ public class Int2LongRBTreeMap extends AbstractInt2LongMap implements Int2LongNa return entry.value; } - @Override - public long supplyLongIfAbsent(int 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(int key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -531,16 +541,6 @@ public class Int2LongRBTreeMap extends AbstractInt2LongMap implements Int2LongNa return entry.value; } - @Override - public long computeLongIfPresent(int key, IntLongUnaryOperator 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(int key, IntLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2LongRBTreeMap extends AbstractInt2LongMap implements Int2LongNa 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/ints/maps/impl/tree/Int2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectAVLTreeMap.java index 0835287..2d59413 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectAVLTreeMap.java @@ -394,25 +394,6 @@ public class Int2ObjectAVLTreeMap extends AbstractInt2ObjectMap implements return newValue; } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Int2ObjectAVLTreeMap extends AbstractInt2ObjectMap implements return entry.value; } - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Int2ObjectAVLTreeMap extends AbstractInt2ObjectMap implements return entry.value; } - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Int2ObjectAVLTreeMap extends AbstractInt2ObjectMap implements return newValue; } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectRBTreeMap.java index d3adb11..a301dde 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ObjectRBTreeMap.java @@ -393,25 +393,6 @@ public class Int2ObjectRBTreeMap extends AbstractInt2ObjectMap implements return newValue; } - @Override - public V computeNonDefault(int key, IntObjectUnaryOperator 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(int key, IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -430,24 +411,6 @@ public class Int2ObjectRBTreeMap extends AbstractInt2ObjectMap implements return entry.value; } - @Override - public V computeIfAbsentNonDefault(int key, IntFunction 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(int key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -466,24 +429,6 @@ public class Int2ObjectRBTreeMap extends AbstractInt2ObjectMap implements return entry.value; } - @Override - public V supplyIfAbsentNonDefault(int 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(int key, IntObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,20 +443,6 @@ public class Int2ObjectRBTreeMap extends AbstractInt2ObjectMap implements return newValue; } - @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator 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(int key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortAVLTreeMap.java index ad8955b..ec89575 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortAVLTreeMap.java @@ -453,6 +453,40 @@ public class Int2ShortAVLTreeMap extends AbstractInt2ShortMap implements Int2Sho return newValue; } + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(int 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(int key, IntShortUnaryOperator 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 computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Int2ShortAVLTreeMap extends AbstractInt2ShortMap implements Int2Sho return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Int2ShortAVLTreeMap extends AbstractInt2ShortMap implements Int2Sho return entry.value; } - @Override - public short supplyShortIfAbsent(int 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(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1557,14 +1557,9 @@ public class Int2ShortAVLTreeMap extends AbstractInt2ShortMap implements Int2Sho 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/ints/maps/impl/tree/Int2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortRBTreeMap.java index 2df30c3..aba819c 100644 --- a/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/impl/tree/Int2ShortRBTreeMap.java @@ -452,6 +452,40 @@ public class Int2ShortRBTreeMap extends AbstractInt2ShortMap implements Int2Shor return newValue; } + @Override + public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(int 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(int key, IntShortUnaryOperator 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 computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -471,18 +505,6 @@ public class Int2ShortRBTreeMap extends AbstractInt2ShortMap implements Int2Shor return newValue; } - @Override - public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -501,46 +523,24 @@ public class Int2ShortRBTreeMap extends AbstractInt2ShortMap implements Int2Shor return entry.value; } - @Override - public short supplyShortIfAbsent(int 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(int 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(int key, IntShortUnaryOperator 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(int key, IntShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1620,14 +1620,9 @@ public class Int2ShortRBTreeMap extends AbstractInt2ShortMap implements Int2Shor 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/ints/maps/interfaces/Int2BooleanMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2BooleanMap.java index 27f7d66..1563e52 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2BooleanMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2BooleanMap.java @@ -283,15 +283,6 @@ public interface Int2BooleanMap extends Map, IntPredicate * @return the result of the computation */ public boolean computeBoolean(int key, IntBooleanUnaryOperator 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 boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Int2BooleanMap extends Map, IntPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(int key, IntPredicate 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". + * 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 boolean supplyBooleanIfAbsent(int 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(int key, IntBooleanUnaryOperator 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 boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Int2BooleanMap extends Map, IntPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate 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". - * 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 boolean supplyBooleanIfAbsent(int key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Int2BooleanMap extends Map, IntPredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(int 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(int key, IntBooleanUnaryOperator 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/ints/maps/interfaces/Int2ByteMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ByteMap.java index be9d544..dc684ac 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ByteMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ByteMap.java @@ -308,15 +308,6 @@ public interface Int2ByteMap extends Map, Int2ByteFunction * @return the result of the computation */ public byte computeByte(int key, IntByteUnaryOperator 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 byte computeByteNonDefault(int key, IntByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2ByteMap extends Map, Int2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(int key, Int2ByteFunction 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". + * 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 byte supplyByteIfAbsent(int 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(int key, IntByteUnaryOperator 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 byte computeByteNonDefault(int key, IntByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2ByteMap extends Map, Int2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction 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". - * 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 byte supplyByteIfAbsent(int key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Int2ByteMap extends Map, Int2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(int 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(int key, IntByteUnaryOperator 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/ints/maps/interfaces/Int2CharMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2CharMap.java index 53c0699..e693300 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2CharMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2CharMap.java @@ -308,15 +308,6 @@ public interface Int2CharMap extends Map, Int2CharFunction * @return the result of the computation */ public char computeChar(int key, IntCharUnaryOperator 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 char computeCharNonDefault(int key, IntCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2CharMap extends Map, Int2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(int key, Int2CharFunction 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". + * 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 char supplyCharIfAbsent(int 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(int key, IntCharUnaryOperator 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 char computeCharNonDefault(int key, IntCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2CharMap extends Map, Int2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(int key, Int2CharFunction 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". - * 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 char supplyCharIfAbsent(int key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Int2CharMap extends Map, Int2CharFunction * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(int 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(int key, IntCharUnaryOperator 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/ints/maps/interfaces/Int2DoubleMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2DoubleMap.java index 52df359..bc34d34 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2DoubleMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2DoubleMap.java @@ -308,15 +308,6 @@ public interface Int2DoubleMap extends Map, Int2DoubleFunction * @return the result of the computation */ public double computeDouble(int key, IntDoubleUnaryOperator 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 double computeDoubleNonDefault(int key, IntDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2DoubleMap extends Map, Int2DoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(int key, Int2DoubleFunction 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". + * 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 double supplyDoubleIfAbsent(int 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(int key, IntDoubleUnaryOperator 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 double computeDoubleNonDefault(int key, IntDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2DoubleMap extends Map, Int2DoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction 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". - * 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 double supplyDoubleIfAbsent(int key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Int2DoubleMap extends Map, Int2DoubleFunction * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(int 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(int key, IntDoubleUnaryOperator 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/ints/maps/interfaces/Int2FloatMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2FloatMap.java index 8d6f621..9f6def3 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2FloatMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2FloatMap.java @@ -308,15 +308,6 @@ public interface Int2FloatMap extends Map, Int2FloatFunction * @return the result of the computation */ public float computeFloat(int key, IntFloatUnaryOperator 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 float computeFloatNonDefault(int key, IntFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2FloatMap extends Map, Int2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(int key, Int2FloatFunction 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". + * 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 float supplyFloatIfAbsent(int 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(int key, IntFloatUnaryOperator 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 float computeFloatNonDefault(int key, IntFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2FloatMap extends Map, Int2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction 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". - * 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 float supplyFloatIfAbsent(int key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Int2FloatMap extends Map, Int2FloatFunction * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(int 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(int key, IntFloatUnaryOperator 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/ints/maps/interfaces/Int2IntMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2IntMap.java index 472413a..9bfae1a 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2IntMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2IntMap.java @@ -307,15 +307,6 @@ public interface Int2IntMap extends Map, IntUnaryOperator * @return the result of the computation */ public int computeInt(int key, IntIntUnaryOperator 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 int computeIntNonDefault(int key, IntIntUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Int2IntMap extends Map, IntUnaryOperator * @return the result of the computed value or present value */ public int computeIntIfAbsent(int key, IntUnaryOperator 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". + * 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 int supplyIntIfAbsent(int 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(int key, IntIntUnaryOperator 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 int computeIntNonDefault(int key, IntIntUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Int2IntMap extends Map, IntUnaryOperator * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator 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". - * 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 int supplyIntIfAbsent(int key, IntSupplier 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". @@ -352,16 +362,6 @@ public interface Int2IntMap extends Map, IntUnaryOperator * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(int 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(int key, IntIntUnaryOperator 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/ints/maps/interfaces/Int2LongMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2LongMap.java index 5f3722c..375503d 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2LongMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2LongMap.java @@ -308,15 +308,6 @@ public interface Int2LongMap extends Map, Int2LongFunction * @return the result of the computation */ public long computeLong(int key, IntLongUnaryOperator 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 long computeLongNonDefault(int key, IntLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2LongMap extends Map, Int2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(int key, Int2LongFunction 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". + * 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 long supplyLongIfAbsent(int 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(int key, IntLongUnaryOperator 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 long computeLongNonDefault(int key, IntLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2LongMap extends Map, Int2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(int key, Int2LongFunction 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". - * 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 long supplyLongIfAbsent(int key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Int2LongMap extends Map, Int2LongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(int 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(int key, IntLongUnaryOperator 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/ints/maps/interfaces/Int2ObjectMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ObjectMap.java index a6a5567..3ed30da 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ObjectMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ObjectMap.java @@ -266,15 +266,6 @@ public interface Int2ObjectMap extends Map, IntFunction * @return the result of the computation */ public V compute(int key, IntObjectUnaryOperator 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(int key, IntObjectUnaryOperator 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 interface Int2ObjectMap extends Map, IntFunction * @return the result of the computed value or present value */ public V computeIfAbsent(int key, IntFunction 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(int key, IntFunction 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 interface Int2ObjectMap extends Map, IntFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(int 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(int 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 interface Int2ObjectMap extends Map, IntFunction * @note if not present then compute is not executed */ public V computeIfPresent(int key, IntObjectUnaryOperator 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(int key, IntObjectUnaryOperator 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/ints/maps/interfaces/Int2ShortMap.java b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ShortMap.java index 27e22e2..3dafdce 100644 --- a/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ShortMap.java +++ b/src/main/java/speiger/src/collections/ints/maps/interfaces/Int2ShortMap.java @@ -308,15 +308,6 @@ public interface Int2ShortMap extends Map, Int2ShortFunction * @return the result of the computation */ public short computeShort(int key, IntShortUnaryOperator 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 short computeShortNonDefault(int key, IntShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Int2ShortMap extends Map, Int2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(int key, Int2ShortFunction 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". + * 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 short supplyShortIfAbsent(int 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(int key, IntShortUnaryOperator 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 short computeShortNonDefault(int key, IntShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Int2ShortMap extends Map, Int2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction 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". - * 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 short supplyShortIfAbsent(int key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Int2ShortMap extends Map, Int2ShortFunction * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(int 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(int key, IntShortUnaryOperator 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/ints/queues/IntArrayFIFOQueue.java b/src/main/java/speiger/src/collections/ints/queues/IntArrayFIFOQueue.java index 8347c09..7003d20 100644 --- a/src/main/java/speiger/src/collections/ints/queues/IntArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/ints/queues/IntArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class IntArrayFIFOQueue extends AbstractIntPriorityQueue implements IntPr return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(int e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class IntIterators } } + private static class InfiniteIterator implements IntIterator + { + IntIterator iter; + CollectionWrapper looper = IntCollections.wrapper(); + int index = 0; + + public InfiniteIterator(IntIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public int nextInt() { + if(iter != null) { + if(iter.hasNext()) { + int value = iter.nextInt(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getInt((index++) % looper.size()); + } + + @Override + public void forEachRemaining(IntConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectIntConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements IntIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/ints/utils/IntLists.java b/src/main/java/speiger/src/collections/ints/utils/IntLists.java index b75418b..cde1333 100644 --- a/src/main/java/speiger/src/collections/ints/utils/IntLists.java +++ b/src/main/java/speiger/src/collections/ints/utils/IntLists.java @@ -317,6 +317,16 @@ public class IntLists return l.listIterator(index); } + @Override + public IntListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public IntListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public IntList subList(int from, int to) { return IntLists.synchronize(l.subList(from, to)); @@ -426,6 +436,16 @@ public class IntLists return IntIterators.unmodifiable(l.listIterator(index)); } + @Override + public IntListIterator indexedIterator(int...indecies) { + return IntIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public IntListIterator indexedIterator(IntList indecies) { + return IntIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public IntList subList(int from, int to) { return IntLists.unmodifiable(l.subList(from, to)); @@ -514,6 +534,16 @@ public class IntLists return IntIterators.empty(); } + @Override + public IntListIterator indexedIterator(int...indecies) { + return IntIterators.empty(); + } + + @Override + public IntListIterator indexedIterator(IntList indecies) { + return IntIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/ints/utils/IntPriorityQueues.java b/src/main/java/speiger/src/collections/ints/utils/IntPriorityQueues.java index 954066f..3cc8bb4 100644 --- a/src/main/java/speiger/src/collections/ints/utils/IntPriorityQueues.java +++ b/src/main/java/speiger/src/collections/ints/utils/IntPriorityQueues.java @@ -89,6 +89,8 @@ public class IntPriorityQueues @Override public int peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(int e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(int e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(int e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2BooleanMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2BooleanMaps.java index 2d3efa9..2213509 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2BooleanMaps.java @@ -246,18 +246,18 @@ public class Int2BooleanMaps @Override public boolean computeBoolean(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(int key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Int2BooleanMaps @Override public boolean computeBoolean(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(int key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Int2BooleanMaps @Override public boolean computeBoolean(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(int key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Int2BooleanMaps @Override public boolean computeBoolean(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(int key, IntPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(int key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(int key, IntPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(int key, IntBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(int key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(int key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ByteMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ByteMaps.java index 08ff2f6..fe794e5 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ByteMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ByteMaps.java @@ -250,18 +250,18 @@ public class Int2ByteMaps @Override public byte computeByte(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(int key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2ByteMaps @Override public byte computeByte(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(int key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2ByteMaps @Override public byte computeByte(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(int key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2ByteMaps @Override public byte computeByte(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(int key, Int2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(int key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(int key, Int2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(int key, IntByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(int key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(int key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2CharMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2CharMaps.java index 5a2180d..ccef037 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2CharMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2CharMaps.java @@ -250,18 +250,18 @@ public class Int2CharMaps @Override public char computeChar(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(int key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2CharMaps @Override public char computeChar(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(int key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2CharMaps @Override public char computeChar(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(int key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2CharMaps @Override public char computeChar(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(int key, Int2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(int key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(int key, Int2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(int key, IntCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(int key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(int key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2DoubleMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2DoubleMaps.java index 0853ef2..9853a78 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2DoubleMaps.java @@ -250,18 +250,18 @@ public class Int2DoubleMaps @Override public double computeDouble(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(int key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2DoubleMaps @Override public double computeDouble(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(int key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2DoubleMaps @Override public double computeDouble(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(int key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2DoubleMaps @Override public double computeDouble(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(int key, Int2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(int key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(int key, Int2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(int key, IntDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(int key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(int key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2FloatMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2FloatMaps.java index 87829bb..d7a416c 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2FloatMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2FloatMaps.java @@ -250,18 +250,18 @@ public class Int2FloatMaps @Override public float computeFloat(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(int key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2FloatMaps @Override public float computeFloat(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(int key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2FloatMaps @Override public float computeFloat(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(int key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2FloatMaps @Override public float computeFloat(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(int key, Int2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(int key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(int key, Int2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(int key, IntFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(int key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(int key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2IntMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2IntMaps.java index ef9a493..becac88 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2IntMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2IntMaps.java @@ -249,18 +249,18 @@ public class Int2IntMaps @Override public int computeInt(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(int key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Int2IntMaps @Override public int computeInt(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(int key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Int2IntMaps @Override public int computeInt(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(int key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Int2IntMaps @Override public int computeInt(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(int key, IntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(int key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(int key, IntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(int key, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(int key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(int key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2LongMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2LongMaps.java index 59945a1..824d5d5 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2LongMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2LongMaps.java @@ -250,18 +250,18 @@ public class Int2LongMaps @Override public long computeLong(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(int key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2LongMaps @Override public long computeLong(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(int key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2LongMaps @Override public long computeLong(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(int key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2LongMaps @Override public long computeLong(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(int key, Int2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(int key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(int key, Int2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(int key, IntLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(int key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(int key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ObjectMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ObjectMaps.java index 9c3cc38..845c626 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ObjectMaps.java @@ -266,20 +266,12 @@ public class Int2ObjectMaps @Override public V compute(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Int2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Int2ObjectMaps @Override public V compute(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Int2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Int2ObjectMaps @Override public V compute(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Int2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Int2ObjectMaps @Override public V compute(int key, IntObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(int key, IntObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(int key, IntFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(int key, IntFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(int key, IntObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(int key, IntObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(int key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(int key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(int key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Int2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ShortMaps.java b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ShortMaps.java index a1143d1..7b7a92f 100644 --- a/src/main/java/speiger/src/collections/ints/utils/maps/Int2ShortMaps.java +++ b/src/main/java/speiger/src/collections/ints/utils/maps/Int2ShortMaps.java @@ -250,18 +250,18 @@ public class Int2ShortMaps @Override public short computeShort(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(int key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Int2ShortMaps @Override public short computeShort(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(int key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Int2ShortMaps @Override public short computeShort(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(int key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Int2ShortMaps @Override public short computeShort(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(int key, Int2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(int key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(int key, Int2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(int key, IntShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(int key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(int key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/lists/AbstractLongList.java b/src/main/java/speiger/src/collections/longs/lists/AbstractLongList.java index 858992a..7eaad53 100644 --- a/src/main/java/speiger/src/collections/longs/lists/AbstractLongList.java +++ b/src/main/java/speiger/src/collections/longs/lists/AbstractLongList.java @@ -12,6 +12,7 @@ import speiger.src.collections.longs.collections.AbstractLongCollection; import speiger.src.collections.longs.collections.LongCollection; import speiger.src.collections.longs.collections.LongIterator; import speiger.src.collections.longs.collections.LongSplititerator; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.longs.utils.LongSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -205,13 +206,23 @@ public abstract class AbstractLongList extends AbstractLongCollection implements public LongListIterator listIterator() { return listIterator(0); } - + @Override public LongListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new LongListIter(index); } + @Override + public LongListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public LongListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add(0L); @@ -566,7 +577,153 @@ public abstract class AbstractLongList extends AbstractLongCollection implements } } } + + private class ListIndexedIterator implements LongListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public long nextLong() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getLong((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public long previousLong() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getLong((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(long e) { throw new UnsupportedOperationException(); } + + @Override + public void set(long e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractLongList.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 LongListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public long nextLong() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getLong((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public long previousLong() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getLong((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(long e) { throw new UnsupportedOperationException(); } + + @Override + public void set(long e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractLongList.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 LongListIter implements LongListIterator { int index; int lastReturned = -1; @@ -644,7 +801,7 @@ public abstract class AbstractLongList extends AbstractLongCollection implements 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/longs/lists/LongList.java b/src/main/java/speiger/src/collections/longs/lists/LongList.java index 40bc403..084424d 100644 --- a/src/main/java/speiger/src/collections/longs/lists/LongList.java +++ b/src/main/java/speiger/src/collections/longs/lists/LongList.java @@ -14,6 +14,7 @@ import speiger.src.collections.ints.functions.consumer.IntLongConsumer; import speiger.src.collections.longs.functions.LongComparator; import speiger.src.collections.longs.utils.LongArrays; import speiger.src.collections.longs.utils.LongLists; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.longs.utils.LongSplititerators; /** @@ -341,6 +342,24 @@ public interface LongList extends LongCollection, List @Override public LongListIterator 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 LongListIterator 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 LongListIterator 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/longs/maps/abstracts/AbstractLong2BooleanMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2BooleanMap.java index 1402a49..b2c51bd 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2BooleanMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2BooleanMap.java @@ -151,6 +151,39 @@ public abstract class AbstractLong2BooleanMap extends AbstractMap return newValue; } + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public boolean supplyBooleanIfAbsent(long 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(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -167,17 +200,6 @@ public abstract class AbstractLong2BooleanMap extends AbstractMap return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -192,17 +214,6 @@ public abstract class AbstractLong2BooleanMap extends AbstractMap return value; } - @Override - public boolean supplyBooleanIfAbsent(long 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(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,17 +228,6 @@ public abstract class AbstractLong2BooleanMap extends AbstractMap return value; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ByteMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ByteMap.java index b3f3b83..cd4b188 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ByteMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ByteMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2ByteMap extends AbstractMap imple return newValue; } + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2ByteMap extends AbstractMap imple return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractLong2ByteMap extends AbstractMap imple return value; } - @Override - public byte supplyByteIfAbsent(long 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(long 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 abstract class AbstractLong2ByteMap extends AbstractMap imple return value; } - @Override - public byte computeByteIfPresent(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2CharMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2CharMap.java index 2fbcc13..a1d9393 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2CharMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2CharMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2CharMap extends AbstractMap return newValue; } + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public char supplyCharIfAbsent(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2CharMap extends AbstractMap return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractLong2CharMap extends AbstractMap return value; } - @Override - public char supplyCharIfAbsent(long 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(long 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 abstract class AbstractLong2CharMap extends AbstractMap return value; } - @Override - public char computeCharIfPresent(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2DoubleMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2DoubleMap.java index a628fda..3c5b1ff 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2DoubleMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2DoubleMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2DoubleMap extends AbstractMap i return newValue; } + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public double supplyDoubleIfAbsent(long 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(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2DoubleMap extends AbstractMap i return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractLong2DoubleMap extends AbstractMap i return value; } - @Override - public double supplyDoubleIfAbsent(long 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(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractLong2DoubleMap extends AbstractMap i return value; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2FloatMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2FloatMap.java index 2507b49..8088982 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2FloatMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2FloatMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2FloatMap extends AbstractMap imp return newValue; } + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2FloatMap extends AbstractMap imp return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractLong2FloatMap extends AbstractMap imp return value; } - @Override - public float supplyFloatIfAbsent(long 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(long 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 abstract class AbstractLong2FloatMap extends AbstractMap imp return value; } - @Override - public float computeFloatIfPresent(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2IntMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2IntMap.java index 706d0fd..6c0262d 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2IntMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2IntMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2IntMap extends AbstractMap imp return newValue; } + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(long 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(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2IntMap extends AbstractMap imp return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractLong2IntMap extends AbstractMap imp return value; } - @Override - public int supplyIntIfAbsent(long 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(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractLong2IntMap extends AbstractMap imp return value; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2LongMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2LongMap.java index e7a3ac4..5739423 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2LongMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2LongMap.java @@ -155,6 +155,39 @@ public abstract class AbstractLong2LongMap extends AbstractMap imple return newValue; } + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(long 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(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -171,17 +204,6 @@ public abstract class AbstractLong2LongMap extends AbstractMap imple return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -196,17 +218,6 @@ public abstract class AbstractLong2LongMap extends AbstractMap imple return value; } - @Override - public long supplyLongIfAbsent(long 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(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -221,17 +232,6 @@ public abstract class AbstractLong2LongMap extends AbstractMap imple return value; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ObjectMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ObjectMap.java index 1d4c819..bb862ff 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ObjectMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ObjectMap.java @@ -159,22 +159,6 @@ public abstract class AbstractLong2ObjectMap extends AbstractMap imp return newValue; } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -189,20 +173,6 @@ public abstract class AbstractLong2ObjectMap extends AbstractMap imp return value; } - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,20 +187,6 @@ public abstract class AbstractLong2ObjectMap extends AbstractMap imp return value; } - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -246,21 +202,6 @@ public abstract class AbstractLong2ObjectMap extends AbstractMap imp return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ShortMap.java b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ShortMap.java index 5b00986..cb42028 100644 --- a/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ShortMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/abstracts/AbstractLong2ShortMap.java @@ -157,6 +157,39 @@ public abstract class AbstractLong2ShortMap extends AbstractMap imp return newValue; } + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractLong2ShortMap extends AbstractMap imp return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractLong2ShortMap extends AbstractMap imp return value; } - @Override - public short supplyShortIfAbsent(long 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(long 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 abstract class AbstractLong2ShortMap extends AbstractMap imp return value; } - @Override - public short computeShortIfPresent(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2BooleanConcurrentOpenHashMap.java index aa991c8..1ae81a1 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2BooleanConcurrentOpenHashMap.java @@ -438,13 +438,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,6 +445,27 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,13 +473,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,13 +480,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2032,6 +2032,54 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i } } + protected boolean computeIfAbsent(int hash, long key, LongPredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, long key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, long key, LongBooleanUnaryOperator 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 computeNonDefault(int hash, long key, LongBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2055,23 +2103,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i } } - protected boolean computeIfAbsent(int hash, long key, LongPredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, long key, LongPredicate mappingFunction) { long stamp = writeLock(); try { @@ -2095,23 +2126,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i } } - protected boolean supplyIfAbsent(int hash, long key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, long key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2135,20 +2149,6 @@ public class Long2BooleanConcurrentOpenHashMap extends AbstractLong2BooleanMap i } } - protected boolean computeIfPresent(int hash, long key, LongBooleanUnaryOperator 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, long key, LongBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ByteConcurrentOpenHashMap.java index 975966c..c27e014 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ByteConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme } } + protected byte computeIfAbsent(int hash, long key, Long2ByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, long key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, long key, LongByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, long key, LongByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme } } - protected byte computeIfAbsent(int hash, long key, Long2ByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, long key, Long2ByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme } } - protected byte supplyIfAbsent(int hash, long key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, long key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Long2ByteConcurrentOpenHashMap extends AbstractLong2ByteMap impleme } } - protected byte computeIfPresent(int hash, long key, LongByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, long key, LongByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2CharConcurrentOpenHashMap.java index 6076cab..a52938a 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2CharConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme } } + protected char computeIfAbsent(int hash, long key, Long2CharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, long key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, long key, LongCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, long key, LongCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme } } - protected char computeIfAbsent(int hash, long key, Long2CharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, long key, Long2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme } } - protected char supplyIfAbsent(int hash, long key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, long key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Long2CharConcurrentOpenHashMap extends AbstractLong2CharMap impleme } } - protected char computeIfPresent(int hash, long key, LongCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, long key, LongCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2DoubleConcurrentOpenHashMap.java index f93d3ac..4b7c51a 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2DoubleConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp } } + protected double computeIfAbsent(int hash, long key, Long2DoubleFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, long key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, long key, LongDoubleUnaryOperator 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 computeNonDefault(int hash, long key, LongDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp } } - protected double computeIfAbsent(int hash, long key, Long2DoubleFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, long key, Long2DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp } } - protected double supplyIfAbsent(int hash, long key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, long key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Long2DoubleConcurrentOpenHashMap extends AbstractLong2DoubleMap imp } } - protected double computeIfPresent(int hash, long key, LongDoubleUnaryOperator 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, long key, LongDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2FloatConcurrentOpenHashMap.java index 694dc6b..d4cdfd3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2FloatConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple } } + protected float computeIfAbsent(int hash, long key, Long2FloatFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, long key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, long key, LongFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, long key, LongFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple } } - protected float computeIfAbsent(int hash, long key, Long2FloatFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, long key, Long2FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple } } - protected float supplyIfAbsent(int hash, long key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, long key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Long2FloatConcurrentOpenHashMap extends AbstractLong2FloatMap imple } } - protected float computeIfPresent(int hash, long key, LongFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, long key, LongFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2IntConcurrentOpenHashMap.java index 19a3ba7..879503c 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2IntConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement } } + protected int computeIfAbsent(int hash, long key, Long2IntFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, long key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, long key, LongIntUnaryOperator 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 computeNonDefault(int hash, long key, LongIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement } } - protected int computeIfAbsent(int hash, long key, Long2IntFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, long key, Long2IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement } } - protected int supplyIfAbsent(int hash, long key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, long key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Long2IntConcurrentOpenHashMap extends AbstractLong2IntMap implement } } - protected int computeIfPresent(int hash, long key, LongIntUnaryOperator 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, long key, LongIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2LongConcurrentOpenHashMap.java index 5d74378..3a09354 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2LongConcurrentOpenHashMap.java @@ -444,13 +444,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,6 +451,27 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,13 +479,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -479,13 +486,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2069,6 +2069,54 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme } } + protected long computeIfAbsent(int hash, long key, LongUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, long key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, long key, LongLongUnaryOperator 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 computeNonDefault(int hash, long key, LongLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2092,23 +2140,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme } } - protected long computeIfAbsent(int hash, long key, LongUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, long key, LongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2132,23 +2163,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme } } - protected long supplyIfAbsent(int hash, long key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, long key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2172,20 +2186,6 @@ public class Long2LongConcurrentOpenHashMap extends AbstractLong2LongMap impleme } } - protected long computeIfPresent(int hash, long key, LongLongUnaryOperator 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, long key, LongLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ObjectConcurrentOpenHashMap.java index 6277983..a0d8021 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ObjectConcurrentOpenHashMap.java @@ -426,13 +426,6 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,13 +433,6 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -454,13 +440,6 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,13 +447,6 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2011,29 +1983,6 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< } } - protected V computeNonDefault(int hash, long key, LongObjectUnaryOperator 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, long key, LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2056,30 +2005,7 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, long key, LongFunction 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, long key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -2102,30 +2028,7 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, long 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, long key, LongObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2144,11 +2047,16 @@ public class Long2ObjectConcurrentOpenHashMap extends AbstractLong2ObjectMap< } } - protected V computeIfPresentNonDefault(int hash, long key, LongObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, long key, LongObjectUnaryOperator 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/longs/maps/impl/concurrent/Long2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ShortConcurrentOpenHashMap.java index c16f772..1638b43 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/concurrent/Long2ShortConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple } } + protected short computeIfAbsent(int hash, long key, Long2ShortFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, long key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, long key, LongShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, long key, LongShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple } } - protected short computeIfAbsent(int hash, long key, Long2ShortFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, long key, Long2ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple } } - protected short supplyIfAbsent(int hash, long key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, long key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Long2ShortConcurrentOpenHashMap extends AbstractLong2ShortMap imple } } - protected short computeIfPresent(int hash, long key, LongShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, long key, LongShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2BooleanOpenCustomHashMap.java index 23825bf..f9dab5f 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2BooleanOpenCustomHashMap.java @@ -440,6 +440,42 @@ public class Long2BooleanOpenCustomHashMap extends AbstractLong2BooleanMap imple return newValue; } + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Long2BooleanOpenCustomHashMap extends AbstractLong2BooleanMap imple return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Long2BooleanOpenCustomHashMap extends AbstractLong2BooleanMap imple return newValue; } - @Override - public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Long2BooleanOpenCustomHashMap extends AbstractLong2BooleanMap imple return newValue; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ByteOpenCustomHashMap.java index 54a98fe..71d93f1 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ByteOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2ByteOpenCustomHashMap extends AbstractLong2ByteMap implements return newValue; } + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2ByteOpenCustomHashMap extends AbstractLong2ByteMap implements return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Long2ByteOpenCustomHashMap extends AbstractLong2ByteMap implements return newValue; } - @Override - public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2CharOpenCustomHashMap.java index 233aeae..3c6dd5b 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2CharOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2CharOpenCustomHashMap extends AbstractLong2CharMap implements return newValue; } + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2CharOpenCustomHashMap extends AbstractLong2CharMap implements return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Long2CharOpenCustomHashMap extends AbstractLong2CharMap implements return newValue; } - @Override - public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2DoubleOpenCustomHashMap.java index cddad7c..8e8fe03 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2DoubleOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2DoubleOpenCustomHashMap extends AbstractLong2DoubleMap impleme return newValue; } + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2DoubleOpenCustomHashMap extends AbstractLong2DoubleMap impleme return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Long2DoubleOpenCustomHashMap extends AbstractLong2DoubleMap impleme return newValue; } - @Override - public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Long2DoubleOpenCustomHashMap extends AbstractLong2DoubleMap impleme return newValue; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2FloatOpenCustomHashMap.java index 4463a7f..c61bd14 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2FloatOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2FloatOpenCustomHashMap extends AbstractLong2FloatMap implement return newValue; } + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2FloatOpenCustomHashMap extends AbstractLong2FloatMap implement return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Long2FloatOpenCustomHashMap extends AbstractLong2FloatMap implement return newValue; } - @Override - public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2IntOpenCustomHashMap.java index 1d6ec41..b8e8376 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2IntOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2IntOpenCustomHashMap extends AbstractLong2IntMap implements IT return newValue; } + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2IntOpenCustomHashMap extends AbstractLong2IntMap implements IT return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Long2IntOpenCustomHashMap extends AbstractLong2IntMap implements IT return newValue; } - @Override - public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Long2IntOpenCustomHashMap extends AbstractLong2IntMap implements IT return newValue; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2LongOpenCustomHashMap.java index ceb6008..5e806bf 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2LongOpenCustomHashMap.java @@ -454,6 +454,42 @@ public class Long2LongOpenCustomHashMap extends AbstractLong2LongMap implements return newValue; } + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Long2LongOpenCustomHashMap extends AbstractLong2LongMap implements return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,19 +528,6 @@ public class Long2LongOpenCustomHashMap extends AbstractLong2LongMap implements return newValue; } - @Override - public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -537,16 +547,6 @@ public class Long2LongOpenCustomHashMap extends AbstractLong2LongMap implements return newValue; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ObjectOpenCustomHashMap.java index 6e6a31b..9dcae59 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ObjectOpenCustomHashMap.java @@ -432,25 +432,6 @@ public class Long2ObjectOpenCustomHashMap extends AbstractLong2ObjectMap i return newValue; } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -469,26 +450,7 @@ public class Long2ObjectOpenCustomHashMap extends AbstractLong2ObjectMap i } return newValue; } - - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,25 +470,6 @@ public class Long2ObjectOpenCustomHashMap extends AbstractLong2ObjectMap i return newValue; } - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -541,20 +484,6 @@ public class Long2ObjectOpenCustomHashMap extends AbstractLong2ObjectMap i return newValue; } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ShortOpenCustomHashMap.java index 8817855..244d63a 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/customHash/Long2ShortOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Long2ShortOpenCustomHashMap extends AbstractLong2ShortMap implement return newValue; } + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Long2ShortOpenCustomHashMap extends AbstractLong2ShortMap implement return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Long2ShortOpenCustomHashMap extends AbstractLong2ShortMap implement return newValue; } - @Override - public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2BooleanOpenHashMap.java index 61ead34..a74edb3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2BooleanOpenHashMap.java @@ -408,6 +408,42 @@ public class Long2BooleanOpenHashMap extends AbstractLong2BooleanMap implements values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Long2BooleanOpenHashMap extends AbstractLong2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Long2BooleanOpenHashMap extends AbstractLong2BooleanMap implements return newValue; } - @Override - public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Long2BooleanOpenHashMap extends AbstractLong2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ByteOpenHashMap.java index 7cc853c..4426acd 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ByteOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2ByteOpenHashMap extends AbstractLong2ByteMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2ByteOpenHashMap extends AbstractLong2ByteMap implements ITrimm return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Long2ByteOpenHashMap extends AbstractLong2ByteMap implements ITrimm return newValue; } - @Override - public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2CharOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2CharOpenHashMap.java index 44b35ec..0a40b2a 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2CharOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2CharOpenHashMap extends AbstractLong2CharMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2CharOpenHashMap extends AbstractLong2CharMap implements ITrimm return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Long2CharOpenHashMap extends AbstractLong2CharMap implements ITrimm return newValue; } - @Override - public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2DoubleOpenHashMap.java index afffa94..4121458 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2DoubleOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2DoubleOpenHashMap extends AbstractLong2DoubleMap implements IT values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2DoubleOpenHashMap extends AbstractLong2DoubleMap implements IT return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Long2DoubleOpenHashMap extends AbstractLong2DoubleMap implements IT return newValue; } - @Override - public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Long2DoubleOpenHashMap extends AbstractLong2DoubleMap implements IT return newValue; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2FloatOpenHashMap.java index 8490d39..6766d65 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2FloatOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2FloatOpenHashMap extends AbstractLong2FloatMap implements ITri values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2FloatOpenHashMap extends AbstractLong2FloatMap implements ITri return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Long2FloatOpenHashMap extends AbstractLong2FloatMap implements ITri return newValue; } - @Override - public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2IntOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2IntOpenHashMap.java index 5275422..ae711f8 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2IntOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2IntOpenHashMap extends AbstractLong2IntMap implements ITrimmab values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2IntOpenHashMap extends AbstractLong2IntMap implements ITrimmab return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Long2IntOpenHashMap extends AbstractLong2IntMap implements ITrimmab return newValue; } - @Override - public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Long2IntOpenHashMap extends AbstractLong2IntMap implements ITrimmab return newValue; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2LongOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2LongOpenHashMap.java index 2af5c01..6321015 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2LongOpenHashMap.java @@ -424,6 +424,42 @@ public class Long2LongOpenHashMap extends AbstractLong2LongMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Long2LongOpenHashMap extends AbstractLong2LongMap implements ITrimm return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,19 +499,6 @@ public class Long2LongOpenHashMap extends AbstractLong2LongMap implements ITrimm return newValue; } - @Override - public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,16 +518,6 @@ public class Long2LongOpenHashMap extends AbstractLong2LongMap implements ITrimm return newValue; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ObjectOpenHashMap.java index db53aa2..6adb62b 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ObjectOpenHashMap.java @@ -401,26 +401,7 @@ public class Long2ObjectOpenHashMap extends AbstractLong2ObjectMap impleme values[index] = newValue; return newValue; } - - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,25 +421,6 @@ public class Long2ObjectOpenHashMap extends AbstractLong2ObjectMap impleme return newValue; } - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -477,26 +439,7 @@ public class Long2ObjectOpenHashMap extends AbstractLong2ObjectMap impleme } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -511,20 +454,6 @@ public class Long2ObjectOpenHashMap extends AbstractLong2ObjectMap impleme return newValue; } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ShortOpenHashMap.java index a643531..bbc5a82 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/hash/Long2ShortOpenHashMap.java @@ -430,6 +430,42 @@ public class Long2ShortOpenHashMap extends AbstractLong2ShortMap implements ITri values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Long2ShortOpenHashMap extends AbstractLong2ShortMap implements ITri return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Long2ShortOpenHashMap extends AbstractLong2ShortMap implements ITri return newValue; } - @Override - public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2BooleanOpenHashMap.java index 52e318f..e15f55d 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2BooleanOpenHashMap.java @@ -413,20 +413,19 @@ public class ImmutableLong2BooleanOpenHashMap extends AbstractLong2BooleanMap im @Override public boolean computeBoolean(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(long key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ByteOpenHashMap.java index 8000a4c..216e7ff 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ByteOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2ByteOpenHashMap extends AbstractLong2ByteMap implemen @Override public byte computeByte(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(long key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2CharOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2CharOpenHashMap.java index 10e135d..0f0697c 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2CharOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2CharOpenHashMap extends AbstractLong2CharMap implemen @Override public char computeChar(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(long key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2DoubleOpenHashMap.java index 352ecc0..daeb313 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2DoubleOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2DoubleOpenHashMap extends AbstractLong2DoubleMap impl @Override public double computeDouble(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(long key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2FloatOpenHashMap.java index 4e5b705..31f3de1 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2FloatOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2FloatOpenHashMap extends AbstractLong2FloatMap implem @Override public float computeFloat(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(long key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2IntOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2IntOpenHashMap.java index 2e58bc0..f4e6e03 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2IntOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2IntOpenHashMap extends AbstractLong2IntMap implements @Override public int computeInt(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(long key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2LongOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2LongOpenHashMap.java index fcfb942..bcb3bd3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2LongOpenHashMap.java @@ -409,20 +409,19 @@ public class ImmutableLong2LongOpenHashMap extends AbstractLong2LongMap implemen @Override public long computeLong(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(long key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ObjectOpenHashMap.java index a406eee..ed9c4cf 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ObjectOpenHashMap.java @@ -397,20 +397,11 @@ public class ImmutableLong2ObjectOpenHashMap extends AbstractLong2ObjectMap mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ShortOpenHashMap.java index f1f0529..b95b6a8 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/immutable/ImmutableLong2ShortOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableLong2ShortOpenHashMap extends AbstractLong2ShortMap implem @Override public short computeShort(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(long key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2BooleanArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2BooleanArrayMap.java index d293f44..d3f06a6 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2BooleanArrayMap.java @@ -419,6 +419,42 @@ public class Long2BooleanArrayMap extends AbstractLong2BooleanMap implements Lon return newValue; } + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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 computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Long2BooleanArrayMap extends AbstractLong2BooleanMap implements Lon return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Long2BooleanArrayMap extends AbstractLong2BooleanMap implements Lon return newValue; } - @Override - public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Long2BooleanArrayMap extends AbstractLong2BooleanMap implements Lon return newValue; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ByteArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ByteArrayMap.java index daa71b4..e065688 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ByteArrayMap.java @@ -442,6 +442,42 @@ public class Long2ByteArrayMap extends AbstractLong2ByteMap implements Long2Byte return newValue; } + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(long key, LongByteUnaryOperator 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 computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2ByteArrayMap extends AbstractLong2ByteMap implements Long2Byte return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Long2ByteArrayMap extends AbstractLong2ByteMap implements Long2Byte return newValue; } - @Override - public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2CharArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2CharArrayMap.java index 6b28354..78e8629 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2CharArrayMap.java @@ -442,6 +442,42 @@ public class Long2CharArrayMap extends AbstractLong2CharMap implements Long2Char return newValue; } + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(long key, LongCharUnaryOperator 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 computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2CharArrayMap extends AbstractLong2CharMap implements Long2Char return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Long2CharArrayMap extends AbstractLong2CharMap implements Long2Char return newValue; } - @Override - public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2DoubleArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2DoubleArrayMap.java index a934e77..699fc3c 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2DoubleArrayMap.java @@ -442,6 +442,42 @@ public class Long2DoubleArrayMap extends AbstractLong2DoubleMap implements Long2 return newValue; } + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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 computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2DoubleArrayMap extends AbstractLong2DoubleMap implements Long2 return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Long2DoubleArrayMap extends AbstractLong2DoubleMap implements Long2 return newValue; } - @Override - public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Long2DoubleArrayMap extends AbstractLong2DoubleMap implements Long2 return newValue; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2FloatArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2FloatArrayMap.java index cdb9269..736b305 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2FloatArrayMap.java @@ -442,6 +442,42 @@ public class Long2FloatArrayMap extends AbstractLong2FloatMap implements Long2Fl return newValue; } + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(long key, LongFloatUnaryOperator 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 computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2FloatArrayMap extends AbstractLong2FloatMap implements Long2Fl return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Long2FloatArrayMap extends AbstractLong2FloatMap implements Long2Fl return newValue; } - @Override - public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2IntArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2IntArrayMap.java index d2209ad..52071b3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2IntArrayMap.java @@ -442,6 +442,42 @@ public class Long2IntArrayMap extends AbstractLong2IntMap implements Long2IntOrd return newValue; } + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(long key, LongIntUnaryOperator 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 computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2IntArrayMap extends AbstractLong2IntMap implements Long2IntOrd return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Long2IntArrayMap extends AbstractLong2IntMap implements Long2IntOrd return newValue; } - @Override - public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Long2IntArrayMap extends AbstractLong2IntMap implements Long2IntOrd return newValue; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2LongArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2LongArrayMap.java index a19e23d..360b542 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2LongArrayMap.java @@ -435,6 +435,42 @@ public class Long2LongArrayMap extends AbstractLong2LongMap implements Long2Long return newValue; } + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(long key, LongLongUnaryOperator 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 computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Long2LongArrayMap extends AbstractLong2LongMap implements Long2Long return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,19 +509,6 @@ public class Long2LongArrayMap extends AbstractLong2LongMap implements Long2Long return newValue; } - @Override - public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -518,16 +528,6 @@ public class Long2LongArrayMap extends AbstractLong2LongMap implements Long2Long return newValue; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ObjectArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ObjectArrayMap.java index fbd308f..11721db 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ObjectArrayMap.java @@ -415,25 +415,6 @@ public class Long2ObjectArrayMap extends AbstractLong2ObjectMap implements return newValue; } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,26 +433,7 @@ public class Long2ObjectArrayMap extends AbstractLong2ObjectMap implements } return newValue; } - - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -490,26 +452,7 @@ public class Long2ObjectArrayMap extends AbstractLong2ObjectMap implements } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -524,20 +467,6 @@ public class Long2ObjectArrayMap extends AbstractLong2ObjectMap implements return newValue; } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ShortArrayMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ShortArrayMap.java index a969c4f..40bddf8 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/misc/Long2ShortArrayMap.java @@ -442,6 +442,42 @@ public class Long2ShortArrayMap extends AbstractLong2ShortMap implements Long2Sh return newValue; } + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(long key, LongShortUnaryOperator 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 computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Long2ShortArrayMap extends AbstractLong2ShortMap implements Long2Sh return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Long2ShortArrayMap extends AbstractLong2ShortMap implements Long2Sh return newValue; } - @Override - public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanAVLTreeMap.java index 11dacd7..c373c47 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanAVLTreeMap.java @@ -395,6 +395,40 @@ public class Long2BooleanAVLTreeMap extends AbstractLong2BooleanMap implements L return newValue; } + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(long 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(long key, LongBooleanUnaryOperator 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 computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Long2BooleanAVLTreeMap extends AbstractLong2BooleanMap implements L return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Long2BooleanAVLTreeMap extends AbstractLong2BooleanMap implements L return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(long 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(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,16 +484,6 @@ public class Long2BooleanAVLTreeMap extends AbstractLong2BooleanMap implements L return entry.value; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1487,14 +1487,9 @@ public class Long2BooleanAVLTreeMap extends AbstractLong2BooleanMap implements L 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/longs/maps/impl/tree/Long2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanRBTreeMap.java index d61f093..d2b721b 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2BooleanRBTreeMap.java @@ -394,6 +394,40 @@ public class Long2BooleanRBTreeMap extends AbstractLong2BooleanMap implements Lo return newValue; } + @Override + public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(long 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(long key, LongBooleanUnaryOperator 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 computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Long2BooleanRBTreeMap extends AbstractLong2BooleanMap implements Lo return newValue; } - @Override - public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Long2BooleanRBTreeMap extends AbstractLong2BooleanMap implements Lo return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(long 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(long key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Long2BooleanRBTreeMap extends AbstractLong2BooleanMap implements Lo return entry.value; } - @Override - public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator 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(long key, LongBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Long2BooleanRBTreeMap extends AbstractLong2BooleanMap implements Lo 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/longs/maps/impl/tree/Long2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteAVLTreeMap.java index 48a7471..1799820 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2ByteAVLTreeMap extends AbstractLong2ByteMap implements Long2By return newValue; } + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(long 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(long key, LongByteUnaryOperator 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 computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2ByteAVLTreeMap extends AbstractLong2ByteMap implements Long2By return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Long2ByteAVLTreeMap extends AbstractLong2ByteMap implements Long2By return entry.value; } - @Override - public byte supplyByteIfAbsent(long 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(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2ByteAVLTreeMap extends AbstractLong2ByteMap implements Long2By 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/longs/maps/impl/tree/Long2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteRBTreeMap.java index aa3a16e..bb87ce7 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ByteRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2ByteRBTreeMap extends AbstractLong2ByteMap implements Long2Byt return newValue; } + @Override + public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(long 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(long key, LongByteUnaryOperator 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 computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2ByteRBTreeMap extends AbstractLong2ByteMap implements Long2Byt return newValue; } - @Override - public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Long2ByteRBTreeMap extends AbstractLong2ByteMap implements Long2Byt return entry.value; } - @Override - public byte supplyByteIfAbsent(long 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(long 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(long key, LongByteUnaryOperator 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(long key, LongByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2ByteRBTreeMap extends AbstractLong2ByteMap implements Long2Byt 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/longs/maps/impl/tree/Long2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharAVLTreeMap.java index e39e56f..04b531e 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2CharAVLTreeMap extends AbstractLong2CharMap implements Long2Ch return newValue; } + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(long 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(long key, LongCharUnaryOperator 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 computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2CharAVLTreeMap extends AbstractLong2CharMap implements Long2Ch return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Long2CharAVLTreeMap extends AbstractLong2CharMap implements Long2Ch return entry.value; } - @Override - public char supplyCharIfAbsent(long 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(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2CharAVLTreeMap extends AbstractLong2CharMap implements Long2Ch 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/longs/maps/impl/tree/Long2CharRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharRBTreeMap.java index c408c97..9fdec06 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2CharRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2CharRBTreeMap extends AbstractLong2CharMap implements Long2Cha return newValue; } + @Override + public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(long 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(long key, LongCharUnaryOperator 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 computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2CharRBTreeMap extends AbstractLong2CharMap implements Long2Cha return newValue; } - @Override - public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Long2CharRBTreeMap extends AbstractLong2CharMap implements Long2Cha return entry.value; } - @Override - public char supplyCharIfAbsent(long 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(long 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(long key, LongCharUnaryOperator 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(long key, LongCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2CharRBTreeMap extends AbstractLong2CharMap implements Long2Cha 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/longs/maps/impl/tree/Long2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleAVLTreeMap.java index 5895301..c127195 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2DoubleAVLTreeMap extends AbstractLong2DoubleMap implements Lon return newValue; } + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(long 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(long key, LongDoubleUnaryOperator 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 computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2DoubleAVLTreeMap extends AbstractLong2DoubleMap implements Lon return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Long2DoubleAVLTreeMap extends AbstractLong2DoubleMap implements Lon return entry.value; } - @Override - public double supplyDoubleIfAbsent(long 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(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Long2DoubleAVLTreeMap extends AbstractLong2DoubleMap implements Lon return entry.value; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2DoubleAVLTreeMap extends AbstractLong2DoubleMap implements Lon 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/longs/maps/impl/tree/Long2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleRBTreeMap.java index f8802f0..264f708 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2DoubleRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2DoubleRBTreeMap extends AbstractLong2DoubleMap implements Long return newValue; } + @Override + public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(long 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(long key, LongDoubleUnaryOperator 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 computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2DoubleRBTreeMap extends AbstractLong2DoubleMap implements Long return newValue; } - @Override - public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Long2DoubleRBTreeMap extends AbstractLong2DoubleMap implements Long return entry.value; } - @Override - public double supplyDoubleIfAbsent(long 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(long key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Long2DoubleRBTreeMap extends AbstractLong2DoubleMap implements Long return entry.value; } - @Override - public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator 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(long key, LongDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2DoubleRBTreeMap extends AbstractLong2DoubleMap implements Long 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/longs/maps/impl/tree/Long2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatAVLTreeMap.java index c274940..db1646d 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2FloatAVLTreeMap extends AbstractLong2FloatMap implements Long2 return newValue; } + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(long 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(long key, LongFloatUnaryOperator 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 computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2FloatAVLTreeMap extends AbstractLong2FloatMap implements Long2 return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Long2FloatAVLTreeMap extends AbstractLong2FloatMap implements Long2 return entry.value; } - @Override - public float supplyFloatIfAbsent(long 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(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2FloatAVLTreeMap extends AbstractLong2FloatMap implements Long2 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/longs/maps/impl/tree/Long2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatRBTreeMap.java index d9e87e5..7b28ce3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2FloatRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2FloatRBTreeMap extends AbstractLong2FloatMap implements Long2F return newValue; } + @Override + public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(long 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(long key, LongFloatUnaryOperator 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 computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2FloatRBTreeMap extends AbstractLong2FloatMap implements Long2F return newValue; } - @Override - public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Long2FloatRBTreeMap extends AbstractLong2FloatMap implements Long2F return entry.value; } - @Override - public float supplyFloatIfAbsent(long 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(long 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(long key, LongFloatUnaryOperator 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(long key, LongFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2FloatRBTreeMap extends AbstractLong2FloatMap implements Long2F 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/longs/maps/impl/tree/Long2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntAVLTreeMap.java index 4220485..d03e1d2 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2IntAVLTreeMap extends AbstractLong2IntMap implements Long2IntN return newValue; } + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(long 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(long key, LongIntUnaryOperator 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 computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2IntAVLTreeMap extends AbstractLong2IntMap implements Long2IntN return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Long2IntAVLTreeMap extends AbstractLong2IntMap implements Long2IntN return entry.value; } - @Override - public int supplyIntIfAbsent(long 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(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Long2IntAVLTreeMap extends AbstractLong2IntMap implements Long2IntN return entry.value; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2IntAVLTreeMap extends AbstractLong2IntMap implements Long2IntN 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/longs/maps/impl/tree/Long2IntRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntRBTreeMap.java index be894be..87b405f 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2IntRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2IntRBTreeMap extends AbstractLong2IntMap implements Long2IntNa return newValue; } + @Override + public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(long 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(long key, LongIntUnaryOperator 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 computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2IntRBTreeMap extends AbstractLong2IntMap implements Long2IntNa return newValue; } - @Override - public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Long2IntRBTreeMap extends AbstractLong2IntMap implements Long2IntNa return entry.value; } - @Override - public int supplyIntIfAbsent(long 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(long key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Long2IntRBTreeMap extends AbstractLong2IntMap implements Long2IntNa return entry.value; } - @Override - public int computeIntIfPresent(long key, LongIntUnaryOperator 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(long key, LongIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2IntRBTreeMap extends AbstractLong2IntMap implements Long2IntNa 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/longs/maps/impl/tree/Long2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongAVLTreeMap.java index c433303..d3f8671 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongAVLTreeMap.java @@ -446,6 +446,40 @@ public class Long2LongAVLTreeMap extends AbstractLong2LongMap implements Long2Lo return newValue; } + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(long 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(long key, LongLongUnaryOperator 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 computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Long2LongAVLTreeMap extends AbstractLong2LongMap implements Long2Lo return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,18 +517,6 @@ public class Long2LongAVLTreeMap extends AbstractLong2LongMap implements Long2Lo return entry.value; } - @Override - public long supplyLongIfAbsent(long 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(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Long2LongAVLTreeMap extends AbstractLong2LongMap implements Long2Lo return entry.value; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Long2LongAVLTreeMap extends AbstractLong2LongMap implements Long2Lo 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/longs/maps/impl/tree/Long2LongRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongRBTreeMap.java index c8e09e4..737e935 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2LongRBTreeMap.java @@ -445,6 +445,40 @@ public class Long2LongRBTreeMap extends AbstractLong2LongMap implements Long2Lon return newValue; } + @Override + public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(long 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(long key, LongLongUnaryOperator 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 computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Long2LongRBTreeMap extends AbstractLong2LongMap implements Long2Lon return newValue; } - @Override - public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,18 +516,6 @@ public class Long2LongRBTreeMap extends AbstractLong2LongMap implements Long2Lon return entry.value; } - @Override - public long supplyLongIfAbsent(long 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(long key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -524,16 +534,6 @@ public class Long2LongRBTreeMap extends AbstractLong2LongMap implements Long2Lon return entry.value; } - @Override - public long computeLongIfPresent(long key, LongLongUnaryOperator 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(long key, LongLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1613,14 +1613,9 @@ public class Long2LongRBTreeMap extends AbstractLong2LongMap implements Long2Lon 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/longs/maps/impl/tree/Long2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectAVLTreeMap.java index 44c8d6c..e7d4b3d 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectAVLTreeMap.java @@ -395,25 +395,6 @@ public class Long2ObjectAVLTreeMap extends AbstractLong2ObjectMap implemen return newValue; } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -432,24 +413,6 @@ public class Long2ObjectAVLTreeMap extends AbstractLong2ObjectMap implemen return entry.value; } - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -468,24 +431,6 @@ public class Long2ObjectAVLTreeMap extends AbstractLong2ObjectMap implemen return entry.value; } - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -500,20 +445,6 @@ public class Long2ObjectAVLTreeMap extends AbstractLong2ObjectMap implemen return newValue; } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectRBTreeMap.java index ecdf2e1..4ae07a4 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ObjectRBTreeMap.java @@ -394,25 +394,6 @@ public class Long2ObjectRBTreeMap extends AbstractLong2ObjectMap implement return newValue; } - @Override - public V computeNonDefault(long key, LongObjectUnaryOperator 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(long key, LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Long2ObjectRBTreeMap extends AbstractLong2ObjectMap implement return entry.value; } - @Override - public V computeIfAbsentNonDefault(long key, LongFunction 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(long key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Long2ObjectRBTreeMap extends AbstractLong2ObjectMap implement return entry.value; } - @Override - public V supplyIfAbsentNonDefault(long 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(long key, LongObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Long2ObjectRBTreeMap extends AbstractLong2ObjectMap implement return newValue; } - @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator 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(long key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortAVLTreeMap.java index 322a77d..b40812d 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortAVLTreeMap.java @@ -454,6 +454,40 @@ public class Long2ShortAVLTreeMap extends AbstractLong2ShortMap implements Long2 return newValue; } + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(long 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(long key, LongShortUnaryOperator 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 computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Long2ShortAVLTreeMap extends AbstractLong2ShortMap implements Long2 return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Long2ShortAVLTreeMap extends AbstractLong2ShortMap implements Long2 return entry.value; } - @Override - public short supplyShortIfAbsent(long 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(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Long2ShortAVLTreeMap extends AbstractLong2ShortMap implements Long2 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/longs/maps/impl/tree/Long2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortRBTreeMap.java index 72b13b2..80373e3 100644 --- a/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/impl/tree/Long2ShortRBTreeMap.java @@ -453,6 +453,40 @@ public class Long2ShortRBTreeMap extends AbstractLong2ShortMap implements Long2S return newValue; } + @Override + public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(long 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(long key, LongShortUnaryOperator 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 computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Long2ShortRBTreeMap extends AbstractLong2ShortMap implements Long2S return newValue; } - @Override - public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Long2ShortRBTreeMap extends AbstractLong2ShortMap implements Long2S return entry.value; } - @Override - public short supplyShortIfAbsent(long 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(long 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(long key, LongShortUnaryOperator 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(long key, LongShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Long2ShortRBTreeMap extends AbstractLong2ShortMap implements Long2S 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/longs/maps/interfaces/Long2BooleanMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2BooleanMap.java index 480203b..97f1e07 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2BooleanMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2BooleanMap.java @@ -283,15 +283,6 @@ public interface Long2BooleanMap extends Map, LongPredicate * @return the result of the computation */ public boolean computeBoolean(long key, LongBooleanUnaryOperator 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 boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Long2BooleanMap extends Map, LongPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(long key, LongPredicate 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". + * 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 boolean supplyBooleanIfAbsent(long 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(long key, LongBooleanUnaryOperator 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 boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Long2BooleanMap extends Map, LongPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate 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". - * 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 boolean supplyBooleanIfAbsent(long key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Long2BooleanMap extends Map, LongPredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(long 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(long key, LongBooleanUnaryOperator 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/longs/maps/interfaces/Long2ByteMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ByteMap.java index e16a131..d059c04 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ByteMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ByteMap.java @@ -308,15 +308,6 @@ public interface Long2ByteMap extends Map, Long2ByteFunction * @return the result of the computation */ public byte computeByte(long key, LongByteUnaryOperator 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 byte computeByteNonDefault(long key, LongByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2ByteMap extends Map, Long2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(long key, Long2ByteFunction 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". + * 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 byte supplyByteIfAbsent(long 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(long key, LongByteUnaryOperator 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 byte computeByteNonDefault(long key, LongByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2ByteMap extends Map, Long2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction 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". - * 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 byte supplyByteIfAbsent(long key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Long2ByteMap extends Map, Long2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(long 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(long key, LongByteUnaryOperator 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/longs/maps/interfaces/Long2CharMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2CharMap.java index 17e5976..19796cb 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2CharMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2CharMap.java @@ -308,15 +308,6 @@ public interface Long2CharMap extends Map, Long2CharFunction * @return the result of the computation */ public char computeChar(long key, LongCharUnaryOperator 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 char computeCharNonDefault(long key, LongCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2CharMap extends Map, Long2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(long key, Long2CharFunction 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". + * 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 char supplyCharIfAbsent(long 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(long key, LongCharUnaryOperator 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 char computeCharNonDefault(long key, LongCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2CharMap extends Map, Long2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(long key, Long2CharFunction 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". - * 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 char supplyCharIfAbsent(long key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Long2CharMap extends Map, Long2CharFunction * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(long 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(long key, LongCharUnaryOperator 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/longs/maps/interfaces/Long2DoubleMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2DoubleMap.java index 9a6bdfb..59d3b70 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2DoubleMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2DoubleMap.java @@ -308,15 +308,6 @@ public interface Long2DoubleMap extends Map, Long2DoubleFunction * @return the result of the computation */ public double computeDouble(long key, LongDoubleUnaryOperator 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 double computeDoubleNonDefault(long key, LongDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2DoubleMap extends Map, Long2DoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(long key, Long2DoubleFunction 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". + * 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 double supplyDoubleIfAbsent(long 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(long key, LongDoubleUnaryOperator 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 double computeDoubleNonDefault(long key, LongDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2DoubleMap extends Map, Long2DoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction 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". - * 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 double supplyDoubleIfAbsent(long key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Long2DoubleMap extends Map, Long2DoubleFunction * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(long 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(long key, LongDoubleUnaryOperator 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/longs/maps/interfaces/Long2FloatMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2FloatMap.java index d89c802..fc653cb 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2FloatMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2FloatMap.java @@ -308,15 +308,6 @@ public interface Long2FloatMap extends Map, Long2FloatFunction * @return the result of the computation */ public float computeFloat(long key, LongFloatUnaryOperator 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 float computeFloatNonDefault(long key, LongFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2FloatMap extends Map, Long2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(long key, Long2FloatFunction 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". + * 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 float supplyFloatIfAbsent(long 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(long key, LongFloatUnaryOperator 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 float computeFloatNonDefault(long key, LongFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2FloatMap extends Map, Long2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction 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". - * 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 float supplyFloatIfAbsent(long key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Long2FloatMap extends Map, Long2FloatFunction * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(long 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(long key, LongFloatUnaryOperator 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/longs/maps/interfaces/Long2IntMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2IntMap.java index a57ddce..4e20d93 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2IntMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2IntMap.java @@ -308,15 +308,6 @@ public interface Long2IntMap extends Map, Long2IntFunction * @return the result of the computation */ public int computeInt(long key, LongIntUnaryOperator 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 int computeIntNonDefault(long key, LongIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2IntMap extends Map, Long2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(long key, Long2IntFunction 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". + * 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 int supplyIntIfAbsent(long 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(long key, LongIntUnaryOperator 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 int computeIntNonDefault(long key, LongIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2IntMap extends Map, Long2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(long key, Long2IntFunction 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". - * 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 int supplyIntIfAbsent(long key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Long2IntMap extends Map, Long2IntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(long 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(long key, LongIntUnaryOperator 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/longs/maps/interfaces/Long2LongMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2LongMap.java index 87a663a..e718d46 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2LongMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2LongMap.java @@ -307,15 +307,6 @@ public interface Long2LongMap extends Map, LongUnaryOperator * @return the result of the computation */ public long computeLong(long key, LongLongUnaryOperator 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 long computeLongNonDefault(long key, LongLongUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Long2LongMap extends Map, LongUnaryOperator * @return the result of the computed value or present value */ public long computeLongIfAbsent(long key, LongUnaryOperator 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". + * 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 long supplyLongIfAbsent(long 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(long key, LongLongUnaryOperator 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 long computeLongNonDefault(long key, LongLongUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Long2LongMap extends Map, LongUnaryOperator * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator 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". - * 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 long supplyLongIfAbsent(long key, LongSupplier 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". @@ -352,16 +362,6 @@ public interface Long2LongMap extends Map, LongUnaryOperator * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(long 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(long key, LongLongUnaryOperator 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/longs/maps/interfaces/Long2ObjectMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ObjectMap.java index 7a8f87d..7248840 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ObjectMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ObjectMap.java @@ -266,15 +266,6 @@ public interface Long2ObjectMap extends Map, LongFunction * @return the result of the computation */ public V compute(long key, LongObjectUnaryOperator 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(long key, LongObjectUnaryOperator 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 interface Long2ObjectMap extends Map, LongFunction * @return the result of the computed value or present value */ public V computeIfAbsent(long key, LongFunction 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(long key, LongFunction 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 interface Long2ObjectMap extends Map, LongFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(long 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(long 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 interface Long2ObjectMap extends Map, LongFunction * @note if not present then compute is not executed */ public V computeIfPresent(long key, LongObjectUnaryOperator 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(long key, LongObjectUnaryOperator 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/longs/maps/interfaces/Long2ShortMap.java b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ShortMap.java index 1a36b6e..012d79e 100644 --- a/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ShortMap.java +++ b/src/main/java/speiger/src/collections/longs/maps/interfaces/Long2ShortMap.java @@ -308,15 +308,6 @@ public interface Long2ShortMap extends Map, Long2ShortFunction * @return the result of the computation */ public short computeShort(long key, LongShortUnaryOperator 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 short computeShortNonDefault(long key, LongShortUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Long2ShortMap extends Map, Long2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(long key, Long2ShortFunction 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". + * 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 short supplyShortIfAbsent(long 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(long key, LongShortUnaryOperator 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 short computeShortNonDefault(long key, LongShortUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Long2ShortMap extends Map, Long2ShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction 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". - * 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 short supplyShortIfAbsent(long key, ShortSupplier 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". @@ -353,16 +363,6 @@ public interface Long2ShortMap extends Map, Long2ShortFunction * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(long 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(long key, LongShortUnaryOperator 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/longs/queues/LongArrayFIFOQueue.java b/src/main/java/speiger/src/collections/longs/queues/LongArrayFIFOQueue.java index cfaba7f..6dbb147 100644 --- a/src/main/java/speiger/src/collections/longs/queues/LongArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/longs/queues/LongArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class LongArrayFIFOQueue extends AbstractLongPriorityQueue implements Lon return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(long e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class LongIterators } } + private static class InfiniteIterator implements LongIterator + { + LongIterator iter; + CollectionWrapper looper = LongCollections.wrapper(); + int index = 0; + + public InfiniteIterator(LongIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public long nextLong() { + if(iter != null) { + if(iter.hasNext()) { + long value = iter.nextLong(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getLong((index++) % looper.size()); + } + + @Override + public void forEachRemaining(LongConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectLongConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements LongIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/longs/utils/LongLists.java b/src/main/java/speiger/src/collections/longs/utils/LongLists.java index efcb5a7..7602481 100644 --- a/src/main/java/speiger/src/collections/longs/utils/LongLists.java +++ b/src/main/java/speiger/src/collections/longs/utils/LongLists.java @@ -12,6 +12,7 @@ import speiger.src.collections.longs.collections.LongCollection; import speiger.src.collections.longs.functions.LongConsumer; import speiger.src.collections.longs.lists.AbstractLongList; import speiger.src.collections.longs.lists.LongList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.longs.lists.LongListIterator; import speiger.src.collections.utils.SanityChecks; @@ -317,6 +318,16 @@ public class LongLists return l.listIterator(index); } + @Override + public LongListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public LongListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public LongList subList(int from, int to) { return LongLists.synchronize(l.subList(from, to)); @@ -426,6 +437,16 @@ public class LongLists return LongIterators.unmodifiable(l.listIterator(index)); } + @Override + public LongListIterator indexedIterator(int...indecies) { + return LongIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public LongListIterator indexedIterator(IntList indecies) { + return LongIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public LongList subList(int from, int to) { return LongLists.unmodifiable(l.subList(from, to)); @@ -514,6 +535,16 @@ public class LongLists return LongIterators.empty(); } + @Override + public LongListIterator indexedIterator(int...indecies) { + return LongIterators.empty(); + } + + @Override + public LongListIterator indexedIterator(IntList indecies) { + return LongIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/longs/utils/LongPriorityQueues.java b/src/main/java/speiger/src/collections/longs/utils/LongPriorityQueues.java index 622a5a5..c739a1e 100644 --- a/src/main/java/speiger/src/collections/longs/utils/LongPriorityQueues.java +++ b/src/main/java/speiger/src/collections/longs/utils/LongPriorityQueues.java @@ -89,6 +89,8 @@ public class LongPriorityQueues @Override public long peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(long e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(long e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(long e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2BooleanMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2BooleanMaps.java index 2c2d1c3..37d3641 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2BooleanMaps.java @@ -246,18 +246,18 @@ public class Long2BooleanMaps @Override public boolean computeBoolean(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(long key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Long2BooleanMaps @Override public boolean computeBoolean(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(long key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Long2BooleanMaps @Override public boolean computeBoolean(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(long key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Long2BooleanMaps @Override public boolean computeBoolean(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(long key, LongPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(long key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(long key, LongPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(long key, LongBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(long key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(long key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ByteMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ByteMaps.java index c2271a4..23d163a 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ByteMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ByteMaps.java @@ -250,18 +250,18 @@ public class Long2ByteMaps @Override public byte computeByte(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(long key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2ByteMaps @Override public byte computeByte(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(long key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2ByteMaps @Override public byte computeByte(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(long key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2ByteMaps @Override public byte computeByte(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(long key, Long2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(long key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(long key, Long2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(long key, LongByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(long key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(long key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2CharMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2CharMaps.java index 3d6de41..145d798 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2CharMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2CharMaps.java @@ -250,18 +250,18 @@ public class Long2CharMaps @Override public char computeChar(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(long key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2CharMaps @Override public char computeChar(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(long key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2CharMaps @Override public char computeChar(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(long key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2CharMaps @Override public char computeChar(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(long key, Long2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(long key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(long key, Long2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(long key, LongCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(long key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(long key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2DoubleMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2DoubleMaps.java index f9e518c..45c1ab9 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2DoubleMaps.java @@ -250,18 +250,18 @@ public class Long2DoubleMaps @Override public double computeDouble(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(long key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2DoubleMaps @Override public double computeDouble(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(long key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2DoubleMaps @Override public double computeDouble(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(long key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2DoubleMaps @Override public double computeDouble(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(long key, Long2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(long key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(long key, Long2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(long key, LongDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(long key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(long key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2FloatMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2FloatMaps.java index 66e5211..9f28f22 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2FloatMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2FloatMaps.java @@ -250,18 +250,18 @@ public class Long2FloatMaps @Override public float computeFloat(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(long key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2FloatMaps @Override public float computeFloat(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(long key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2FloatMaps @Override public float computeFloat(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(long key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2FloatMaps @Override public float computeFloat(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(long key, Long2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(long key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(long key, Long2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(long key, LongFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(long key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(long key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2IntMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2IntMaps.java index d9387ea..3214c6a 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2IntMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2IntMaps.java @@ -250,18 +250,18 @@ public class Long2IntMaps @Override public int computeInt(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(long key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2IntMaps @Override public int computeInt(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(long key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2IntMaps @Override public int computeInt(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(long key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2IntMaps @Override public int computeInt(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(long key, Long2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(long key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(long key, Long2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(long key, LongIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(long key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(long key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2LongMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2LongMaps.java index 28f3f89..9473182 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2LongMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2LongMaps.java @@ -249,18 +249,18 @@ public class Long2LongMaps @Override public long computeLong(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(long key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Long2LongMaps @Override public long computeLong(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(long key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Long2LongMaps @Override public long computeLong(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(long key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Long2LongMaps @Override public long computeLong(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(long key, LongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(long key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(long key, LongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(long key, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(long key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(long key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ObjectMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ObjectMaps.java index 3aade01..7e8ed8c 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ObjectMaps.java @@ -266,20 +266,12 @@ public class Long2ObjectMaps @Override public V compute(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Long2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Long2ObjectMaps @Override public V compute(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Long2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Long2ObjectMaps @Override public V compute(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Long2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Long2ObjectMaps @Override public V compute(long key, LongObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(long key, LongObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(long key, LongFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(long key, LongFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(long key, LongObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(long key, LongObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(long key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(long key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(long key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Long2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ShortMaps.java b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ShortMaps.java index e59f114..67aa431 100644 --- a/src/main/java/speiger/src/collections/longs/utils/maps/Long2ShortMaps.java +++ b/src/main/java/speiger/src/collections/longs/utils/maps/Long2ShortMaps.java @@ -250,18 +250,18 @@ public class Long2ShortMaps @Override public short computeShort(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(long key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Long2ShortMaps @Override public short computeShort(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(long key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Long2ShortMaps @Override public short computeShort(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(long key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Long2ShortMaps @Override public short computeShort(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(long key, Long2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(long key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(long key, Long2ShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(long key, LongShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(long key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(long key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/collections/ObjectIterable.java b/src/main/java/speiger/src/collections/objects/collections/ObjectIterable.java index 8627874..11209e4 100644 --- a/src/main/java/speiger/src/collections/objects/collections/ObjectIterable.java +++ b/src/main/java/speiger/src/collections/objects/collections/ObjectIterable.java @@ -8,6 +8,19 @@ import java.util.function.BiFunction; import java.util.function.IntFunction; import java.util.Comparator; +import speiger.src.collections.booleans.collections.BooleanIterable; +import speiger.src.collections.objects.functions.function.ToByteFunction; +import speiger.src.collections.bytes.collections.ByteIterable; +import speiger.src.collections.objects.functions.function.ToShortFunction; +import speiger.src.collections.shorts.collections.ShortIterable; +import speiger.src.collections.objects.functions.function.ToIntFunction; +import speiger.src.collections.ints.collections.IntIterable; +import speiger.src.collections.objects.functions.function.ToLongFunction; +import speiger.src.collections.longs.collections.LongIterable; +import speiger.src.collections.objects.functions.function.ToFloatFunction; +import speiger.src.collections.floats.collections.FloatIterable; +import speiger.src.collections.objects.functions.function.ToDoubleFunction; +import speiger.src.collections.doubles.collections.DoubleIterable; import speiger.src.collections.objects.functions.function.UnaryOperator; import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer; @@ -87,6 +100,69 @@ public interface ObjectIterable extends Iterable return ObjectIterables.map(this, mapper); } + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default BooleanIterable mapToBoolean(Predicate mapper) { + return ObjectIterables.mapToBoolean(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default ByteIterable mapToByte(ToByteFunction mapper) { + return ObjectIterables.mapToByte(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default ShortIterable mapToShort(ToShortFunction mapper) { + return ObjectIterables.mapToShort(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default IntIterable mapToInt(ToIntFunction mapper) { + return ObjectIterables.mapToInt(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default LongIterable mapToLong(ToLongFunction mapper) { + return ObjectIterables.mapToLong(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default FloatIterable mapToFloat(ToFloatFunction mapper) { + return ObjectIterables.mapToFloat(this, mapper); + } + + /** + * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. + * @param mapper the mapping function + * @return a new Iterable that returns the desired result + */ + default DoubleIterable mapToDouble(ToDoubleFunction mapper) { + return ObjectIterables.mapToDouble(this, mapper); + } + /** * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. * @param mapper the flatMapping function diff --git a/src/main/java/speiger/src/collections/objects/lists/AbstractObjectList.java b/src/main/java/speiger/src/collections/objects/lists/AbstractObjectList.java index a3292da..3f56c12 100644 --- a/src/main/java/speiger/src/collections/objects/lists/AbstractObjectList.java +++ b/src/main/java/speiger/src/collections/objects/lists/AbstractObjectList.java @@ -12,6 +12,7 @@ import speiger.src.collections.objects.collections.AbstractObjectCollection; import speiger.src.collections.objects.collections.ObjectCollection; import speiger.src.collections.objects.collections.ObjectIterator; import speiger.src.collections.objects.collections.ObjectSplititerator; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.objects.utils.ObjectSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -166,13 +167,23 @@ public abstract class AbstractObjectList extends AbstractObjectCollection public ObjectListIterator listIterator() { return listIterator(0); } - + @Override public ObjectListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new ObjectListIter(index); } + @Override + public ObjectListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public ObjectListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add(null); @@ -526,7 +537,153 @@ public abstract class AbstractObjectList extends AbstractObjectCollection } } } + + private class ListIndexedIterator implements ObjectListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public T next() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return get((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public T previous() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return get((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(T e) { throw new UnsupportedOperationException(); } + + @Override + public void set(T e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractObjectList.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 ObjectListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public T next() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return get((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public T previous() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return get((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(T e) { throw new UnsupportedOperationException(); } + + @Override + public void set(T e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractObjectList.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 ObjectListIter implements ObjectListIterator { int index; int lastReturned = -1; @@ -604,7 +761,7 @@ public abstract class AbstractObjectList extends AbstractObjectCollection 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/objects/lists/ObjectList.java b/src/main/java/speiger/src/collections/objects/lists/ObjectList.java index 285282b..17fb787 100644 --- a/src/main/java/speiger/src/collections/objects/lists/ObjectList.java +++ b/src/main/java/speiger/src/collections/objects/lists/ObjectList.java @@ -11,6 +11,7 @@ import speiger.src.collections.objects.collections.ObjectSplititerator; import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; import speiger.src.collections.objects.utils.ObjectArrays; import speiger.src.collections.objects.utils.ObjectLists; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.objects.utils.ObjectSplititerators; /** @@ -253,6 +254,24 @@ public interface ObjectList extends ObjectCollection, List @Override public ObjectListIterator 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 ObjectListIterator 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 ObjectListIterator 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/objects/maps/abstracts/AbstractObject2BooleanMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2BooleanMap.java index 6f37f3d..4381c53 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2BooleanMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2BooleanMap.java @@ -150,6 +150,39 @@ public abstract class AbstractObject2BooleanMap extends AbstractMap mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public boolean supplyBooleanIfAbsent(T 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(T key, ObjectBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + boolean newValue = mappingFunction.applyAsBoolean(key, getBoolean(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -166,17 +199,6 @@ public abstract class AbstractObject2BooleanMap extends AbstractMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -191,17 +213,6 @@ public abstract class AbstractObject2BooleanMap extends AbstractMap extends AbstractMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - boolean newValue = mappingFunction.applyAsBoolean(key, getBoolean(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ByteMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ByteMap.java index ee5df6c..71996ce 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ByteMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ByteMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2ByteMap extends AbstractMap imp return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(T 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(T key, ObjectByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key, getByte(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2ByteMap extends AbstractMap imp return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,23 +219,12 @@ public abstract class AbstractObject2ByteMap extends AbstractMap imp return value; } - @Override - public byte supplyByteIfAbsent(T 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(T key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); byte value; if((value = getByte(key)) == getDefaultReturnValue() || !containsKey(key)) { - byte newValue = valueProvider.getAsInt(); + byte newValue = valueProvider.getAsByte(); if(newValue != getDefaultReturnValue()) { put(key, newValue); return newValue; @@ -222,17 +233,6 @@ public abstract class AbstractObject2ByteMap extends AbstractMap imp return value; } - @Override - public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key, getByte(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2CharMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2CharMap.java index 3f639f0..a323c74 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2CharMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2CharMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2CharMap extends AbstractMap mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public char supplyCharIfAbsent(T 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(T key, ObjectCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + char newValue = mappingFunction.applyAsChar(key, getChar(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2CharMap extends AbstractMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,23 +219,12 @@ public abstract class AbstractObject2CharMap extends AbstractMap extends AbstractMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - char newValue = mappingFunction.applyAsChar(key, getChar(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2DoubleMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2DoubleMap.java index 5e39d56..4c26865 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2DoubleMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2DoubleMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2DoubleMap extends AbstractMap return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public double supplyDoubleIfAbsent(T 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(T key, ObjectDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key, getDouble(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2DoubleMap extends AbstractMap return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,17 +219,6 @@ public abstract class AbstractObject2DoubleMap extends AbstractMap return value; } - @Override - public double supplyDoubleIfAbsent(T 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(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -222,17 +233,6 @@ public abstract class AbstractObject2DoubleMap extends AbstractMap return value; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key, getDouble(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2FloatMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2FloatMap.java index 0fdc6ec..ed86fe7 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2FloatMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2FloatMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2FloatMap extends AbstractMap i return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(T 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(T key, ObjectFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key, getFloat(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2FloatMap extends AbstractMap i return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,23 +219,12 @@ public abstract class AbstractObject2FloatMap extends AbstractMap i return value; } - @Override - public float supplyFloatIfAbsent(T 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(T key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); float value; if((value = getFloat(key)) == getDefaultReturnValue() || !containsKey(key)) { - float newValue = valueProvider.getAsDouble(); + float newValue = valueProvider.getAsFloat(); if(Float.floatToIntBits(newValue) != Float.floatToIntBits(getDefaultReturnValue())) { put(key, newValue); return newValue; @@ -222,17 +233,6 @@ public abstract class AbstractObject2FloatMap extends AbstractMap i return value; } - @Override - public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key, getFloat(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2IntMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2IntMap.java index b06b23c..8da0824 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2IntMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2IntMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2IntMap extends AbstractMap i return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(T 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(T key, ObjectIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key, getInt(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2IntMap extends AbstractMap i return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,17 +219,6 @@ public abstract class AbstractObject2IntMap extends AbstractMap i return value; } - @Override - public int supplyIntIfAbsent(T 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(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -222,17 +233,6 @@ public abstract class AbstractObject2IntMap extends AbstractMap i return value; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key, getInt(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2LongMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2LongMap.java index e19d6c7..02a034d 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2LongMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2LongMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2LongMap extends AbstractMap imp return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(T 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(T key, ObjectLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key, getLong(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2LongMap extends AbstractMap imp return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,17 +219,6 @@ public abstract class AbstractObject2LongMap extends AbstractMap imp return value; } - @Override - public long supplyLongIfAbsent(T 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(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -222,17 +233,6 @@ public abstract class AbstractObject2LongMap extends AbstractMap imp return value; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key, getLong(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ObjectMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ObjectMap.java index faf933e..aa866e4 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ObjectMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ObjectMap.java @@ -144,22 +144,6 @@ public abstract class AbstractObject2ObjectMap extends AbstractMap i return newValue; } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - V value = getObject(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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -174,20 +158,6 @@ public abstract class AbstractObject2ObjectMap extends AbstractMap i return value; } - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - V value; - if((value = getObject(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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -202,20 +172,6 @@ public abstract class AbstractObject2ObjectMap extends AbstractMap i return value; } - @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - V value; - if((value = getObject(key)) == getDefaultReturnValue() || !containsKey(key)) { - V newValue = valueProvider.get(); - if(!Objects.equals(newValue, getDefaultReturnValue())) { - put(key, newValue); - return newValue; - } - } - return value; - } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -231,21 +187,6 @@ public abstract class AbstractObject2ObjectMap extends AbstractMap i return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - V value; - if(!Objects.equals((value = getObject(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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ShortMap.java b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ShortMap.java index 55ca7df..852c7c1 100644 --- a/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ShortMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/abstracts/AbstractObject2ShortMap.java @@ -156,6 +156,39 @@ public abstract class AbstractObject2ShortMap extends AbstractMap i return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(T 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(T key, ObjectShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key, getShort(key)); + put(key, newValue); + return newValue; + } + return getDefaultReturnValue(); + } + @Override public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -172,17 +205,6 @@ public abstract class AbstractObject2ShortMap extends AbstractMap i return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -197,23 +219,12 @@ public abstract class AbstractObject2ShortMap extends AbstractMap i return value; } - @Override - public short supplyShortIfAbsent(T 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(T key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); short value; if((value = getShort(key)) == getDefaultReturnValue() || !containsKey(key)) { - short newValue = valueProvider.getAsInt(); + short newValue = valueProvider.getAsShort(); if(newValue != getDefaultReturnValue()) { put(key, newValue); return newValue; @@ -222,17 +233,6 @@ public abstract class AbstractObject2ShortMap extends AbstractMap i return value; } - @Override - public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key, getShort(key)); - put(key, newValue); - return newValue; - } - return getDefaultReturnValue(); - } - @Override public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2BooleanConcurrentOpenHashMap.java index 13522d0..bc5d081 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2BooleanConcurrentOpenHashMap.java @@ -426,13 +426,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,6 +433,27 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -447,13 +461,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -461,13 +468,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1984,6 +1984,54 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole } } + protected boolean computeIfAbsent(int hash, T key, Predicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, T key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, T key, ObjectBooleanUnaryOperator 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 computeNonDefault(int hash, T key, ObjectBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2007,23 +2055,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole } } - protected boolean computeIfAbsent(int hash, T key, Predicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, T key, Predicate mappingFunction) { long stamp = writeLock(); try { @@ -2047,23 +2078,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole } } - protected boolean supplyIfAbsent(int hash, T key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, T key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2087,20 +2101,6 @@ public class Object2BooleanConcurrentOpenHashMap extends AbstractObject2Boole } } - protected boolean computeIfPresent(int hash, T key, ObjectBooleanUnaryOperator 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, T key, ObjectBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ByteConcurrentOpenHashMap.java index 6788f04..968741e 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ByteConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< } } + protected byte computeIfAbsent(int hash, T key, ToByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, T key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, T key, ObjectByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, T key, ObjectByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< } } - protected byte computeIfAbsent(int hash, T key, ToByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, T key, ToByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,36 +2122,19 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< } } - protected byte supplyIfAbsent(int hash, T key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, T key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2131,20 +2145,6 @@ public class Object2ByteConcurrentOpenHashMap extends AbstractObject2ByteMap< } } - protected byte computeIfPresent(int hash, T key, ObjectByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, T key, ObjectByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2CharConcurrentOpenHashMap.java index 72aac2b..4881516 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2CharConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< } } + protected char computeIfAbsent(int hash, T key, ToCharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, T key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, T key, ObjectCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, T key, ObjectCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< } } - protected char computeIfAbsent(int hash, T key, ToCharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, T key, ToCharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,36 +2122,19 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< } } - protected char supplyIfAbsent(int hash, T key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, T key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2131,20 +2145,6 @@ public class Object2CharConcurrentOpenHashMap extends AbstractObject2CharMap< } } - protected char computeIfPresent(int hash, T key, ObjectCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, T key, ObjectCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2DoubleConcurrentOpenHashMap.java index 8f4cbb2..2e98776 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2DoubleConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double } } + protected double computeIfAbsent(int hash, T key, ToDoubleFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, T key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, T key, ObjectDoubleUnaryOperator 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 computeNonDefault(int hash, T key, ObjectDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double } } - protected double computeIfAbsent(int hash, T key, ToDoubleFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, T key, ToDoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,23 +2122,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double } } - protected double supplyIfAbsent(int hash, T key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, T key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2131,20 +2145,6 @@ public class Object2DoubleConcurrentOpenHashMap extends AbstractObject2Double } } - protected double computeIfPresent(int hash, T key, ObjectDoubleUnaryOperator 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, T key, ObjectDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2FloatConcurrentOpenHashMap.java index 9319024..4e79d12 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2FloatConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa } } + protected float computeIfAbsent(int hash, T key, ToFloatFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, T key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, T key, ObjectFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, T key, ObjectFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa } } - protected float computeIfAbsent(int hash, T key, ToFloatFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, T key, ToFloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,36 +2122,19 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa } } - protected float supplyIfAbsent(int hash, T key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, T key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2131,20 +2145,6 @@ public class Object2FloatConcurrentOpenHashMap extends AbstractObject2FloatMa } } - protected float computeIfPresent(int hash, T key, ObjectFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, T key, ObjectFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2IntConcurrentOpenHashMap.java index 0ff9797..b51ad7b 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2IntConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap } } + protected int computeIfAbsent(int hash, T key, ToIntFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, T key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, T key, ObjectIntUnaryOperator 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 computeNonDefault(int hash, T key, ObjectIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap } } - protected int computeIfAbsent(int hash, T key, ToIntFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, T key, ToIntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,23 +2122,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap } } - protected int supplyIfAbsent(int hash, T key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, T key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2131,20 +2145,6 @@ public class Object2IntConcurrentOpenHashMap extends AbstractObject2IntMap } } - protected int computeIfPresent(int hash, T key, ObjectIntUnaryOperator 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, T key, ObjectIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2LongConcurrentOpenHashMap.java index 75035be..35cc307 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2LongConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< } } + protected long computeIfAbsent(int hash, T key, ToLongFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, T key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, T key, ObjectLongUnaryOperator 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 computeNonDefault(int hash, T key, ObjectLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< } } - protected long computeIfAbsent(int hash, T key, ToLongFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, T key, ToLongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,23 +2122,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< } } - protected long supplyIfAbsent(int hash, T key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, T key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2131,20 +2145,6 @@ public class Object2LongConcurrentOpenHashMap extends AbstractObject2LongMap< } } - protected long computeIfPresent(int hash, T key, ObjectLongUnaryOperator 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, T key, ObjectLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ObjectConcurrentOpenHashMap.java index f970017..700b2f5 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ObjectConcurrentOpenHashMap.java @@ -354,13 +354,6 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -368,13 +361,6 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -382,13 +368,6 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -396,13 +375,6 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1873,29 +1845,6 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj } } - protected V computeNonDefault(int hash, T key, ObjectObjectUnaryOperator 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, T key, UnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -1918,30 +1867,7 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, T key, UnaryOperator 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, T key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -1964,30 +1890,7 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, T 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, T key, ObjectObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2006,11 +1909,16 @@ public class Object2ObjectConcurrentOpenHashMap extends AbstractObject2Obj } } - protected V computeIfPresentNonDefault(int hash, T key, ObjectObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, T key, ObjectObjectUnaryOperator 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/objects/maps/impl/concurrent/Object2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ShortConcurrentOpenHashMap.java index 06bf8b6..b06e725 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/concurrent/Object2ShortConcurrentOpenHashMap.java @@ -439,13 +439,6 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -453,6 +446,27 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,13 +474,6 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,13 +481,6 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2028,6 +2028,54 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa } } + protected short computeIfAbsent(int hash, T key, ToShortFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, T key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, T key, ObjectShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, T key, ObjectShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2051,23 +2099,6 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa } } - protected short computeIfAbsent(int hash, T key, ToShortFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, T key, ToShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2091,36 +2122,19 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa } } - protected short supplyIfAbsent(int hash, T key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, T key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2131,20 +2145,6 @@ public class Object2ShortConcurrentOpenHashMap extends AbstractObject2ShortMa } } - protected short computeIfPresent(int hash, T key, ObjectShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, T key, ObjectShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2BooleanOpenCustomHashMap.java index 97c2ef0..df027ea 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2BooleanOpenCustomHashMap.java @@ -424,6 +424,42 @@ public class Object2BooleanOpenCustomHashMap extends AbstractObject2BooleanMa return newValue; } + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,19 +479,6 @@ public class Object2BooleanOpenCustomHashMap extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -475,19 +498,6 @@ public class Object2BooleanOpenCustomHashMap extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -507,16 +517,6 @@ public class Object2BooleanOpenCustomHashMap extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ByteOpenCustomHashMap.java index 749ef9c..abbafaf 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ByteOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2ByteOpenCustomHashMap extends AbstractObject2ByteMap i return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2ByteOpenCustomHashMap extends AbstractObject2ByteMap i return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,48 +520,25 @@ public class Object2ByteOpenCustomHashMap extends AbstractObject2ByteMap i return newValue; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(T 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(T key, ObjectByteUnaryOperator 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2CharOpenCustomHashMap.java index 1bdd481..3163824 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2CharOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2CharOpenCustomHashMap extends AbstractObject2CharMap i return newValue; } + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2CharOpenCustomHashMap extends AbstractObject2CharMap i return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,48 +520,25 @@ public class Object2CharOpenCustomHashMap extends AbstractObject2CharMap i return newValue; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(T 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(T key, ObjectCharUnaryOperator 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2DoubleOpenCustomHashMap.java index e475df9..281c4d3 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2DoubleOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2DoubleOpenCustomHashMap extends AbstractObject2DoubleMap< return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2DoubleOpenCustomHashMap extends AbstractObject2DoubleMap< return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,19 +520,6 @@ public class Object2DoubleOpenCustomHashMap extends AbstractObject2DoubleMap< return newValue; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -529,16 +539,6 @@ public class Object2DoubleOpenCustomHashMap extends AbstractObject2DoubleMap< return newValue; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2FloatOpenCustomHashMap.java index a07dc01..741f672 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2FloatOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2FloatOpenCustomHashMap extends AbstractObject2FloatMap return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2FloatOpenCustomHashMap extends AbstractObject2FloatMap return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,48 +520,25 @@ public class Object2FloatOpenCustomHashMap extends AbstractObject2FloatMap return newValue; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(T 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(T key, ObjectFloatUnaryOperator 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2IntOpenCustomHashMap.java index 4cf3e3c..8441830 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2IntOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2IntOpenCustomHashMap extends AbstractObject2IntMap imp return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2IntOpenCustomHashMap extends AbstractObject2IntMap imp return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,19 +520,6 @@ public class Object2IntOpenCustomHashMap extends AbstractObject2IntMap imp return newValue; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -529,16 +539,6 @@ public class Object2IntOpenCustomHashMap extends AbstractObject2IntMap imp return newValue; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2LongOpenCustomHashMap.java index f4c9c45..f3245eb 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2LongOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2LongOpenCustomHashMap extends AbstractObject2LongMap i return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2LongOpenCustomHashMap extends AbstractObject2LongMap i return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,19 +520,6 @@ public class Object2LongOpenCustomHashMap extends AbstractObject2LongMap i return newValue; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -529,16 +539,6 @@ public class Object2LongOpenCustomHashMap extends AbstractObject2LongMap i return newValue; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ObjectOpenCustomHashMap.java index 0a6c4c3..bb39a87 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ObjectOpenCustomHashMap.java @@ -359,25 +359,6 @@ public class Object2ObjectOpenCustomHashMap extends AbstractObject2ObjectM return newValue; } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator 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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -396,26 +377,7 @@ public class Object2ObjectOpenCustomHashMap extends AbstractObject2ObjectM } return newValue; } - - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator 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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -435,25 +397,6 @@ public class Object2ObjectOpenCustomHashMap extends AbstractObject2ObjectM return newValue; } - @Override - public V supplyIfAbsentNonDefault(T 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(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,20 +411,6 @@ public class Object2ObjectOpenCustomHashMap extends AbstractObject2ObjectM return newValue; } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator 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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ShortOpenCustomHashMap.java index 8b134fb..3359c79 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/customHash/Object2ShortOpenCustomHashMap.java @@ -446,6 +446,42 @@ public class Object2ShortOpenCustomHashMap extends AbstractObject2ShortMap return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,19 +501,6 @@ public class Object2ShortOpenCustomHashMap extends AbstractObject2ShortMap return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -497,48 +520,25 @@ public class Object2ShortOpenCustomHashMap extends AbstractObject2ShortMap return newValue; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(T 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(T key, ObjectShortUnaryOperator 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2BooleanOpenHashMap.java index 2cea87a..d70a287 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2BooleanOpenHashMap.java @@ -396,6 +396,42 @@ public class Object2BooleanOpenHashMap extends AbstractObject2BooleanMap i values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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(T key, ObjectBooleanUnaryOperator mappingFunction) { @@ -416,19 +452,6 @@ public class Object2BooleanOpenHashMap extends AbstractObject2BooleanMap i return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +471,6 @@ public class Object2BooleanOpenHashMap extends AbstractObject2BooleanMap i return newValue; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -480,16 +490,6 @@ public class Object2BooleanOpenHashMap extends AbstractObject2BooleanMap i return newValue; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ByteOpenHashMap.java index 71398d0..a5d7f78 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ByteOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2ByteOpenHashMap extends AbstractObject2ByteMap impleme values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator 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(T key, ObjectByteUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2ByteOpenHashMap extends AbstractObject2ByteMap impleme return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,48 +493,25 @@ public class Object2ByteOpenHashMap extends AbstractObject2ByteMap impleme return newValue; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(T 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(T key, ObjectByteUnaryOperator 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2CharOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2CharOpenHashMap.java index 283d46a..6c921e4 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2CharOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2CharOpenHashMap extends AbstractObject2CharMap impleme values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator 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(T key, ObjectCharUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2CharOpenHashMap extends AbstractObject2CharMap impleme return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,48 +493,25 @@ public class Object2CharOpenHashMap extends AbstractObject2CharMap impleme return newValue; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(T 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(T key, ObjectCharUnaryOperator 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2DoubleOpenHashMap.java index a279492..fde7098 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2DoubleOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2DoubleOpenHashMap extends AbstractObject2DoubleMap imp values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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(T key, ObjectDoubleUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2DoubleOpenHashMap extends AbstractObject2DoubleMap imp return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Object2DoubleOpenHashMap extends AbstractObject2DoubleMap imp return newValue; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Object2DoubleOpenHashMap extends AbstractObject2DoubleMap imp return newValue; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2FloatOpenHashMap.java index c5a5edc..0c9f39b 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2FloatOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2FloatOpenHashMap extends AbstractObject2FloatMap imple values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator 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(T key, ObjectFloatUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2FloatOpenHashMap extends AbstractObject2FloatMap imple return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,48 +493,25 @@ public class Object2FloatOpenHashMap extends AbstractObject2FloatMap imple return newValue; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(T 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(T key, ObjectFloatUnaryOperator 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2IntOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2IntOpenHashMap.java index 9c2a79a..6b580f3 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2IntOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2IntOpenHashMap extends AbstractObject2IntMap implement values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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(T key, ObjectIntUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2IntOpenHashMap extends AbstractObject2IntMap implement return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Object2IntOpenHashMap extends AbstractObject2IntMap implement return newValue; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Object2IntOpenHashMap extends AbstractObject2IntMap implement return newValue; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2LongOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2LongOpenHashMap.java index 4f631c9..22c1ba5 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2LongOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2LongOpenHashMap extends AbstractObject2LongMap impleme values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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(T key, ObjectLongUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2LongOpenHashMap extends AbstractObject2LongMap impleme return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Object2LongOpenHashMap extends AbstractObject2LongMap impleme return newValue; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Object2LongOpenHashMap extends AbstractObject2LongMap impleme return newValue; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ObjectOpenHashMap.java index 911915d..b0a03cd 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ObjectOpenHashMap.java @@ -336,26 +336,7 @@ public class Object2ObjectOpenHashMap extends AbstractObject2ObjectMap 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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -375,25 +356,6 @@ public class Object2ObjectOpenHashMap extends AbstractObject2ObjectMap 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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -412,26 +374,7 @@ public class Object2ObjectOpenHashMap extends AbstractObject2ObjectMap 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(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -446,20 +389,6 @@ public class Object2ObjectOpenHashMap extends AbstractObject2ObjectMap 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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ShortOpenHashMap.java index edb27a0..9e94053 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/hash/Object2ShortOpenHashMap.java @@ -418,6 +418,42 @@ public class Object2ShortOpenHashMap extends AbstractObject2ShortMap imple values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator 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(T key, ObjectShortUnaryOperator mappingFunction) { @@ -438,19 +474,6 @@ public class Object2ShortOpenHashMap extends AbstractObject2ShortMap imple return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,48 +493,25 @@ public class Object2ShortOpenHashMap extends AbstractObject2ShortMap imple return newValue; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(T 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(T key, ObjectShortUnaryOperator 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2BooleanOpenHashMap.java index 3f78f8f..ccbf6c3 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2BooleanOpenHashMap.java @@ -397,20 +397,19 @@ public class ImmutableObject2BooleanOpenHashMap extends AbstractObject2Boolea @Override public boolean computeBoolean(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(T key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ByteOpenHashMap.java index 3dadab3..0e22bab 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ByteOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2ByteOpenHashMap extends AbstractObject2ByteMap mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(T key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2CharOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2CharOpenHashMap.java index 9417846..027799b 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2CharOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2CharOpenHashMap extends AbstractObject2CharMap mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(T key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2DoubleOpenHashMap.java index 2a32028..78e4be2 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2DoubleOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2DoubleOpenHashMap extends AbstractObject2DoubleM @Override public double computeDouble(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(T key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2FloatOpenHashMap.java index d000956..2a99403 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2FloatOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2FloatOpenHashMap extends AbstractObject2FloatMap @Override public float computeFloat(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(T key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2IntOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2IntOpenHashMap.java index 7408cfd..b0ab5b4 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2IntOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2IntOpenHashMap extends AbstractObject2IntMap @Override public int computeInt(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2LongOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2LongOpenHashMap.java index 92560a1..c611f80 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2LongOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2LongOpenHashMap extends AbstractObject2LongMap mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(T key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ObjectOpenHashMap.java index ec8ecf4..6e6aa9c 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ObjectOpenHashMap.java @@ -353,20 +353,11 @@ public class ImmutableObject2ObjectOpenHashMap extends AbstractObject2Obje @Override public V compute(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ShortOpenHashMap.java index f09c50d..67dfc25 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/immutable/ImmutableObject2ShortOpenHashMap.java @@ -402,20 +402,19 @@ public class ImmutableObject2ShortOpenHashMap extends AbstractObject2ShortMap @Override public short computeShort(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(T key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2BooleanMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2BooleanMap.java index 00eeee4..755a940 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2BooleanMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2BooleanMap.java @@ -301,6 +301,41 @@ public class Enum2BooleanMap> extends AbstractObject2BooleanMa return newValue; } + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + boolean newValue = mappingFunction.test(key); + set(index); + values[index] = newValue; + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + boolean newValue = valueProvider.getAsBoolean(); + set(index); + values[index] = newValue; + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + boolean newValue = mappingFunction.applyAsBoolean(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -321,19 +356,6 @@ public class Enum2BooleanMap> extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - boolean newValue = mappingFunction.test(key); - set(index); - values[index] = newValue; - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { int index = key.ordinal(); @@ -353,19 +375,6 @@ public class Enum2BooleanMap> extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - boolean newValue = valueProvider.getAsBoolean(); - set(index); - values[index] = newValue; - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { int index = key.ordinal(); @@ -385,15 +394,6 @@ public class Enum2BooleanMap> extends AbstractObject2BooleanMa return newValue; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - boolean newValue = mappingFunction.applyAsBoolean(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ByteMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ByteMap.java index c7deb34..ee3132c 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ByteMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ByteMap.java @@ -326,6 +326,41 @@ public class Enum2ByteMap> extends AbstractObject2ByteMap return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + byte newValue = mappingFunction.applyAsByte(key); + set(index); + values[index] = newValue; + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + byte newValue = valueProvider.getAsByte(); + set(index); + values[index] = newValue; + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2ByteMap> extends AbstractObject2ByteMap return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - byte newValue = mappingFunction.applyAsByte(key); - set(index); - values[index] = newValue; - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { int index = key.ordinal(); @@ -378,24 +400,11 @@ public class Enum2ByteMap> extends AbstractObject2ByteMap return newValue; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - byte newValue = valueProvider.getAsInt(); - set(index); - values[index] = newValue; - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { int index = key.ordinal(); if(!isSet(index)) { - byte newValue = valueProvider.getAsInt(); + byte newValue = valueProvider.getAsByte(); if(newValue == getDefaultReturnValue()) return newValue; set(index); values[index] = newValue; @@ -403,22 +412,13 @@ public class Enum2ByteMap> extends AbstractObject2ByteMap } 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(T key, ObjectByteUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2CharMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2CharMap.java index 032ac67..a42fa79 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2CharMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2CharMap.java @@ -326,6 +326,41 @@ public class Enum2CharMap> extends AbstractObject2CharMap return newValue; } + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + char newValue = mappingFunction.applyAsChar(key); + set(index); + values[index] = newValue; + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + char newValue = valueProvider.getAsChar(); + set(index); + values[index] = newValue; + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2CharMap> extends AbstractObject2CharMap return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - char newValue = mappingFunction.applyAsChar(key); - set(index); - values[index] = newValue; - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { int index = key.ordinal(); @@ -378,24 +400,11 @@ public class Enum2CharMap> extends AbstractObject2CharMap return newValue; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - char newValue = valueProvider.getAsInt(); - set(index); - values[index] = newValue; - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { int index = key.ordinal(); if(!isSet(index)) { - char newValue = valueProvider.getAsInt(); + char newValue = valueProvider.getAsChar(); if(newValue == getDefaultReturnValue()) return newValue; set(index); values[index] = newValue; @@ -403,22 +412,13 @@ public class Enum2CharMap> extends AbstractObject2CharMap } 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(T key, ObjectCharUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2DoubleMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2DoubleMap.java index 5b6639f..1b8af65 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2DoubleMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2DoubleMap.java @@ -326,6 +326,41 @@ public class Enum2DoubleMap> extends AbstractObject2DoubleMap< return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + double newValue = mappingFunction.applyAsDouble(key); + set(index); + values[index] = newValue; + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + double newValue = valueProvider.getAsDouble(); + set(index); + values[index] = newValue; + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + double newValue = mappingFunction.applyAsDouble(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2DoubleMap> extends AbstractObject2DoubleMap< return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - double newValue = mappingFunction.applyAsDouble(key); - set(index); - values[index] = newValue; - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { int index = key.ordinal(); @@ -378,19 +400,6 @@ public class Enum2DoubleMap> extends AbstractObject2DoubleMap< return newValue; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - double newValue = valueProvider.getAsDouble(); - set(index); - values[index] = newValue; - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { int index = key.ordinal(); @@ -410,15 +419,6 @@ public class Enum2DoubleMap> extends AbstractObject2DoubleMap< return newValue; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - double newValue = mappingFunction.applyAsDouble(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2FloatMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2FloatMap.java index 5336123..67fc5dd 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2FloatMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2FloatMap.java @@ -326,6 +326,41 @@ public class Enum2FloatMap> extends AbstractObject2FloatMap return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + float newValue = mappingFunction.applyAsFloat(key); + set(index); + values[index] = newValue; + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + float newValue = valueProvider.getAsFloat(); + set(index); + values[index] = newValue; + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2FloatMap> extends AbstractObject2FloatMap return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - float newValue = mappingFunction.applyAsFloat(key); - set(index); - values[index] = newValue; - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { int index = key.ordinal(); @@ -378,24 +400,11 @@ public class Enum2FloatMap> extends AbstractObject2FloatMap return newValue; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - float newValue = valueProvider.getAsDouble(); - set(index); - values[index] = newValue; - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { int index = key.ordinal(); if(!isSet(index)) { - float newValue = valueProvider.getAsDouble(); + float newValue = valueProvider.getAsFloat(); if(Float.floatToIntBits(newValue) == Float.floatToIntBits(getDefaultReturnValue())) return newValue; set(index); values[index] = newValue; @@ -403,22 +412,13 @@ public class Enum2FloatMap> extends AbstractObject2FloatMap } 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(T key, ObjectFloatUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2IntMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2IntMap.java index 36d19a5..4c24fe1 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2IntMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2IntMap.java @@ -326,6 +326,41 @@ public class Enum2IntMap> extends AbstractObject2IntMap return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + int newValue = mappingFunction.applyAsInt(key); + set(index); + values[index] = newValue; + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + int newValue = valueProvider.getAsInt(); + set(index); + values[index] = newValue; + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + int newValue = mappingFunction.applyAsInt(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2IntMap> extends AbstractObject2IntMap return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - int newValue = mappingFunction.applyAsInt(key); - set(index); - values[index] = newValue; - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { int index = key.ordinal(); @@ -378,19 +400,6 @@ public class Enum2IntMap> extends AbstractObject2IntMap return newValue; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - int newValue = valueProvider.getAsInt(); - set(index); - values[index] = newValue; - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { int index = key.ordinal(); @@ -410,15 +419,6 @@ public class Enum2IntMap> extends AbstractObject2IntMap return newValue; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - int newValue = mappingFunction.applyAsInt(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2LongMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2LongMap.java index a9a99e4..21cdcb2 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2LongMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2LongMap.java @@ -326,6 +326,41 @@ public class Enum2LongMap> extends AbstractObject2LongMap return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + long newValue = mappingFunction.applyAsLong(key); + set(index); + values[index] = newValue; + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + long newValue = valueProvider.getAsLong(); + set(index); + values[index] = newValue; + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + long newValue = mappingFunction.applyAsLong(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2LongMap> extends AbstractObject2LongMap return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - long newValue = mappingFunction.applyAsLong(key); - set(index); - values[index] = newValue; - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { int index = key.ordinal(); @@ -378,19 +400,6 @@ public class Enum2LongMap> extends AbstractObject2LongMap return newValue; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - long newValue = valueProvider.getAsLong(); - set(index); - values[index] = newValue; - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { int index = key.ordinal(); @@ -410,15 +419,6 @@ public class Enum2LongMap> extends AbstractObject2LongMap return newValue; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - long newValue = mappingFunction.applyAsLong(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ObjectMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ObjectMap.java index 1bcd63e..d863247 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ObjectMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ObjectMap.java @@ -290,26 +290,6 @@ public class Enum2ObjectMap, V> extends AbstractObject2ObjectM return newValue; } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - V newValue = mappingFunction.apply(key, getDefaultReturnValue()); - if(Objects.equals(newValue, getDefaultReturnValue())) return newValue; - set(index); - values[index] = newValue; - return newValue; - } - V newValue = mappingFunction.apply(key, values[index]); - if(Objects.equals(newValue, getDefaultReturnValue())) { - clear(index); - values[index] = null; - return newValue; - } - values[index] = newValue; - return newValue; - } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { int index = key.ordinal(); @@ -328,26 +308,7 @@ public class Enum2ObjectMap, V> extends AbstractObject2ObjectM } return newValue; } - - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - V newValue = mappingFunction.apply(key); - if(Objects.equals(newValue, getDefaultReturnValue())) return newValue; - set(index); - values[index] = 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(T key, ObjectSupplier valueProvider) { int index = key.ordinal(); @@ -367,25 +328,6 @@ public class Enum2ObjectMap, V> extends AbstractObject2ObjectM return newValue; } - @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - V newValue = valueProvider.get(); - if(Objects.equals(newValue, getDefaultReturnValue())) return newValue; - set(index); - values[index] = 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(T key, ObjectObjectUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -400,20 +342,6 @@ public class Enum2ObjectMap, V> extends AbstractObject2ObjectM return newValue; } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index) || Objects.equals(values[index], getDefaultReturnValue())) return getDefaultReturnValue(); - V newValue = mappingFunction.apply(key, values[index]); - if(Objects.equals(newValue, getDefaultReturnValue())) { - clear(index); - values[index] = null; - return newValue; - } - values[index] = newValue; - return newValue; - } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ShortMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ShortMap.java index f9fbf66..a862fb0 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ShortMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Enum2ShortMap.java @@ -326,6 +326,41 @@ public class Enum2ShortMap> extends AbstractObject2ShortMap return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) { + short newValue = mappingFunction.applyAsShort(key); + set(index); + values[index] = newValue; + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + int index = key.ordinal(); + if(!isSet(index)) { + short newValue = valueProvider.getAsShort(); + set(index); + values[index] = newValue; + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { + int index = key.ordinal(); + if(!isSet(index)) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + @Override public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { int index = key.ordinal(); @@ -346,19 +381,6 @@ public class Enum2ShortMap> extends AbstractObject2ShortMap return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) { - short newValue = mappingFunction.applyAsShort(key); - set(index); - values[index] = newValue; - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { int index = key.ordinal(); @@ -378,24 +400,11 @@ public class Enum2ShortMap> extends AbstractObject2ShortMap return newValue; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - int index = key.ordinal(); - if(!isSet(index)) { - short newValue = valueProvider.getAsInt(); - set(index); - values[index] = newValue; - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { int index = key.ordinal(); if(!isSet(index)) { - short newValue = valueProvider.getAsInt(); + short newValue = valueProvider.getAsShort(); if(newValue == getDefaultReturnValue()) return newValue; set(index); values[index] = newValue; @@ -403,22 +412,13 @@ public class Enum2ShortMap> extends AbstractObject2ShortMap } 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(T key, ObjectShortUnaryOperator mappingFunction) { - int index = key.ordinal(); - if(!isSet(index)) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - @Override public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { int index = key.ordinal(); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2BooleanArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2BooleanArrayMap.java index 611f502..a970ee4 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2BooleanArrayMap.java @@ -406,6 +406,42 @@ public class Object2BooleanArrayMap extends AbstractObject2BooleanMap impl return newValue; } + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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 computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -425,19 +461,6 @@ public class Object2BooleanArrayMap extends AbstractObject2BooleanMap impl return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -457,19 +480,6 @@ public class Object2BooleanArrayMap extends AbstractObject2BooleanMap impl return newValue; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -489,16 +499,6 @@ public class Object2BooleanArrayMap extends AbstractObject2BooleanMap impl return newValue; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ByteArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ByteArrayMap.java index 4dcf83b..15bbb78 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ByteArrayMap.java @@ -429,6 +429,42 @@ public class Object2ByteArrayMap extends AbstractObject2ByteMap implements return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator 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 computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2ByteArrayMap extends AbstractObject2ByteMap implements return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,48 +503,25 @@ public class Object2ByteArrayMap extends AbstractObject2ByteMap implements return newValue; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(T 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(T key, ObjectByteUnaryOperator 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2CharArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2CharArrayMap.java index c3921c5..290796f 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2CharArrayMap.java @@ -429,6 +429,42 @@ public class Object2CharArrayMap extends AbstractObject2CharMap implements return newValue; } + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator 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 computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2CharArrayMap extends AbstractObject2CharMap implements return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,48 +503,25 @@ public class Object2CharArrayMap extends AbstractObject2CharMap implements return newValue; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(T 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(T key, ObjectCharUnaryOperator 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2DoubleArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2DoubleArrayMap.java index ed80134..44d9360 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2DoubleArrayMap.java @@ -429,6 +429,42 @@ public class Object2DoubleArrayMap extends AbstractObject2DoubleMap implem return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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 computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2DoubleArrayMap extends AbstractObject2DoubleMap implem return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +503,6 @@ public class Object2DoubleArrayMap extends AbstractObject2DoubleMap implem return newValue; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -512,16 +522,6 @@ public class Object2DoubleArrayMap extends AbstractObject2DoubleMap implem return newValue; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2FloatArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2FloatArrayMap.java index 11261ee..c1bb770 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2FloatArrayMap.java @@ -429,6 +429,42 @@ public class Object2FloatArrayMap extends AbstractObject2FloatMap implemen return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator 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 computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2FloatArrayMap extends AbstractObject2FloatMap implemen return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,48 +503,25 @@ public class Object2FloatArrayMap extends AbstractObject2FloatMap implemen return newValue; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(T 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(T key, ObjectFloatUnaryOperator 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2IntArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2IntArrayMap.java index 1069192..c0aef88 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2IntArrayMap.java @@ -429,6 +429,42 @@ public class Object2IntArrayMap extends AbstractObject2IntMap implements O return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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 computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2IntArrayMap extends AbstractObject2IntMap implements O return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +503,6 @@ public class Object2IntArrayMap extends AbstractObject2IntMap implements O return newValue; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -512,16 +522,6 @@ public class Object2IntArrayMap extends AbstractObject2IntMap implements O return newValue; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2LongArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2LongArrayMap.java index a3ea10e..e560fce 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2LongArrayMap.java @@ -429,6 +429,42 @@ public class Object2LongArrayMap extends AbstractObject2LongMap implements return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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 computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2LongArrayMap extends AbstractObject2LongMap implements return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,19 +503,6 @@ public class Object2LongArrayMap extends AbstractObject2LongMap implements return newValue; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -512,16 +522,6 @@ public class Object2LongArrayMap extends AbstractObject2LongMap implements return newValue; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ObjectArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ObjectArrayMap.java index 9cda838..5dc393c 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ObjectArrayMap.java @@ -368,25 +368,6 @@ public class Object2ObjectArrayMap extends AbstractObject2ObjectMap return newValue; } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator 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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -405,26 +386,7 @@ public class Object2ObjectArrayMap extends AbstractObject2ObjectMap } return newValue; } - - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator 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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -443,26 +405,7 @@ public class Object2ObjectArrayMap extends AbstractObject2ObjectMap } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(T 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(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -477,20 +420,6 @@ public class Object2ObjectArrayMap extends AbstractObject2ObjectMap return newValue; } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator 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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ShortArrayMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ShortArrayMap.java index bb49175..c76e08d 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/misc/Object2ShortArrayMap.java @@ -429,6 +429,42 @@ public class Object2ShortArrayMap extends AbstractObject2ShortMap implemen return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator 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 computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -448,19 +484,6 @@ public class Object2ShortArrayMap extends AbstractObject2ShortMap implemen return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -480,48 +503,25 @@ public class Object2ShortArrayMap extends AbstractObject2ShortMap implemen return newValue; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(T 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(T key, ObjectShortUnaryOperator 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanAVLTreeMap.java index 8087af1..f57ef65 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanAVLTreeMap.java @@ -387,6 +387,43 @@ public class Object2BooleanAVLTreeMap extends AbstractObject2BooleanMap im return newValue; } + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = valueProvider.getAsBoolean(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + boolean newValue = mappingFunction.applyAsBoolean(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -407,19 +444,6 @@ public class Object2BooleanAVLTreeMap extends AbstractObject2BooleanMap im return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -439,19 +463,6 @@ public class Object2BooleanAVLTreeMap extends AbstractObject2BooleanMap im return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = valueProvider.getAsBoolean(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -471,17 +482,6 @@ public class Object2BooleanAVLTreeMap extends AbstractObject2BooleanMap im return entry.value; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1449,14 +1449,9 @@ public class Object2BooleanAVLTreeMap extends AbstractObject2BooleanMap im map.validate(key); 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/objects/maps/impl/tree/Object2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanRBTreeMap.java index 4b7319e..5cb91c1 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2BooleanRBTreeMap.java @@ -386,6 +386,43 @@ public class Object2BooleanRBTreeMap extends AbstractObject2BooleanMap imp return newValue; } + @Override + public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = valueProvider.getAsBoolean(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + boolean newValue = mappingFunction.applyAsBoolean(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -406,19 +443,6 @@ public class Object2BooleanRBTreeMap extends AbstractObject2BooleanMap imp return newValue; } - @Override - public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +462,6 @@ public class Object2BooleanRBTreeMap extends AbstractObject2BooleanMap imp return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = valueProvider.getAsBoolean(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -470,17 +481,6 @@ public class Object2BooleanRBTreeMap extends AbstractObject2BooleanMap imp return entry.value; } - @Override - public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1512,14 +1512,9 @@ public class Object2BooleanRBTreeMap extends AbstractObject2BooleanMap imp map.validate(key); 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/objects/maps/impl/tree/Object2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteAVLTreeMap.java index d59cfee..c3afcf3 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2ByteAVLTreeMap extends AbstractObject2ByteMap implemen return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + byte newValue = valueProvider.getAsByte(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2ByteAVLTreeMap extends AbstractObject2ByteMap implemen return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2ByteAVLTreeMap extends AbstractObject2ByteMap implemen return entry.value; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - byte newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2ByteAVLTreeMap extends AbstractObject2ByteMap implemen map.validate(key); 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/objects/maps/impl/tree/Object2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteRBTreeMap.java index ea979a8..425bb43 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ByteRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2ByteRBTreeMap extends AbstractObject2ByteMap implement return newValue; } + @Override + public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + byte newValue = valueProvider.getAsByte(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2ByteRBTreeMap extends AbstractObject2ByteMap implement return newValue; } - @Override - public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2ByteRBTreeMap extends AbstractObject2ByteMap implement return entry.value; } - @Override - public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - byte newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2ByteRBTreeMap extends AbstractObject2ByteMap implement map.validate(key); 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/objects/maps/impl/tree/Object2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharAVLTreeMap.java index fcfe825..19ec9d4 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2CharAVLTreeMap extends AbstractObject2CharMap implemen return newValue; } + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + char newValue = valueProvider.getAsChar(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2CharAVLTreeMap extends AbstractObject2CharMap implemen return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2CharAVLTreeMap extends AbstractObject2CharMap implemen return entry.value; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - char newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2CharAVLTreeMap extends AbstractObject2CharMap implemen map.validate(key); 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/objects/maps/impl/tree/Object2CharRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharRBTreeMap.java index 0cb34e1..5cc3c50 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2CharRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2CharRBTreeMap extends AbstractObject2CharMap implement return newValue; } + @Override + public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + char newValue = valueProvider.getAsChar(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2CharRBTreeMap extends AbstractObject2CharMap implement return newValue; } - @Override - public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2CharRBTreeMap extends AbstractObject2CharMap implement return entry.value; } - @Override - public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - char newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2CharRBTreeMap extends AbstractObject2CharMap implement map.validate(key); 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/objects/maps/impl/tree/Object2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleAVLTreeMap.java index 83685ba..b90675f 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2DoubleAVLTreeMap extends AbstractObject2DoubleMap impl return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + double newValue = valueProvider.getAsDouble(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + double newValue = mappingFunction.applyAsDouble(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2DoubleAVLTreeMap extends AbstractObject2DoubleMap impl return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2DoubleAVLTreeMap extends AbstractObject2DoubleMap impl return entry.value; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - double newValue = valueProvider.getAsDouble(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2DoubleAVLTreeMap extends AbstractObject2DoubleMap impl return entry.value; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2DoubleAVLTreeMap extends AbstractObject2DoubleMap impl map.validate(key); 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/objects/maps/impl/tree/Object2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleRBTreeMap.java index 7ef9f0f..c66ed1e 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2DoubleRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2DoubleRBTreeMap extends AbstractObject2DoubleMap imple return newValue; } + @Override + public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + double newValue = valueProvider.getAsDouble(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + double newValue = mappingFunction.applyAsDouble(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2DoubleRBTreeMap extends AbstractObject2DoubleMap imple return newValue; } - @Override - public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2DoubleRBTreeMap extends AbstractObject2DoubleMap imple return entry.value; } - @Override - public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - double newValue = valueProvider.getAsDouble(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2DoubleRBTreeMap extends AbstractObject2DoubleMap imple return entry.value; } - @Override - public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2DoubleRBTreeMap extends AbstractObject2DoubleMap imple map.validate(key); 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/objects/maps/impl/tree/Object2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatAVLTreeMap.java index 67e5b29..63e27a0 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2FloatAVLTreeMap extends AbstractObject2FloatMap implem return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + float newValue = valueProvider.getAsFloat(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2FloatAVLTreeMap extends AbstractObject2FloatMap implem return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2FloatAVLTreeMap extends AbstractObject2FloatMap implem return entry.value; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - float newValue = valueProvider.getAsDouble(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2FloatAVLTreeMap extends AbstractObject2FloatMap implem map.validate(key); 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/objects/maps/impl/tree/Object2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatRBTreeMap.java index ce46394..6b20aa9 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2FloatRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2FloatRBTreeMap extends AbstractObject2FloatMap impleme return newValue; } + @Override + public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + float newValue = valueProvider.getAsFloat(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2FloatRBTreeMap extends AbstractObject2FloatMap impleme return newValue; } - @Override - public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2FloatRBTreeMap extends AbstractObject2FloatMap impleme return entry.value; } - @Override - public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - float newValue = valueProvider.getAsDouble(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2FloatRBTreeMap extends AbstractObject2FloatMap impleme map.validate(key); 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/objects/maps/impl/tree/Object2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntAVLTreeMap.java index bf0bb8b..854fa01 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2IntAVLTreeMap extends AbstractObject2IntMap implements return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + int newValue = valueProvider.getAsInt(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + int newValue = mappingFunction.applyAsInt(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2IntAVLTreeMap extends AbstractObject2IntMap implements return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2IntAVLTreeMap extends AbstractObject2IntMap implements return entry.value; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - int newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2IntAVLTreeMap extends AbstractObject2IntMap implements return entry.value; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2IntAVLTreeMap extends AbstractObject2IntMap implements map.validate(key); 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/objects/maps/impl/tree/Object2IntRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntRBTreeMap.java index 1ae54be..8479046 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2IntRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2IntRBTreeMap extends AbstractObject2IntMap implements return newValue; } + @Override + public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + int newValue = valueProvider.getAsInt(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + int newValue = mappingFunction.applyAsInt(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2IntRBTreeMap extends AbstractObject2IntMap implements return newValue; } - @Override - public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2IntRBTreeMap extends AbstractObject2IntMap implements return entry.value; } - @Override - public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - int newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2IntRBTreeMap extends AbstractObject2IntMap implements return entry.value; } - @Override - public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2IntRBTreeMap extends AbstractObject2IntMap implements map.validate(key); 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/objects/maps/impl/tree/Object2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongAVLTreeMap.java index 90d61b3..1d863fb 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2LongAVLTreeMap extends AbstractObject2LongMap implemen return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + long newValue = valueProvider.getAsLong(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + long newValue = mappingFunction.applyAsLong(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2LongAVLTreeMap extends AbstractObject2LongMap implemen return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2LongAVLTreeMap extends AbstractObject2LongMap implemen return entry.value; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - long newValue = valueProvider.getAsLong(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2LongAVLTreeMap extends AbstractObject2LongMap implemen return entry.value; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2LongAVLTreeMap extends AbstractObject2LongMap implemen map.validate(key); 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/objects/maps/impl/tree/Object2LongRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongRBTreeMap.java index a733640..a26d87f 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2LongRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2LongRBTreeMap extends AbstractObject2LongMap implement return newValue; } + @Override + public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + long newValue = valueProvider.getAsLong(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + long newValue = mappingFunction.applyAsLong(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2LongRBTreeMap extends AbstractObject2LongMap implement return newValue; } - @Override - public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,19 +522,6 @@ public class Object2LongRBTreeMap extends AbstractObject2LongMap implement return entry.value; } - @Override - public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - long newValue = valueProvider.getAsLong(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -530,17 +541,6 @@ public class Object2LongRBTreeMap extends AbstractObject2LongMap implement return entry.value; } - @Override - public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2LongRBTreeMap extends AbstractObject2LongMap implement map.validate(key); 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/objects/maps/impl/tree/Object2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectAVLTreeMap.java index 7eab9dd..4f43612 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectAVLTreeMap.java @@ -362,26 +362,6 @@ public class Object2ObjectAVLTreeMap extends AbstractObject2ObjectMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -401,25 +381,6 @@ public class Object2ObjectAVLTreeMap extends AbstractObject2ObjectMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -439,25 +400,6 @@ public class Object2ObjectAVLTreeMap extends AbstractObject2ObjectMap valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - 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(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,21 +415,6 @@ public class Object2ObjectAVLTreeMap extends AbstractObject2ObjectMap mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectRBTreeMap.java index 03fc838..b940756 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ObjectRBTreeMap.java @@ -361,26 +361,6 @@ public class Object2ObjectRBTreeMap extends AbstractObject2ObjectMap return newValue; } - @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, UnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -400,25 +380,6 @@ public class Object2ObjectRBTreeMap extends AbstractObject2ObjectMap return entry.value; } - @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -438,25 +399,6 @@ public class Object2ObjectRBTreeMap extends AbstractObject2ObjectMap return entry.value; } - @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - 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(T key, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,21 +414,6 @@ public class Object2ObjectRBTreeMap extends AbstractObject2ObjectMap return newValue; } - @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortAVLTreeMap.java index e6eff98..b24f665 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortAVLTreeMap.java @@ -446,6 +446,43 @@ public class Object2ShortAVLTreeMap extends AbstractObject2ShortMap implem return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + short newValue = valueProvider.getAsShort(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2ShortAVLTreeMap extends AbstractObject2ShortMap implem return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2ShortAVLTreeMap extends AbstractObject2ShortMap implem return entry.value; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - short newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1520,14 +1520,9 @@ public class Object2ShortAVLTreeMap extends AbstractObject2ShortMap implem map.validate(key); 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/objects/maps/impl/tree/Object2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortRBTreeMap.java index 01c479c..d6b647e 100644 --- a/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/impl/tree/Object2ShortRBTreeMap.java @@ -446,6 +446,43 @@ public class Object2ShortRBTreeMap extends AbstractObject2ShortMap impleme return newValue; } + @Override + public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + validate(key); + Node entry = findNode(key); + if(entry == null) { + short newValue = valueProvider.getAsShort(); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + validate(key); + Node entry = findNode(key); + if(entry == null) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, entry.value); + entry.value = newValue; + return newValue; + } + @Override public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -466,19 +503,6 @@ public class Object2ShortRBTreeMap extends AbstractObject2ShortMap impleme return newValue; } - @Override - public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -498,49 +522,25 @@ public class Object2ShortRBTreeMap extends AbstractObject2ShortMap impleme return entry.value; } - @Override - public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - validate(key); - Node entry = findNode(key); - if(entry == null) { - short newValue = valueProvider.getAsInt(); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); validate(key); 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(T key, ObjectShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - validate(key); - 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(T key, ObjectShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1584,14 +1584,9 @@ public class Object2ShortRBTreeMap extends AbstractObject2ShortMap impleme map.validate(key); 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/objects/maps/interfaces/Object2BooleanMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2BooleanMap.java index 5bcb299..22316bb 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2BooleanMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2BooleanMap.java @@ -267,15 +267,6 @@ public interface Object2BooleanMap extends Map, Predicate * @return the result of the computation */ public boolean computeBoolean(T key, ObjectBooleanUnaryOperator 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 boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator 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". @@ -285,6 +276,34 @@ public interface Object2BooleanMap extends Map, Predicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(T key, Predicate 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". + * 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 boolean supplyBooleanIfAbsent(T 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(T key, ObjectBooleanUnaryOperator 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 boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator 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". @@ -294,15 +313,6 @@ public interface Object2BooleanMap extends Map, Predicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(T key, Predicate 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". - * 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 boolean supplyBooleanIfAbsent(T key, BooleanSupplier 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". @@ -312,16 +322,6 @@ public interface Object2BooleanMap extends Map, Predicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(T 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(T key, ObjectBooleanUnaryOperator 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/objects/maps/interfaces/Object2ByteMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ByteMap.java index 12f7845..e9e2cf1 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ByteMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ByteMap.java @@ -292,15 +292,6 @@ public interface Object2ByteMap extends Map, ToByteFunction * @return the result of the computation */ public byte computeByte(T key, ObjectByteUnaryOperator 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 byte computeByteNonDefault(T key, ObjectByteUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2ByteMap extends Map, ToByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(T key, ToByteFunction 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". + * 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 byte supplyByteIfAbsent(T 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(T key, ObjectByteUnaryOperator 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 byte computeByteNonDefault(T key, ObjectByteUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2ByteMap extends Map, ToByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(T key, ToByteFunction 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". - * 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 byte supplyByteIfAbsent(T key, ByteSupplier 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". @@ -337,16 +347,6 @@ public interface Object2ByteMap extends Map, ToByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(T 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(T key, ObjectByteUnaryOperator 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/objects/maps/interfaces/Object2CharMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2CharMap.java index 20c5650..9703047 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2CharMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2CharMap.java @@ -292,15 +292,6 @@ public interface Object2CharMap extends Map, ToCharFunction * @return the result of the computation */ public char computeChar(T key, ObjectCharUnaryOperator 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 char computeCharNonDefault(T key, ObjectCharUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2CharMap extends Map, ToCharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(T key, ToCharFunction 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". + * 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 char supplyCharIfAbsent(T 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(T key, ObjectCharUnaryOperator 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 char computeCharNonDefault(T key, ObjectCharUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2CharMap extends Map, ToCharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(T key, ToCharFunction 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". - * 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 char supplyCharIfAbsent(T key, CharSupplier 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". @@ -337,16 +347,6 @@ public interface Object2CharMap extends Map, ToCharFunction * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(T 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(T key, ObjectCharUnaryOperator 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/objects/maps/interfaces/Object2DoubleMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2DoubleMap.java index f81c8f4..090d645 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2DoubleMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2DoubleMap.java @@ -292,15 +292,6 @@ public interface Object2DoubleMap extends Map, ToDoubleFunction * @return the result of the computation */ public double computeDouble(T key, ObjectDoubleUnaryOperator 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 double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2DoubleMap extends Map, ToDoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(T key, ToDoubleFunction 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". + * 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 double supplyDoubleIfAbsent(T 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(T key, ObjectDoubleUnaryOperator 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 double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2DoubleMap extends Map, ToDoubleFunction * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction 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". - * 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 double supplyDoubleIfAbsent(T key, DoubleSupplier 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". @@ -337,16 +347,6 @@ public interface Object2DoubleMap extends Map, ToDoubleFunction * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(T 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(T key, ObjectDoubleUnaryOperator 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/objects/maps/interfaces/Object2FloatMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2FloatMap.java index a7393f8..29b9a8a 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2FloatMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2FloatMap.java @@ -292,15 +292,6 @@ public interface Object2FloatMap extends Map, ToFloatFunction * @return the result of the computation */ public float computeFloat(T key, ObjectFloatUnaryOperator 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 float computeFloatNonDefault(T key, ObjectFloatUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2FloatMap extends Map, ToFloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(T key, ToFloatFunction 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". + * 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 float supplyFloatIfAbsent(T 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(T key, ObjectFloatUnaryOperator 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 float computeFloatNonDefault(T key, ObjectFloatUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2FloatMap extends Map, ToFloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction 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". - * 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 float supplyFloatIfAbsent(T key, FloatSupplier 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". @@ -337,16 +347,6 @@ public interface Object2FloatMap extends Map, ToFloatFunction * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(T 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(T key, ObjectFloatUnaryOperator 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/objects/maps/interfaces/Object2IntMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2IntMap.java index c1018f8..c717f92 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2IntMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2IntMap.java @@ -292,15 +292,6 @@ public interface Object2IntMap extends Map, ToIntFunction * @return the result of the computation */ public int computeInt(T key, ObjectIntUnaryOperator 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 int computeIntNonDefault(T key, ObjectIntUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2IntMap extends Map, ToIntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(T key, ToIntFunction 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". + * 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 int supplyIntIfAbsent(T 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(T key, ObjectIntUnaryOperator 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 int computeIntNonDefault(T key, ObjectIntUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2IntMap extends Map, ToIntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(T key, ToIntFunction 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". - * 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 int supplyIntIfAbsent(T key, IntSupplier 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". @@ -337,16 +347,6 @@ public interface Object2IntMap extends Map, ToIntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(T 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(T key, ObjectIntUnaryOperator 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/objects/maps/interfaces/Object2LongMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2LongMap.java index 7c95a52..9ff0463 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2LongMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2LongMap.java @@ -292,15 +292,6 @@ public interface Object2LongMap extends Map, ToLongFunction * @return the result of the computation */ public long computeLong(T key, ObjectLongUnaryOperator 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 long computeLongNonDefault(T key, ObjectLongUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2LongMap extends Map, ToLongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(T key, ToLongFunction 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". + * 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 long supplyLongIfAbsent(T 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(T key, ObjectLongUnaryOperator 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 long computeLongNonDefault(T key, ObjectLongUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2LongMap extends Map, ToLongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(T key, ToLongFunction 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". - * 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 long supplyLongIfAbsent(T key, LongSupplier 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". @@ -337,16 +347,6 @@ public interface Object2LongMap extends Map, ToLongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(T 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(T key, ObjectLongUnaryOperator 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/objects/maps/interfaces/Object2ObjectMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ObjectMap.java index 3069edb..3f9aeeb 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ObjectMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ObjectMap.java @@ -197,15 +197,6 @@ public interface Object2ObjectMap extends Map, UnaryOperator * @return the result of the computation */ public V compute(T key, ObjectObjectUnaryOperator 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(T key, ObjectObjectUnaryOperator 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". @@ -215,15 +206,6 @@ public interface Object2ObjectMap extends Map, UnaryOperator * @return the result of the computed value or present value */ public V computeIfAbsent(T key, UnaryOperator 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(T key, UnaryOperator 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". @@ -233,15 +215,6 @@ public interface Object2ObjectMap extends Map, UnaryOperator * @return the result of the computed value or present value */ public V supplyIfAbsent(T 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(T 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". @@ -252,16 +225,6 @@ public interface Object2ObjectMap extends Map, UnaryOperator * @note if not present then compute is not executed */ public V computeIfPresent(T key, ObjectObjectUnaryOperator 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(T key, ObjectObjectUnaryOperator 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/objects/maps/interfaces/Object2ShortMap.java b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ShortMap.java index 8f7d001..2d3148f 100644 --- a/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ShortMap.java +++ b/src/main/java/speiger/src/collections/objects/maps/interfaces/Object2ShortMap.java @@ -292,15 +292,6 @@ public interface Object2ShortMap extends Map, ToShortFunction * @return the result of the computation */ public short computeShort(T key, ObjectShortUnaryOperator 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 short computeShortNonDefault(T key, ObjectShortUnaryOperator 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". @@ -310,6 +301,34 @@ public interface Object2ShortMap extends Map, ToShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsent(T key, ToShortFunction 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". + * 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 short supplyShortIfAbsent(T 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(T key, ObjectShortUnaryOperator 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 short computeShortNonDefault(T key, ObjectShortUnaryOperator 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". @@ -319,15 +338,6 @@ public interface Object2ShortMap extends Map, ToShortFunction * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(T key, ToShortFunction 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". - * 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 short supplyShortIfAbsent(T key, ShortSupplier 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". @@ -337,16 +347,6 @@ public interface Object2ShortMap extends Map, ToShortFunction * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(T 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(T key, ObjectShortUnaryOperator 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/objects/queues/ObjectArrayFIFOQueue.java b/src/main/java/speiger/src/collections/objects/queues/ObjectArrayFIFOQueue.java index 2bf92dc..c72376f 100644 --- a/src/main/java/speiger/src/collections/objects/queues/ObjectArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/objects/queues/ObjectArrayFIFOQueue.java @@ -151,6 +151,15 @@ public class ObjectArrayFIFOQueue extends AbstractObjectPriorityQueue impl return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(T e) { + if(first == last) return false; + for(int i = 0,m=size();i extends AbstractObjectPriorityQueue return array[index]; } + @Override + public boolean contains(T e) { + for(int i = 0;i extends AbstractObjectPriorityQueue return array[index]; } + @Override + public boolean contains(T e) { + for(int i = 0;i extends ObjectIterable */ public default T first() { return peek(0); } + /** + * Method to find out if a element is part of the queue + * @param e the element that is searched for + * @return true if the element is in the queue + */ + public boolean contains(T e); + /** * Removes the first found element in the queue * @param e the element that should be removed diff --git a/src/main/java/speiger/src/collections/objects/utils/ObjectAsyncBuilder.java b/src/main/java/speiger/src/collections/objects/utils/ObjectAsyncBuilder.java index 9e54d39..67c70dc 100644 --- a/src/main/java/speiger/src/collections/objects/utils/ObjectAsyncBuilder.java +++ b/src/main/java/speiger/src/collections/objects/utils/ObjectAsyncBuilder.java @@ -11,20 +11,31 @@ import java.util.function.IntFunction; import java.util.function.BiFunction; import java.util.Comparator; +import speiger.src.collections.objects.functions.function.Predicate; +import speiger.src.collections.booleans.utils.BooleanAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToByteFunction; +import speiger.src.collections.bytes.utils.ByteAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToShortFunction; +import speiger.src.collections.shorts.utils.ShortAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToIntFunction; +import speiger.src.collections.ints.utils.IntAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToLongFunction; +import speiger.src.collections.longs.utils.LongAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToFloatFunction; +import speiger.src.collections.floats.utils.FloatAsyncBuilder; +import speiger.src.collections.objects.functions.function.ToDoubleFunction; +import speiger.src.collections.doubles.utils.DoubleAsyncBuilder; import speiger.src.collections.objects.collections.ObjectIterable; import speiger.src.collections.objects.collections.ObjectCollection; import speiger.src.collections.objects.collections.ObjectIterator; import speiger.src.collections.objects.functions.ObjectTask; -import speiger.src.collections.objects.functions.function.Predicate; import speiger.src.collections.objects.functions.function.UnaryOperator; import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator; import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.sets.ObjectSet; import speiger.src.collections.objects.sets.ObjectLinkedOpenHashSet; -import speiger.src.collections.booleans.utils.BooleanAsyncBuilder; import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask; -import speiger.src.collections.ints.utils.IntAsyncBuilder; import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask; import speiger.src.collections.utils.ISizeProvider; import speiger.src.collections.utils.SanityChecks; @@ -140,6 +151,69 @@ public class ObjectAsyncBuilder return new ObjectAsyncBuilder<>(ObjectIterables.arrayFlatMap(iterable, mapper)); } + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public BooleanAsyncBuilder mapToBoolean(Predicate mapper) { + return new BooleanAsyncBuilder(ObjectIterables.mapToBoolean(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public ByteAsyncBuilder mapToByte(ToByteFunction mapper) { + return new ByteAsyncBuilder(ObjectIterables.mapToByte(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public ShortAsyncBuilder mapToShort(ToShortFunction mapper) { + return new ShortAsyncBuilder(ObjectIterables.mapToShort(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public IntAsyncBuilder mapToInt(ToIntFunction mapper) { + return new IntAsyncBuilder(ObjectIterables.mapToInt(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public LongAsyncBuilder mapToLong(ToLongFunction mapper) { + return new LongAsyncBuilder(ObjectIterables.mapToLong(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public FloatAsyncBuilder mapToFloat(ToFloatFunction mapper) { + return new FloatAsyncBuilder(ObjectIterables.mapToFloat(iterable, mapper)); + } + + /** + * Maps the elements to something else + * @param mapper the mapping function + * @return a new Builder Object with the mapped Iterable + */ + public DoubleAsyncBuilder mapToDouble(ToDoubleFunction mapper) { + return new DoubleAsyncBuilder(ObjectIterables.mapToDouble(iterable, mapper)); + } + /** * Filters out the unwanted elements out of the Iterable * @param filter the elements that should be kept diff --git a/src/main/java/speiger/src/collections/objects/utils/ObjectIterables.java b/src/main/java/speiger/src/collections/objects/utils/ObjectIterables.java index 374376e..f1f5065 100644 --- a/src/main/java/speiger/src/collections/objects/utils/ObjectIterables.java +++ b/src/main/java/speiger/src/collections/objects/utils/ObjectIterables.java @@ -8,6 +8,33 @@ import java.util.function.Predicate; import speiger.src.collections.objects.collections.ObjectIterable; import speiger.src.collections.objects.collections.ObjectCollection; +import speiger.src.collections.booleans.functions.BooleanConsumer; +import speiger.src.collections.booleans.collections.BooleanIterable; +import speiger.src.collections.booleans.collections.BooleanIterator; +import speiger.src.collections.bytes.functions.ByteConsumer; +import speiger.src.collections.objects.functions.function.ToByteFunction; +import speiger.src.collections.bytes.collections.ByteIterable; +import speiger.src.collections.bytes.collections.ByteIterator; +import speiger.src.collections.shorts.functions.ShortConsumer; +import speiger.src.collections.objects.functions.function.ToShortFunction; +import speiger.src.collections.shorts.collections.ShortIterable; +import speiger.src.collections.shorts.collections.ShortIterator; +import speiger.src.collections.ints.functions.IntConsumer; +import speiger.src.collections.objects.functions.function.ToIntFunction; +import speiger.src.collections.ints.collections.IntIterable; +import speiger.src.collections.ints.collections.IntIterator; +import speiger.src.collections.longs.functions.LongConsumer; +import speiger.src.collections.objects.functions.function.ToLongFunction; +import speiger.src.collections.longs.collections.LongIterable; +import speiger.src.collections.longs.collections.LongIterator; +import speiger.src.collections.floats.functions.FloatConsumer; +import speiger.src.collections.objects.functions.function.ToFloatFunction; +import speiger.src.collections.floats.collections.FloatIterable; +import speiger.src.collections.floats.collections.FloatIterator; +import speiger.src.collections.doubles.functions.DoubleConsumer; +import speiger.src.collections.objects.functions.function.ToDoubleFunction; +import speiger.src.collections.doubles.collections.DoubleIterable; +import speiger.src.collections.doubles.collections.DoubleIterator; import speiger.src.collections.objects.collections.ObjectIterator; import speiger.src.collections.objects.functions.function.UnaryOperator; import speiger.src.collections.utils.ISizeProvider; @@ -41,6 +68,160 @@ public class ObjectIterables return new MappedIterable<>(iterable, mapper); } + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static BooleanIterable mapToBoolean(Iterable iterable, Predicate mapper) { + return new MappedBooleanIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static BooleanIterable mapToBoolean(ObjectIterable iterable, Predicate mapper) { + return new MappedBooleanIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static ByteIterable mapToByte(Iterable iterable, ToByteFunction mapper) { + return new MappedByteIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static ByteIterable mapToByte(ObjectIterable iterable, ToByteFunction mapper) { + return new MappedByteIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static ShortIterable mapToShort(Iterable iterable, ToShortFunction mapper) { + return new MappedShortIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static ShortIterable mapToShort(ObjectIterable iterable, ToShortFunction mapper) { + return new MappedShortIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static IntIterable mapToInt(Iterable iterable, ToIntFunction mapper) { + return new MappedIntIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static IntIterable mapToInt(ObjectIterable iterable, ToIntFunction mapper) { + return new MappedIntIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static LongIterable mapToLong(Iterable iterable, ToLongFunction mapper) { + return new MappedLongIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static LongIterable mapToLong(ObjectIterable iterable, ToLongFunction mapper) { + return new MappedLongIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static FloatIterable mapToFloat(Iterable iterable, ToFloatFunction mapper) { + return new MappedFloatIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static FloatIterable mapToFloat(ObjectIterable iterable, ToFloatFunction mapper) { + return new MappedFloatIterable<>(iterable, mapper); + } + + /** + * A Helper function that maps a Java-Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static DoubleIterable mapToDouble(Iterable iterable, ToDoubleFunction mapper) { + return new MappedDoubleIterable<>(wrap(iterable), mapper); + } + + /** + * A Helper function that maps a Iterable into a new Type. + * @param iterable the iterable that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterable that is mapped to a new result + */ + public static DoubleIterable mapToDouble(ObjectIterable iterable, ToDoubleFunction mapper) { + return new MappedDoubleIterable<>(iterable, mapper); + } + /** * A Helper function that flatMaps a Java-Iterable into a new Type. * @param iterable the iterable that should be flatMapped @@ -257,6 +438,195 @@ public class ObjectIterables } } + private static class MappedBooleanIterable implements BooleanIterable, ISizeProvider + { + ObjectIterable iterable; + Predicate mapper; + + MappedBooleanIterable(ObjectIterable iterable, Predicate mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public BooleanIterator iterator() { + return ObjectIterators.mapToBoolean(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(BooleanConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.test(E))); + } + } + + private static class MappedByteIterable implements ByteIterable, ISizeProvider + { + ObjectIterable iterable; + ToByteFunction mapper; + + MappedByteIterable(ObjectIterable iterable, ToByteFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public ByteIterator iterator() { + return ObjectIterators.mapToByte(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(ByteConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsByte(E))); + } + } + + private static class MappedShortIterable implements ShortIterable, ISizeProvider + { + ObjectIterable iterable; + ToShortFunction mapper; + + MappedShortIterable(ObjectIterable iterable, ToShortFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public ShortIterator iterator() { + return ObjectIterators.mapToShort(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(ShortConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsShort(E))); + } + } + + private static class MappedIntIterable implements IntIterable, ISizeProvider + { + ObjectIterable iterable; + ToIntFunction mapper; + + MappedIntIterable(ObjectIterable iterable, ToIntFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public IntIterator iterator() { + return ObjectIterators.mapToInt(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(IntConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsInt(E))); + } + } + + private static class MappedLongIterable implements LongIterable, ISizeProvider + { + ObjectIterable iterable; + ToLongFunction mapper; + + MappedLongIterable(ObjectIterable iterable, ToLongFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public LongIterator iterator() { + return ObjectIterators.mapToLong(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(LongConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsLong(E))); + } + } + + private static class MappedFloatIterable implements FloatIterable, ISizeProvider + { + ObjectIterable iterable; + ToFloatFunction mapper; + + MappedFloatIterable(ObjectIterable iterable, ToFloatFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public FloatIterator iterator() { + return ObjectIterators.mapToFloat(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(FloatConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsFloat(E))); + } + } + + private static class MappedDoubleIterable implements DoubleIterable, ISizeProvider + { + ObjectIterable iterable; + ToDoubleFunction mapper; + + MappedDoubleIterable(ObjectIterable iterable, ToDoubleFunction mapper) { + this.iterable = iterable; + this.mapper = mapper; + } + + public DoubleIterator iterator() { + return ObjectIterators.mapToDouble(iterable.iterator(), mapper); + } + + @Override + public int size() { + ISizeProvider prov = ISizeProvider.of(this); + return prov == null ? -1 : prov.size(); + } + + @Override + public void forEach(DoubleConsumer action) { + Objects.requireNonNull(action); + iterable.forEach(E -> action.accept(mapper.applyAsDouble(E))); + } + } + private static class MappedIterable implements ObjectIterable, ISizeProvider { ObjectIterable iterable; diff --git a/src/main/java/speiger/src/collections/objects/utils/ObjectIterators.java b/src/main/java/speiger/src/collections/objects/utils/ObjectIterators.java index 4c71ec8..dac2bcb 100644 --- a/src/main/java/speiger/src/collections/objects/utils/ObjectIterators.java +++ b/src/main/java/speiger/src/collections/objects/utils/ObjectIterators.java @@ -7,13 +7,28 @@ import java.util.function.Consumer; import java.util.function.Predicate; import speiger.src.collections.objects.collections.ObjectIterator; +import speiger.src.collections.booleans.collections.BooleanIterator; +import speiger.src.collections.objects.functions.function.ToByteFunction; +import speiger.src.collections.bytes.collections.ByteIterator; +import speiger.src.collections.objects.functions.function.ToShortFunction; +import speiger.src.collections.shorts.collections.ShortIterator; +import speiger.src.collections.objects.functions.function.ToIntFunction; +import speiger.src.collections.ints.collections.IntIterator; +import speiger.src.collections.objects.functions.function.ToLongFunction; +import speiger.src.collections.longs.collections.LongIterator; +import speiger.src.collections.objects.functions.function.ToFloatFunction; +import speiger.src.collections.floats.collections.FloatIterator; +import speiger.src.collections.objects.functions.function.ToDoubleFunction; +import speiger.src.collections.doubles.collections.DoubleIterator; import speiger.src.collections.objects.functions.function.UnaryOperator; +import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer; import speiger.src.collections.objects.lists.ObjectList; import speiger.src.collections.objects.lists.ObjectArrayList; import speiger.src.collections.objects.lists.ObjectListIterator; import speiger.src.collections.objects.collections.ObjectBidirectionalIterator; import speiger.src.collections.objects.collections.ObjectCollection; +import speiger.src.collections.objects.utils.ObjectCollections.CollectionWrapper; /** * A Helper class for Iterators @@ -108,6 +123,160 @@ public class ObjectIterators return new MappedIterator<>(iterator, mapper); } + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static BooleanIterator mapToBoolean(Iterator iterator, Predicate mapper) { + return new MappedBooleanIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static BooleanIterator mapToBoolean(ObjectIterator iterator, Predicate mapper) { + return new MappedBooleanIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static ByteIterator mapToByte(Iterator iterator, ToByteFunction mapper) { + return new MappedByteIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static ByteIterator mapToByte(ObjectIterator iterator, ToByteFunction mapper) { + return new MappedByteIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static ShortIterator mapToShort(Iterator iterator, ToShortFunction mapper) { + return new MappedShortIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static ShortIterator mapToShort(ObjectIterator iterator, ToShortFunction mapper) { + return new MappedShortIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static IntIterator mapToInt(Iterator iterator, ToIntFunction mapper) { + return new MappedIntIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static IntIterator mapToInt(ObjectIterator iterator, ToIntFunction mapper) { + return new MappedIntIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static LongIterator mapToLong(Iterator iterator, ToLongFunction mapper) { + return new MappedLongIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static LongIterator mapToLong(ObjectIterator iterator, ToLongFunction mapper) { + return new MappedLongIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static FloatIterator mapToFloat(Iterator iterator, ToFloatFunction mapper) { + return new MappedFloatIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static FloatIterator mapToFloat(ObjectIterator iterator, ToFloatFunction mapper) { + return new MappedFloatIterator<>(iterator, mapper); + } + + /** + * A Helper function that maps a Java-Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static DoubleIterator mapToDouble(Iterator iterator, ToDoubleFunction mapper) { + return new MappedDoubleIterator<>(wrap(iterator), mapper); + } + + /** + * A Helper function that maps a Iterator into a new Type. + * @param iterator that should be mapped + * @param mapper the function that decides what the result turns into. + * @param the keyType of elements maintained by this Collection + * @return a iterator that is mapped to a new result + */ + public static DoubleIterator mapToDouble(ObjectIterator iterator, ToDoubleFunction mapper) { + return new MappedDoubleIterator<>(iterator, mapper); + } + /** * A Helper function that flatMaps a Java-Iterator into a new Type. * @param iterator that should be flatMapped @@ -222,6 +391,26 @@ public class ObjectIterators return new RepeatingIterator<>(wrap(iterator), repeats); } + /** + * A Helper function that creates a infinitely looping iterator + * @param iterator that should be looping infinitely + * @param the keyType of elements maintained by this Collection + * @return a infinitely looping iterator + */ + public static ObjectIterator infinite(ObjectIterator 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 + * @param the keyType of elements maintained by this Collection + * @return a infinitely looping iterator + */ + public static ObjectIterator infinite(Iterator iterator) { + return new InfiniteIterator<>(wrap(iterator)); + } + /** * A Helper function that hard limits the Iterator to a specific size * @param iterator that should be limited @@ -760,6 +949,188 @@ public class ObjectIterators } } + private static class MappedBooleanIterator implements BooleanIterator + { + ObjectIterator iterator; + Predicate mapper; + + MappedBooleanIterator(ObjectIterator iterator, Predicate mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public boolean nextBoolean() { + return mapper.test(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedByteIterator implements ByteIterator + { + ObjectIterator iterator; + ToByteFunction mapper; + + MappedByteIterator(ObjectIterator iterator, ToByteFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public byte nextByte() { + return mapper.applyAsByte(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedShortIterator implements ShortIterator + { + ObjectIterator iterator; + ToShortFunction mapper; + + MappedShortIterator(ObjectIterator iterator, ToShortFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public short nextShort() { + return mapper.applyAsShort(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedIntIterator implements IntIterator + { + ObjectIterator iterator; + ToIntFunction mapper; + + MappedIntIterator(ObjectIterator iterator, ToIntFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public int nextInt() { + return mapper.applyAsInt(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedLongIterator implements LongIterator + { + ObjectIterator iterator; + ToLongFunction mapper; + + MappedLongIterator(ObjectIterator iterator, ToLongFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public long nextLong() { + return mapper.applyAsLong(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedFloatIterator implements FloatIterator + { + ObjectIterator iterator; + ToFloatFunction mapper; + + MappedFloatIterator(ObjectIterator iterator, ToFloatFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public float nextFloat() { + return mapper.applyAsFloat(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + + private static class MappedDoubleIterator implements DoubleIterator + { + ObjectIterator iterator; + ToDoubleFunction mapper; + + MappedDoubleIterator(ObjectIterator iterator, ToDoubleFunction mapper) { + this.iterator = iterator; + this.mapper = mapper; + } + + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public double nextDouble() { + return mapper.applyAsDouble(iterator.next()); + } + + @Override + public int skip(int amount) { + return iterator.skip(amount); + } + } + private static class FlatMappedIterator> implements ObjectIterator { ObjectIterator iterator; @@ -832,6 +1203,38 @@ public class ObjectIterators } } + private static class InfiniteIterator implements ObjectIterator + { + ObjectIterator iter; + CollectionWrapper looper = ObjectCollections.wrapper(); + int index = 0; + + public InfiniteIterator(ObjectIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public T next() { + if(iter != null) { + if(iter.hasNext()) { + T value = iter.next(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.get((index++) % looper.size()); + } + + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectObjectConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements ObjectIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/objects/utils/ObjectLists.java b/src/main/java/speiger/src/collections/objects/utils/ObjectLists.java index b8c58f0..ad4eee4 100644 --- a/src/main/java/speiger/src/collections/objects/utils/ObjectLists.java +++ b/src/main/java/speiger/src/collections/objects/utils/ObjectLists.java @@ -10,6 +10,7 @@ import java.util.function.Consumer; import speiger.src.collections.objects.collections.ObjectCollection; import speiger.src.collections.objects.lists.AbstractObjectList; import speiger.src.collections.objects.lists.ObjectList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.objects.lists.ObjectListIterator; import speiger.src.collections.utils.SanityChecks; @@ -324,6 +325,16 @@ public class ObjectLists return l.listIterator(index); } + @Override + public ObjectListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public ObjectListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public ObjectList subList(int from, int to) { return ObjectLists.synchronize(l.subList(from, to)); @@ -420,6 +431,16 @@ public class ObjectLists return ObjectIterators.unmodifiable(l.listIterator(index)); } + @Override + public ObjectListIterator indexedIterator(int...indecies) { + return ObjectIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public ObjectListIterator indexedIterator(IntList indecies) { + return ObjectIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public ObjectList subList(int from, int to) { return ObjectLists.unmodifiable(l.subList(from, to)); @@ -499,6 +520,16 @@ public class ObjectLists return ObjectIterators.empty(); } + @Override + public ObjectListIterator indexedIterator(int...indecies) { + return ObjectIterators.empty(); + } + + @Override + public ObjectListIterator indexedIterator(IntList indecies) { + return ObjectIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/objects/utils/ObjectPriorityQueues.java b/src/main/java/speiger/src/collections/objects/utils/ObjectPriorityQueues.java index b14c413..76e24e5 100644 --- a/src/main/java/speiger/src/collections/objects/utils/ObjectPriorityQueues.java +++ b/src/main/java/speiger/src/collections/objects/utils/ObjectPriorityQueues.java @@ -97,6 +97,8 @@ public class ObjectPriorityQueues @Override public T peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(T e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(T e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(T e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2BooleanMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2BooleanMaps.java index 01b52c7..3b995da 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2BooleanMaps.java @@ -260,18 +260,18 @@ public class Object2BooleanMaps @Override public boolean computeBoolean(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(T key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -319,18 +319,18 @@ public class Object2BooleanMaps @Override public boolean computeBoolean(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(T key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Object2BooleanMaps @Override public boolean computeBoolean(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(T key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -889,18 +889,18 @@ public class Object2BooleanMaps @Override public boolean computeBoolean(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(T key, Predicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(T key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(T key, Predicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(T key, ObjectBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(T key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(T key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ByteMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ByteMaps.java index a66e270..670a778 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ByteMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ByteMaps.java @@ -264,18 +264,18 @@ public class Object2ByteMaps @Override public byte computeByte(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(T key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2ByteMaps @Override public byte computeByte(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(T key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2ByteMaps @Override public byte computeByte(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(T key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2ByteMaps @Override public byte computeByte(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(T key, ToByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(T key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(T key, ToByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(T key, ObjectByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(T key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(T key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2CharMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2CharMaps.java index 757b81d..9a7d2f7 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2CharMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2CharMaps.java @@ -264,18 +264,18 @@ public class Object2CharMaps @Override public char computeChar(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(T key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2CharMaps @Override public char computeChar(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(T key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2CharMaps @Override public char computeChar(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(T key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2CharMaps @Override public char computeChar(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(T key, ToCharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(T key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(T key, ToCharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(T key, ObjectCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(T key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(T key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2DoubleMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2DoubleMaps.java index a46cae2..917e2e9 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2DoubleMaps.java @@ -264,18 +264,18 @@ public class Object2DoubleMaps @Override public double computeDouble(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(T key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2DoubleMaps @Override public double computeDouble(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(T key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2DoubleMaps @Override public double computeDouble(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(T key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2DoubleMaps @Override public double computeDouble(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(T key, ToDoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(T key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(T key, ToDoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(T key, ObjectDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(T key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(T key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2FloatMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2FloatMaps.java index 30e7fc4..9ef8caf 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2FloatMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2FloatMaps.java @@ -264,18 +264,18 @@ public class Object2FloatMaps @Override public float computeFloat(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(T key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2FloatMaps @Override public float computeFloat(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(T key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2FloatMaps @Override public float computeFloat(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(T key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2FloatMaps @Override public float computeFloat(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(T key, ToFloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(T key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(T key, ToFloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(T key, ObjectFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(T key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(T key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2IntMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2IntMaps.java index 394bdd1..a1a6d81 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2IntMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2IntMaps.java @@ -264,18 +264,18 @@ public class Object2IntMaps @Override public int computeInt(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2IntMaps @Override public int computeInt(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2IntMaps @Override public int computeInt(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2IntMaps @Override public int computeInt(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(T key, ToIntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(T key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(T key, ToIntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(T key, ObjectIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(T key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(T key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2LongMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2LongMaps.java index 7cf7d0d..8b13db2 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2LongMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2LongMaps.java @@ -264,18 +264,18 @@ public class Object2LongMaps @Override public long computeLong(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(T key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2LongMaps @Override public long computeLong(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(T key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2LongMaps @Override public long computeLong(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(T key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2LongMaps @Override public long computeLong(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(T key, ToLongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(T key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(T key, ToLongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(T key, ObjectLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(T key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(T key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ObjectMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ObjectMaps.java index 8e1678b..55647be 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ObjectMaps.java @@ -275,20 +275,12 @@ public class Object2ObjectMaps @Override public V compute(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Object2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -331,20 +323,12 @@ public class Object2ObjectMaps @Override public V compute(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Object2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -560,20 +544,12 @@ public class Object2ObjectMaps @Override public V compute(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Object2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -904,20 +880,12 @@ public class Object2ObjectMaps @Override public V compute(T key, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(T key, UnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(T key, UnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(T key, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(T key, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(T key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(T key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(T key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Object2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ShortMaps.java b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ShortMaps.java index 84e038b..2e90b19 100644 --- a/src/main/java/speiger/src/collections/objects/utils/maps/Object2ShortMaps.java +++ b/src/main/java/speiger/src/collections/objects/utils/maps/Object2ShortMaps.java @@ -264,18 +264,18 @@ public class Object2ShortMaps @Override public short computeShort(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(T key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -327,18 +327,18 @@ public class Object2ShortMaps @Override public short computeShort(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(T key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -559,18 +559,18 @@ public class Object2ShortMaps @Override public short computeShort(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(T key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -906,18 +906,18 @@ public class Object2ShortMaps @Override public short computeShort(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(T key, ToShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(T key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(T key, ToShortFunction mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(T key, ObjectShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(T key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(T key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/functions/ShortSupplier.java b/src/main/java/speiger/src/collections/shorts/functions/ShortSupplier.java index 23dc04d..fd51e7e 100644 --- a/src/main/java/speiger/src/collections/shorts/functions/ShortSupplier.java +++ b/src/main/java/speiger/src/collections/shorts/functions/ShortSupplier.java @@ -8,5 +8,5 @@ public interface ShortSupplier /** * @return the supplied value */ - public short getAsInt(); + public short getAsShort(); } \ No newline at end of file diff --git a/src/main/java/speiger/src/collections/shorts/lists/AbstractShortList.java b/src/main/java/speiger/src/collections/shorts/lists/AbstractShortList.java index c00d48a..bed164c 100644 --- a/src/main/java/speiger/src/collections/shorts/lists/AbstractShortList.java +++ b/src/main/java/speiger/src/collections/shorts/lists/AbstractShortList.java @@ -12,6 +12,7 @@ import speiger.src.collections.shorts.collections.AbstractShortCollection; import speiger.src.collections.shorts.collections.ShortCollection; import speiger.src.collections.shorts.collections.ShortIterator; import speiger.src.collections.shorts.collections.ShortSplititerator; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.shorts.utils.ShortSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -205,13 +206,23 @@ public abstract class AbstractShortList extends AbstractShortCollection implemen public ShortListIterator listIterator() { return listIterator(0); } - + @Override public ShortListIterator listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); return new ShortListIter(index); } + @Override + public ShortListIterator indexedIterator(int...indecies) { + return new IndexedIterator(indecies); + } + + @Override + public ShortListIterator indexedIterator(IntList indecies) { + return new ListIndexedIterator(indecies); + } + @Override public void size(int size) { while(size > size()) add((short)0); @@ -566,7 +577,153 @@ public abstract class AbstractShortList extends AbstractShortCollection implemen } } } + + private class ListIndexedIterator implements ShortListIterator { + IntList indecies; + int index; + int lastReturned = -1; + ListIndexedIterator(IntList indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.size(); + } + + @Override + public short nextShort() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getShort((lastReturned = indecies.getInt(i))); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public short previousShort() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getShort((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(short e) { throw new UnsupportedOperationException(); } + + @Override + public void set(short e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractShortList.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 ShortListIterator { + int[] indecies; + int index; + int lastReturned = -1; + + IndexedIterator(int[] indecies) { + this.indecies = indecies; + } + + @Override + public boolean hasNext() { + return index < indecies.length; + } + + @Override + public short nextShort() { + if(!hasNext()) throw new NoSuchElementException(); + int i = index++; + return getShort((lastReturned = indecies[i])); + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public short previousShort() { + if(!hasPrevious()) throw new NoSuchElementException(); + index--; + return getShort((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(short e) { throw new UnsupportedOperationException(); } + + @Override + public void set(short e) { + if(lastReturned == -1) throw new IllegalStateException(); + AbstractShortList.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 ShortListIter implements ShortListIterator { int index; int lastReturned = -1; @@ -644,7 +801,7 @@ public abstract class AbstractShortList extends AbstractShortCollection implemen 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/shorts/lists/ShortList.java b/src/main/java/speiger/src/collections/shorts/lists/ShortList.java index 2b06252..ffc782c 100644 --- a/src/main/java/speiger/src/collections/shorts/lists/ShortList.java +++ b/src/main/java/speiger/src/collections/shorts/lists/ShortList.java @@ -14,6 +14,7 @@ import speiger.src.collections.ints.functions.consumer.IntShortConsumer; import speiger.src.collections.shorts.functions.ShortComparator; import speiger.src.collections.shorts.utils.ShortArrays; import speiger.src.collections.shorts.utils.ShortLists; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.shorts.utils.ShortSplititerators; import speiger.src.collections.utils.SanityChecks; @@ -342,6 +343,24 @@ public interface ShortList extends ShortCollection, List @Override public ShortListIterator 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 ShortListIterator 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 ShortListIterator 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/shorts/maps/abstracts/AbstractShort2BooleanMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2BooleanMap.java index 2dc0464..a986333 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2BooleanMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2BooleanMap.java @@ -151,6 +151,39 @@ public abstract class AbstractShort2BooleanMap extends AbstractMap imp return newValue; } + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public byte supplyByteIfAbsent(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractShort2ByteMap extends AbstractMap imp return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractShort2ByteMap extends AbstractMap imp return value; } - @Override - public byte supplyByteIfAbsent(short 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(short 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 abstract class AbstractShort2ByteMap extends AbstractMap imp return value; } - @Override - public byte computeByteIfPresent(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2CharMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2CharMap.java index 8ded9cc..4b3a35a 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2CharMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2CharMap.java @@ -157,6 +157,39 @@ public abstract class AbstractShort2CharMap extends AbstractMap return newValue; } + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public double supplyDoubleIfAbsent(short 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(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractShort2DoubleMap extends AbstractMap return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractShort2DoubleMap extends AbstractMap return value; } - @Override - public double supplyDoubleIfAbsent(short 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(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractShort2DoubleMap extends AbstractMap return value; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2FloatMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2FloatMap.java index a4cefd2..9ae69ba 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2FloatMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2FloatMap.java @@ -157,6 +157,39 @@ public abstract class AbstractShort2FloatMap extends AbstractMap i return newValue; } + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public float supplyFloatIfAbsent(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractShort2FloatMap extends AbstractMap i return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,23 +220,12 @@ public abstract class AbstractShort2FloatMap extends AbstractMap i return value; } - @Override - public float supplyFloatIfAbsent(short 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(short 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 abstract class AbstractShort2FloatMap extends AbstractMap i return value; } - @Override - public float computeFloatIfPresent(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2IntMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2IntMap.java index 2459c78..7275dff 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2IntMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2IntMap.java @@ -157,6 +157,39 @@ public abstract class AbstractShort2IntMap extends AbstractMap i return newValue; } + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public int supplyIntIfAbsent(short 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(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractShort2IntMap extends AbstractMap i return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractShort2IntMap extends AbstractMap i return value; } - @Override - public int supplyIntIfAbsent(short 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(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractShort2IntMap extends AbstractMap i return value; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2LongMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2LongMap.java index 3d0d863..c2c1763 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2LongMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2LongMap.java @@ -157,6 +157,39 @@ public abstract class AbstractShort2LongMap extends AbstractMap imp return newValue; } + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public long supplyLongIfAbsent(short 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(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -173,17 +206,6 @@ public abstract class AbstractShort2LongMap extends AbstractMap imp return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -198,17 +220,6 @@ public abstract class AbstractShort2LongMap extends AbstractMap imp return value; } - @Override - public long supplyLongIfAbsent(short 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(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -223,17 +234,6 @@ public abstract class AbstractShort2LongMap extends AbstractMap imp return value; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ObjectMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ObjectMap.java index 5e33f11..58433af 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ObjectMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ObjectMap.java @@ -159,22 +159,6 @@ public abstract class AbstractShort2ObjectMap extends AbstractMap i return newValue; } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -189,20 +173,6 @@ public abstract class AbstractShort2ObjectMap extends AbstractMap i return value; } - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -217,20 +187,6 @@ public abstract class AbstractShort2ObjectMap extends AbstractMap i return value; } - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -246,21 +202,6 @@ public abstract class AbstractShort2ObjectMap extends AbstractMap i return getDefaultReturnValue(); } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ShortMap.java b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ShortMap.java index 54b42eb..100732c 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ShortMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/abstracts/AbstractShort2ShortMap.java @@ -155,6 +155,39 @@ public abstract class AbstractShort2ShortMap extends AbstractMap i return newValue; } + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + if(!containsKey(key)) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return get(key); + } + + @Override + public short supplyShortIfAbsent(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -171,17 +204,6 @@ public abstract class AbstractShort2ShortMap extends AbstractMap i return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - if(!containsKey(key)) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return get(key); - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -196,23 +218,12 @@ public abstract class AbstractShort2ShortMap extends AbstractMap i return value; } - @Override - public short supplyShortIfAbsent(short 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(short 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; @@ -221,17 +232,6 @@ public abstract class AbstractShort2ShortMap extends AbstractMap i return value; } - @Override - public short computeShortIfPresent(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2BooleanConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2BooleanConcurrentOpenHashMap.java index 68ddacb..be3cceb 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2BooleanConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2BooleanConcurrentOpenHashMap.java @@ -438,13 +438,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,6 +445,27 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,13 +473,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,13 +480,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2032,6 +2032,54 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap } } + protected boolean computeIfAbsent(int hash, short key, ShortPredicate mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean supplyIfAbsent(int hash, short key, BooleanSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected boolean computeIfPresent(int hash, short key, ShortBooleanUnaryOperator 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 computeNonDefault(int hash, short key, ShortBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2055,23 +2103,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap } } - protected boolean computeIfAbsent(int hash, short key, ShortPredicate mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean computeIfAbsentNonDefault(int hash, short key, ShortPredicate mappingFunction) { long stamp = writeLock(); try { @@ -2095,23 +2126,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap } } - protected boolean supplyIfAbsent(int hash, short key, BooleanSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected boolean supplyIfAbsentNonDefault(int hash, short key, BooleanSupplier valueProvider) { long stamp = writeLock(); try { @@ -2135,20 +2149,6 @@ public class Short2BooleanConcurrentOpenHashMap extends AbstractShort2BooleanMap } } - protected boolean computeIfPresent(int hash, short key, ShortBooleanUnaryOperator 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, short key, ShortBooleanUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ByteConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ByteConcurrentOpenHashMap.java index f93accd..3a88ebb 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ByteConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ByteConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple } } + protected byte computeIfAbsent(int hash, short key, Short2ByteFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte supplyIfAbsent(int hash, short key, ByteSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected byte computeIfPresent(int hash, short key, ShortByteUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + byte newValue = mappingFunction.applyAsByte(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected byte computeNonDefault(int hash, short key, ShortByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple } } - protected byte computeIfAbsent(int hash, short key, Short2ByteFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfAbsentNonDefault(int hash, short key, Short2ByteFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple } } - protected byte supplyIfAbsent(int hash, short key, ByteSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte supplyIfAbsentNonDefault(int hash, short key, ByteSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Short2ByteConcurrentOpenHashMap extends AbstractShort2ByteMap imple } } - protected byte computeIfPresent(int hash, short key, ShortByteUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - byte newValue = mappingFunction.applyAsByte(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected byte computeIfPresentNonDefault(int hash, short key, ShortByteUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2CharConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2CharConcurrentOpenHashMap.java index f53f124..a73a6c6 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2CharConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2CharConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple } } + protected char computeIfAbsent(int hash, short key, Short2CharFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char supplyIfAbsent(int hash, short key, CharSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected char computeIfPresent(int hash, short key, ShortCharUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + char newValue = mappingFunction.applyAsChar(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected char computeNonDefault(int hash, short key, ShortCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple } } - protected char computeIfAbsent(int hash, short key, Short2CharFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfAbsentNonDefault(int hash, short key, Short2CharFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple } } - protected char supplyIfAbsent(int hash, short key, CharSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char supplyIfAbsentNonDefault(int hash, short key, CharSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Short2CharConcurrentOpenHashMap extends AbstractShort2CharMap imple } } - protected char computeIfPresent(int hash, short key, ShortCharUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - char newValue = mappingFunction.applyAsChar(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected char computeIfPresentNonDefault(int hash, short key, ShortCharUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2DoubleConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2DoubleConcurrentOpenHashMap.java index c184d20..201bab7 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2DoubleConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2DoubleConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i } } + protected double computeIfAbsent(int hash, short key, Short2DoubleFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double supplyIfAbsent(int hash, short key, DoubleSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected double computeIfPresent(int hash, short key, ShortDoubleUnaryOperator 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 computeNonDefault(int hash, short key, ShortDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i } } - protected double computeIfAbsent(int hash, short key, Short2DoubleFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double computeIfAbsentNonDefault(int hash, short key, Short2DoubleFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i } } - protected double supplyIfAbsent(int hash, short key, DoubleSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected double supplyIfAbsentNonDefault(int hash, short key, DoubleSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Short2DoubleConcurrentOpenHashMap extends AbstractShort2DoubleMap i } } - protected double computeIfPresent(int hash, short key, ShortDoubleUnaryOperator 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, short key, ShortDoubleUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2FloatConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2FloatConcurrentOpenHashMap.java index 625bab9..c32ac13 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2FloatConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2FloatConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp } } + protected float computeIfAbsent(int hash, short key, Short2FloatFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float supplyIfAbsent(int hash, short key, FloatSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected float computeIfPresent(int hash, short key, ShortFloatUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + float newValue = mappingFunction.applyAsFloat(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected float computeNonDefault(int hash, short key, ShortFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp } } - protected float computeIfAbsent(int hash, short key, Short2FloatFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfAbsentNonDefault(int hash, short key, Short2FloatFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,36 +2170,19 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp } } - protected float supplyIfAbsent(int hash, short key, FloatSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float supplyIfAbsentNonDefault(int hash, short key, FloatSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2179,20 +2193,6 @@ public class Short2FloatConcurrentOpenHashMap extends AbstractShort2FloatMap imp } } - protected float computeIfPresent(int hash, short key, ShortFloatUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - float newValue = mappingFunction.applyAsFloat(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected float computeIfPresentNonDefault(int hash, short key, ShortFloatUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2IntConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2IntConcurrentOpenHashMap.java index 3c95e7c..2cb66eb 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2IntConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2IntConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme } } + protected int computeIfAbsent(int hash, short key, Short2IntFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int supplyIfAbsent(int hash, short key, IntSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected int computeIfPresent(int hash, short key, ShortIntUnaryOperator 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 computeNonDefault(int hash, short key, ShortIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme } } - protected int computeIfAbsent(int hash, short key, Short2IntFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int computeIfAbsentNonDefault(int hash, short key, Short2IntFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme } } - protected int supplyIfAbsent(int hash, short key, IntSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected int supplyIfAbsentNonDefault(int hash, short key, IntSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Short2IntConcurrentOpenHashMap extends AbstractShort2IntMap impleme } } - protected int computeIfPresent(int hash, short key, ShortIntUnaryOperator 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, short key, ShortIntUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2LongConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2LongConcurrentOpenHashMap.java index 394718b..ef8f269 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2LongConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2LongConcurrentOpenHashMap.java @@ -451,13 +451,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,6 +458,27 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,13 +486,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -486,13 +493,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2076,6 +2076,54 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple } } + protected long computeIfAbsent(int hash, short key, Short2LongFunction mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long supplyIfAbsent(int hash, short key, LongSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected long computeIfPresent(int hash, short key, ShortLongUnaryOperator 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 computeNonDefault(int hash, short key, ShortLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2099,23 +2147,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple } } - protected long computeIfAbsent(int hash, short key, Short2LongFunction mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long computeIfAbsentNonDefault(int hash, short key, Short2LongFunction mappingFunction) { long stamp = writeLock(); try { @@ -2139,23 +2170,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple } } - protected long supplyIfAbsent(int hash, short key, LongSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected long supplyIfAbsentNonDefault(int hash, short key, LongSupplier valueProvider) { long stamp = writeLock(); try { @@ -2179,20 +2193,6 @@ public class Short2LongConcurrentOpenHashMap extends AbstractShort2LongMap imple } } - protected long computeIfPresent(int hash, short key, ShortLongUnaryOperator 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, short key, ShortLongUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ObjectConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ObjectConcurrentOpenHashMap.java index 574470a..3c43e6c 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ObjectConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ObjectConcurrentOpenHashMap.java @@ -426,13 +426,6 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,13 +433,6 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); - } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -454,13 +440,6 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); } - @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); - } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -468,13 +447,6 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa return getSegment(hash).computeIfPresent(hash, key, mappingFunction); } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction); - } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2011,29 +1983,6 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa } } - protected V computeNonDefault(int hash, short key, ShortObjectUnaryOperator 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, short key, ShortFunction mappingFunction) { long stamp = writeLock(); try { @@ -2056,30 +2005,7 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa unlockWrite(stamp); } } - - protected V computeIfAbsentNonDefault(int hash, short key, ShortFunction 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, short key, ObjectSupplier valueProvider) { long stamp = writeLock(); try { @@ -2102,30 +2028,7 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa unlockWrite(stamp); } } - - protected V supplyIfAbsentNonDefault(int hash, short 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, short key, ShortObjectUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2144,11 +2047,16 @@ public class Short2ObjectConcurrentOpenHashMap extends AbstractShort2ObjectMa } } - protected V computeIfPresentNonDefault(int hash, short key, ShortObjectUnaryOperator mappingFunction) { + protected V computeNonDefault(int hash, short key, ShortObjectUnaryOperator 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/shorts/maps/impl/concurrent/Short2ShortConcurrentOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ShortConcurrentOpenHashMap.java index 3bdc944..22467b6 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ShortConcurrentOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/concurrent/Short2ShortConcurrentOpenHashMap.java @@ -444,13 +444,6 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp return getSegment(hash).compute(hash, key, mappingFunction); } - @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeNonDefault(hash, key, mappingFunction); - } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -458,6 +451,27 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp return getSegment(hash).computeIfAbsent(hash, key, mappingFunction); } + @Override + public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int hash = getHashCode(key); + return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); + } + + @Override + public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeIfPresent(hash, key, mappingFunction); + } + + @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int hash = getHashCode(key); + return getSegment(hash).computeNonDefault(hash, key, mappingFunction); + } + @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,13 +479,6 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction); } - @Override - public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int hash = getHashCode(key); - return getSegment(hash).supplyIfAbsent(hash, key, valueProvider); - } - @Override public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -479,13 +486,6 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider); } - @Override - public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int hash = getHashCode(key); - return getSegment(hash).computeIfPresent(hash, key, mappingFunction); - } - @Override public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -2069,6 +2069,54 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp } } + protected short computeIfAbsent(int hash, short key, ShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short supplyIfAbsent(int hash, short key, ShortSupplier valueProvider) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + + protected short computeIfPresent(int hash, short key, ShortShortUnaryOperator mappingFunction) { + long stamp = writeLock(); + try { + int index = findIndex(hash, key); + if(index < 0) return getDefaultReturnValue(); + short newValue = mappingFunction.applyAsShort(key, values[index]); + values[index] = newValue; + return newValue; + } + finally { + unlockWrite(stamp); + } + } + protected short computeNonDefault(int hash, short key, ShortShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2092,23 +2140,6 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp } } - protected short computeIfAbsent(int hash, short key, ShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfAbsentNonDefault(int hash, short key, ShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { @@ -2132,36 +2163,19 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp } } - protected short supplyIfAbsent(int hash, short key, ShortSupplier valueProvider) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short supplyIfAbsentNonDefault(int hash, short key, ShortSupplier valueProvider) { long stamp = writeLock(); try { int index = findIndex(hash, 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; } @@ -2172,20 +2186,6 @@ public class Short2ShortConcurrentOpenHashMap extends AbstractShort2ShortMap imp } } - protected short computeIfPresent(int hash, short key, ShortShortUnaryOperator mappingFunction) { - long stamp = writeLock(); - try { - int index = findIndex(hash, key); - if(index < 0) return getDefaultReturnValue(); - short newValue = mappingFunction.applyAsShort(key, values[index]); - values[index] = newValue; - return newValue; - } - finally { - unlockWrite(stamp); - } - } - protected short computeIfPresentNonDefault(int hash, short key, ShortShortUnaryOperator mappingFunction) { long stamp = writeLock(); try { diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2BooleanOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2BooleanOpenCustomHashMap.java index cee36ab..d4919f3 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2BooleanOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2BooleanOpenCustomHashMap.java @@ -440,6 +440,42 @@ public class Short2BooleanOpenCustomHashMap extends AbstractShort2BooleanMap imp return newValue; } + @Override + public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -459,19 +495,6 @@ public class Short2BooleanOpenCustomHashMap extends AbstractShort2BooleanMap imp return newValue; } - @Override - public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -491,19 +514,6 @@ public class Short2BooleanOpenCustomHashMap extends AbstractShort2BooleanMap imp return newValue; } - @Override - public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -523,16 +533,6 @@ public class Short2BooleanOpenCustomHashMap extends AbstractShort2BooleanMap imp return newValue; } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ByteOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ByteOpenCustomHashMap.java index 73ef345..da20618 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ByteOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ByteOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2ByteOpenCustomHashMap extends AbstractShort2ByteMap implement return newValue; } + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2ByteOpenCustomHashMap extends AbstractShort2ByteMap implement return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Short2ByteOpenCustomHashMap extends AbstractShort2ByteMap implement return newValue; } - @Override - public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2CharOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2CharOpenCustomHashMap.java index 74eb0d6..20889e7 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2CharOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2CharOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2CharOpenCustomHashMap extends AbstractShort2CharMap implement return newValue; } + @Override + public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2CharOpenCustomHashMap extends AbstractShort2CharMap implement return newValue; } - @Override - public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Short2CharOpenCustomHashMap extends AbstractShort2CharMap implement return newValue; } - @Override - public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(short 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(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2DoubleOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2DoubleOpenCustomHashMap.java index edab497..622c748 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2DoubleOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2DoubleOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2DoubleOpenCustomHashMap extends AbstractShort2DoubleMap imple return newValue; } + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2DoubleOpenCustomHashMap extends AbstractShort2DoubleMap imple return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Short2DoubleOpenCustomHashMap extends AbstractShort2DoubleMap imple return newValue; } - @Override - public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Short2DoubleOpenCustomHashMap extends AbstractShort2DoubleMap imple return newValue; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2FloatOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2FloatOpenCustomHashMap.java index 1e2d135..a1e1bfd 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2FloatOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2FloatOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2FloatOpenCustomHashMap extends AbstractShort2FloatMap impleme return newValue; } + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2FloatOpenCustomHashMap extends AbstractShort2FloatMap impleme return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,48 +536,25 @@ public class Short2FloatOpenCustomHashMap extends AbstractShort2FloatMap impleme return newValue; } - @Override - public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2IntOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2IntOpenCustomHashMap.java index c3e795a..6f13f38 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2IntOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2IntOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2IntOpenCustomHashMap extends AbstractShort2IntMap implements return newValue; } + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2IntOpenCustomHashMap extends AbstractShort2IntMap implements return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Short2IntOpenCustomHashMap extends AbstractShort2IntMap implements return newValue; } - @Override - public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Short2IntOpenCustomHashMap extends AbstractShort2IntMap implements return newValue; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2LongOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2LongOpenCustomHashMap.java index 4aa62b3..8bc0edd 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2LongOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2LongOpenCustomHashMap.java @@ -462,6 +462,42 @@ public class Short2LongOpenCustomHashMap extends AbstractShort2LongMap implement return newValue; } + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -481,19 +517,6 @@ public class Short2LongOpenCustomHashMap extends AbstractShort2LongMap implement return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -513,19 +536,6 @@ public class Short2LongOpenCustomHashMap extends AbstractShort2LongMap implement return newValue; } - @Override - public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -545,16 +555,6 @@ public class Short2LongOpenCustomHashMap extends AbstractShort2LongMap implement return newValue; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ObjectOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ObjectOpenCustomHashMap.java index 82d5256..98e7a19 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ObjectOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ObjectOpenCustomHashMap.java @@ -432,25 +432,6 @@ public class Short2ObjectOpenCustomHashMap extends AbstractShort2ObjectMap return newValue; } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -469,26 +450,7 @@ public class Short2ObjectOpenCustomHashMap extends AbstractShort2ObjectMap } return newValue; } - - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -508,25 +470,6 @@ public class Short2ObjectOpenCustomHashMap extends AbstractShort2ObjectMap return newValue; } - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -541,20 +484,6 @@ public class Short2ObjectOpenCustomHashMap extends AbstractShort2ObjectMap return newValue; } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ShortOpenCustomHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ShortOpenCustomHashMap.java index 51c7947..61bf567 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ShortOpenCustomHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/customHash/Short2ShortOpenCustomHashMap.java @@ -454,6 +454,42 @@ public class Short2ShortOpenCustomHashMap extends AbstractShort2ShortMap impleme return newValue; } + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,19 +509,6 @@ public class Short2ShortOpenCustomHashMap extends AbstractShort2ShortMap impleme return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -505,48 +528,25 @@ public class Short2ShortOpenCustomHashMap extends AbstractShort2ShortMap impleme return newValue; } - @Override - public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2BooleanOpenHashMap.java index 21f7cbd..051f03f 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2BooleanOpenHashMap.java @@ -408,6 +408,42 @@ public class Short2BooleanOpenHashMap extends AbstractShort2BooleanMap implement values[index] = newValue; return newValue; } + + @Override + public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + boolean newValue = mappingFunction.test(key); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + boolean newValue = valueProvider.getAsBoolean(); + insert(-index-1, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { @@ -428,19 +464,6 @@ public class Short2BooleanOpenHashMap extends AbstractShort2BooleanMap implement return newValue; } - @Override - public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - boolean newValue = mappingFunction.test(key); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -460,19 +483,6 @@ public class Short2BooleanOpenHashMap extends AbstractShort2BooleanMap implement return newValue; } - @Override - public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - boolean newValue = valueProvider.getAsBoolean(); - insert(-index-1, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -492,16 +502,6 @@ public class Short2BooleanOpenHashMap extends AbstractShort2BooleanMap implement return newValue; } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ByteOpenHashMap.java index 355734b..9bc56e1 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ByteOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2ByteOpenHashMap extends AbstractShort2ByteMap implements ITri values[index] = newValue; return newValue; } + + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + byte newValue = mappingFunction.applyAsByte(key); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + byte newValue = valueProvider.getAsByte(); + insert(-index-1, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2ByteOpenHashMap extends AbstractShort2ByteMap implements ITri return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - byte newValue = mappingFunction.applyAsByte(key); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Short2ByteOpenHashMap extends AbstractShort2ByteMap implements ITri return newValue; } - @Override - public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - byte newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2CharOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2CharOpenHashMap.java index 3a441a7..589f37a 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2CharOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2CharOpenHashMap extends AbstractShort2CharMap implements ITri values[index] = newValue; return newValue; } + + @Override + public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + char newValue = mappingFunction.applyAsChar(key); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + char newValue = valueProvider.getAsChar(); + insert(-index-1, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2CharOpenHashMap extends AbstractShort2CharMap implements ITri return newValue; } - @Override - public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - char newValue = mappingFunction.applyAsChar(key); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Short2CharOpenHashMap extends AbstractShort2CharMap implements ITri return newValue; } - @Override - public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - char newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(short 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(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2DoubleOpenHashMap.java index 6b32399..88ad5da 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2DoubleOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2DoubleOpenHashMap extends AbstractShort2DoubleMap implements values[index] = newValue; return newValue; } + + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + double newValue = mappingFunction.applyAsDouble(key); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + double newValue = valueProvider.getAsDouble(); + insert(-index-1, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2DoubleOpenHashMap extends AbstractShort2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - double newValue = mappingFunction.applyAsDouble(key); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Short2DoubleOpenHashMap extends AbstractShort2DoubleMap implements return newValue; } - @Override - public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - double newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Short2DoubleOpenHashMap extends AbstractShort2DoubleMap implements return newValue; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2FloatOpenHashMap.java index 70b0a73..3069940 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2FloatOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2FloatOpenHashMap extends AbstractShort2FloatMap implements IT values[index] = newValue; return newValue; } + + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + float newValue = mappingFunction.applyAsFloat(key); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + float newValue = valueProvider.getAsFloat(); + insert(-index-1, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2FloatOpenHashMap extends AbstractShort2FloatMap implements IT return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - float newValue = mappingFunction.applyAsFloat(key); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,48 +505,25 @@ public class Short2FloatOpenHashMap extends AbstractShort2FloatMap implements IT return newValue; } - @Override - public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - float newValue = valueProvider.getAsDouble(); - insert(-index-1, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2IntOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2IntOpenHashMap.java index 7992d0b..9a0012b 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2IntOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2IntOpenHashMap extends AbstractShort2IntMap implements ITrimm values[index] = newValue; return newValue; } + + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + int newValue = mappingFunction.applyAsInt(key); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + int newValue = valueProvider.getAsInt(); + insert(-index-1, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2IntOpenHashMap extends AbstractShort2IntMap implements ITrimm return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - int newValue = mappingFunction.applyAsInt(key); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Short2IntOpenHashMap extends AbstractShort2IntMap implements ITrimm return newValue; } - @Override - public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - int newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Short2IntOpenHashMap extends AbstractShort2IntMap implements ITrimm return newValue; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2LongOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2LongOpenHashMap.java index e5215f8..2603732 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2LongOpenHashMap.java @@ -430,6 +430,42 @@ public class Short2LongOpenHashMap extends AbstractShort2LongMap implements ITri values[index] = newValue; return newValue; } + + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + long newValue = mappingFunction.applyAsLong(key); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + long newValue = valueProvider.getAsLong(); + insert(-index-1, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { @@ -450,19 +486,6 @@ public class Short2LongOpenHashMap extends AbstractShort2LongMap implements ITri return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - long newValue = mappingFunction.applyAsLong(key); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -482,19 +505,6 @@ public class Short2LongOpenHashMap extends AbstractShort2LongMap implements ITri return newValue; } - @Override - public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - long newValue = valueProvider.getAsLong(); - insert(-index-1, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -514,16 +524,6 @@ public class Short2LongOpenHashMap extends AbstractShort2LongMap implements ITri return newValue; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ObjectOpenHashMap.java index c6a0867..86d1a5b 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ObjectOpenHashMap.java @@ -401,26 +401,7 @@ public class Short2ObjectOpenHashMap extends AbstractShort2ObjectMap imple values[index] = newValue; return newValue; } - - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -440,25 +421,6 @@ public class Short2ObjectOpenHashMap extends AbstractShort2ObjectMap imple return newValue; } - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -477,26 +439,7 @@ public class Short2ObjectOpenHashMap extends AbstractShort2ObjectMap imple } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -511,20 +454,6 @@ public class Short2ObjectOpenHashMap extends AbstractShort2ObjectMap imple return newValue; } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ShortOpenHashMap.java index 404d15a..5c532aa 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/hash/Short2ShortOpenHashMap.java @@ -424,6 +424,42 @@ public class Short2ShortOpenHashMap extends AbstractShort2ShortMap implements IT values[index] = newValue; return newValue; } + + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index < 0) { + short newValue = mappingFunction.applyAsShort(key); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index < 0) { + short newValue = valueProvider.getAsShort(); + insert(-index-1, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { @@ -444,19 +480,6 @@ public class Short2ShortOpenHashMap extends AbstractShort2ShortMap implements IT return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index < 0) { - short newValue = mappingFunction.applyAsShort(key); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -476,48 +499,25 @@ public class Short2ShortOpenHashMap extends AbstractShort2ShortMap implements IT return newValue; } - @Override - public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index < 0) { - short newValue = valueProvider.getAsInt(); - insert(-index-1, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2BooleanOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2BooleanOpenHashMap.java index 27a491f..115d75e 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2BooleanOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2BooleanOpenHashMap.java @@ -413,20 +413,19 @@ public class ImmutableShort2BooleanOpenHashMap extends AbstractShort2BooleanMap @Override public boolean computeBoolean(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean mergeBoolean(short key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ByteOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ByteOpenHashMap.java index 84df545..537470e 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ByteOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ByteOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2ByteOpenHashMap extends AbstractShort2ByteMap implem @Override public byte computeByte(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte mergeByte(short key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2CharOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2CharOpenHashMap.java index fc4e192..dadecbc 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2CharOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2CharOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2CharOpenHashMap extends AbstractShort2CharMap implem @Override public char computeChar(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char mergeChar(short key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2DoubleOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2DoubleOpenHashMap.java index 412523a..01c27cc 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2DoubleOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2DoubleOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2DoubleOpenHashMap extends AbstractShort2DoubleMap im @Override public double computeDouble(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double mergeDouble(short key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2FloatOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2FloatOpenHashMap.java index 0f9f1f0..787248f 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2FloatOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2FloatOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2FloatOpenHashMap extends AbstractShort2FloatMap impl @Override public float computeFloat(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float mergeFloat(short key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2IntOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2IntOpenHashMap.java index 8d96e77..da1291c 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2IntOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2IntOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2IntOpenHashMap extends AbstractShort2IntMap implemen @Override public int computeInt(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int mergeInt(short key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2LongOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2LongOpenHashMap.java index 1882b4b..a176f39 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2LongOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2LongOpenHashMap.java @@ -418,20 +418,19 @@ public class ImmutableShort2LongOpenHashMap extends AbstractShort2LongMap implem @Override public long computeLong(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long mergeLong(short key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ObjectOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ObjectOpenHashMap.java index de0f320..e4bd9b4 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ObjectOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ObjectOpenHashMap.java @@ -397,20 +397,11 @@ public class ImmutableShort2ObjectOpenHashMap extends AbstractShort2ObjectMap @Override public V compute(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ShortOpenHashMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ShortOpenHashMap.java index 220c31d..9ed403e 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ShortOpenHashMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/immutable/ImmutableShort2ShortOpenHashMap.java @@ -409,20 +409,19 @@ public class ImmutableShort2ShortOpenHashMap extends AbstractShort2ShortMap impl @Override public short computeShort(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } + @Override public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short mergeShort(short key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2BooleanArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2BooleanArrayMap.java index 61099e9..551da09 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2BooleanArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2BooleanArrayMap.java @@ -419,6 +419,42 @@ public class Short2BooleanArrayMap extends AbstractShort2BooleanMap implements S return newValue; } + @Override + public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + boolean newValue = mappingFunction.test(key); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + boolean newValue = valueProvider.getAsBoolean(); + insertIndex(size++, key, newValue); + return newValue; + } + boolean newValue = values[index]; + return newValue; + } + + @Override + public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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 computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -438,19 +474,6 @@ public class Short2BooleanArrayMap extends AbstractShort2BooleanMap implements S return newValue; } - @Override - public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - boolean newValue = mappingFunction.test(key); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -470,19 +493,6 @@ public class Short2BooleanArrayMap extends AbstractShort2BooleanMap implements S return newValue; } - @Override - public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - boolean newValue = valueProvider.getAsBoolean(); - insertIndex(size++, key, newValue); - return newValue; - } - boolean newValue = values[index]; - return newValue; - } - @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -502,16 +512,6 @@ public class Short2BooleanArrayMap extends AbstractShort2BooleanMap implements S return newValue; } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ByteArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ByteArrayMap.java index 1e9c5f4..a88c306 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ByteArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ByteArrayMap.java @@ -442,6 +442,42 @@ public class Short2ByteArrayMap extends AbstractShort2ByteMap implements Short2B return newValue; } + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + byte newValue = mappingFunction.applyAsByte(key); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + byte newValue = valueProvider.getAsByte(); + insertIndex(size++, key, newValue); + return newValue; + } + byte newValue = values[index]; + return newValue; + } + + @Override + public byte computeByteIfPresent(short key, ShortByteUnaryOperator 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 computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2ByteArrayMap extends AbstractShort2ByteMap implements Short2B return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - byte newValue = mappingFunction.applyAsByte(key); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Short2ByteArrayMap extends AbstractShort2ByteMap implements Short2B return newValue; } - @Override - public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - byte newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - byte newValue = values[index]; - return newValue; - } - @Override public byte supplyByteIfAbsentNonDefault(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2CharArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2CharArrayMap.java index 2086fa6..e97000d 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2CharArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2CharArrayMap.java @@ -442,6 +442,42 @@ public class Short2CharArrayMap extends AbstractShort2CharMap implements Short2C return newValue; } + @Override + public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + char newValue = mappingFunction.applyAsChar(key); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + char newValue = valueProvider.getAsChar(); + insertIndex(size++, key, newValue); + return newValue; + } + char newValue = values[index]; + return newValue; + } + + @Override + public char computeCharIfPresent(short key, ShortCharUnaryOperator 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 computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2CharArrayMap extends AbstractShort2CharMap implements Short2C return newValue; } - @Override - public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - char newValue = mappingFunction.applyAsChar(key); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Short2CharArrayMap extends AbstractShort2CharMap implements Short2C return newValue; } - @Override - public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - char newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - char newValue = values[index]; - return newValue; - } - @Override public char supplyCharIfAbsentNonDefault(short 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(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2DoubleArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2DoubleArrayMap.java index 870ec5b..a59d79a 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2DoubleArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2DoubleArrayMap.java @@ -442,6 +442,42 @@ public class Short2DoubleArrayMap extends AbstractShort2DoubleMap implements Sho return newValue; } + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + double newValue = mappingFunction.applyAsDouble(key); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + double newValue = valueProvider.getAsDouble(); + insertIndex(size++, key, newValue); + return newValue; + } + double newValue = values[index]; + return newValue; + } + + @Override + public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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 computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2DoubleArrayMap extends AbstractShort2DoubleMap implements Sho return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - double newValue = mappingFunction.applyAsDouble(key); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Short2DoubleArrayMap extends AbstractShort2DoubleMap implements Sho return newValue; } - @Override - public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - double newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - double newValue = values[index]; - return newValue; - } - @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Short2DoubleArrayMap extends AbstractShort2DoubleMap implements Sho return newValue; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2FloatArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2FloatArrayMap.java index 7e64191..c5a7b00 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2FloatArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2FloatArrayMap.java @@ -442,6 +442,42 @@ public class Short2FloatArrayMap extends AbstractShort2FloatMap implements Short return newValue; } + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + float newValue = mappingFunction.applyAsFloat(key); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + float newValue = valueProvider.getAsFloat(); + insertIndex(size++, key, newValue); + return newValue; + } + float newValue = values[index]; + return newValue; + } + + @Override + public float computeFloatIfPresent(short key, ShortFloatUnaryOperator 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 computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2FloatArrayMap extends AbstractShort2FloatMap implements Short return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - float newValue = mappingFunction.applyAsFloat(key); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,48 +516,25 @@ public class Short2FloatArrayMap extends AbstractShort2FloatMap implements Short return newValue; } - @Override - public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - float newValue = valueProvider.getAsDouble(); - insertIndex(size++, key, newValue); - return newValue; - } - float newValue = values[index]; - return newValue; - } - @Override public float supplyFloatIfAbsentNonDefault(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2IntArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2IntArrayMap.java index 50f2d07..5845690 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2IntArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2IntArrayMap.java @@ -442,6 +442,42 @@ public class Short2IntArrayMap extends AbstractShort2IntMap implements Short2Int return newValue; } + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + int newValue = mappingFunction.applyAsInt(key); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + int newValue = valueProvider.getAsInt(); + insertIndex(size++, key, newValue); + return newValue; + } + int newValue = values[index]; + return newValue; + } + + @Override + public int computeIntIfPresent(short key, ShortIntUnaryOperator 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 computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2IntArrayMap extends AbstractShort2IntMap implements Short2Int return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - int newValue = mappingFunction.applyAsInt(key); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Short2IntArrayMap extends AbstractShort2IntMap implements Short2Int return newValue; } - @Override - public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - int newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - int newValue = values[index]; - return newValue; - } - @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Short2IntArrayMap extends AbstractShort2IntMap implements Short2Int return newValue; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2LongArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2LongArrayMap.java index 0443cd9..7080b30 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2LongArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2LongArrayMap.java @@ -442,6 +442,42 @@ public class Short2LongArrayMap extends AbstractShort2LongMap implements Short2L return newValue; } + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + long newValue = mappingFunction.applyAsLong(key); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + long newValue = valueProvider.getAsLong(); + insertIndex(size++, key, newValue); + return newValue; + } + long newValue = values[index]; + return newValue; + } + + @Override + public long computeLongIfPresent(short key, ShortLongUnaryOperator 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 computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -461,19 +497,6 @@ public class Short2LongArrayMap extends AbstractShort2LongMap implements Short2L return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - long newValue = mappingFunction.applyAsLong(key); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -493,19 +516,6 @@ public class Short2LongArrayMap extends AbstractShort2LongMap implements Short2L return newValue; } - @Override - public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - long newValue = valueProvider.getAsLong(); - insertIndex(size++, key, newValue); - return newValue; - } - long newValue = values[index]; - return newValue; - } - @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -525,16 +535,6 @@ public class Short2LongArrayMap extends AbstractShort2LongMap implements Short2L return newValue; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ObjectArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ObjectArrayMap.java index c12d9e5..be0d91a 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ObjectArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ObjectArrayMap.java @@ -415,25 +415,6 @@ public class Short2ObjectArrayMap extends AbstractShort2ObjectMap implemen return newValue; } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -452,26 +433,7 @@ public class Short2ObjectArrayMap extends AbstractShort2ObjectMap implemen } return newValue; } - - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -490,26 +452,7 @@ public class Short2ObjectArrayMap extends AbstractShort2ObjectMap implemen } return newValue; } - - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -524,20 +467,6 @@ public class Short2ObjectArrayMap extends AbstractShort2ObjectMap implemen return newValue; } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ShortArrayMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ShortArrayMap.java index ba7ee6c..b9b3bbf 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ShortArrayMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/misc/Short2ShortArrayMap.java @@ -435,6 +435,42 @@ public class Short2ShortArrayMap extends AbstractShort2ShortMap implements Short return newValue; } + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + int index = findIndex(key); + if(index == -1) { + short newValue = mappingFunction.applyAsShort(key); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { + Objects.requireNonNull(valueProvider); + int index = findIndex(key); + if(index == -1) { + short newValue = valueProvider.getAsShort(); + insertIndex(size++, key, newValue); + return newValue; + } + short newValue = values[index]; + return newValue; + } + + @Override + public short computeShortIfPresent(short key, ShortShortUnaryOperator 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 computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -454,19 +490,6 @@ public class Short2ShortArrayMap extends AbstractShort2ShortMap implements Short return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - int index = findIndex(key); - if(index == -1) { - short newValue = mappingFunction.applyAsShort(key); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -486,48 +509,25 @@ public class Short2ShortArrayMap extends AbstractShort2ShortMap implements Short return newValue; } - @Override - public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { - Objects.requireNonNull(valueProvider); - int index = findIndex(key); - if(index == -1) { - short newValue = valueProvider.getAsInt(); - insertIndex(size++, key, newValue); - return newValue; - } - short newValue = values[index]; - return newValue; - } - @Override public short supplyShortIfAbsentNonDefault(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanAVLTreeMap.java index 5f36bcb..0d7a0fd 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanAVLTreeMap.java @@ -395,6 +395,40 @@ public class Short2BooleanAVLTreeMap extends AbstractShort2BooleanMap implements return newValue; } + @Override + public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(short 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(short key, ShortBooleanUnaryOperator 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 computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -414,18 +448,6 @@ public class Short2BooleanAVLTreeMap extends AbstractShort2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -444,18 +466,6 @@ public class Short2BooleanAVLTreeMap extends AbstractShort2BooleanMap implements return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(short 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(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -474,16 +484,6 @@ public class Short2BooleanAVLTreeMap extends AbstractShort2BooleanMap implements return entry.value; } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1487,14 +1487,9 @@ public class Short2BooleanAVLTreeMap extends AbstractShort2BooleanMap implements 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/shorts/maps/impl/tree/Short2BooleanRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanRBTreeMap.java index 3e6b60c..14bdd49 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2BooleanRBTreeMap.java @@ -394,6 +394,40 @@ public class Short2BooleanRBTreeMap extends AbstractShort2BooleanMap implements return newValue; } + @Override + public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + boolean newValue = mappingFunction.test(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public boolean supplyBooleanIfAbsent(short 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(short key, ShortBooleanUnaryOperator 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 computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -413,18 +447,6 @@ public class Short2BooleanRBTreeMap extends AbstractShort2BooleanMap implements return newValue; } - @Override - public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - boolean newValue = mappingFunction.test(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -443,18 +465,6 @@ public class Short2BooleanRBTreeMap extends AbstractShort2BooleanMap implements return entry.value; } - @Override - public boolean supplyBooleanIfAbsent(short 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(short key, BooleanSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -473,16 +483,6 @@ public class Short2BooleanRBTreeMap extends AbstractShort2BooleanMap implements return entry.value; } - @Override - public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator 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(short key, ShortBooleanUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Short2BooleanRBTreeMap extends AbstractShort2BooleanMap implements 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/shorts/maps/impl/tree/Short2ByteAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteAVLTreeMap.java index 72dae5e..64c54a3 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2ByteAVLTreeMap extends AbstractShort2ByteMap implements Short return newValue; } + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(short 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(short key, ShortByteUnaryOperator 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 computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2ByteAVLTreeMap extends AbstractShort2ByteMap implements Short return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Short2ByteAVLTreeMap extends AbstractShort2ByteMap implements Short return entry.value; } - @Override - public byte supplyByteIfAbsent(short 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(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2ByteAVLTreeMap extends AbstractShort2ByteMap implements Short 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/shorts/maps/impl/tree/Short2ByteRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteRBTreeMap.java index 3d133a5..fbd6d93 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ByteRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2ByteRBTreeMap extends AbstractShort2ByteMap implements Short2 return newValue; } + @Override + public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + byte newValue = mappingFunction.applyAsByte(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public byte supplyByteIfAbsent(short 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(short key, ShortByteUnaryOperator 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 computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2ByteRBTreeMap extends AbstractShort2ByteMap implements Short2 return newValue; } - @Override - public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - byte newValue = mappingFunction.applyAsByte(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Short2ByteRBTreeMap extends AbstractShort2ByteMap implements Short2 return entry.value; } - @Override - public byte supplyByteIfAbsent(short 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(short 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(short key, ShortByteUnaryOperator 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(short key, ShortByteUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2ByteRBTreeMap extends AbstractShort2ByteMap implements Short2 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/shorts/maps/impl/tree/Short2CharAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharAVLTreeMap.java index b2535f5..b4e0b48 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2CharAVLTreeMap extends AbstractShort2CharMap implements Short return newValue; } + @Override + public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(short 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(short key, ShortCharUnaryOperator 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 computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2CharAVLTreeMap extends AbstractShort2CharMap implements Short return newValue; } - @Override - public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Short2CharAVLTreeMap extends AbstractShort2CharMap implements Short return entry.value; } - @Override - public char supplyCharIfAbsent(short 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(short 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(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2CharAVLTreeMap extends AbstractShort2CharMap implements Short 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/shorts/maps/impl/tree/Short2CharRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharRBTreeMap.java index f0b7d28..fa5e1d8 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2CharRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2CharRBTreeMap extends AbstractShort2CharMap implements Short2 return newValue; } + @Override + public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + char newValue = mappingFunction.applyAsChar(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public char supplyCharIfAbsent(short 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(short key, ShortCharUnaryOperator 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 computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2CharRBTreeMap extends AbstractShort2CharMap implements Short2 return newValue; } - @Override - public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - char newValue = mappingFunction.applyAsChar(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Short2CharRBTreeMap extends AbstractShort2CharMap implements Short2 return entry.value; } - @Override - public char supplyCharIfAbsent(short 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(short 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(short key, ShortCharUnaryOperator 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(short key, ShortCharUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2CharRBTreeMap extends AbstractShort2CharMap implements Short2 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/shorts/maps/impl/tree/Short2DoubleAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleAVLTreeMap.java index a064688..cee365c 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2DoubleAVLTreeMap extends AbstractShort2DoubleMap implements S return newValue; } + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(short 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(short key, ShortDoubleUnaryOperator 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 computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2DoubleAVLTreeMap extends AbstractShort2DoubleMap implements S return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Short2DoubleAVLTreeMap extends AbstractShort2DoubleMap implements S return entry.value; } - @Override - public double supplyDoubleIfAbsent(short 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(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Short2DoubleAVLTreeMap extends AbstractShort2DoubleMap implements S return entry.value; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2DoubleAVLTreeMap extends AbstractShort2DoubleMap implements S 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/shorts/maps/impl/tree/Short2DoubleRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleRBTreeMap.java index c93a483..2ad3ac9 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2DoubleRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2DoubleRBTreeMap extends AbstractShort2DoubleMap implements Sh return newValue; } + @Override + public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + double newValue = mappingFunction.applyAsDouble(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public double supplyDoubleIfAbsent(short 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(short key, ShortDoubleUnaryOperator 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 computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2DoubleRBTreeMap extends AbstractShort2DoubleMap implements Sh return newValue; } - @Override - public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - double newValue = mappingFunction.applyAsDouble(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Short2DoubleRBTreeMap extends AbstractShort2DoubleMap implements Sh return entry.value; } - @Override - public double supplyDoubleIfAbsent(short 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(short key, DoubleSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Short2DoubleRBTreeMap extends AbstractShort2DoubleMap implements Sh return entry.value; } - @Override - public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator 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(short key, ShortDoubleUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2DoubleRBTreeMap extends AbstractShort2DoubleMap implements Sh 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/shorts/maps/impl/tree/Short2FloatAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatAVLTreeMap.java index fa36677..7a51fdf 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2FloatAVLTreeMap extends AbstractShort2FloatMap implements Sho return newValue; } + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(short 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(short key, ShortFloatUnaryOperator 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 computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2FloatAVLTreeMap extends AbstractShort2FloatMap implements Sho return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,46 +525,24 @@ public class Short2FloatAVLTreeMap extends AbstractShort2FloatMap implements Sho return entry.value; } - @Override - public float supplyFloatIfAbsent(short 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(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2FloatAVLTreeMap extends AbstractShort2FloatMap implements Sho 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/shorts/maps/impl/tree/Short2FloatRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatRBTreeMap.java index 4558ba2..9c98a92 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2FloatRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2FloatRBTreeMap extends AbstractShort2FloatMap implements Shor return newValue; } + @Override + public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + float newValue = mappingFunction.applyAsFloat(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public float supplyFloatIfAbsent(short 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(short key, ShortFloatUnaryOperator 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 computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2FloatRBTreeMap extends AbstractShort2FloatMap implements Shor return newValue; } - @Override - public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - float newValue = mappingFunction.applyAsFloat(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,46 +524,24 @@ public class Short2FloatRBTreeMap extends AbstractShort2FloatMap implements Shor return entry.value; } - @Override - public float supplyFloatIfAbsent(short 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(short 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(short key, ShortFloatUnaryOperator 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(short key, ShortFloatUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2FloatRBTreeMap extends AbstractShort2FloatMap implements Shor 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/shorts/maps/impl/tree/Short2IntAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntAVLTreeMap.java index 2b16f11..b1b561b 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2IntAVLTreeMap extends AbstractShort2IntMap implements Short2I return newValue; } + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(short 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(short key, ShortIntUnaryOperator 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 computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2IntAVLTreeMap extends AbstractShort2IntMap implements Short2I return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Short2IntAVLTreeMap extends AbstractShort2IntMap implements Short2I return entry.value; } - @Override - public int supplyIntIfAbsent(short 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(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Short2IntAVLTreeMap extends AbstractShort2IntMap implements Short2I return entry.value; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2IntAVLTreeMap extends AbstractShort2IntMap implements Short2I 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/shorts/maps/impl/tree/Short2IntRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntRBTreeMap.java index aa7d6c9..b3206ac 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2IntRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2IntRBTreeMap extends AbstractShort2IntMap implements Short2In return newValue; } + @Override + public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + int newValue = mappingFunction.applyAsInt(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public int supplyIntIfAbsent(short 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(short key, ShortIntUnaryOperator 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 computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2IntRBTreeMap extends AbstractShort2IntMap implements Short2In return newValue; } - @Override - public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - int newValue = mappingFunction.applyAsInt(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Short2IntRBTreeMap extends AbstractShort2IntMap implements Short2In return entry.value; } - @Override - public int supplyIntIfAbsent(short 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(short key, IntSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Short2IntRBTreeMap extends AbstractShort2IntMap implements Short2In return entry.value; } - @Override - public int computeIntIfPresent(short key, ShortIntUnaryOperator 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(short key, ShortIntUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2IntRBTreeMap extends AbstractShort2IntMap implements Short2In 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/shorts/maps/impl/tree/Short2LongAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongAVLTreeMap.java index 5def582..4d4f814 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongAVLTreeMap.java @@ -454,6 +454,40 @@ public class Short2LongAVLTreeMap extends AbstractShort2LongMap implements Short return newValue; } + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(short 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(short key, ShortLongUnaryOperator 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 computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -473,18 +507,6 @@ public class Short2LongAVLTreeMap extends AbstractShort2LongMap implements Short return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -503,18 +525,6 @@ public class Short2LongAVLTreeMap extends AbstractShort2LongMap implements Short return entry.value; } - @Override - public long supplyLongIfAbsent(short 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(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -533,16 +543,6 @@ public class Short2LongAVLTreeMap extends AbstractShort2LongMap implements Short return entry.value; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1558,14 +1558,9 @@ public class Short2LongAVLTreeMap extends AbstractShort2LongMap implements Short 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/shorts/maps/impl/tree/Short2LongRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongRBTreeMap.java index 40f206e..f9804f0 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2LongRBTreeMap.java @@ -453,6 +453,40 @@ public class Short2LongRBTreeMap extends AbstractShort2LongMap implements Short2 return newValue; } + @Override + public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + long newValue = mappingFunction.applyAsLong(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public long supplyLongIfAbsent(short 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(short key, ShortLongUnaryOperator 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 computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -472,18 +506,6 @@ public class Short2LongRBTreeMap extends AbstractShort2LongMap implements Short2 return newValue; } - @Override - public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - long newValue = mappingFunction.applyAsLong(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -502,18 +524,6 @@ public class Short2LongRBTreeMap extends AbstractShort2LongMap implements Short2 return entry.value; } - @Override - public long supplyLongIfAbsent(short 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(short key, LongSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -532,16 +542,6 @@ public class Short2LongRBTreeMap extends AbstractShort2LongMap implements Short2 return entry.value; } - @Override - public long computeLongIfPresent(short key, ShortLongUnaryOperator 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(short key, ShortLongUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1621,14 +1621,9 @@ public class Short2LongRBTreeMap extends AbstractShort2LongMap implements Short2 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/shorts/maps/impl/tree/Short2ObjectAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectAVLTreeMap.java index 85c31cc..0fdfe9c 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectAVLTreeMap.java @@ -395,25 +395,6 @@ public class Short2ObjectAVLTreeMap extends AbstractShort2ObjectMap implem return newValue; } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -432,24 +413,6 @@ public class Short2ObjectAVLTreeMap extends AbstractShort2ObjectMap implem return entry.value; } - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -468,24 +431,6 @@ public class Short2ObjectAVLTreeMap extends AbstractShort2ObjectMap implem return entry.value; } - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -500,20 +445,6 @@ public class Short2ObjectAVLTreeMap extends AbstractShort2ObjectMap implem return newValue; } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectRBTreeMap.java index f0c8c9c..7a845fc 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ObjectRBTreeMap.java @@ -394,25 +394,6 @@ public class Short2ObjectRBTreeMap extends AbstractShort2ObjectMap impleme return newValue; } - @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator 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(short key, ShortFunction mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -431,24 +412,6 @@ public class Short2ObjectRBTreeMap extends AbstractShort2ObjectMap impleme return entry.value; } - @Override - public V computeIfAbsentNonDefault(short key, ShortFunction 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(short key, ObjectSupplier valueProvider) { Objects.requireNonNull(valueProvider); @@ -467,24 +430,6 @@ public class Short2ObjectRBTreeMap extends AbstractShort2ObjectMap impleme return entry.value; } - @Override - public V supplyIfAbsentNonDefault(short 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(short key, ShortObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -499,20 +444,6 @@ public class Short2ObjectRBTreeMap extends AbstractShort2ObjectMap impleme return newValue; } - @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator 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(short key, V value, ObjectObjectUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); diff --git a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortAVLTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortAVLTreeMap.java index 2553579..84dd0f5 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortAVLTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortAVLTreeMap.java @@ -446,6 +446,40 @@ public class Short2ShortAVLTreeMap extends AbstractShort2ShortMap implements Sho return newValue; } + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(short 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(short key, ShortShortUnaryOperator 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 computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -465,18 +499,6 @@ public class Short2ShortAVLTreeMap extends AbstractShort2ShortMap implements Sho return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -495,46 +517,24 @@ public class Short2ShortAVLTreeMap extends AbstractShort2ShortMap implements Sho return entry.value; } - @Override - public short supplyShortIfAbsent(short 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(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1550,14 +1550,9 @@ public class Short2ShortAVLTreeMap extends AbstractShort2ShortMap implements Sho 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/shorts/maps/impl/tree/Short2ShortRBTreeMap.java b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortRBTreeMap.java index ab98667..71544d0 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortRBTreeMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/impl/tree/Short2ShortRBTreeMap.java @@ -445,6 +445,40 @@ public class Short2ShortRBTreeMap extends AbstractShort2ShortMap implements Shor return newValue; } + @Override + public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { + Objects.requireNonNull(mappingFunction); + Node entry = findNode(key); + if(entry == null) { + short newValue = mappingFunction.applyAsShort(key); + put(key, newValue); + return newValue; + } + return entry.value; + } + + @Override + public short supplyShortIfAbsent(short 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(short key, ShortShortUnaryOperator 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 computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -464,18 +498,6 @@ public class Short2ShortRBTreeMap extends AbstractShort2ShortMap implements Shor return newValue; } - @Override - public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { - Objects.requireNonNull(mappingFunction); - Node entry = findNode(key); - if(entry == null) { - short newValue = mappingFunction.applyAsShort(key); - put(key, newValue); - return newValue; - } - return entry.value; - } - @Override public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -494,46 +516,24 @@ public class Short2ShortRBTreeMap extends AbstractShort2ShortMap implements Shor return entry.value; } - @Override - public short supplyShortIfAbsent(short 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(short 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(short key, ShortShortUnaryOperator 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(short key, ShortShortUnaryOperator mappingFunction) { Objects.requireNonNull(mappingFunction); @@ -1613,14 +1613,9 @@ public class Short2ShortRBTreeMap extends AbstractShort2ShortMap implements Shor 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/shorts/maps/interfaces/Short2BooleanMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2BooleanMap.java index 2f6c363..b072a67 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2BooleanMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2BooleanMap.java @@ -283,15 +283,6 @@ public interface Short2BooleanMap extends Map, ShortPredicate * @return the result of the computation */ public boolean computeBoolean(short key, ShortBooleanUnaryOperator 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 boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator 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". @@ -301,6 +292,34 @@ public interface Short2BooleanMap extends Map, ShortPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsent(short key, ShortPredicate 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". + * 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 boolean supplyBooleanIfAbsent(short 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(short key, ShortBooleanUnaryOperator 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 boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator 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". @@ -310,15 +329,6 @@ public interface Short2BooleanMap extends Map, ShortPredicate * @return the result of the computed value or present value */ public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate 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". - * 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 boolean supplyBooleanIfAbsent(short key, BooleanSupplier 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". @@ -328,16 +338,6 @@ public interface Short2BooleanMap extends Map, ShortPredicate * @return the result of the computed value or present value */ public boolean supplyBooleanIfAbsentNonDefault(short 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(short key, ShortBooleanUnaryOperator 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/shorts/maps/interfaces/Short2ByteMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ByteMap.java index c4c7e3b..58820b1 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ByteMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ByteMap.java @@ -308,15 +308,6 @@ public interface Short2ByteMap extends Map, Short2ByteFunction * @return the result of the computation */ public byte computeByte(short key, ShortByteUnaryOperator 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 byte computeByteNonDefault(short key, ShortByteUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2ByteMap extends Map, Short2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsent(short key, Short2ByteFunction 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". + * 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 byte supplyByteIfAbsent(short 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(short key, ShortByteUnaryOperator 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 byte computeByteNonDefault(short key, ShortByteUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2ByteMap extends Map, Short2ByteFunction * @return the result of the computed value or present value */ public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction 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". - * 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 byte supplyByteIfAbsent(short key, ByteSupplier 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". @@ -353,16 +363,6 @@ public interface Short2ByteMap extends Map, Short2ByteFunction * @return the result of the computed value or present value */ public byte supplyByteIfAbsentNonDefault(short 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(short key, ShortByteUnaryOperator 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/shorts/maps/interfaces/Short2CharMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2CharMap.java index ab3e90f..af57eb2 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2CharMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2CharMap.java @@ -308,15 +308,6 @@ public interface Short2CharMap extends Map, Short2CharFunction * @return the result of the computation */ public char computeChar(short key, ShortCharUnaryOperator 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 char computeCharNonDefault(short key, ShortCharUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2CharMap extends Map, Short2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsent(short key, Short2CharFunction 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". + * 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 char supplyCharIfAbsent(short 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(short key, ShortCharUnaryOperator 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 char computeCharNonDefault(short key, ShortCharUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2CharMap extends Map, Short2CharFunction * @return the result of the computed value or present value */ public char computeCharIfAbsentNonDefault(short key, Short2CharFunction 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". - * 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 char supplyCharIfAbsent(short key, CharSupplier 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". @@ -353,16 +363,6 @@ public interface Short2CharMap extends Map, Short2CharFunction * @return the result of the computed value or present value */ public char supplyCharIfAbsentNonDefault(short 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(short key, ShortCharUnaryOperator 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/shorts/maps/interfaces/Short2DoubleMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2DoubleMap.java index 04b1629..ba98412 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2DoubleMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2DoubleMap.java @@ -308,15 +308,6 @@ public interface Short2DoubleMap extends Map, Short2DoubleFunctio * @return the result of the computation */ public double computeDouble(short key, ShortDoubleUnaryOperator 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 double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2DoubleMap extends Map, Short2DoubleFunctio * @return the result of the computed value or present value */ public double computeDoubleIfAbsent(short key, Short2DoubleFunction 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". + * 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 double supplyDoubleIfAbsent(short 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(short key, ShortDoubleUnaryOperator 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 double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2DoubleMap extends Map, Short2DoubleFunctio * @return the result of the computed value or present value */ public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction 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". - * 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 double supplyDoubleIfAbsent(short key, DoubleSupplier 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". @@ -353,16 +363,6 @@ public interface Short2DoubleMap extends Map, Short2DoubleFunctio * @return the result of the computed value or present value */ public double supplyDoubleIfAbsentNonDefault(short 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(short key, ShortDoubleUnaryOperator 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/shorts/maps/interfaces/Short2FloatMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2FloatMap.java index 105873f..41d117a 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2FloatMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2FloatMap.java @@ -308,15 +308,6 @@ public interface Short2FloatMap extends Map, Short2FloatFunction * @return the result of the computation */ public float computeFloat(short key, ShortFloatUnaryOperator 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 float computeFloatNonDefault(short key, ShortFloatUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2FloatMap extends Map, Short2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsent(short key, Short2FloatFunction 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". + * 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 float supplyFloatIfAbsent(short 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(short key, ShortFloatUnaryOperator 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 float computeFloatNonDefault(short key, ShortFloatUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2FloatMap extends Map, Short2FloatFunction * @return the result of the computed value or present value */ public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction 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". - * 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 float supplyFloatIfAbsent(short key, FloatSupplier 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". @@ -353,16 +363,6 @@ public interface Short2FloatMap extends Map, Short2FloatFunction * @return the result of the computed value or present value */ public float supplyFloatIfAbsentNonDefault(short 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(short key, ShortFloatUnaryOperator 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/shorts/maps/interfaces/Short2IntMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2IntMap.java index b2b3b50..0dc2b8d 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2IntMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2IntMap.java @@ -308,15 +308,6 @@ public interface Short2IntMap extends Map, Short2IntFunction * @return the result of the computation */ public int computeInt(short key, ShortIntUnaryOperator 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 int computeIntNonDefault(short key, ShortIntUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2IntMap extends Map, Short2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsent(short key, Short2IntFunction 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". + * 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 int supplyIntIfAbsent(short 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(short key, ShortIntUnaryOperator 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 int computeIntNonDefault(short key, ShortIntUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2IntMap extends Map, Short2IntFunction * @return the result of the computed value or present value */ public int computeIntIfAbsentNonDefault(short key, Short2IntFunction 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". - * 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 int supplyIntIfAbsent(short key, IntSupplier 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". @@ -353,16 +363,6 @@ public interface Short2IntMap extends Map, Short2IntFunction * @return the result of the computed value or present value */ public int supplyIntIfAbsentNonDefault(short 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(short key, ShortIntUnaryOperator 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/shorts/maps/interfaces/Short2LongMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2LongMap.java index 93073c3..65f039f 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2LongMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2LongMap.java @@ -308,15 +308,6 @@ public interface Short2LongMap extends Map, Short2LongFunction * @return the result of the computation */ public long computeLong(short key, ShortLongUnaryOperator 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 long computeLongNonDefault(short key, ShortLongUnaryOperator 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". @@ -326,6 +317,34 @@ public interface Short2LongMap extends Map, Short2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsent(short key, Short2LongFunction 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". + * 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 long supplyLongIfAbsent(short 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(short key, ShortLongUnaryOperator 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 long computeLongNonDefault(short key, ShortLongUnaryOperator 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". @@ -335,15 +354,6 @@ public interface Short2LongMap extends Map, Short2LongFunction * @return the result of the computed value or present value */ public long computeLongIfAbsentNonDefault(short key, Short2LongFunction 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". - * 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 long supplyLongIfAbsent(short key, LongSupplier 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". @@ -353,16 +363,6 @@ public interface Short2LongMap extends Map, Short2LongFunction * @return the result of the computed value or present value */ public long supplyLongIfAbsentNonDefault(short 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(short key, ShortLongUnaryOperator 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/shorts/maps/interfaces/Short2ObjectMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ObjectMap.java index 7e7db37..82878ee 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ObjectMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ObjectMap.java @@ -266,15 +266,6 @@ public interface Short2ObjectMap extends Map, ShortFunction * @return the result of the computation */ public V compute(short key, ShortObjectUnaryOperator 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(short key, ShortObjectUnaryOperator 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 interface Short2ObjectMap extends Map, ShortFunction * @return the result of the computed value or present value */ public V computeIfAbsent(short key, ShortFunction 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(short key, ShortFunction 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 interface Short2ObjectMap extends Map, ShortFunction * @return the result of the computed value or present value */ public V supplyIfAbsent(short 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(short 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 interface Short2ObjectMap extends Map, ShortFunction * @note if not present then compute is not executed */ public V computeIfPresent(short key, ShortObjectUnaryOperator 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(short key, ShortObjectUnaryOperator 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/shorts/maps/interfaces/Short2ShortMap.java b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ShortMap.java index 98303aa..9075120 100644 --- a/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ShortMap.java +++ b/src/main/java/speiger/src/collections/shorts/maps/interfaces/Short2ShortMap.java @@ -307,15 +307,6 @@ public interface Short2ShortMap extends Map, ShortUnaryOperator * @return the result of the computation */ public short computeShort(short key, ShortShortUnaryOperator 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 short computeShortNonDefault(short key, ShortShortUnaryOperator 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". @@ -325,6 +316,34 @@ public interface Short2ShortMap extends Map, ShortUnaryOperator * @return the result of the computed value or present value */ public short computeShortIfAbsent(short key, ShortUnaryOperator 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". + * 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 short supplyShortIfAbsent(short 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(short key, ShortShortUnaryOperator 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 short computeShortNonDefault(short key, ShortShortUnaryOperator 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". @@ -334,15 +353,6 @@ public interface Short2ShortMap extends Map, ShortUnaryOperator * @return the result of the computed value or present value */ public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator 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". - * 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 short supplyShortIfAbsent(short key, ShortSupplier 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". @@ -352,16 +362,6 @@ public interface Short2ShortMap extends Map, ShortUnaryOperator * @return the result of the computed value or present value */ public short supplyShortIfAbsentNonDefault(short 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(short key, ShortShortUnaryOperator 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/shorts/queues/ShortArrayFIFOQueue.java b/src/main/java/speiger/src/collections/shorts/queues/ShortArrayFIFOQueue.java index bebc50f..65b8816 100644 --- a/src/main/java/speiger/src/collections/shorts/queues/ShortArrayFIFOQueue.java +++ b/src/main/java/speiger/src/collections/shorts/queues/ShortArrayFIFOQueue.java @@ -146,6 +146,15 @@ public class ShortArrayFIFOQueue extends AbstractShortPriorityQueue implements S return index >= array.length ? array[index-array.length] : array[index]; } + @Override + public boolean contains(short e) { + if(first == last) return false; + for(int i = 0,m=size();i 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 class ShortIterators } } + private static class InfiniteIterator implements ShortIterator + { + ShortIterator iter; + CollectionWrapper looper = ShortCollections.wrapper(); + int index = 0; + + public InfiniteIterator(ShortIterator iter) { + this.iter = iter; + } + + @Override + public boolean hasNext() { + return true; + } + + @Override + public short nextShort() { + if(iter != null) { + if(iter.hasNext()) { + short value = iter.nextShort(); + looper.add(value); + return value; + } + else iter = null; + } + return looper.getShort((index++) % looper.size()); + } + + @Override + public void forEachRemaining(ShortConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(Consumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + public void forEachRemaining(E input, ObjectShortConsumer action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); } + } + private static class RepeatingIterator implements ShortIterator { final int repeats; diff --git a/src/main/java/speiger/src/collections/shorts/utils/ShortLists.java b/src/main/java/speiger/src/collections/shorts/utils/ShortLists.java index 291782c..ecc4438 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/ShortLists.java +++ b/src/main/java/speiger/src/collections/shorts/utils/ShortLists.java @@ -12,6 +12,7 @@ import speiger.src.collections.shorts.collections.ShortCollection; import speiger.src.collections.shorts.functions.ShortConsumer; import speiger.src.collections.shorts.lists.AbstractShortList; import speiger.src.collections.shorts.lists.ShortList; +import speiger.src.collections.ints.lists.IntList; import speiger.src.collections.shorts.lists.ShortListIterator; import speiger.src.collections.utils.SanityChecks; @@ -317,6 +318,16 @@ public class ShortLists return l.listIterator(index); } + @Override + public ShortListIterator indexedIterator(int...indecies) { + return l.indexedIterator(indecies); + } + + @Override + public ShortListIterator indexedIterator(IntList indecies) { + return l.indexedIterator(indecies); + } + @Override public ShortList subList(int from, int to) { return ShortLists.synchronize(l.subList(from, to)); @@ -426,6 +437,16 @@ public class ShortLists return ShortIterators.unmodifiable(l.listIterator(index)); } + @Override + public ShortListIterator indexedIterator(int...indecies) { + return ShortIterators.unmodifiable(l.indexedIterator(indecies)); + } + + @Override + public ShortListIterator indexedIterator(IntList indecies) { + return ShortIterators.unmodifiable(l.indexedIterator(indecies)); + } + @Override public ShortList subList(int from, int to) { return ShortLists.unmodifiable(l.subList(from, to)); @@ -514,6 +535,16 @@ public class ShortLists return ShortIterators.empty(); } + @Override + public ShortListIterator indexedIterator(int...indecies) { + return ShortIterators.empty(); + } + + @Override + public ShortListIterator indexedIterator(IntList indecies) { + return ShortIterators.empty(); + } + @Override public int hashCode() { return 1; } diff --git a/src/main/java/speiger/src/collections/shorts/utils/ShortPriorityQueues.java b/src/main/java/speiger/src/collections/shorts/utils/ShortPriorityQueues.java index e948c14..e060c64 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/ShortPriorityQueues.java +++ b/src/main/java/speiger/src/collections/shorts/utils/ShortPriorityQueues.java @@ -89,6 +89,8 @@ public class ShortPriorityQueues @Override public short peek(int index) { synchronized(mutex) { return queue.peek(index); } } @Override + public boolean contains(short e) { synchronized(mutex) { return queue.contains(e); } } + @Override public boolean removeFirst(short e) { synchronized(mutex) { return queue.removeFirst(e); } } @Override public boolean removeLast(short e) { synchronized(mutex) { return queue.removeLast(e); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2BooleanMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2BooleanMaps.java index c88e9a4..16e46f3 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2BooleanMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2BooleanMaps.java @@ -246,18 +246,18 @@ public class Short2BooleanMaps @Override public boolean computeBoolean(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(short key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -304,18 +304,18 @@ public class Short2BooleanMaps @Override public boolean computeBoolean(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(short key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -535,18 +535,18 @@ public class Short2BooleanMaps @Override public boolean computeBoolean(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public boolean mergeBoolean(short key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -938,18 +938,18 @@ public class Short2BooleanMaps @Override public boolean computeBoolean(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBoolean(key, mappingFunction); } } @Override - public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfAbsent(short key, ShortPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsent(key, mappingFunction); } } @Override - public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } - @Override public boolean computeBooleanIfPresent(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresent(key, mappingFunction); } } @Override - public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } - @Override public boolean supplyBooleanIfAbsent(short key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsent(key, valueProvider); } } @Override + public boolean computeBooleanNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfAbsentNonDefault(short key, ShortPredicate mappingFunction) { synchronized(mutex) { return map.computeBooleanIfAbsentNonDefault(key, mappingFunction); } } + @Override + public boolean computeBooleanIfPresentNonDefault(short key, ShortBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeBooleanIfPresentNonDefault(key, mappingFunction); } } + @Override public boolean supplyBooleanIfAbsentNonDefault(short key, BooleanSupplier valueProvider) { synchronized(mutex) { return map.supplyBooleanIfAbsentNonDefault(key, valueProvider); } } @Override public boolean mergeBoolean(short key, boolean value, BooleanBooleanUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeBoolean(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ByteMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ByteMaps.java index f9ea6d2..62405e4 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ByteMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ByteMaps.java @@ -250,18 +250,18 @@ public class Short2ByteMaps @Override public byte computeByte(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(short key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2ByteMaps @Override public byte computeByte(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(short key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2ByteMaps @Override public byte computeByte(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public byte mergeByte(short key, byte value, ByteByteUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2ByteMaps @Override public byte computeByte(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByte(key, mappingFunction); } } @Override - public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfAbsent(short key, Short2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsent(key, mappingFunction); } } @Override - public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } - @Override public byte computeByteIfPresent(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresent(key, mappingFunction); } } @Override - public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } - @Override public byte supplyByteIfAbsent(short key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsent(key, valueProvider); } } @Override + public byte computeByteNonDefault(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfAbsentNonDefault(short key, Short2ByteFunction mappingFunction) { synchronized(mutex) { return map.computeByteIfAbsentNonDefault(key, mappingFunction); } } + @Override + public byte computeByteIfPresentNonDefault(short key, ShortByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeByteIfPresentNonDefault(key, mappingFunction); } } + @Override public byte supplyByteIfAbsentNonDefault(short key, ByteSupplier valueProvider) { synchronized(mutex) { return map.supplyByteIfAbsentNonDefault(key, valueProvider); } } @Override public byte mergeByte(short key, byte value, ByteByteUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeByte(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2CharMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2CharMaps.java index be0b814..2437a1f 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2CharMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2CharMaps.java @@ -250,18 +250,18 @@ public class Short2CharMaps @Override public char computeChar(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(short key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2CharMaps @Override public char computeChar(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(short key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2CharMaps @Override public char computeChar(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public char mergeChar(short key, char value, CharCharUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2CharMaps @Override public char computeChar(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeChar(key, mappingFunction); } } @Override - public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } - @Override public char computeCharIfAbsent(short key, Short2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsent(key, mappingFunction); } } @Override - public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } - @Override public char computeCharIfPresent(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresent(key, mappingFunction); } } @Override - public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } - @Override public char supplyCharIfAbsent(short key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsent(key, valueProvider); } } @Override + public char computeCharNonDefault(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfAbsentNonDefault(short key, Short2CharFunction mappingFunction) { synchronized(mutex) { return map.computeCharIfAbsentNonDefault(key, mappingFunction); } } + @Override + public char computeCharIfPresentNonDefault(short key, ShortCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeCharIfPresentNonDefault(key, mappingFunction); } } + @Override public char supplyCharIfAbsentNonDefault(short key, CharSupplier valueProvider) { synchronized(mutex) { return map.supplyCharIfAbsentNonDefault(key, valueProvider); } } @Override public char mergeChar(short key, char value, CharCharUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeChar(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2DoubleMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2DoubleMaps.java index b2796ee..283580f 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2DoubleMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2DoubleMaps.java @@ -250,18 +250,18 @@ public class Short2DoubleMaps @Override public double computeDouble(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(short key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2DoubleMaps @Override public double computeDouble(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(short key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2DoubleMaps @Override public double computeDouble(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public double mergeDouble(short key, double value, DoubleDoubleUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2DoubleMaps @Override public double computeDouble(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDouble(key, mappingFunction); } } @Override - public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfAbsent(short key, Short2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsent(key, mappingFunction); } } @Override - public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } - @Override public double computeDoubleIfPresent(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresent(key, mappingFunction); } } @Override - public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } - @Override public double supplyDoubleIfAbsent(short key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsent(key, valueProvider); } } @Override + public double computeDoubleNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfAbsentNonDefault(short key, Short2DoubleFunction mappingFunction) { synchronized(mutex) { return map.computeDoubleIfAbsentNonDefault(key, mappingFunction); } } + @Override + public double computeDoubleIfPresentNonDefault(short key, ShortDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeDoubleIfPresentNonDefault(key, mappingFunction); } } + @Override public double supplyDoubleIfAbsentNonDefault(short key, DoubleSupplier valueProvider) { synchronized(mutex) { return map.supplyDoubleIfAbsentNonDefault(key, valueProvider); } } @Override public double mergeDouble(short key, double value, DoubleDoubleUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeDouble(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2FloatMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2FloatMaps.java index 0428e7d..b2c6a8b 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2FloatMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2FloatMaps.java @@ -250,18 +250,18 @@ public class Short2FloatMaps @Override public float computeFloat(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(short key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2FloatMaps @Override public float computeFloat(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(short key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2FloatMaps @Override public float computeFloat(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public float mergeFloat(short key, float value, FloatFloatUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2FloatMaps @Override public float computeFloat(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloat(key, mappingFunction); } } @Override - public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfAbsent(short key, Short2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsent(key, mappingFunction); } } @Override - public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } - @Override public float computeFloatIfPresent(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresent(key, mappingFunction); } } @Override - public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } - @Override public float supplyFloatIfAbsent(short key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsent(key, valueProvider); } } @Override + public float computeFloatNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfAbsentNonDefault(short key, Short2FloatFunction mappingFunction) { synchronized(mutex) { return map.computeFloatIfAbsentNonDefault(key, mappingFunction); } } + @Override + public float computeFloatIfPresentNonDefault(short key, ShortFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeFloatIfPresentNonDefault(key, mappingFunction); } } + @Override public float supplyFloatIfAbsentNonDefault(short key, FloatSupplier valueProvider) { synchronized(mutex) { return map.supplyFloatIfAbsentNonDefault(key, valueProvider); } } @Override public float mergeFloat(short key, float value, FloatFloatUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeFloat(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2IntMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2IntMaps.java index efb3210..95c7d24 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2IntMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2IntMaps.java @@ -250,18 +250,18 @@ public class Short2IntMaps @Override public int computeInt(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(short key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2IntMaps @Override public int computeInt(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(short key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2IntMaps @Override public int computeInt(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public int mergeInt(short key, int value, IntIntUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2IntMaps @Override public int computeInt(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeInt(key, mappingFunction); } } @Override - public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } - @Override public int computeIntIfAbsent(short key, Short2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsent(key, mappingFunction); } } @Override - public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } - @Override public int computeIntIfPresent(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresent(key, mappingFunction); } } @Override - public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } - @Override public int supplyIntIfAbsent(short key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsent(key, valueProvider); } } @Override + public int computeIntNonDefault(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfAbsentNonDefault(short key, Short2IntFunction mappingFunction) { synchronized(mutex) { return map.computeIntIfAbsentNonDefault(key, mappingFunction); } } + @Override + public int computeIntIfPresentNonDefault(short key, ShortIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIntIfPresentNonDefault(key, mappingFunction); } } + @Override public int supplyIntIfAbsentNonDefault(short key, IntSupplier valueProvider) { synchronized(mutex) { return map.supplyIntIfAbsentNonDefault(key, valueProvider); } } @Override public int mergeInt(short key, int value, IntIntUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeInt(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2LongMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2LongMaps.java index 9e56bf1..f0e8323 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2LongMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2LongMaps.java @@ -250,18 +250,18 @@ public class Short2LongMaps @Override public long computeLong(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(short key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -312,18 +312,18 @@ public class Short2LongMaps @Override public long computeLong(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(short key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -547,18 +547,18 @@ public class Short2LongMaps @Override public long computeLong(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public long mergeLong(short key, long value, LongLongUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -955,18 +955,18 @@ public class Short2LongMaps @Override public long computeLong(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLong(key, mappingFunction); } } @Override - public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } - @Override public long computeLongIfAbsent(short key, Short2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsent(key, mappingFunction); } } @Override - public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } - @Override public long computeLongIfPresent(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresent(key, mappingFunction); } } @Override - public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } - @Override public long supplyLongIfAbsent(short key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsent(key, valueProvider); } } @Override + public long computeLongNonDefault(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfAbsentNonDefault(short key, Short2LongFunction mappingFunction) { synchronized(mutex) { return map.computeLongIfAbsentNonDefault(key, mappingFunction); } } + @Override + public long computeLongIfPresentNonDefault(short key, ShortLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeLongIfPresentNonDefault(key, mappingFunction); } } + @Override public long supplyLongIfAbsentNonDefault(short key, LongSupplier valueProvider) { synchronized(mutex) { return map.supplyLongIfAbsentNonDefault(key, valueProvider); } } @Override public long mergeLong(short key, long value, LongLongUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeLong(key, value, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ObjectMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ObjectMaps.java index c0e8c4f..694b1fb 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ObjectMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ObjectMaps.java @@ -266,20 +266,12 @@ public class Short2ObjectMaps @Override public V compute(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Short2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -325,20 +317,12 @@ public class Short2ObjectMaps @Override public V compute(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Short2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -561,20 +545,12 @@ public class Short2ObjectMaps @Override public V compute(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { throw new UnsupportedOperationException(); } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override public void mergeAll(Short2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -968,20 +944,12 @@ public class Short2ObjectMaps @Override public V compute(short key, ShortObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.compute(key, mappingFunction); } } @Override - public V computeNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeNonDefault(key, mappingFunction); } } - @Override public V computeIfAbsent(short key, ShortFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsent(key, mappingFunction); } } @Override - public V computeIfAbsentNonDefault(short key, ShortFunction mappingFunction) { synchronized(mutex) { return map.computeIfAbsentNonDefault(key, mappingFunction); } } - @Override public V computeIfPresent(short key, ShortObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresent(key, mappingFunction); } } @Override - public V computeIfPresentNonDefault(short key, ShortObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeIfPresentNonDefault(key, mappingFunction); } } - @Override public V supplyIfAbsent(short key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsent(key, valueProvider); } } @Override - public V supplyIfAbsentNonDefault(short key, ObjectSupplier valueProvider) { synchronized(mutex) { return map.supplyIfAbsentNonDefault(key, valueProvider); } } - @Override public V merge(short key, V value, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { return map.merge(key, value, mappingFunction); } } @Override public void mergeAll(Short2ObjectMap m, ObjectObjectUnaryOperator mappingFunction) { synchronized(mutex) { map.mergeAll(m, mappingFunction); } } diff --git a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ShortMaps.java b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ShortMaps.java index 27a0a11..07b0954 100644 --- a/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ShortMaps.java +++ b/src/main/java/speiger/src/collections/shorts/utils/maps/Short2ShortMaps.java @@ -249,18 +249,18 @@ public class Short2ShortMaps @Override public short computeShort(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(short key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -311,18 +311,18 @@ public class Short2ShortMaps @Override public short computeShort(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(short key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -546,18 +546,18 @@ public class Short2ShortMaps @Override public short computeShort(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @Override - public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } - @Override public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override + public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } + @Override public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { throw new UnsupportedOperationException(); } @Override public short mergeShort(short key, short value, ShortShortUnaryOperator mappingFunction) { throw new UnsupportedOperationException(); } @@ -954,18 +954,18 @@ public class Short2ShortMaps @Override public short computeShort(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShort(key, mappingFunction); } } @Override - public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } - @Override public short computeShortIfAbsent(short key, ShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsent(key, mappingFunction); } } @Override - public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } - @Override public short computeShortIfPresent(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresent(key, mappingFunction); } } @Override - public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } - @Override public short supplyShortIfAbsent(short key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsent(key, valueProvider); } } @Override + public short computeShortNonDefault(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfAbsentNonDefault(short key, ShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfAbsentNonDefault(key, mappingFunction); } } + @Override + public short computeShortIfPresentNonDefault(short key, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.computeShortIfPresentNonDefault(key, mappingFunction); } } + @Override public short supplyShortIfAbsentNonDefault(short key, ShortSupplier valueProvider) { synchronized(mutex) { return map.supplyShortIfAbsentNonDefault(key, valueProvider); } } @Override public short mergeShort(short key, short value, ShortShortUnaryOperator mappingFunction) { synchronized(mutex) { return map.mergeShort(key, value, mappingFunction); } }