Added forEach(CONSUMER, Input)

This commit is contained in:
2026-08-09 21:43:57 +02:00
parent 075f3ad183
commit 2306917b10
29 changed files with 2462 additions and 1842 deletions
@@ -1,8 +1,8 @@
package speiger.src.builder;
@SuppressWarnings("javadoc")
public enum RequiredType
{
BI_CLASS,
ENUM
}
package speiger.src.builder;
@SuppressWarnings("javadoc")
public enum RequiredType
{
BI_CLASS,
ENUM
}
@@ -1,123 +1,124 @@
package speiger.src.builder.modules;
import java.util.Arrays;
import java.util.List;
import speiger.src.builder.ClassType;
import speiger.src.builder.RequiredType;
import speiger.src.builder.dependencies.IDependency;
import speiger.src.builder.dependencies.ModuleDependency;
@SuppressWarnings("javadoc")
public class FunctionModule extends BaseModule
{
public static final BaseModule INSTANCE = new FunctionModule();
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(JavaModule.MODULE);
@Override
public String getModuleName() { return "Function"; }
@Override
public boolean isBiModule() { return true; }
@Override
protected void loadVariables() {}
@Override
protected void loadFlags() {}
@Override
protected void loadTestClasses() {}
@Override
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
return Arrays.asList(MODULE);
}
@Override
protected void loadBlockades()
{
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Optional", "Function", "UnaryOperator");
if(!keyType.needsCustomJDKType()) addBlockedFiles("Optional");
}
@Override
protected void loadRemappers()
{
addBiRequirement("BiConsumer", "");
addBiRequirement("UnaryOperator", "");
if(valueType == ClassType.BOOLEAN) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate");
}
else if(keyType.isObject() && !valueType.isObject()) {
addRequirement("Function", "%2$s", RequiredType.BI_CLASS);
addRemapper("Function", "To%sFunction");
}
else if(keyType == valueType) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"UnaryOperator");
}
else if(valueType.isObject()) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", "%sFunction");
}
else addBiRequirement("Function");
addRemapper("BiConsumer", "%sConsumer");
addRemapper("Optional", "Optional%s");
}
@Override
protected void loadFunctions()
{
addSimpleMapper("APPLY", keyType.getApply(valueType));
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
}
@Override
protected void loadClasses()
{
//Interfaces
addBiClassMapper("BI_CONSUMER", "Consumer", "");
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
addAbstractMapper("BI_FROM_INT_CONSUMER", "Int%sConsumer");
if(keyType.isObject()) {
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
}
else {
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"Function");
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
}
if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate");
else if(keyType.isObject() && !valueType.isObject()) addFunctionValueMappers("FUNCTION", "To%sFunction");
else if(keyType == valueType) addFunctionMappers("FUNCTION", "%sUnaryOperator");
else if(valueType.isObject()) addFunctionMappers("FUNCTION", "%sFunction");
else addBiClassMapper("FUNCTION", "Function", "2");
addFunctionMappers("PREDICATE", "%sPredicate");
addClassMapper("SUPPLIER", "Supplier");
addSimpleMapper("OPTIONAL", keyType.isObject() ? "Optional" : String.format("Optional%s", keyType.getFileType()));
addSimpleMapper("VALUE_OPTIONAL", valueType.isObject() ? "Optional" : String.format("Optional%s", valueType.getFileType()));
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
if(keyType.isObject())
{
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", "Consumer");
addSimpleMapper("IARRAY", "IObjectArray");
}
else
{
if(valueType.isObject())
{
addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer");
}
else addClassMapper("CONSUMER", "Consumer");
addFunctionMappers("IARRAY", "I%sArray");
}
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType()));
}
package speiger.src.builder.modules;
import java.util.Arrays;
import java.util.List;
import speiger.src.builder.ClassType;
import speiger.src.builder.RequiredType;
import speiger.src.builder.dependencies.IDependency;
import speiger.src.builder.dependencies.ModuleDependency;
@SuppressWarnings("javadoc")
public class FunctionModule extends BaseModule
{
public static final BaseModule INSTANCE = new FunctionModule();
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(JavaModule.MODULE);
@Override
public String getModuleName() { return "Function"; }
@Override
public boolean isBiModule() { return true; }
@Override
protected void loadVariables() {}
@Override
protected void loadFlags() {}
@Override
protected void loadTestClasses() {}
@Override
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
return Arrays.asList(MODULE);
}
@Override
protected void loadBlockades()
{
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Optional", "Function", "UnaryOperator");
if(!keyType.needsCustomJDKType()) addBlockedFiles("Optional");
}
@Override
protected void loadRemappers()
{
addBiRequirement("BiConsumer", "");
addBiRequirement("UnaryOperator", "");
if(valueType == ClassType.BOOLEAN) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate");
}
else if(keyType.isObject() && !valueType.isObject()) {
addRequirement("Function", "%2$s", RequiredType.BI_CLASS);
addRemapper("Function", "To%sFunction");
}
else if(keyType == valueType) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"UnaryOperator");
}
else if(valueType.isObject()) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", "%sFunction");
}
else addBiRequirement("Function");
addRemapper("BiConsumer", "%sConsumer");
addRemapper("Optional", "Optional%s");
}
@Override
protected void loadFunctions()
{
addSimpleMapper("APPLY", keyType.getApply(valueType));
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
}
@Override
protected void loadClasses()
{
//Interfaces
addBiClassMapper("BI_CONSUMER", "Consumer", "");
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
addAbstractMapper("BI_TO_OBJECT_CONSUMER", "%sObjectConsumer");
addAbstractMapper("BI_FROM_INT_CONSUMER", "Int%sConsumer");
if(keyType.isObject()) {
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
}
else {
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"Function");
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
}
if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate");
else if(keyType.isObject() && !valueType.isObject()) addFunctionValueMappers("FUNCTION", "To%sFunction");
else if(keyType == valueType) addFunctionMappers("FUNCTION", "%sUnaryOperator");
else if(valueType.isObject()) addFunctionMappers("FUNCTION", "%sFunction");
else addBiClassMapper("FUNCTION", "Function", "2");
addFunctionMappers("PREDICATE", "%sPredicate");
addClassMapper("SUPPLIER", "Supplier");
addSimpleMapper("OPTIONAL", keyType.isObject() ? "Optional" : String.format("Optional%s", keyType.getFileType()));
addSimpleMapper("VALUE_OPTIONAL", valueType.isObject() ? "Optional" : String.format("Optional%s", valueType.getFileType()));
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
if(keyType.isObject())
{
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", "Consumer");
addSimpleMapper("IARRAY", "IObjectArray");
}
else
{
if(valueType.isObject())
{
addSimpleMapper("VALUE_CONSUMER", "Consumer");
addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer");
}
else addClassMapper("CONSUMER", "Consumer");
addFunctionMappers("IARRAY", "I%sArray");
}
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType()));
}
}
@@ -39,6 +39,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
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 !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -153,6 +156,18 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
iterator().forEachRemaining(input, action);
}
/**
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
* @param action The action to be performed for each element
* @param input the object that should be included
* @param <E> the generic type of the Object
* @throws java.lang.NullPointerException if the specified action is null
*/
default <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
iterator().forEachRemaining(action, input);
}
#if SPLIT_ITERATOR_FEATURE
/**
* A Type Specific Type Splititerator to reduce boxing/unboxing
@@ -1,93 +1,108 @@
package speiger.src.collections.PACKAGE.collections;
import java.util.Iterator;
import java.util.Objects;
#if !TYPE_OBJECT
import java.util.function.Consumer;
import speiger.src.collections.PACKAGE.functions.CONSUMER;
#endif
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
/**
* A Type-Specific {@link Iterator} that reduces (un)boxing
* @Type(T)
*/
public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
{
#if !TYPE_OBJECT
/**
* Returns the next element in the iteration.
*
* @return the next element in the iteration
* @throws java.util.NoSuchElementException if the iteration has no more elements
* @see Iterator#next()
*/
public KEY_TYPE NEXT();
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
public default CLASS_TYPE next() { return KEY_TO_OBJ(NEXT()); }
/**
* Performs the given action for each remaining element until all elements
* have been processed or the action throws an exception. Actions are
* performed in the order of iteration, if that order is specified.
* Exceptions thrown by the action are relayed to the caller.
*
* @implSpec
* <p>The default implementation behaves as if:
* <pre>{@code
* while (hasNext()) action.accept(NEXT());
* }</pre>
*
* @param action The action to be performed for each element
* @throws java.lang.NullPointerException if the specified action is null
* @see Iterator#forEachRemaining(Consumer)
*/
public default void forEachRemaining(CONSUMER action) {
Objects.requireNonNull(action);
while(hasNext()) { action.accept(NEXT()); }
}
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Deprecated
@Override
default void forEachRemaining(Consumer<? super CLASS_TYPE> action) {
Objects.requireNonNull(action);
forEachRemaining(action::accept);
}
#endif
/**
* 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
* @param action The action to be performed for each element
* @param <E> the generic type of the Object
* @throws java.lang.NullPointerException if the specified action is null
*/
default <E> void forEachRemaining(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
Objects.requireNonNull(action);
while(hasNext()) { action.accept(input, NEXT()); }
}
/**
* Skips the Given amount of elements if possible. A Optimization function to skip elements faster if the implementation allows it.
* @param amount the amount of elements that should be skipped
* @return the amount of elements that were skipped
*/
default int skip(int amount) {
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
int i = 0;
for(;i<amount && hasNext();NEXT(), i++);
return i;
}
package speiger.src.collections.PACKAGE.collections;
import java.util.Iterator;
import java.util.Objects;
#if !TYPE_OBJECT
import java.util.function.Consumer;
import speiger.src.collections.PACKAGE.functions.CONSUMER;
#endif
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
/**
* A Type-Specific {@link Iterator} that reduces (un)boxing
* @Type(T)
*/
public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
{
#if !TYPE_OBJECT
/**
* Returns the next element in the iteration.
*
* @return the next element in the iteration
* @throws java.util.NoSuchElementException if the iteration has no more elements
* @see Iterator#next()
*/
public KEY_TYPE NEXT();
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Override
@Deprecated
public default CLASS_TYPE next() { return KEY_TO_OBJ(NEXT()); }
/**
* Performs the given action for each remaining element until all elements
* have been processed or the action throws an exception. Actions are
* performed in the order of iteration, if that order is specified.
* Exceptions thrown by the action are relayed to the caller.
*
* @implSpec
* <p>The default implementation behaves as if:
* <pre>{@code
* while (hasNext()) action.accept(NEXT());
* }</pre>
*
* @param action The action to be performed for each element
* @throws java.lang.NullPointerException if the specified action is null
* @see Iterator#forEachRemaining(Consumer)
*/
public default void forEachRemaining(CONSUMER action) {
Objects.requireNonNull(action);
while(hasNext()) { action.accept(NEXT()); }
}
/** {@inheritDoc}
* <p>This default implementation delegates to the corresponding type-specific function.
* @deprecated Please use the corresponding type-specific function instead.
*/
@Deprecated
@Override
default void forEachRemaining(Consumer<? super CLASS_TYPE> action) {
Objects.requireNonNull(action);
forEachRemaining(action::accept);
}
#endif
/**
* 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
* @param action The action to be performed for each element
* @param <E> the generic type of the Object
* @throws java.lang.NullPointerException if the specified action is null
*/
default <E> void forEachRemaining(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
Objects.requireNonNull(action);
while(hasNext()) { action.accept(input, NEXT()); }
}
/**
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
* @param action The action to be performed for each element
* @param input the object that should be included
* @param <E> the generic type of the Object
* @throws java.lang.NullPointerException if the specified action is null
*/
default <E> void forEachRemaining(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
while(hasNext()) { action.accept(NEXT(), input); }
}
/**
* Skips the Given amount of elements if possible. A Optimization function to skip elements faster if the implementation allows it.
* @param amount the amount of elements that should be skipped
* @return the amount of elements that were skipped
*/
default int skip(int amount) {
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
int i = 0;
for(;i<amount && hasNext();NEXT(), i++);
return i;
}
}
@@ -50,7 +50,11 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
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 !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -700,7 +704,21 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++)
action.accept(input, data[i]);
action.accept(input, data[i]);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++)
action.accept(data[i], input);
}
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++)
action.accept(i, data[i]);
}
@Override
@@ -49,7 +49,11 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
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 !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -826,6 +830,22 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
action.accept(input, data[i]);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
KEY_TYPE[] data = this.data;
for(int i = 0,m=data.length;i<m;i++)
action.accept(data[i], input);
}
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
Objects.requireNonNull(action);
KEY_TYPE[] data = this.data;
for(int i = 0,m=data.length;i<m;i++)
action.accept(i, data[i]);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -47,6 +47,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -512,6 +515,13 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
action.accept(input, entry.value);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next)
action.accept(entry.value, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -25,15 +25,20 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
#endif
import speiger.src.collections.PACKAGE.functions.CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !VALUE_BOOLEAN || !JDK_TYPE
@@ -82,6 +87,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
@@ -758,6 +766,25 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0,m=segments.length;i<m;i++) {
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
long stamp = seg.readLock();
try {
int index = seg.firstIndex;
while(index != -1) {
action.accept(new ValueMapEntry(index, i), input);
index = (int)seg.links[index];
}
}
finally {
seg.unlockRead(stamp);
}
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -1087,6 +1114,25 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0,m=segments.length;i<m;i++) {
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
long stamp = seg.readLock();
try {
int index = seg.firstIndex;
while(index != -1){
action.accept(seg.keys[index], input);
index = (int)seg.links[index];
}
}
finally {
seg.unlockRead(stamp);
}
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1355,6 +1401,25 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0,m=segments.length;i<m;i++) {
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
long stamp = seg.readLock();
try {
int index = seg.firstIndex;
while(index != -1){
action.accept(seg.values[index], input);
index = (int)seg.links[index];
}
}
finally {
seg.unlockRead(stamp);
}
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -21,9 +21,14 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -33,7 +38,7 @@ import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUME
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
@@ -60,6 +65,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -827,6 +835,17 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1) {
action.accept(new ValueMapEntry(index), input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -1108,6 +1127,17 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1291,6 +1321,17 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(values[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -22,15 +22,20 @@ import java.util.VALUE_OPTIONAL;
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;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !VALUE_BOOLEAN || !JDK_TYPE
@@ -77,7 +82,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !SAME_TYPE
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -1030,6 +1037,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(new ValueMapEntry(nullIndex), input);
for(int i = nullIndex-1;i>=0;i--) {
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(new ValueMapEntry(i), input);
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -1277,6 +1294,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(keys[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i], input);
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1443,6 +1470,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(values[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i], input);
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -21,9 +21,14 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -33,7 +38,7 @@ import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUME
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
@@ -58,7 +63,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !SAME_TYPE
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -831,6 +838,17 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1) {
action.accept(new ValueMapEntry(index), input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -1110,6 +1128,17 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1295,6 +1324,17 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(values[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -22,15 +22,20 @@ import java.util.VALUE_OPTIONAL;
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;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !VALUE_BOOLEAN || !JDK_TYPE
@@ -76,7 +81,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
@@ -989,6 +996,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(new ValueMapEntry(nullIndex), input);
for(int i = nullIndex-1;i>=0;i--) {
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(new ValueMapEntry(i), input);
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -1232,6 +1249,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(keys[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i], input);
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1398,6 +1425,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(values[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(values[i], input);
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -21,9 +21,14 @@ import java.util.VALUE_OPTIONAL;
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;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -35,7 +40,7 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !VALUE_BOOLEAN || !JDK_TYPE
@@ -82,6 +87,9 @@ import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_ARRAYS;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#endif
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
#if !TYPE_OBJECT
@@ -739,6 +747,17 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1) {
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]), input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -990,6 +1009,17 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1166,6 +1196,17 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
}
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
int index = firstIndex;
while(index != -1){
action.accept(values[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -21,9 +21,14 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -35,7 +40,7 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !VALUE_BOOLEAN || !JDK_TYPE
@@ -66,9 +71,12 @@ import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#endif
#if !SAME_TYPE
#if VALUE_OBJECT
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -972,6 +980,13 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
action.accept(input, new ValueMapEntry(i));
}
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++) {
action.accept(new ValueMapEntry(i), input);
}
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
@@ -1181,6 +1196,12 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
for(int i = 0;i<size;action.accept(input, keys[i++]));
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0;i<size;action.accept(keys[i++], input));
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1323,6 +1344,18 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
for(int i = 0;i<size;action.accept(i, values[i++]));
}
@Override
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
Objects.requireNonNull(action);
for(int i = 0;i<size;action.accept(input, values[i++]));
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0;i<size;action.accept(values[i++], input));
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -26,9 +26,14 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
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;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -37,7 +42,7 @@ import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUME
#if !VALUE_BOOLEAN || !JDK_TYPE
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !TYPE_OBJECT && !JDK_TYPE
@@ -76,6 +81,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -1284,6 +1292,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1986,6 +2001,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -2126,6 +2148,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
action.accept(input, entry.value);
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
action.accept(entry.value, input);
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -2647,6 +2676,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -25,9 +25,14 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
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;
#if !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#endif
#if !TYPE_INT || !SAME_TYPE
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
#if !TYPE_OBJECT && !VALUE_OBJECT
#endif
#if !TYPE_OBJECT && !VALUE_OBJECT && !TYPE_INT
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
#endif
#if !SAME_TYPE && !TYPE_INT
@@ -36,7 +41,7 @@ import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUME
#if !VALUE_BOOLEAN || !JDK_TYPE
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
#endif
#if !TYPE_INT || !SAME_TYPE
#if !TYPE_INT || !SAME_TYPE || !VALUE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
#endif
#if !TYPE_OBJECT && !JDK_TYPE
@@ -74,7 +79,9 @@ import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
#if !SAME_TYPE
#if !TYPE_OBJECT
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
#endif
#if !VALUE_OBJECT && !VALUE_INT
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_VALUE
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
@@ -1340,6 +1347,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -2052,6 +2066,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -2192,6 +2213,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
action.accept(input, entry.value);
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
action.accept(entry.value, input);
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -2548,6 +2576,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
action.accept(input, entry.value);
}
@Override
public <E> void forEach(VALUE_BI_TO_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
action.accept(entry.value, input);
}
@Override
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -2713,6 +2748,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
}
@Override
public <E> void forEach(ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action, E input) {
Objects.requireNonNull(action);
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
}
@Override
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
Objects.requireNonNull(filter);
@@ -33,6 +33,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -425,6 +428,13 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1311,6 +1321,13 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry))
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
File diff suppressed because it is too large Load Diff
@@ -27,6 +27,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -363,6 +366,16 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
int index = firstIndex;
while(index != -1) {
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -37,6 +37,9 @@ 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 !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -683,6 +686,16 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
int index = firstIndex;
while(index != -1) {
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -35,6 +35,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -538,6 +541,16 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
int index = firstIndex;
while(index != -1) {
action.accept(keys[index], input);
index = (int)links[index];
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -34,6 +34,9 @@ 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 !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -622,6 +625,16 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(keys[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i], input);
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -34,6 +34,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -485,6 +488,16 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
}
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
if(size() <= 0) return;
if(containsNull) action.accept(keys[nullIndex], input);
for(int i = nullIndex-1;i>=0;i--) {
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i], input);
}
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -33,6 +33,9 @@ import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !JDK_FUNCTION
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
#endif
@@ -424,6 +427,13 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -1371,6 +1381,13 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
action.accept(input, entry.key);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry))
action.accept(entry.key, input);
}
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
Objects.requireNonNull(filter);
@@ -46,6 +46,9 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
#if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.functions.consumer.BI_TO_OBJECT_CONSUMER;
#endif
#if !TYPE_BOOLEAN
import speiger.src.collections.utils.HashUtil;
#endif
@@ -150,6 +153,9 @@ public class COLLECTIONS
/**
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
*/
#if !TYPE_OBJECT
@SuppressWarnings("exports")
#endif
public static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
return new CollectionWrapperBRACES();
}
@@ -294,6 +300,13 @@ public class COLLECTIONS
action.accept(elements[i]);
}
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++)
action.accept(i, elements[i]);
}
@Override
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
Objects.requireNonNull(action);
@@ -301,6 +314,13 @@ public class COLLECTIONS
action.accept(input, elements[i]);
}
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) {
Objects.requireNonNull(action);
for(int i = 0;i<size;i++)
action.accept(elements[i], input);
}
@Override
public boolean trim(int size) {
if(size > size() || size() == elements.length) return false;
@@ -855,6 +875,10 @@ public class COLLECTIONS
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { synchronized(mutex) { c.forEachIndexed(action); } }
@Override
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { synchronized(mutex) { c.forEach(input, action); } }
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) { synchronized(mutex) { c.forEach(action, input); } }
@Override
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
@Override
public boolean equals(Object obj) {
@@ -864,8 +888,6 @@ public class COLLECTIONS
@Override
public String toString() { synchronized(mutex) { return c.toString(); } }
@Override
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { synchronized(mutex) { c.forEach(input, action); } }
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.matchesAny(filter); } }
@Override
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.matchesNone(filter); } }
@@ -1010,14 +1032,16 @@ public class COLLECTIONS
@Override
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { c.forEachIndexed(action); }
@Override
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { c.forEach(input, action); }
@Override
public <E> void forEach(BI_TO_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action, E input) { c.forEach(action, input); }
@Override
public int hashCode() { return c.hashCode(); }
@Override
public boolean equals(Object obj) { return obj == this || c.equals(obj); }
@Override
public String toString() { return c.toString(); }
@Override
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { c.forEach(input, action); }
@Override
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { return c.matchesAny(filter); }
@Override
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { return c.matchesNone(filter); }
@@ -44,6 +44,15 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
}
#ignore
@CollectionFeature.Require(absent = KNOWN_ORDER)
public void testForEachExtraUnknownOrder() {
#endignore
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
collection.forEach(elements, (K, V) -> V.add(K));
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
}
#ignore
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachKnownOrder() {
@@ -70,4 +79,13 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
collection.forEach(elements, LIST::add);
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
}
#ignore
@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachExtraKnownOrderReverse() {
#endignore
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
collection.forEach((K, V) -> V.add(K), elements);
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
}
}
@@ -1,20 +1,20 @@
package speiger.src.collections.utils;
import java.util.RandomAccess;
/**
* A Helper interface that allows to detect if the Underlying implementation is
* using a Array. This allows to read methods through synchronization layers.
* Also it implements {@link RandomAccess} and {@link ITrimmable}
*/
public interface IArray extends RandomAccess, ITrimmable
{
/**
* Increases the capacity of this implementation instance, if necessary,
* to ensure that it can hold at least the number of elements specified by
* the minimum capacity argument.
*
* @param size the desired minimum capacity
*/
public void ensureCapacity(int size);
}
package speiger.src.collections.utils;
import java.util.RandomAccess;
/**
* A Helper interface that allows to detect if the Underlying implementation is
* using a Array. This allows to read methods through synchronization layers.
* Also it implements {@link RandomAccess} and {@link ITrimmable}
*/
public interface IArray extends RandomAccess, ITrimmable
{
/**
* Increases the capacity of this implementation instance, if necessary,
* to ensure that it can hold at least the number of elements specified by
* the minimum capacity argument.
*
* @param size the desired minimum capacity
*/
public void ensureCapacity(int size);
}
@@ -1,178 +1,178 @@
package speiger.src.collections.utils;
import java.util.Random;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
/**
* Helper class that provides functions that are shared within the library.
* On top of that it provides some helper functions that allow control of some internals of the Library
*/
public class SanityChecks
{
/** Max Possible ArraySize without the JVM Crashing */
public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
private static ForkJoinPool WORK_POOL = ForkJoinPool.commonPool();
private static boolean FORCE_IGNORE_PARALLELISM = false;
private static ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
private static ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
private static ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
/**
* Internal function to cast a Integer to a Byte
* @param value that should be turned into a byte
* @return the value as a byte
* @throws IllegalStateException if the value does not fit within a byte
*/
public static byte castToByte(int value) {
if(value > Byte.MAX_VALUE || value < Byte.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Byte[-128,127] range");
return (byte)value;
}
/**
* Internal function to cast a Integer to a Short
* @param value that should be turned into a short
* @return the value as a short
* @throws IllegalStateException if the value does not fit within a short
*/
public static short castToShort(int value) {
if(value > Short.MAX_VALUE || value < Short.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Short[-32768,32767] range");
return (short)value;
}
/**
* Internal function to cast a Integer to a Character
* @param value that should be turned into a char
* @return the value as a char
* @throws IllegalStateException if the value does not fit within a char
*/
public static char castToChar(int value) {
if(value > Character.MAX_VALUE || value < Character.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Character[0,65535] range");
return (char)value;
}
/**
* Internal function to cast a Double to a Double
* @param value that should be turned into a float
* @return the value as a float
* @throws IllegalStateException if the value does not fit within a float
*/
public static float castToFloat(double value) {
if(Double.isNaN(value)) return Float.NaN;
if(Double.isInfinite(value)) return value > 0 ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY;
if(value < -Float.MAX_VALUE || value > Float.MAX_VALUE) throw new IllegalStateException("Value ["+value+"] out of Float range");
return (float)value;
}
/**
* Internal function that checks if the given array-size is big enough for the access.
* @param arraySize the size of the Array
* @param offset the offset of the access
* @param accessSize the length of the access
* @throws IllegalStateException if offset or accessSize is negative or the range goes out of the array-size
*/
public static void checkArrayCapacity(int arraySize, int offset, int accessSize) {
if(offset < 0) throw new IndexOutOfBoundsException("Offset is negative ("+offset+")");
else if(accessSize < 0) throw new IllegalArgumentException("Size is negative ("+accessSize+")");
else if(arraySize < offset + accessSize) throw new IndexOutOfBoundsException("Index (" + (offset + accessSize) + ") is not in size (" + arraySize + ")");
}
/**
* Returns if the current thread-pool can handle Multi-threading tasks
* @return true if the thread-count is bigger the 1
*/
public static boolean canParallelTask() {
return getPool().getParallelism() > 1 || FORCE_IGNORE_PARALLELISM;
}
/**
* Helper method to start a ForkJoinTask. This method will await the finalization of said task
* @param task the Task to invoke
* @param <T> the type of the task
*/
public static <T> void invokeTask(ForkJoinTask<T> task) {
if(FORCE_ASYNC.get().booleanValue()) invokeAsyncTask(task);
else getPool().invoke(task);
}
/**
* Helper method to start a ForkJoinTask. This method will not await the finalization of said task
* @param task the Task to invoke
* @param <T> the type of the task
*/
public static <T> void invokeAsyncTask(ForkJoinTask<T> task) {
getPool().execute(task);
}
/**
* A Helper method to start a Async Task. This method will not await the finalization of said task
* @param task the Task to invoke
*/
public static void invokeAsyncTask(Runnable task) {
getPool().execute(task);
}
/**
* Helper method to control what ForkJoinPool is being used for any given task.
* @note this method is not thread-save. It is only there to provide control over how Library specific Threaded tasks are handled.
* @param pool The ForkJoinPool that should receive the tasks. If null {@link ForkJoinPool#commonPool()} is set instead
*/
public static void setWorkPool(ForkJoinPool pool) {
WORK_POOL = pool == null ? ForkJoinPool.commonPool() : pool;
}
private static ForkJoinPool getPool() {
if(FORCE_TASK_POOL.get().booleanValue()) {
ForkJoinPool pool = ForkJoinTask.getPool();
if(pool != null) return pool;
}
return WORK_POOL;
}
/**
* Helper method to detect if the Current Thread forces not to await task completion.
* @return if the Current Thread has not to await task completion.
*/
public static boolean isForcedAsync() {
return FORCE_ASYNC.get().booleanValue();
}
/**
* Helper method to detect if the current thread forces to execute tasks in the current Thread-pool if it is a ForkJoinPool.
* @return if the task checks the current pool to be executed in if it is valid.
*/
public static boolean isForcedTaskPool() {
return FORCE_TASK_POOL.get().booleanValue();
}
/**
* Helper method to decide if the current thread should forcefully not wait on tasks to be completed.
* @param value it tasks should not be awaited for
*/
public static void setForcedAsync(boolean value) {
FORCE_ASYNC.set(Boolean.valueOf(value));
}
/**
* Helper method to decide if it should be checked for if the current thread is a ThreadPool Worker (ForkJoinPool Worker to be specific) and if tasks should be delegated into it.
* @param value if the current thread should check if it is a ThreadPoolWorker.
*/
public static void setForcedTaskPool(boolean value) {
FORCE_TASK_POOL.set(Boolean.valueOf(value));
}
/**
* Helper method to decide if Parallelism should be checked or not.
* @param value if the Parallelism should be ignored
*/
public static void setForceIgnoreParallelism(boolean value) {
FORCE_IGNORE_PARALLELISM = value;
}
/**
* @return Thread Specific Random needed for internal functions in this library.
*/
public static Random getRandom() {
return RANDOM.get();
}
}
package speiger.src.collections.utils;
import java.util.Random;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
/**
* Helper class that provides functions that are shared within the library.
* On top of that it provides some helper functions that allow control of some internals of the Library
*/
public class SanityChecks
{
/** Max Possible ArraySize without the JVM Crashing */
public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
private static ForkJoinPool WORK_POOL = ForkJoinPool.commonPool();
private static boolean FORCE_IGNORE_PARALLELISM = false;
private static ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
private static ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
private static ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
/**
* Internal function to cast a Integer to a Byte
* @param value that should be turned into a byte
* @return the value as a byte
* @throws IllegalStateException if the value does not fit within a byte
*/
public static byte castToByte(int value) {
if(value > Byte.MAX_VALUE || value < Byte.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Byte[-128,127] range");
return (byte)value;
}
/**
* Internal function to cast a Integer to a Short
* @param value that should be turned into a short
* @return the value as a short
* @throws IllegalStateException if the value does not fit within a short
*/
public static short castToShort(int value) {
if(value > Short.MAX_VALUE || value < Short.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Short[-32768,32767] range");
return (short)value;
}
/**
* Internal function to cast a Integer to a Character
* @param value that should be turned into a char
* @return the value as a char
* @throws IllegalStateException if the value does not fit within a char
*/
public static char castToChar(int value) {
if(value > Character.MAX_VALUE || value < Character.MIN_VALUE) throw new IllegalStateException("Value ["+value+"] out of Character[0,65535] range");
return (char)value;
}
/**
* Internal function to cast a Double to a Double
* @param value that should be turned into a float
* @return the value as a float
* @throws IllegalStateException if the value does not fit within a float
*/
public static float castToFloat(double value) {
if(Double.isNaN(value)) return Float.NaN;
if(Double.isInfinite(value)) return value > 0 ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY;
if(value < -Float.MAX_VALUE || value > Float.MAX_VALUE) throw new IllegalStateException("Value ["+value+"] out of Float range");
return (float)value;
}
/**
* Internal function that checks if the given array-size is big enough for the access.
* @param arraySize the size of the Array
* @param offset the offset of the access
* @param accessSize the length of the access
* @throws IllegalStateException if offset or accessSize is negative or the range goes out of the array-size
*/
public static void checkArrayCapacity(int arraySize, int offset, int accessSize) {
if(offset < 0) throw new IndexOutOfBoundsException("Offset is negative ("+offset+")");
else if(accessSize < 0) throw new IllegalArgumentException("Size is negative ("+accessSize+")");
else if(arraySize < offset + accessSize) throw new IndexOutOfBoundsException("Index (" + (offset + accessSize) + ") is not in size (" + arraySize + ")");
}
/**
* Returns if the current thread-pool can handle Multi-threading tasks
* @return true if the thread-count is bigger the 1
*/
public static boolean canParallelTask() {
return getPool().getParallelism() > 1 || FORCE_IGNORE_PARALLELISM;
}
/**
* Helper method to start a ForkJoinTask. This method will await the finalization of said task
* @param task the Task to invoke
* @param <T> the type of the task
*/
public static <T> void invokeTask(ForkJoinTask<T> task) {
if(FORCE_ASYNC.get().booleanValue()) invokeAsyncTask(task);
else getPool().invoke(task);
}
/**
* Helper method to start a ForkJoinTask. This method will not await the finalization of said task
* @param task the Task to invoke
* @param <T> the type of the task
*/
public static <T> void invokeAsyncTask(ForkJoinTask<T> task) {
getPool().execute(task);
}
/**
* A Helper method to start a Async Task. This method will not await the finalization of said task
* @param task the Task to invoke
*/
public static void invokeAsyncTask(Runnable task) {
getPool().execute(task);
}
/**
* Helper method to control what ForkJoinPool is being used for any given task.
* @note this method is not thread-save. It is only there to provide control over how Library specific Threaded tasks are handled.
* @param pool The ForkJoinPool that should receive the tasks. If null {@link ForkJoinPool#commonPool()} is set instead
*/
public static void setWorkPool(ForkJoinPool pool) {
WORK_POOL = pool == null ? ForkJoinPool.commonPool() : pool;
}
private static ForkJoinPool getPool() {
if(FORCE_TASK_POOL.get().booleanValue()) {
ForkJoinPool pool = ForkJoinTask.getPool();
if(pool != null) return pool;
}
return WORK_POOL;
}
/**
* Helper method to detect if the Current Thread forces not to await task completion.
* @return if the Current Thread has not to await task completion.
*/
public static boolean isForcedAsync() {
return FORCE_ASYNC.get().booleanValue();
}
/**
* Helper method to detect if the current thread forces to execute tasks in the current Thread-pool if it is a ForkJoinPool.
* @return if the task checks the current pool to be executed in if it is valid.
*/
public static boolean isForcedTaskPool() {
return FORCE_TASK_POOL.get().booleanValue();
}
/**
* Helper method to decide if the current thread should forcefully not wait on tasks to be completed.
* @param value it tasks should not be awaited for
*/
public static void setForcedAsync(boolean value) {
FORCE_ASYNC.set(Boolean.valueOf(value));
}
/**
* Helper method to decide if it should be checked for if the current thread is a ThreadPool Worker (ForkJoinPool Worker to be specific) and if tasks should be delegated into it.
* @param value if the current thread should check if it is a ThreadPoolWorker.
*/
public static void setForcedTaskPool(boolean value) {
FORCE_TASK_POOL.set(Boolean.valueOf(value));
}
/**
* Helper method to decide if Parallelism should be checked or not.
* @param value if the Parallelism should be ignored
*/
public static void setForceIgnoreParallelism(boolean value) {
FORCE_IGNORE_PARALLELISM = value;
}
/**
* @return Thread Specific Random needed for internal functions in this library.
*/
public static Random getRandom() {
return RANDOM.get();
}
}