Fixes and a lot new features. But still WIP
- Fixed: Supplier get function wasn't referencing original function. - Added: addIfPresent/Absent to lists - Added: distinct, limit and peek iterators - Added: Iterable's can now reduce its contents
This commit is contained in:
@@ -15,6 +15,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.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
@@ -346,6 +347,32 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
|
||||
@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 = first;entry != null;entry = entry.next()) {
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@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 = first;entry != null;entry = entry.next()) {
|
||||
if(empty) {
|
||||
empty = false;
|
||||
state = entry.key;
|
||||
continue;
|
||||
}
|
||||
state = operator.APPLY_VALUE(state, entry.key);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
|
||||
Reference in New Issue
Block a user