forked from Speiger/Primitive-Collections
AVLTreeMap gets some love regarding forEach/etc
This commit is contained in:
parent
4aac66b6fb
commit
abc1c075f5
|
@ -4,13 +4,22 @@ import java.util.Map;
|
|||
#if TYPE_OBJECT
|
||||
import java.util.Comparator;
|
||||
#endif
|
||||
import java.util.function.Consumer;
|
||||
import java.util.Objects;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||
#if !TYPE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||
#endif
|
||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||
#endif
|
||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||
#endif
|
||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||
|
@ -31,6 +40,21 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
|
|||
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_ITERATORS;
|
||||
#endif
|
||||
#if !VALUE_OBJECT && !SAME_TYPE
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||
#endif
|
||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||
#endif
|
||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
||||
#if !VALUE_OBJECT || SAME_TYPE
|
||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
||||
#endif
|
||||
#endif
|
||||
#if !SAME_TYPE
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||
#endif
|
||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||
|
@ -545,7 +569,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
else subEntry.value = newValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||
for(Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
action.accept(entry.key, entry.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
|
@ -904,6 +934,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return descendingMap;
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
|
@ -984,6 +1022,18 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE higherEntry(KEY_TYPE e) { return super.lowerEntry(e); }
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE findLowest() {
|
||||
if(fromStart) return m.last;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = loInclusive ? m.findFloorNode(high) : m.findLowerNode(high);
|
||||
return entry == null || tooHigh(entry.key) ? null : entry;
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE findHighest() {
|
||||
if(toEnd) return m.first;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = hiInclusive ? m.findCeilingNode(low) : m.findHigherNode(low);
|
||||
return entry == null || tooLow(entry.key) ? null : entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending) {
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = new SubMapKeyIterator(!descending);
|
||||
|
@ -996,6 +1046,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return entry == null || !inClosedRange(key) ? null : ITERATORS.invert(new SubMapKeyIterator(entry, fromStart ? null : findLowest(), toEnd ? null : findHighest()));
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator() == null ? null : m.comparator().reversed(); }
|
||||
|
||||
|
@ -1058,7 +1116,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
||||
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
|
||||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||
@Override
|
||||
|
@ -1066,8 +1127,8 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive);
|
||||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive);
|
||||
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive);
|
||||
|
||||
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? m.compare(key, low) < 0 : m.compare(key, low) <= 0); }
|
||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); }
|
||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||
|
@ -1266,6 +1327,12 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
action.accept(entry.key, entry.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return (fromStart && toEnd) ? m.size() : entrySet().size();
|
||||
|
@ -1411,6 +1478,68 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public int size() { return NavigableSubMap.this.size(); }
|
||||
@Override
|
||||
public void clear() { NavigableSubMap.this.clear(); }
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1442,6 +1571,52 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public void clear() {
|
||||
NavigableSubMap.this.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
action.accept(entry.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
action.accept(entry.value, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
@ -1615,6 +1790,68 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public void clear() {
|
||||
AVL_TREE_MAP.this.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return false;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return true;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(!filter.getBoolean(subEntry)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
if(size() <= 0) return null;
|
||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||
subEntry.set(entry.key, entry.value);
|
||||
if(filter.getBoolean(subEntry)) return subEntry;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static final class KeySet KEY_VALUE_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE {
|
||||
|
@ -1726,6 +1963,72 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public void clear() {
|
||||
m.clear();
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE start() {
|
||||
if(m instanceof AVL_TREE_MAP) return ((AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE)m).first;
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest();
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE end() {
|
||||
if(m instanceof AVL_TREE_MAP) return null;
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest();
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof AVL_TREE_MAP) return entry.next();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof AVL_TREE_MAP) return entry.previous();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
action.accept(entry.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
action.accept(entry.key, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||
return EMPTY_KEY_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
@ -1758,6 +2061,52 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
public void clear() {
|
||||
AVL_TREE_MAP.this.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
action.accept(entry.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
action.accept(entry.value, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||
return EMPTY_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
Loading…
Reference in New Issue