Added Reduce function to all implementations
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -347,6 +348,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
@@ -357,6 +359,18 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
@@ -1096,6 +1110,45 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = entry.key;
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
@@ -423,6 +424,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
@@ -433,6 +435,18 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(int i = 0;i<size;i++) {
|
||||
state = operator.APPLY_VALUE(state, data[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
|
||||
+46
@@ -3,6 +3,7 @@ package speiger.src.collections.PACKAGE.sets;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -19,6 +20,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
@@ -346,6 +348,50 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(empty) {
|
||||
state = keys[index];
|
||||
empty = false;
|
||||
}
|
||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
+46
@@ -3,6 +3,7 @@ package speiger.src.collections.PACKAGE.sets;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
@@ -25,6 +26,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
import speiger.src.collections.utils.HashUtil;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
@@ -577,6 +579,50 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(empty) {
|
||||
state = keys[index];
|
||||
empty = false;
|
||||
}
|
||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
+46
@@ -10,6 +10,7 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
@@ -23,6 +24,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
@@ -432,6 +434,50 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(empty) {
|
||||
state = keys[index];
|
||||
empty = false;
|
||||
}
|
||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
+50
@@ -8,6 +8,7 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
@@ -20,6 +21,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||
|
||||
import speiger.src.collections.utils.HashUtil;
|
||||
@@ -527,6 +529,54 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
if(containsNull) state = operator.APPLY_VALUE(state, keys[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
if(containsNull) state = operator.APPLY_VALUE(state, keys[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
if(containsNull) {
|
||||
state = keys[nullIndex];
|
||||
empty = false;
|
||||
}
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = keys[i];
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
@@ -20,6 +21,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.utils.HashUtil;
|
||||
import speiger.src.collections.utils.ITrimmable;
|
||||
import speiger.src.collections.utils.SanityChecks;
|
||||
@@ -380,6 +382,54 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
if(containsNull) state = operator.APPLY_VALUE(state, keys[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
if(containsNull) state = operator.APPLY_VALUE(state, keys[nullIndex]);
|
||||
for(int i = nullIndex-1;i>=0;i--) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
if(containsNull) {
|
||||
state = keys[nullIndex];
|
||||
empty = false;
|
||||
}
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = keys[i];
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, keys[i]);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.Collection;
|
||||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.BiFunction;
|
||||
#endif
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -338,15 +339,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
@@ -357,6 +350,18 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
@@ -373,6 +378,15 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
@@ -1157,6 +1171,45 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_SPECIAL_TYPE state = identity;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = entry.key;
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
Reference in New Issue
Block a user