forked from Speiger/Primitive-Collections
Added forEachIndexed
This commit is contained in:
parent
5650c6e69b
commit
3f6e7fbb88
|
@ -6,6 +6,7 @@
|
||||||
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
||||||
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
||||||
- Added: Functions of a BooleanValue have now alwaysTrue/False function.
|
- Added: Functions of a BooleanValue have now alwaysTrue/False function.
|
||||||
|
- Added: ForEachIndexed for Lists only for now. (Might get added to others too if necessary)
|
||||||
- Fixed: putIfAbsent now replaces defaultValues
|
- Fixed: putIfAbsent now replaces defaultValues
|
||||||
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
||||||
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class FunctionModule extends BaseModule
|
||||||
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
||||||
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
||||||
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
||||||
|
addAbstractMapper("BI_FROM_INT_CONSUMER", "Int%sConsumer");
|
||||||
if(keyType.isObject()) {
|
if(keyType.isObject()) {
|
||||||
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
|
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
|
||||||
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
||||||
|
|
|
@ -32,6 +32,7 @@ import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
@ -420,6 +421,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST 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.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
|
|
|
@ -5,17 +5,18 @@ import java.nio.JAVA_BUFFER;
|
||||||
#endif
|
#endif
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
import java.util.function.UnaryOperator;
|
#endif
|
||||||
#else if TYPE_OBJECT
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Comparator;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
@ -360,6 +361,15 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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);
|
||||||
|
for(int i = 0,m=size();i<m;action.accept(i, GET_KEY(i++)));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A Type-Specific Iterator of listIterator
|
* A Type-Specific Iterator of listIterator
|
||||||
* @see java.util.List#listIterator
|
* @see java.util.List#listIterator
|
||||||
|
|
Loading…
Reference in New Issue