Breaking update
- Added: Optionals for the missing JDK ones. - Removed: Default values for Reduce and FindFirst. Using Optionals instead.
This commit is contained in:
+11
-5
@@ -9,6 +9,9 @@ import java.util.Objects;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
#if JDK_TYPE
|
||||
import java.util.OPTIONAL;
|
||||
#endif
|
||||
#if JDK_FUNCTION
|
||||
import java.util.function.PREDICATE;
|
||||
#endif
|
||||
@@ -18,6 +21,9 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||
#endif
|
||||
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;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||
@@ -656,7 +662,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||
Objects.requireNonNull(operator);
|
||||
KEY_TYPE state = EMPTY_VALUE;
|
||||
boolean empty = true;
|
||||
@@ -669,18 +675,18 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return state;
|
||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
int index = firstIndex;
|
||||
while(index != -1) {
|
||||
if(filter.test(keys[index])) return keys[index];
|
||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
||||
index = (int)links[index];
|
||||
}
|
||||
return EMPTY_VALUE;
|
||||
return OPTIONAL.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user