Cleanup Space are now converted into tabs.
This commit is contained in:
+50
-50
@@ -128,20 +128,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
||||
@Override
|
||||
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) {
|
||||
VALUE_TYPE curValue = GET_VALUE(key);
|
||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||
return false;
|
||||
}
|
||||
put(key, newValue);
|
||||
return true;
|
||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||
return false;
|
||||
}
|
||||
put(key, newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) {
|
||||
VALUE_TYPE curValue;
|
||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
curValue = put(key, value);
|
||||
}
|
||||
return curValue;
|
||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
curValue = put(key, value);
|
||||
}
|
||||
return curValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,68 +161,68 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||
remove(key);
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
put(key, newValue);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||
remove(key);
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
remove(key);
|
||||
}
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
remove(key);
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1175,8 +1175,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
||||
MapIterator(KEY_TYPE from) {
|
||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
||||
+1
-1
@@ -523,7 +523,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
|
||||
+2
-2
@@ -1153,8 +1153,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
||||
MapIterator(KEY_TYPE from) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
||||
+1
-1
@@ -484,7 +484,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
|
||||
+2
-2
@@ -1067,8 +1067,8 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
||||
MapIterator(KEY_TYPE from) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
||||
+4
-4
@@ -514,7 +514,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
@@ -954,7 +954,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||
if(keySet == null) keySet = new SubKeySet();
|
||||
return keySet;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||
if(valuesC == null) valuesC = new SubValues();
|
||||
@@ -966,12 +966,12 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||
if(entrySet == null) entrySet = new SubMapEntrySet();
|
||||
return entrySet;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, KEY_TYPE toKey) {
|
||||
int fromIndex = findIndex(fromKey);
|
||||
|
||||
+74
-74
@@ -28,26 +28,26 @@ import speiger.src.collections.objects.sets.ObjectSet;
|
||||
public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** Enum Type that is being used */
|
||||
protected final Class<T> keyType;
|
||||
protected final Class<T> keyType;
|
||||
/** The Backing keys array. */
|
||||
protected transient final T[] keys;
|
||||
protected transient final T[] keys;
|
||||
/** The Backing values array */
|
||||
protected transient final VALUE_TYPE[] values;
|
||||
protected transient final VALUE_TYPE[] values;
|
||||
/** The Backing array that indicates which index is present or not */
|
||||
protected transient final long[] present;
|
||||
protected transient final long[] present;
|
||||
/** Amount of Elements stored in the ArrayMap */
|
||||
protected int size = 0;
|
||||
protected int size = 0;
|
||||
/** EntrySet cache */
|
||||
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
/** KeySet cache */
|
||||
protected transient ObjectSet<T> keySet;
|
||||
protected transient ObjectSet<T> keySet;
|
||||
/** Values cache */
|
||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
public ENUM_MAP(Class<T> keyType) {
|
||||
this.keyType = keyType;
|
||||
keys = getKeyUniverse(keyType);
|
||||
@@ -219,32 +219,32 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||
onNodeRemoved(index);
|
||||
}
|
||||
protected boolean isSet(int index) { return (present[index >> 6] & (1L << index)) != 0; }
|
||||
|
||||
|
||||
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
|
||||
return keyType.getEnumConstants();
|
||||
}
|
||||
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if(o instanceof Map.Entry) {
|
||||
if(o instanceof MAP.Entry) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
||||
}
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if(o instanceof Map.Entry) {
|
||||
if(o instanceof MAP.Entry) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
||||
}
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||
return new EntryIterator();
|
||||
@@ -259,22 +259,22 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||
public void clear() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class KeySet extends AbstractObjectSet<T> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return containsKey(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
int size = size();
|
||||
ENUM_MAP.this.remove(o);
|
||||
return size != size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class KeySet extends AbstractObjectSet<T> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return containsKey(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
int size = size();
|
||||
ENUM_MAP.this.remove(o);
|
||||
return size != size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIterator<T> iterator() {
|
||||
return new KeyIterator();
|
||||
@@ -284,14 +284,14 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||
public int size() {
|
||||
return ENUM_MAP.this.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
}
|
||||
|
||||
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
||||
@Override
|
||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
@@ -314,40 +314,40 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||
public int size() {
|
||||
return ENUM_MAP.this.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class EntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
}
|
||||
|
||||
class EntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||
int index = nextEntry();
|
||||
return new BasicEntry<>(keys[index], values[index]);
|
||||
}
|
||||
}
|
||||
|
||||
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
||||
}
|
||||
|
||||
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
||||
@Override
|
||||
public T next() {
|
||||
return keys[nextEntry()];
|
||||
}
|
||||
}
|
||||
|
||||
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
||||
}
|
||||
|
||||
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
||||
@Override
|
||||
public VALUE_TYPE VALUE_NEXT() {
|
||||
return values[nextEntry()];
|
||||
}
|
||||
}
|
||||
|
||||
class MapIterator {
|
||||
int index;
|
||||
int lastReturnValue = -1;
|
||||
int nextIndex = -1;
|
||||
|
||||
}
|
||||
|
||||
class MapIterator {
|
||||
int index;
|
||||
int lastReturnValue = -1;
|
||||
int nextIndex = -1;
|
||||
|
||||
public boolean hasNext() {
|
||||
if(nextIndex == -1 && index < values.length) {
|
||||
while(index < values.length && !isSet(index++));
|
||||
@@ -368,5 +368,5 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||
clear(lastReturnValue);
|
||||
values[lastReturnValue] = EMPTY_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -50,10 +50,10 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||
protected int firstIndex = -1;
|
||||
/** The Last Index in the Map */
|
||||
protected int lastIndex = -1;
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
public LINKED_ENUM_MAP(Class<T> keyType) {
|
||||
super(keyType);
|
||||
links = new long[keys.length];
|
||||
|
||||
+93
-93
@@ -934,31 +934,31 @@ 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();
|
||||
}
|
||||
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");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1046,13 +1046,13 @@ 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();
|
||||
}
|
||||
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(); }
|
||||
@@ -1071,21 +1071,21 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
|
||||
@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");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1093,17 +1093,17 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
final AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||
final KEY_TYPE low;
|
||||
final KEY_TYPE high;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
this.fromStart = fromStart;
|
||||
@@ -1111,15 +1111,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
this.loInclusive = loInclusive;
|
||||
this.hiInclusive = hiInclusive;
|
||||
}
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
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);
|
||||
|
||||
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
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
|
||||
@@ -1130,11 +1130,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
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); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
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); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||
public KEY_TYPE getDefaultMinValue() { return m.getDefaultMinValue(); }
|
||||
@@ -1158,18 +1158,18 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||
#if TYPE_OBJECT
|
||||
@@ -1620,9 +1620,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapEntrySetIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1640,9 +1640,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
}
|
||||
|
||||
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapKeyIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1660,9 +1660,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
}
|
||||
|
||||
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapValueIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1685,11 +1685,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
|
||||
public SubMapEntryIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
next = entry;
|
||||
@@ -1697,7 +1697,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
this.lowerFence = lowerFence != null ? KEY_TO_OBJ(lowerFence.key) : null;
|
||||
this.upperFence = upperFence != null ? KEY_TO_OBJ(upperFence.key) : null;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != null && (upperFence == null || KEY_EQUALS(next.key, OBJ_TO_KEY(upperFence)));
|
||||
}
|
||||
@@ -1713,7 +1713,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
public int previousIndex() {
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
|
||||
protected void updateNext() {
|
||||
next = current.next();
|
||||
}
|
||||
@@ -1974,15 +1974,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
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) {
|
||||
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) {
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -2185,11 +2185,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
}
|
||||
|
||||
abstract class MapEntryIterator {
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public MapEntryIterator(boolean descending) {
|
||||
if(descending) previous = last;
|
||||
else next = first;
|
||||
@@ -2199,7 +2199,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
next = entry;
|
||||
previous = entry.previous();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != null;
|
||||
}
|
||||
@@ -2215,7 +2215,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||
public int previousIndex() {
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
|
||||
protected void updateNext() {
|
||||
next = current.next();
|
||||
}
|
||||
|
||||
+81
-81
@@ -555,8 +555,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
Entry KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||
VALUE_TYPE newValue = subEntry == null ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||
@@ -998,21 +998,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@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");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1125,21 +1125,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
|
||||
@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");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1147,17 +1147,17 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
final RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||
final KEY_TYPE low;
|
||||
final KEY_TYPE high;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
this.fromStart = fromStart;
|
||||
@@ -1165,14 +1165,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
this.loInclusive = loInclusive;
|
||||
this.hiInclusive = hiInclusive;
|
||||
}
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
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 RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
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 RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||
@Override
|
||||
@@ -1181,13 +1181,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
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);
|
||||
|
||||
|
||||
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); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
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); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||
public KEY_TYPE getDefaultMinValue() { return m.getDefaultMinValue(); }
|
||||
@@ -1211,18 +1211,18 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||
#if TYPE_OBJECT
|
||||
@@ -1673,9 +1673,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapEntrySetIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1693,9 +1693,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
}
|
||||
|
||||
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapKeyIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1713,9 +1713,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
}
|
||||
|
||||
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapValueIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
@@ -1738,11 +1738,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
|
||||
public SubMapEntryIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
next = entry;
|
||||
@@ -1750,7 +1750,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
this.lowerFence = lowerFence != null ? KEY_TO_OBJ(lowerFence.key) : null;
|
||||
this.upperFence = upperFence != null ? KEY_TO_OBJ(upperFence.key) : null;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != null && (upperFence == null || KEY_EQUALS(next.key, OBJ_TO_KEY(upperFence)));
|
||||
}
|
||||
@@ -1766,7 +1766,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
public int previousIndex() {
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
|
||||
protected void updateNext() {
|
||||
next = current.next();
|
||||
}
|
||||
@@ -2027,15 +2027,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest();
|
||||
}
|
||||
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof RB_TREE_MAP) return entry.next();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
||||
}
|
||||
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
}
|
||||
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof RB_TREE_MAP) return entry.previous();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
@@ -2238,11 +2238,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
}
|
||||
|
||||
abstract class MapEntryIterator {
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public MapEntryIterator(boolean descending) {
|
||||
if(descending) previous = last;
|
||||
else next = first;
|
||||
@@ -2252,7 +2252,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
next = entry;
|
||||
previous = entry.previous();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != null;
|
||||
}
|
||||
@@ -2268,7 +2268,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||
public int previousIndex() {
|
||||
return index - 1;
|
||||
}
|
||||
|
||||
|
||||
protected void updateNext() {
|
||||
next = current.next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user