Compare commits
No commits in common. "3d39d5526d76d459e2551d6bbaea0dcfa17863d1" and "f0139d1a22d493aca41156cd52896e3936575e97" have entirely different histories.
3d39d5526d
...
f0139d1a22
@ -2,7 +2,7 @@
|
|||||||
[](https://jitpack.io/#Speiger/Primitive-Collections)
|
[](https://jitpack.io/#Speiger/Primitive-Collections)
|
||||||

|

|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
[](https://codecov.io/gh/Speiger/Primitive-Collections)
|
[](https://codecov.io/gh/Speiger/Primitive-Collections)
|
||||||
|
|||||||
@ -34,8 +34,7 @@ public class FunctionModule extends BaseModule
|
|||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Optional", "Function", "UnaryOperator");
|
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Function", "UnaryOperator");
|
||||||
if(!keyType.needsCustomJDKType()) addBlockedFiles("Optional");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,7 +60,6 @@ public class FunctionModule extends BaseModule
|
|||||||
}
|
}
|
||||||
else addBiRequirement("Function");
|
else addBiRequirement("Function");
|
||||||
addRemapper("BiConsumer", "%sConsumer");
|
addRemapper("BiConsumer", "%sConsumer");
|
||||||
addRemapper("Optional", "Optional%s");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -96,8 +94,6 @@ public class FunctionModule extends BaseModule
|
|||||||
|
|
||||||
addFunctionMappers("PREDICATE", "%sPredicate");
|
addFunctionMappers("PREDICATE", "%sPredicate");
|
||||||
addClassMapper("SUPPLIER", "Supplier");
|
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");
|
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
||||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
||||||
if(keyType.isObject())
|
if(keyType.isObject())
|
||||||
|
|||||||
@ -60,8 +60,6 @@ public class JavaModule extends BaseModule
|
|||||||
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
addSimpleMapper("GET_OPTIONAL", keyType.isObject() ? "ofNullable" : "of");
|
|
||||||
addSimpleMapper("GET_OPTIONAL_VALUE", valueType.isObject() ? "ofNullable" : "of");
|
|
||||||
|
|
||||||
//Shared by Maps and Pairs so moved to java.
|
//Shared by Maps and Pairs so moved to java.
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||||
|
|||||||
@ -5,9 +5,6 @@ import java.util.function.Consumer;
|
|||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
@ -33,9 +30,6 @@ import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
|||||||
#endif
|
#endif
|
||||||
#enditerate
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
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.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;
|
||||||
@ -414,13 +408,13 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param filter that should be applied
|
* @param filter that should be applied
|
||||||
* @return the found value or the null equivalent variant.
|
* @return the found value or the null equivalent variant.
|
||||||
*/
|
*/
|
||||||
default OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
if(filter.test(entry)) return OPTIONAL.GET_OPTIONAL(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -465,7 +459,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param operator the operation that should be applied
|
* @param operator the operation that should be applied
|
||||||
* @return the reduction result, returns null value if nothing was found
|
* @return the reduction result, returns null value if nothing was found
|
||||||
*/
|
*/
|
||||||
default OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -477,7 +471,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,89 +0,0 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public final class OPTIONAL KEY_GENERIC_TYPE {
|
|
||||||
private static final OPTIONAL NO_GENERIC_TYPE EMPTY = new OPTIONALBRACES();
|
|
||||||
|
|
||||||
private final boolean isPresent;
|
|
||||||
private final KEY_TYPE value;
|
|
||||||
|
|
||||||
private OPTIONAL() {
|
|
||||||
this.isPresent = false;
|
|
||||||
this.value = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OPTIONAL(KEY_TYPE value) {
|
|
||||||
this.isPresent = true;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OPTIONAL KEY_GENERIC_TYPE empty() {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OPTIONAL KEY_GENERIC_TYPE of(KEY_TYPE value) {
|
|
||||||
return new OPTIONALBRACES(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE SUPPLY_GET() {
|
|
||||||
if(!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPresent() {
|
|
||||||
return isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return !isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresent(CONSUMER KEY_GENERIC_TYPE consumer) {
|
|
||||||
if(isPresent) consumer.accept(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresentOrElse(CONSUMER KEY_GENERIC_TYPE action, Runnable emptyAction) {
|
|
||||||
if (isPresent) action.accept(value);
|
|
||||||
else emptyAction.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElse(KEY_TYPE other) {
|
|
||||||
return isPresent ? value : other;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElseGet(SUPPLIER KEY_GENERIC_TYPE other) {
|
|
||||||
return isPresent ? value : other.SUPPLY_GET();
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElseThrow() {
|
|
||||||
if (!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <X extends Throwable> KEY_TYPE orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
|
||||||
if(isPresent) return value;
|
|
||||||
else throw exceptionSupplier.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == this) return true;
|
|
||||||
if(obj instanceof OPTIONAL) {
|
|
||||||
OPTIONAL KEY_GENERIC_TYPE other = (OPTIONAL KEY_GENERIC_TYPE)obj;
|
|
||||||
return (isPresent && other.isPresent ? KEY_EQUALS(value, other.value) : isPresent == other.isPresent);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return isPresent ? KEY_TO_HASH(value) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return isPresent ? "OPTIONAL["+value+"]" : "OPTIONAL.empty";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,9 +7,6 @@ import java.util.Comparator;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
#if IARRAY_FEATURE || TYPE_OBJECT
|
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -36,9 +33,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.STACK;
|
import speiger.src.collections.PACKAGE.collections.STACK;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -688,12 +682,12 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -720,7 +714,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -732,7 +726,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -8,9 +8,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@ -36,9 +33,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.STACK;
|
import speiger.src.collections.PACKAGE.collections.STACK;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -816,13 +810,13 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -851,7 +845,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
@ -864,7 +858,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -7,9 +7,6 @@ import java.util.Comparator;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -30,9 +27,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
@ -341,12 +335,12 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -373,7 +367,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -385,7 +379,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,6 +4,7 @@ package speiger.src.collections.PACKAGE.lists;
|
|||||||
#if DEQUEUE_FEATURE
|
#if DEQUEUE_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#else if PRIMITIVES
|
#else if PRIMITIVES
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
@ -11,9 +12,6 @@ import java.nio.JAVA_BUFFER;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
@ -36,9 +34,6 @@ import java.util.function.JAVA_PREDICATE;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -498,12 +493,12 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.test(entry.value)) return OPTIONAL.GET_OPTIONAL(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -530,7 +525,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -542,7 +537,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,18 +4,15 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.locks.StampedLock;
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -43,12 +40,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
||||||
@ -84,7 +78,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@ -846,7 +839,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -870,11 +863,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@ -884,7 +877,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index, i);
|
entry.set(index, i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -892,7 +885,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1193,7 +1186,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1217,11 +1210,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
@ -1229,7 +1222,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(seg.keys[index])) return OPTIONAL.GET_OPTIONAL(seg.keys[index]);
|
if(filter.test(seg.keys[index])) return seg.keys[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1237,7 +1230,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1461,7 +1454,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1485,20 +1478,20 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
long stamp = seg.readLock();
|
long stamp = seg.readLock();
|
||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(seg.values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(seg.values[index]);
|
if(filter.test(seg.values[index])) return seg.values[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1506,7 +1499,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@ -30,7 +27,6 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
@ -63,7 +59,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -878,7 +873,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -893,21 +888,21 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.apply(state, new ValueMapEntry(index));
|
state = operator.apply(state, new ValueMapEntry(index));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index);
|
entry.set(index);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1165,7 +1160,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1180,19 +1175,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1348,7 +1343,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1363,19 +1358,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,17 +5,14 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -81,7 +75,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@ -1097,7 +1090,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1114,25 +1107,25 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(nullIndex);
|
entry.set(nullIndex);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1338,7 +1331,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1355,18 +1348,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1504,7 +1497,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1521,18 +1514,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(values[nullIndex])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[nullIndex]);
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@ -30,7 +27,6 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
@ -62,7 +58,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -882,7 +877,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -897,21 +892,21 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.apply(state, new ValueMapEntry(index));
|
state = operator.apply(state, new ValueMapEntry(index));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index);
|
entry.set(index);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1164,7 +1159,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1179,19 +1174,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1349,7 +1344,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1364,19 +1359,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,17 +5,14 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -79,7 +73,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
|
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@ -1056,7 +1049,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1073,25 +1066,25 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(nullIndex);
|
entry.set(nullIndex);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1293,7 +1286,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1310,18 +1303,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1459,7 +1452,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1476,18 +1469,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(values[nullIndex])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[nullIndex]);
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -29,12 +26,9 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
#if !SAME_TYPE && !TYPE_INT
|
#if !SAME_TYPE && !TYPE_INT
|
||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
@ -65,7 +59,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -790,7 +783,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -805,21 +798,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1044,7 +1037,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1059,19 +1052,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1220,7 +1213,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1235,19 +1228,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@ -29,12 +26,9 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
#if !SAME_TYPE && !TYPE_INT
|
#if !SAME_TYPE && !TYPE_INT
|
||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
@ -72,7 +66,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@ -1016,7 +1009,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1028,19 +1021,19 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1225,7 +1218,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1237,16 +1230,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1366,7 +1359,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1378,16 +1371,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,18 +6,15 @@ import java.util.Map;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
|||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@ -79,7 +73,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@ -1330,7 +1323,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1342,15 +1335,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2033,7 +2026,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2045,19 +2038,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2172,7 +2165,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2184,15 +2177,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2528,7 +2521,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2540,15 +2533,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2694,7 +2687,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2706,19 +2699,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,18 +6,15 @@ import java.util.Map;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@ -39,12 +36,9 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
|||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@ -78,7 +72,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@ -1386,7 +1379,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1398,15 +1391,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2099,7 +2092,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2111,19 +2104,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2238,7 +2231,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2250,15 +2243,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2594,7 +2587,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2606,15 +2599,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -2760,7 +2753,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -2772,19 +2765,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -7,18 +7,12 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -324,17 +318,17 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
int index = (first + i) % array.length;
|
int index = (first + i) % array.length;
|
||||||
if(filter.test(array[index])) {
|
if(filter.test(array[index])) {
|
||||||
KEY_TYPE data = array[index];
|
KEY_TYPE data = array[index];
|
||||||
removeIndex(index);
|
removeIndex(index);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -361,7 +355,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -373,7 +367,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -8,18 +8,12 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -352,7 +346,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -364,20 +358,20 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -8,18 +8,12 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -332,7 +326,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -344,20 +338,20 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -10,9 +10,6 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@ -22,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -411,12 +405,12 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -443,7 +437,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -455,7 +449,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1320,7 +1314,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1332,16 +1326,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -8,9 +8,6 @@ import java.util.function.BiFunction;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@ -21,9 +18,7 @@ import java.util.function.JAVA_PREDICATE;
|
|||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -443,12 +438,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@ -475,7 +470,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -487,7 +482,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -9,9 +9,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@ -22,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -420,7 +414,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -433,18 +427,18 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -9,9 +9,6 @@ import java.util.Objects;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@ -21,9 +18,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
@ -662,7 +656,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -675,18 +669,18 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -5,9 +5,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -24,9 +21,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -517,7 +511,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -530,18 +524,18 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,9 +6,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -19,9 +16,6 @@ import java.util.function.PREDICATE;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -641,7 +635,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -658,18 +652,18 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, keys[i]);
|
state = operator.APPLY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,9 +6,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -23,9 +20,6 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -504,7 +498,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -521,18 +515,18 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, keys[i]);
|
state = operator.APPLY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -2,9 +2,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -22,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
||||||
@ -433,7 +427,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -445,16 +439,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1380,7 +1374,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@ -1392,16 +1386,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -8,9 +8,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -33,9 +30,6 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@ -875,9 +869,9 @@ public class COLLECTIONS
|
|||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(identity, operator); } }
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(identity, operator); } }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(operator); } }
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(operator); } }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.findFirst(filter); } }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.findFirst(filter); } }
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
|
||||||
}
|
}
|
||||||
@ -1027,9 +1021,9 @@ public class COLLECTIONS
|
|||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(identity, operator); }
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(identity, operator); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(operator); }
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(operator); }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { return c.findFirst(filter); }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { return c.findFirst(filter); }
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { return c.count(filter); }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { return c.count(filter); }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,22 +4,16 @@ package speiger.src.collections.PACKAGE.utils;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if DEQUEUE_FEATURE
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
#endif
|
#endif
|
||||||
@ -30,7 +24,6 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,15 +140,7 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAll(filter); } }
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAll(filter); } }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.findFirst(filter); } }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.findFirst(filter); } }
|
||||||
#if TYPE_OBJECT
|
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) { synchronized(mutex) { return queue.reduce(identity, operator); } }
|
|
||||||
#else
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return queue.reduce(identity, operator); } }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return queue.reduce(operator); } }
|
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,15 +25,6 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
collection.forEach(elements::add);
|
collection.forEach(elements::add);
|
||||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
|
||||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
|
||||||
public void testIndexedForEachUnknownOrder() {
|
|
||||||
#endignore
|
|
||||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
|
||||||
collection.forEachIndexed((K, V) -> elements.add(V));
|
|
||||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||||
@ -52,15 +43,6 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
collection.forEach(elements::add);
|
collection.forEach(elements::add);
|
||||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
|
||||||
@CollectionFeature.Require(KNOWN_ORDER)
|
|
||||||
public void testIndexedForEachKnownOrder() {
|
|
||||||
#endignore
|
|
||||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
|
||||||
collection.forEachIndexed((K, V) -> elements.add(V));
|
|
||||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionFeature.Require(KNOWN_ORDER)
|
@CollectionFeature.Require(KNOWN_ORDER)
|
||||||
|
|||||||
@ -4,12 +4,6 @@ package speiger.src.testers.PACKAGE.tests.iterable;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
@ -33,17 +27,17 @@ public class FILE_KEY_TYPEIterableFindFirstTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testIterableFindFirst_FindFirstElements() {
|
public void testIterableFindFirst_FindFirstElements() {
|
||||||
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())).SUPPLY_GET());
|
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableFindFirst_FindNothing() {
|
public void testIterableFindFirst_FindNothing() {
|
||||||
assertEquals("No element should be found", OPTIONAL.empty(), container.findFirst(T -> KEY_EQUALS(T, e4())));
|
assertEquals("No element should be found", EMPTY_KEY_VALUE, container.findFirst(T -> KEY_EQUALS(T, e4())));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testIterableFindFirst_FindLastElement() {
|
public void testIterableFindFirst_FindLastElement() {
|
||||||
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())).SUPPLY_GET());
|
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,16 +3,9 @@ package speiger.src.testers.PACKAGE.tests.iterable;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@ -36,7 +29,7 @@ public class FILE_KEY_TYPEIterableReduceTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableReduce() {
|
public void testIterableReduce() {
|
||||||
assertEquals("The sum of the collection should match", size == CollectionSize.ZERO ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(getSum()), collection.reduce(this::sum));
|
assertEquals("The sum of the collection should match", getSum(), collection.reduce(this::sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableExtraReduce() {
|
public void testIterableExtraReduce() {
|
||||||
|
|||||||
@ -96,7 +96,7 @@ public abstract class BaseIntIterableTest
|
|||||||
public void testStreamFindFirst() {
|
public void testStreamFindFirst() {
|
||||||
if(getValidIterableTests().contains(IterableTest.STREAM_FIND_FIRST)) {
|
if(getValidIterableTests().contains(IterableTest.STREAM_FIND_FIRST)) {
|
||||||
int expected = IntStream.of(TEST_ARRAY).filter(T -> T / 50 > 0).findFirst().getAsInt();
|
int expected = IntStream.of(TEST_ARRAY).filter(T -> T / 50 > 0).findFirst().getAsInt();
|
||||||
int actual = create(TEST_ARRAY).findFirst(T -> T / 50 > 0).getAsInt();
|
int actual = create(TEST_ARRAY).findFirst(T -> T / 50 > 0);
|
||||||
Assert.assertEquals(expected, actual);
|
Assert.assertEquals(expected, actual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user