From 477f3c9f40749df9f956609d5cfa54f36683be3a Mon Sep 17 00:00:00 2001 From: Speiger Date: Fri, 16 Dec 2022 13:03:28 +0100 Subject: [PATCH] Implemented ForEachIndexed into all collections --- .../templates/collections/Iterable.template | 12 ++++ .../collections/templates/lists/List.template | 1 + .../concurrent/ConcurrentOpenHashMap.template | 67 +++++++++++++++++++ .../LinkedOpenCustomHashMap.template | 43 ++++++++++++ .../customHash/OpenCustomHashMap.template | 37 ++++++++++ .../maps/impl/hash/LinkedOpenHashMap.template | 43 ++++++++++++ .../maps/impl/hash/OpenHashMap.template | 37 ++++++++++ .../immutable/ImmutableOpenHashMap.template | 43 ++++++++++++ .../maps/impl/misc/ArrayMap.template | 28 +++++++- .../maps/impl/tree/AVLTreeMap.template | 47 +++++++++++++ .../maps/impl/tree/RBTreeMap.template | 47 +++++++++++++ .../templates/queues/ArrayFIFOQueue.template | 10 +++ .../queues/ArrayPriorityQueue.template | 14 ++++ .../queues/HeapPriorityQueue.template | 7 ++ .../templates/sets/AVLTreeSet.template | 19 ++++++ .../templates/sets/ArraySet.template | 7 ++ .../sets/ImmutableOpenHashSet.template | 12 ++++ .../sets/LinkedOpenCustomHashSet.template | 12 ++++ .../templates/sets/LinkedOpenHashSet.template | 12 ++++ .../templates/sets/OpenCustomHashSet.template | 12 ++++ .../templates/sets/OpenHashSet.template | 11 +++ .../templates/sets/RBTreeSet.template | 18 +++++ 22 files changed, 538 insertions(+), 1 deletion(-) diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template index 0a610852..e2e0f792 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template @@ -18,6 +18,7 @@ import java.util.Comparator; #endif import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -110,6 +111,17 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable } #endif + /** + * A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over. + * @param action The action to be performed for each element + * @throws java.lang.NullPointerException if the specified action is null + */ + public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT())); + } + /** * Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner. * @param input the object that should be included diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/List.template b/src/builder/resources/speiger/assets/collections/templates/lists/List.template index 59faaf0b..080e374b 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/List.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/List.template @@ -366,6 +366,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List * @param action The action to be performed for each element * @throws java.lang.NullPointerException if the specified action is null */ + @Override public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { Objects.requireNonNull(action); for(int i = 0,m=size();i action) { + Objects.requireNonNull(action); + int count = 0; + for(int i = 0,m=segments.length;i void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -982,6 +1009,26 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int count = 0; + for(int i = 0,m=segments.length;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1230,6 +1277,26 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY } } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int count = 0; + for(int i = 0,m=segments.length;i void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template index a53409bd..85bcf7d6 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template @@ -19,6 +19,13 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif #if !TYPE_OBJECT && !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif @@ -687,6 +694,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index])); + index = (int)links[index]; + } + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -948,6 +967,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1111,6 +1142,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M } } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, values[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template index 1d6a8c6b..d736385c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template @@ -20,6 +20,13 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER; #if !VALUE_BOOLEAN || !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.FUNCTION; @@ -873,6 +880,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex])); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i])); + } + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -1110,6 +1127,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i]); } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, keys[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, keys[i]); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1266,6 +1293,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, values[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, values[i]); + } + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template index a46646ac..32a4e4bd 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template @@ -19,6 +19,13 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif #if !TYPE_OBJECT && !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif @@ -691,6 +698,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index])); + index = (int)links[index]; + } + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -947,6 +966,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1111,6 +1142,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G } } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, values[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template index ad0cb7b8..60060d1d 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template @@ -20,6 +20,13 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER; #if !VALUE_BOOLEAN || !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.FUNCTION; @@ -832,6 +839,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex])); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i])); + } + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -1065,6 +1082,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]); } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, keys[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, keys[i]); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1221,6 +1248,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(values[i]); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, values[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, values[i]); + } + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template index f74237fc..5d8f2f09 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template @@ -19,6 +19,13 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif #if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif @@ -664,6 +671,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index])); + index = (int)links[index]; + } + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -892,6 +911,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1053,6 +1084,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ } } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + int count = 0; + int index = firstIndex; + while(index != -1){ + action.accept(count++, values[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template index a3d0c0eb..3ba43418 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template @@ -19,6 +19,13 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif #if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif @@ -793,6 +800,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN } } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + for(int i = 0;i void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -991,11 +1006,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN for(int i = 0;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); for(int i = 0;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1841,6 +1856,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ action.accept(new BasicEntryKV_BRACES(entry.key, entry.value)); } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) + action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value)); + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -1973,6 +1996,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ action.accept(entry.value); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) + action.accept(index++, entry.value); + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -2321,6 +2352,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ action.accept(entry.value); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) + action.accept(index++, entry.value); + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -2478,6 +2517,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ action.accept(new BasicEntryKV_BRACES(entry.key, entry.value)); } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) + action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value)); + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template index 44aa0335..14b7e59c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template @@ -23,6 +23,13 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; +#if !TYPE_OBJECT && !VALUE_OBJECT +import speiger.src.collections.ints.functions.consumer.IntObjectConsumer; +#endif +#if !SAME_TYPE +import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER; +#endif #if !VALUE_BOOLEAN || !JDK_TYPE import speiger.src.collections.PACKAGE.functions.function.FUNCTION; #endif @@ -1209,6 +1216,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G action.accept(entry.key); } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry)) + action.accept(index++, entry.key); + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1907,6 +1922,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G action.accept(new BasicEntryKV_BRACES(entry.key, entry.value)); } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) + action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value)); + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); @@ -2039,6 +2062,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G action.accept(entry.value); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) + action.accept(index++, entry.value); + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -2387,6 +2418,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G action.accept(entry.value); } + @Override + public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) + action.accept(index++, entry.value); + } + @Override public void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -2544,6 +2583,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G action.accept(new BasicEntryKV_BRACES(entry.key, entry.value)); } + @Override + public void forEachIndexed(IntObjectConsumer action) { + Objects.requireNonNull(action); + int index = 0; + for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) + action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value)); + } + @Override public void forEach(E input, ObjectObjectConsumer action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template index 55ef4d19..4a522913 100644 --- a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template +++ b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template @@ -17,6 +17,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -262,6 +263,15 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K clearAndTrim(0); } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(first == last) return; + for(int i = 0,m=size();i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayPriorityQueue.template b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayPriorityQueue.template index b2831a61..c4e90477 100644 --- a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayPriorityQueue.template +++ b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayPriorityQueue.template @@ -18,6 +18,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -214,6 +215,13 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE return value; } + @Override + public KEY_TYPE first() { + if(isEmpty()) throw new NoSuchElementException(); + if(firstIndex == -1) findFirstIndex(); + return array[firstIndex]; + } + @Override public KEY_TYPE peek(int index) { if(index < 0 || index >= size) throw new NoSuchElementException(); @@ -268,6 +276,12 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE for(int i = 0,m=size;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/queues/HeapPriorityQueue.template b/src/builder/resources/speiger/assets/collections/templates/queues/HeapPriorityQueue.template index 4d8cdea8..3906caa6 100644 --- a/src/builder/resources/speiger/assets/collections/templates/queues/HeapPriorityQueue.template +++ b/src/builder/resources/speiger/assets/collections/templates/queues/HeapPriorityQueue.template @@ -18,6 +18,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -255,6 +256,12 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU for(int i = 0,m=size;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template index 1d7b99e2..51d1c115 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template @@ -19,6 +19,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -359,6 +360,15 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { + action.accept(index++, entry.key); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1198,6 +1208,15 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { + action.accept(index++, entry.key); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template index 79adf83e..b71994af 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template @@ -19,6 +19,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.ITERATOR; +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -396,6 +397,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im for(int i = 0;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template index 5f6bd61a..d56f6ca8 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template @@ -19,6 +19,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -328,6 +329,17 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template index ee1398e6..d638c903 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template @@ -23,6 +23,7 @@ import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR; import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -537,6 +538,17 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template index d63c051e..3e7818b0 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template @@ -21,6 +21,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -392,6 +393,17 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int count = 0; + int index = firstIndex; + while(index != -1) { + action.accept(count++, keys[index]); + index = (int)links[index]; + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template index 31426da9..6ac37b03 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template @@ -20,6 +20,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -506,6 +507,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T @Override public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { + Objects.requireNonNull(action); if(size() <= 0) return; if(containsNull) action.accept(keys[nullIndex]); for(int i = nullIndex-1;i>=0;i--) { @@ -513,6 +515,16 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, keys[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, keys[i]); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template index d59c1231..fe19c15d 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template @@ -20,6 +20,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -376,6 +377,16 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + if(size() <= 0) return; + if(containsNull) action.accept(0, keys[nullIndex]); + for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) { + if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, keys[i]); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template index 18f62c03..c7d5a832 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template @@ -19,6 +19,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; #if !JDK_FUNCTION import speiger.src.collections.PACKAGE.functions.function.PREDICATE; @@ -359,6 +360,14 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) + action.accept(index++, entry.key); + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action); @@ -1259,6 +1268,15 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE } } + @Override + public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { + Objects.requireNonNull(action); + int index = 0; + for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { + action.accept(index++, entry.key); + } + } + @Override public void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { Objects.requireNonNull(action);