forked from Speiger/Primitive-Collections
Cleanup Space are now converted into tabs.
This commit is contained in:
parent
fa3cf743f9
commit
6e30a54ead
|
@ -187,7 +187,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY() {
|
public KEY_TYPE[] TO_ARRAY() {
|
||||||
|
@ -197,7 +197,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||||
/**
|
/**
|
||||||
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
||||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||||
|
|
|
@ -97,7 +97,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
* @see Collection#toArray()
|
* @see Collection#toArray()
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE[] TO_ARRAY();
|
public KEY_TYPE[] TO_ARRAY();
|
||||||
|
@ -105,8 +105,8 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
/**
|
/**
|
||||||
* A Type-Specific toArray function that reduces (un)boxing.
|
* A Type-Specific toArray function that reduces (un)boxing.
|
||||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
* @see Collection#toArray(Object[])
|
* @see Collection#toArray(Object[])
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
||||||
|
|
||||||
|
@ -135,16 +135,16 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
* @throws java.lang.NullPointerException if filter is null
|
* @throws java.lang.NullPointerException if filter is null
|
||||||
*/
|
*/
|
||||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
final ITERATOR each = iterator();
|
final ITERATOR each = iterator();
|
||||||
while (each.hasNext()) {
|
while (each.hasNext()) {
|
||||||
if (filter.test(each.NEXT())) {
|
if (filter.test(each.NEXT())) {
|
||||||
each.remove();
|
each.remove();
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -164,7 +164,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,25 +34,25 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE next() { return KEY_TO_OBJ(NEXT()); }
|
public default CLASS_TYPE next() { return KEY_TO_OBJ(NEXT()); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the given action for each remaining element until all elements
|
* Performs the given action for each remaining element until all elements
|
||||||
* have been processed or the action throws an exception. Actions are
|
* have been processed or the action throws an exception. Actions are
|
||||||
* performed in the order of iteration, if that order is specified.
|
* performed in the order of iteration, if that order is specified.
|
||||||
* Exceptions thrown by the action are relayed to the caller.
|
* Exceptions thrown by the action are relayed to the caller.
|
||||||
*
|
*
|
||||||
* @implSpec
|
* @implSpec
|
||||||
* <p>The default implementation behaves as if:
|
* <p>The default implementation behaves as if:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* while (hasNext()) action.accept(NEXT());
|
* while (hasNext()) action.accept(NEXT());
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param action The action to be performed for each element
|
* @param action The action to be performed for each element
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
* @see Iterator#forEachRemaining(Consumer)
|
* @see Iterator#forEachRemaining(Consumer)
|
||||||
*/
|
*/
|
||||||
public default void forEachRemaining(CONSUMER action) {
|
public default void forEachRemaining(CONSUMER action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
while(hasNext()) { action.accept(NEXT()); }
|
while(hasNext()) { action.accept(NEXT()); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
|
@ -62,21 +62,21 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
default void forEachRemaining(Consumer<? super CLASS_TYPE> action) {
|
default void forEachRemaining(Consumer<? super CLASS_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
forEachRemaining(action::accept);
|
forEachRemaining(action::accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||||
* @param input the object that should be included
|
* @param input the object that should be included
|
||||||
* @param action The action to be performed for each element
|
* @param action The action to be performed for each element
|
||||||
* @param <E> the generic type of the Object
|
* @param <E> the generic type of the Object
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
*/
|
*/
|
||||||
default <E> void forEachRemaining(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
default <E> void forEachRemaining(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
while(hasNext()) { action.accept(NEXT(), input); }
|
while(hasNext()) { action.accept(NEXT(), input); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,17 +10,17 @@ public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Type-Specific compare function to reduce (un)boxing
|
* Type-Specific compare function to reduce (un)boxing
|
||||||
* @param o1 the first object to be compared.
|
* @param o1 the first object to be compared.
|
||||||
* @param o2 the second object to be compared.
|
* @param o2 the second object to be compared.
|
||||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||||
* @see Comparator#compare(Object, Object)
|
* @see Comparator#compare(Object, Object)
|
||||||
*/
|
*/
|
||||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||||
|
|
|
@ -12,12 +12,12 @@ public interface CONSUMER extends Consumer<CLASS_TYPE>, JAVA_CONSUMER
|
||||||
public interface CONSUMER extends Consumer<CLASS_TYPE>
|
public interface CONSUMER extends Consumer<CLASS_TYPE>
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Type-Specific function to reduce (un)boxing.
|
* Type-Specific function to reduce (un)boxing.
|
||||||
* Performs this operation on the given argument.
|
* Performs this operation on the given argument.
|
||||||
*
|
*
|
||||||
* @param t the input argument
|
* @param t the input argument
|
||||||
*/
|
*/
|
||||||
void accept(KEY_TYPE t);
|
void accept(KEY_TYPE t);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,13 +10,13 @@ import java.util.function.BiConsumer;
|
||||||
*/
|
*/
|
||||||
public interface BI_CONSUMER KEY_VALUE_GENERIC_TYPE extends BiConsumer<CLASS_TYPE, CLASS_VALUE_TYPE>
|
public interface BI_CONSUMER KEY_VALUE_GENERIC_TYPE extends BiConsumer<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A Type Specific operation method to reduce boxing/unboxing
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
* Performs this operation on the given arguments.
|
* Performs this operation on the given arguments.
|
||||||
*
|
*
|
||||||
* @param k the first input argument
|
* @param k the first input argument
|
||||||
* @param v the second input argument
|
* @param v the second input argument
|
||||||
*/
|
*/
|
||||||
void accept(KEY_TYPE k, VALUE_TYPE v);
|
void accept(KEY_TYPE k, VALUE_TYPE v);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,15 +34,15 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||||
* @return a function that compares values in a and comparason
|
* @return a function that compares values in a and comparason
|
||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) && other.test(T);
|
return T -> GET_VALUE(T) && other.test(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,15 +56,15 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||||
* @return a function that compares values in a or comparason
|
* @return a function that compares values in a or comparason
|
||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) || other.test(T);
|
return T -> GET_VALUE(T) || other.test(T);
|
||||||
}
|
}
|
||||||
#else if VALUE_OBJECT
|
#else if VALUE_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction<CLASS_
|
||||||
#else
|
#else
|
||||||
/**
|
/**
|
||||||
* A Type Specifc apply method to reduce boxing/unboxing.
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
* Applies this function to the given arguments.
|
* Applies this function to the given arguments.
|
||||||
*
|
*
|
||||||
* @param k the first function argument
|
* @param k the first function argument
|
||||||
* @param v the second function argument
|
* @param v the second function argument
|
||||||
* @return the function result
|
* @return the function result
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE APPLY_VALUE(KEY_TYPE k, VALUE_TYPE v);
|
public VALUE_TYPE APPLY_VALUE(KEY_TYPE k, VALUE_TYPE v);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -160,31 +160,31 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof List))
|
if (!(o instanceof List))
|
||||||
return false;
|
return false;
|
||||||
List<?> l = (List<?>)o;
|
List<?> l = (List<?>)o;
|
||||||
if(l.size() != size()) return false;
|
if(l.size() != size()) return false;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
if(l instanceof LIST)
|
if(l instanceof LIST)
|
||||||
{
|
{
|
||||||
LIST_ITERATOR e1 = listIterator();
|
LIST_ITERATOR e1 = listIterator();
|
||||||
LIST_ITERATOR e2 = ((LIST)l).listIterator();
|
LIST_ITERATOR e2 = ((LIST)l).listIterator();
|
||||||
while (e1.hasNext() && e2.hasNext()) {
|
while (e1.hasNext() && e2.hasNext()) {
|
||||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(e1.hasNext() || e2.hasNext());
|
return !(e1.hasNext() || e2.hasNext());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
ListIterator<CLASS_TYPE> e1 = listIterator();
|
ListIterator<CLASS_TYPE> e1 = listIterator();
|
||||||
ListIterator<?> e2 = l.listIterator();
|
ListIterator<?> e2 = l.listIterator();
|
||||||
while (e1.hasNext() && e2.hasNext()) {
|
while (e1.hasNext() && e2.hasNext()) {
|
||||||
if(!Objects.equals(e1.next(), e2.next()))
|
if(!Objects.equals(e1.next(), e2.next()))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(e1.hasNext() || e2.hasNext());
|
return !(e1.hasNext() || e2.hasNext());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,15 +192,15 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hashCode = 1;
|
int hashCode = 1;
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE i = listIterator();
|
LIST_ITERATOR KEY_GENERIC_TYPE i = listIterator();
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
hashCode = 31 * hashCode + i.next().hashCode();
|
hashCode = 31 * hashCode + i.next().hashCode();
|
||||||
#else
|
#else
|
||||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||||
#endif
|
#endif
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -572,17 +572,17 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
/**
|
/**
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
*
|
*
|
||||||
* @implSpec
|
* @implSpec
|
||||||
* <p>The default implementation behaves as if:
|
* <p>The default implementation behaves as if:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* for(int i = 0;i<size;i++)
|
* for(int i = 0;i<size;i++)
|
||||||
* action.accept(data[i]);
|
* action.accept(data[i]);
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param action The action to be performed for each element
|
* @param action The action to be performed for each element
|
||||||
* @throws NullPointerException if the specified action is null
|
* @throws NullPointerException if the specified action is null
|
||||||
* @see Iterable#forEach(java.util.function.Consumer)
|
* @see Iterable#forEach(java.util.function.Consumer)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
|
|
|
@ -262,17 +262,17 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
||||||
/**
|
/**
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
*
|
*
|
||||||
* @implSpec
|
* @implSpec
|
||||||
* <p>The default implementation behaves as if:
|
* <p>The default implementation behaves as if:
|
||||||
* <pre>{@code
|
* <pre>{@code
|
||||||
* for(int i = 0;i<size;i++)
|
* for(int i = 0;i<size;i++)
|
||||||
* action.accept(data[i]);
|
* action.accept(data[i]);
|
||||||
* }</pre>
|
* }</pre>
|
||||||
*
|
*
|
||||||
* @param action The action to be performed for each element
|
* @param action The action to be performed for each element
|
||||||
* @throws NullPointerException if the specified action is null
|
* @throws NullPointerException if the specified action is null
|
||||||
* @see Iterable#forEach(java.util.function.Consumer)
|
* @see Iterable#forEach(java.util.function.Consumer)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
|
|
|
@ -877,7 +877,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
x.value = null;
|
x.value = null;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (prev == null) first = next;
|
if (prev == null) first = next;
|
||||||
else {
|
else {
|
||||||
prev.next = next;
|
prev.next = next;
|
||||||
|
@ -988,8 +987,8 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
|
|
||||||
private static class TypeSplitIterator KEY_GENERIC_TYPE implements SPLIT_ITERATOR KEY_GENERIC_TYPE
|
private static class TypeSplitIterator KEY_GENERIC_TYPE implements SPLIT_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
static final int BATCH_UNIT = 1 << 10;
|
static final int BATCH_UNIT = 1 << 10;
|
||||||
static final int MAX_BATCH = 1 << 25;
|
static final int MAX_BATCH = 1 << 25;
|
||||||
LINKED_LIST KEY_GENERIC_TYPE list;
|
LINKED_LIST KEY_GENERIC_TYPE list;
|
||||||
Entry KEY_GENERIC_TYPE entry;
|
Entry KEY_GENERIC_TYPE entry;
|
||||||
int index;
|
int index;
|
||||||
|
@ -1049,7 +1048,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int characteristics() {
|
public int characteristics() {
|
||||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1069,9 +1068,9 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
private static class SplitIterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE
|
private static class SplitIterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
static final int BATCH_UNIT = 1 << 10;
|
static final int BATCH_UNIT = 1 << 10;
|
||||||
static final int MAX_BATCH = 1 << 25;
|
static final int MAX_BATCH = 1 << 25;
|
||||||
LINKED_LIST KEY_GENERIC_TYPE list;
|
LINKED_LIST KEY_GENERIC_TYPE list;
|
||||||
Entry entry;
|
Entry entry;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
@ -1115,7 +1114,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int characteristics() {
|
public int characteristics() {
|
||||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KEY_TYPE next() {
|
public KEY_TYPE next() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
/**
|
/**
|
||||||
* A Type-Specific add Function to reduce (un)boxing
|
* A Type-Specific add Function to reduce (un)boxing
|
||||||
* @param e the element to add
|
* @param e the element to add
|
||||||
* @param index index at which the specified element is to be inserted
|
* @param index index at which the specified element is to be inserted
|
||||||
* @see List#add(int, Object)
|
* @see List#add(int, Object)
|
||||||
*/
|
*/
|
||||||
public void add(int index, KEY_TYPE e);
|
public void add(int index, KEY_TYPE e);
|
||||||
|
@ -50,7 +50,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
/**
|
/**
|
||||||
* A Type-Specific addAll Function to reduce (un)boxing
|
* A Type-Specific addAll Function to reduce (un)boxing
|
||||||
* @param c the elements that need to be added
|
* @param c the elements that need to be added
|
||||||
* @param index index at which the specified elements is to be inserted
|
* @param index index at which the specified elements is to be inserted
|
||||||
* @return true if the list was modified
|
* @return true if the list was modified
|
||||||
* @see java.util.List#addAll(int, java.util.Collection)
|
* @see java.util.List#addAll(int, java.util.Collection)
|
||||||
*/
|
*/
|
||||||
|
@ -66,7 +66,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
/**
|
/**
|
||||||
* A Type-Specific and optimized addAll function that allows a faster transfer of elements
|
* A Type-Specific and optimized addAll function that allows a faster transfer of elements
|
||||||
* @param c the elements that need to be added
|
* @param c the elements that need to be added
|
||||||
* @param index index at which the specified elements is to be inserted
|
* @param index index at which the specified elements is to be inserted
|
||||||
* @return true if the list was modified
|
* @return true if the list was modified
|
||||||
*/
|
*/
|
||||||
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c);
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c);
|
||||||
|
@ -83,19 +83,19 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific set function to reduce (un)boxing
|
* A Type-Specific set function to reduce (un)boxing
|
||||||
* @param index index of the element to replace
|
* @param index index of the element to replace
|
||||||
* @param e element to be stored at the specified position
|
* @param e element to be stored at the specified position
|
||||||
* @return the element previously at the specified position
|
* @return the element previously at the specified position
|
||||||
* @throws IndexOutOfBoundsException if the index is not within the list range
|
* @throws IndexOutOfBoundsException if the index is not within the list range
|
||||||
* @see List#set(int, Object)
|
* @see List#set(int, Object)
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE set(int index, KEY_TYPE e);
|
public KEY_TYPE set(int index, KEY_TYPE e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific remove function to reduce (un)boxing
|
* A Type-Specific remove function to reduce (un)boxing
|
||||||
* @param index the index of the element to be removed
|
* @param index the index of the element to be removed
|
||||||
* @return the element previously at the specified position
|
* @return the element previously at the specified position
|
||||||
* @see List#remove(int)
|
* @see List#remove(int)
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE REMOVE(int index);
|
public KEY_TYPE REMOVE(int index);
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
* @throws NullPointerException if o is null
|
* @throws NullPointerException if o is null
|
||||||
*/
|
*/
|
||||||
public default void REPLACE(JAVA_UNARY_OPERATOR o) {
|
public default void REPLACE(JAVA_UNARY_OPERATOR o) {
|
||||||
Objects.requireNonNull(o);
|
Objects.requireNonNull(o);
|
||||||
LIST_ITERATOR iter = listIterator();
|
LIST_ITERATOR iter = listIterator();
|
||||||
while (iter.hasNext())
|
while (iter.hasNext())
|
||||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
iter.set(SanityChecks.SANITY_CAST(o.APPLY_CAST(iter.NEXT())));
|
iter.set(SanityChecks.SANITY_CAST(o.APPLY_CAST(iter.NEXT())));
|
||||||
#else
|
#else
|
||||||
iter.set(o.APPLY(iter.NEXT()));
|
iter.set(o.APPLY(iter.NEXT()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -141,17 +141,17 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public default void replaceAll(UnaryOperator<CLASS_TYPE> o) {
|
public default void replaceAll(UnaryOperator<CLASS_TYPE> o) {
|
||||||
Objects.requireNonNull(o);
|
Objects.requireNonNull(o);
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||||
while (iter.hasNext()) iter.set(o.apply(iter.NEXT()));
|
while (iter.hasNext()) iter.set(o.apply(iter.NEXT()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* A function to fast add elements to the list
|
* A function to fast add elements to the list
|
||||||
* @param a the elements that should be added
|
* @param a the elements that should be added
|
||||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||||
*/
|
*/
|
||||||
public default void addElements(KEY_TYPE... a) { addElements(size(), a, 0, a.length); }
|
public default void addElements(KEY_TYPE... a) { addElements(size(), a, 0, a.length); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,11 +224,11 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
KEY_TYPE[] array = (KEY_TYPE[])TO_ARRAY();
|
KEY_TYPE[] array = (KEY_TYPE[])TO_ARRAY();
|
||||||
if(c != null) ARRAYS.stableSort(array, c);
|
if(c != null) ARRAYS.stableSort(array, c);
|
||||||
else ARRAYS.stableSort(array);
|
else ARRAYS.stableSort(array);
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||||
iter.NEXT();
|
iter.NEXT();
|
||||||
iter.set(array[i]);
|
iter.set(array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -240,11 +240,11 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
KEY_TYPE[] array = (KEY_TYPE[])TO_ARRAY();
|
KEY_TYPE[] array = (KEY_TYPE[])TO_ARRAY();
|
||||||
if(c != null) ARRAYS.unstableSort(array, c);
|
if(c != null) ARRAYS.unstableSort(array, c);
|
||||||
else ARRAYS.unstableSort(array);
|
else ARRAYS.unstableSort(array);
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||||
iter.NEXT();
|
iter.NEXT();
|
||||||
iter.set(array[i]);
|
iter.set(array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -303,11 +303,11 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
||||||
KEY_TYPE[] array = TO_ARRAY();
|
KEY_TYPE[] array = TO_ARRAY();
|
||||||
if(c != null) ARRAYS.unstableSort(array, c);
|
if(c != null) ARRAYS.unstableSort(array, c);
|
||||||
else ARRAYS.unstableSort(array);
|
else ARRAYS.unstableSort(array);
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||||
iter.NEXT();
|
iter.NEXT();
|
||||||
iter.set(array[i]);
|
iter.set(array[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,9 +26,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
||||||
public void add(KEY_TYPE e);
|
public void add(KEY_TYPE e);
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE previous() {
|
public default CLASS_TYPE previous() {
|
||||||
|
@ -36,9 +36,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE next() {
|
public default CLASS_TYPE next() {
|
||||||
|
@ -46,9 +46,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default void set(CLASS_TYPE e) {
|
public default void set(CLASS_TYPE e) {
|
||||||
|
@ -56,9 +56,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default void add(CLASS_TYPE e) {
|
public default void add(CLASS_TYPE e) {
|
||||||
|
|
|
@ -128,20 +128,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
||||||
@Override
|
@Override
|
||||||
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) {
|
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) {
|
||||||
VALUE_TYPE curValue = GET_VALUE(key);
|
VALUE_TYPE curValue = GET_VALUE(key);
|
||||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) {
|
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) {
|
||||||
VALUE_TYPE curValue;
|
VALUE_TYPE curValue;
|
||||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||||
curValue = put(key, value);
|
curValue = put(key, value);
|
||||||
}
|
}
|
||||||
return curValue;
|
return curValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -161,68 +161,68 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value = GET_VALUE(key);
|
VALUE_TYPE value = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||||
remove(key);
|
remove(key);
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
remove(key);
|
remove(key);
|
||||||
}
|
}
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||||
else put(key, newValue);
|
else put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
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)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||||
else put(key, newValue);
|
else put(key, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1175,8 +1175,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
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)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
|
|
|
@ -1153,8 +1153,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,7 +484,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
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)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
|
|
|
@ -1067,8 +1067,8 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,7 +514,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
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)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
|
|
|
@ -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
|
public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** Enum Type that is being used */
|
/** Enum Type that is being used */
|
||||||
protected final Class<T> keyType;
|
protected final Class<T> keyType;
|
||||||
/** The Backing keys array. */
|
/** The Backing keys array. */
|
||||||
protected transient final T[] keys;
|
protected transient final T[] keys;
|
||||||
/** The Backing values array */
|
/** 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 */
|
/** 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 */
|
/** Amount of Elements stored in the ArrayMap */
|
||||||
protected int size = 0;
|
protected int size = 0;
|
||||||
/** EntrySet cache */
|
/** EntrySet cache */
|
||||||
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||||
/** KeySet cache */
|
/** KeySet cache */
|
||||||
protected transient ObjectSet<T> keySet;
|
protected transient ObjectSet<T> keySet;
|
||||||
/** Values cache */
|
/** Values cache */
|
||||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param keyType the type of Enum that should be used
|
* @param keyType the type of Enum that should be used
|
||||||
*/
|
*/
|
||||||
public ENUM_MAP(Class<T> keyType) {
|
public ENUM_MAP(Class<T> keyType) {
|
||||||
this.keyType = keyType;
|
this.keyType = keyType;
|
||||||
keys = getKeyUniverse(keyType);
|
keys = getKeyUniverse(keyType);
|
||||||
|
@ -222,28 +222,28 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
|
|
||||||
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
|
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
|
||||||
return keyType.getEnumConstants();
|
return keyType.getEnumConstants();
|
||||||
}
|
}
|
||||||
|
|
||||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if(o instanceof Map.Entry) {
|
if(o instanceof Map.Entry) {
|
||||||
if(o instanceof MAP.Entry) {
|
if(o instanceof MAP.Entry) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
||||||
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
||||||
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
|
@ -259,21 +259,21 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ENUM_MAP.this.clear();
|
ENUM_MAP.this.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeySet extends AbstractObjectSet<T> {
|
class KeySet extends AbstractObjectSet<T> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
return containsKey(o);
|
return containsKey(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
int size = size();
|
int size = size();
|
||||||
ENUM_MAP.this.remove(o);
|
ENUM_MAP.this.remove(o);
|
||||||
return size != size();
|
return size != size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectIterator<T> iterator() {
|
public ObjectIterator<T> iterator() {
|
||||||
|
@ -289,9 +289,9 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ENUM_MAP.this.clear();
|
ENUM_MAP.this.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@ -319,34 +319,34 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
public void clear() {
|
public void clear() {
|
||||||
ENUM_MAP.this.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
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
int index = nextEntry();
|
int index = nextEntry();
|
||||||
return new BasicEntry<>(keys[index], values[index]);
|
return new BasicEntry<>(keys[index], values[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
||||||
@Override
|
@Override
|
||||||
public T next() {
|
public T next() {
|
||||||
return keys[nextEntry()];
|
return keys[nextEntry()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_NEXT() {
|
public VALUE_TYPE VALUE_NEXT() {
|
||||||
return values[nextEntry()];
|
return values[nextEntry()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MapIterator {
|
class MapIterator {
|
||||||
int index;
|
int index;
|
||||||
int lastReturnValue = -1;
|
int lastReturnValue = -1;
|
||||||
int nextIndex = -1;
|
int nextIndex = -1;
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(nextIndex == -1 && index < values.length) {
|
if(nextIndex == -1 && index < values.length) {
|
||||||
|
@ -368,5 +368,5 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
||||||
clear(lastReturnValue);
|
clear(lastReturnValue);
|
||||||
values[lastReturnValue] = EMPTY_VALUE;
|
values[lastReturnValue] = EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
||||||
protected int firstIndex = -1;
|
protected int firstIndex = -1;
|
||||||
/** The Last Index in the Map */
|
/** The Last Index in the Map */
|
||||||
protected int lastIndex = -1;
|
protected int lastIndex = -1;
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param keyType the type of Enum that should be used
|
* @param keyType the type of Enum that should be used
|
||||||
*/
|
*/
|
||||||
public LINKED_ENUM_MAP(Class<T> keyType) {
|
public LINKED_ENUM_MAP(Class<T> keyType) {
|
||||||
super(keyType);
|
super(keyType);
|
||||||
links = new long[keys.length];
|
links = new long[keys.length];
|
||||||
|
|
|
@ -934,31 +934,31 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
return descendingMap;
|
return descendingMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||||
return entry.next();
|
return entry.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||||
return entry.previous();
|
return entry.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
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(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey 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);
|
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
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()));
|
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) {
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||||
return entry.previous();
|
return entry.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||||
return entry.next();
|
return entry.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator() == null ? null : m.comparator().reversed(); }
|
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
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
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(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey 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);
|
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
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 AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||||
final KEY_TYPE low;
|
final KEY_TYPE low;
|
||||||
final KEY_TYPE high;
|
final KEY_TYPE high;
|
||||||
final boolean fromStart;
|
final boolean fromStart;
|
||||||
final boolean toEnd;
|
final boolean toEnd;
|
||||||
final boolean loInclusive;
|
final boolean loInclusive;
|
||||||
final boolean hiInclusive;
|
final boolean hiInclusive;
|
||||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||||
transient SubMapEntrySet entrySet;
|
transient SubMapEntrySet entrySet;
|
||||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||||
transient SubMapValues values;
|
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) {
|
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.m = m;
|
||||||
this.low = low;
|
this.low = low;
|
||||||
this.high = high;
|
this.high = high;
|
||||||
this.fromStart = fromStart;
|
this.fromStart = fromStart;
|
||||||
|
@ -1112,12 +1112,12 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
this.hiInclusive = hiInclusive;
|
this.hiInclusive = hiInclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
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 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 AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1130,10 +1130,10 @@ 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);
|
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 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 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 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 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 inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||||
|
@ -1158,18 +1158,18 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||||
#if TYPE_OBJECT
|
#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> {
|
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
public SubMapEntrySetIterator(boolean descending) {
|
public SubMapEntrySetIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 {
|
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
public SubMapKeyIterator(boolean descending) {
|
public SubMapKeyIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 {
|
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public SubMapValueIterator(boolean descending) {
|
public SubMapValueIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 next;
|
||||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
public SubMapEntryIterator(boolean descending) {
|
public SubMapEntryIterator(boolean descending) {
|
||||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
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) {
|
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;
|
next = entry;
|
||||||
|
@ -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();
|
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();
|
if(m instanceof AVL_TREE_MAP) return entry.next();
|
||||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
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();
|
if(m instanceof AVL_TREE_MAP) return entry.previous();
|
||||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
@ -2185,10 +2185,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MapEntryIterator {
|
abstract class MapEntryIterator {
|
||||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
public MapEntryIterator(boolean descending) {
|
public MapEntryIterator(boolean descending) {
|
||||||
if(descending) previous = last;
|
if(descending) previous = last;
|
||||||
|
|
|
@ -555,8 +555,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
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)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
Entry KEY_VALUE_GENERIC_TYPE subEntry = findNode(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());
|
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
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
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(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey 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);
|
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
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
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
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(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey 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);
|
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
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 RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||||
final KEY_TYPE low;
|
final KEY_TYPE low;
|
||||||
final KEY_TYPE high;
|
final KEY_TYPE high;
|
||||||
final boolean fromStart;
|
final boolean fromStart;
|
||||||
final boolean toEnd;
|
final boolean toEnd;
|
||||||
final boolean loInclusive;
|
final boolean loInclusive;
|
||||||
final boolean hiInclusive;
|
final boolean hiInclusive;
|
||||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||||
transient SubMapEntrySet entrySet;
|
transient SubMapEntrySet entrySet;
|
||||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||||
transient SubMapValues values;
|
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) {
|
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.m = m;
|
||||||
this.low = low;
|
this.low = low;
|
||||||
this.high = high;
|
this.high = high;
|
||||||
this.fromStart = fromStart;
|
this.fromStart = fromStart;
|
||||||
|
@ -1166,12 +1166,12 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
this.hiInclusive = hiInclusive;
|
this.hiInclusive = hiInclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
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 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 RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
|
@ -1183,10 +1183,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
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 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 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 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 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 inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||||
|
@ -1211,18 +1211,18 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||||
#if TYPE_OBJECT
|
#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> {
|
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
public SubMapEntrySetIterator(boolean descending) {
|
public SubMapEntrySetIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 {
|
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
public SubMapKeyIterator(boolean descending) {
|
public SubMapKeyIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 {
|
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public SubMapValueIterator(boolean descending) {
|
public SubMapValueIterator(boolean descending) {
|
||||||
super(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) {
|
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);
|
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 next;
|
||||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
public SubMapEntryIterator(boolean descending) {
|
public SubMapEntryIterator(boolean descending) {
|
||||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
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) {
|
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;
|
next = entry;
|
||||||
|
@ -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();
|
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();
|
if(m instanceof RB_TREE_MAP) return entry.next();
|
||||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
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();
|
if(m instanceof RB_TREE_MAP) return entry.previous();
|
||||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
@ -2238,10 +2238,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class MapEntryIterator {
|
abstract class MapEntryIterator {
|
||||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
public MapEntryIterator(boolean descending) {
|
public MapEntryIterator(boolean descending) {
|
||||||
if(descending) previous = last;
|
if(descending) previous = last;
|
||||||
|
|
|
@ -25,8 +25,8 @@ import speiger.src.collections.utils.ITrimmable;
|
||||||
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
||||||
{
|
{
|
||||||
/** Max Possible ArraySize without the JVM Crashing */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
/** The Minimum Capacity that is allowed */
|
/** The Minimum Capacity that is allowed */
|
||||||
public static final int MIN_CAPACITY = 4;
|
public static final int MIN_CAPACITY = 4;
|
||||||
/** The Backing array */
|
/** The Backing array */
|
||||||
protected transient KEY_TYPE[] array;
|
protected transient KEY_TYPE[] array;
|
||||||
|
|
|
@ -748,7 +748,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.previous(); }
|
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.previous(); }
|
||||||
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_KEY() { return super.LAST_KEY(); }
|
public KEY_TYPE FIRST_KEY() { return super.LAST_KEY(); }
|
||||||
|
@ -816,13 +816,13 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
AVL_TREE_SET KEY_GENERIC_TYPE set;
|
AVL_TREE_SET KEY_GENERIC_TYPE set;
|
||||||
KEY_TYPE start;
|
KEY_TYPE start;
|
||||||
KEY_TYPE end;
|
KEY_TYPE end;
|
||||||
boolean fromStart;
|
boolean fromStart;
|
||||||
boolean toEnd;
|
boolean toEnd;
|
||||||
boolean loInclusive;
|
boolean loInclusive;
|
||||||
boolean hiInclusive;
|
boolean hiInclusive;
|
||||||
|
|
||||||
SubSet(AVL_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
SubSet(AVL_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
||||||
this.set = set;
|
this.set = set;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.fromStart = fromStart;
|
this.fromStart = fromStart;
|
||||||
|
@ -851,12 +851,12 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? set.compare(key, start) < 0 : set.compare(key, start) <= 0); }
|
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? set.compare(key, start) < 0 : set.compare(key, start) <= 0); }
|
||||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? set.compare(key, end) > 0 : set.compare(key, end) >= 0); }
|
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? set.compare(key, end) > 0 : set.compare(key, end) >= 0); }
|
||||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || set.compare(key, start) >= 0) && (toEnd || set.compare(end, key) >= 0); }
|
boolean inClosedRange(KEY_TYPE key) { return (fromStart || set.compare(key, start) >= 0) && (toEnd || set.compare(end, key) >= 0); }
|
||||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
||||||
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
|
@ -18,31 +18,31 @@ public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hashCode = 1;
|
int hashCode = 1;
|
||||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof Set))
|
if (!(o instanceof Set))
|
||||||
return false;
|
return false;
|
||||||
Set<?> l = (Set<?>)o;
|
Set<?> l = (Set<?>)o;
|
||||||
if(l.size() != size()) return false;
|
if(l.size() != size()) return false;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
if(l instanceof SET)
|
if(l instanceof SET)
|
||||||
{
|
{
|
||||||
ITERATOR e1 = iterator();
|
ITERATOR e1 = iterator();
|
||||||
ITERATOR e2 = ((SET)l).iterator();
|
ITERATOR e2 = ((SET)l).iterator();
|
||||||
while (e1.hasNext() && e2.hasNext()) {
|
while (e1.hasNext() && e2.hasNext()) {
|
||||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !(e1.hasNext() || e2.hasNext());
|
return !(e1.hasNext() || e2.hasNext());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
Iterator<CLASS_TYPE> e1 = iterator();
|
Iterator<CLASS_TYPE> e1 = iterator();
|
||||||
|
|
|
@ -389,8 +389,8 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -618,8 +618,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,8 +589,8 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
previous = nullIndex;
|
previous = nullIndex;
|
||||||
}
|
}
|
||||||
else throw new NoSuchElementException("The null element is not in the set");
|
else throw new NoSuchElementException("The null element is not in the set");
|
||||||
}
|
}
|
||||||
|
|
|
@ -809,7 +809,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.previous(); }
|
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.previous(); }
|
||||||
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_KEY() { return super.LAST_KEY(); }
|
public KEY_TYPE FIRST_KEY() { return super.LAST_KEY(); }
|
||||||
|
@ -877,13 +877,13 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
RB_TREE_SET KEY_GENERIC_TYPE set;
|
RB_TREE_SET KEY_GENERIC_TYPE set;
|
||||||
KEY_TYPE start;
|
KEY_TYPE start;
|
||||||
KEY_TYPE end;
|
KEY_TYPE end;
|
||||||
boolean fromStart;
|
boolean fromStart;
|
||||||
boolean toEnd;
|
boolean toEnd;
|
||||||
boolean loInclusive;
|
boolean loInclusive;
|
||||||
boolean hiInclusive;
|
boolean hiInclusive;
|
||||||
|
|
||||||
SubSet(RB_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
SubSet(RB_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
||||||
this.set = set;
|
this.set = set;
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
this.fromStart = fromStart;
|
this.fromStart = fromStart;
|
||||||
|
@ -912,12 +912,12 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? set.compare(key, start) < 0 : set.compare(key, start) <= 0); }
|
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? set.compare(key, start) < 0 : set.compare(key, start) <= 0); }
|
||||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? set.compare(key, end) > 0 : set.compare(key, end) >= 0); }
|
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? set.compare(key, end) > 0 : set.compare(key, end) >= 0); }
|
||||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || set.compare(key, start) >= 0) && (toEnd || set.compare(end, key) >= 0); }
|
boolean inClosedRange(KEY_TYPE key) { return (fromStart || set.compare(key, start) >= 0) && (toEnd || set.compare(end, key) >= 0); }
|
||||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
||||||
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
|
@ -560,11 +560,11 @@ public class ARRAYS
|
||||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) {
|
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) {
|
||||||
for (int i = from+1;i<to; i++) {
|
for (int i = from+1;i<to; i++) {
|
||||||
KEY_TYPE current = array[i];
|
KEY_TYPE current = array[i];
|
||||||
int j = i - 1;
|
int j = i - 1;
|
||||||
while(j >= from && COMPAREABLE_TO_KEY(current, array[j]) < 0) {
|
while(j >= from && COMPAREABLE_TO_KEY(current, array[j]) < 0) {
|
||||||
array[j+1] = array[j--];
|
array[j+1] = array[j--];
|
||||||
}
|
}
|
||||||
array[j+1] = current;
|
array[j+1] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,19 +598,19 @@ public class ARRAYS
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
for (int i = from; i < to; i++) {
|
for (int i = from; i < to; i++) {
|
||||||
KEY_TYPE min = array[i];
|
KEY_TYPE min = array[i];
|
||||||
int minId = i;
|
int minId = i;
|
||||||
for(int j = i+1; j < to; j++) {
|
for(int j = i+1; j < to; j++) {
|
||||||
if(comp.compare(array[j], min) < 0) {
|
if(comp.compare(array[j], min) < 0) {
|
||||||
min = array[j];
|
min = array[j];
|
||||||
minId = j;
|
minId = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KEY_TYPE temp = array[i];
|
KEY_TYPE temp = array[i];
|
||||||
array[i] = min;
|
array[i] = min;
|
||||||
array[minId] = temp;
|
array[minId] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -640,19 +640,19 @@ public class ARRAYS
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) {
|
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) {
|
||||||
for (int i = from; i < to; i++) {
|
for (int i = from; i < to; i++) {
|
||||||
KEY_TYPE min = array[i];
|
KEY_TYPE min = array[i];
|
||||||
int minId = i;
|
int minId = i;
|
||||||
for(int j = i+1; j < to; j++) {
|
for(int j = i+1; j < to; j++) {
|
||||||
if(COMPAREABLE_TO_KEY(array[j], min) < 0) {
|
if(COMPAREABLE_TO_KEY(array[j], min) < 0) {
|
||||||
min = array[j];
|
min = array[j];
|
||||||
minId = j;
|
minId = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KEY_TYPE temp = array[i];
|
KEY_TYPE temp = array[i];
|
||||||
array[i] = min;
|
array[i] = min;
|
||||||
array[minId] = temp;
|
array[minId] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1431,7 +1431,7 @@ public class ARRAYS
|
||||||
}
|
}
|
||||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
if(supp == null) supp = Arrays.copyOf(array, to);
|
||||||
int mid = (from + to) >>> 1;
|
int mid = (from + to) >>> 1;
|
||||||
invokeAll(new MergeSortActionBRACES(supp, array, from, mid), new MergeSortActionBRACES(supp, array, mid, to));
|
invokeAll(new MergeSortActionBRACES(supp, array, from, mid), new MergeSortActionBRACES(supp, array, mid, to));
|
||||||
if(COMPAREABLE_TO_KEY(supp[mid - 1], supp[mid]) <= 0)
|
if(COMPAREABLE_TO_KEY(supp[mid - 1], supp[mid]) <= 0)
|
||||||
{
|
{
|
||||||
System.arraycopy(supp, from, array, from, to - from);
|
System.arraycopy(supp, from, array, from, to - from);
|
||||||
|
@ -1470,7 +1470,7 @@ public class ARRAYS
|
||||||
}
|
}
|
||||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
if(supp == null) supp = Arrays.copyOf(array, to);
|
||||||
int mid = (from + to) >>> 1;
|
int mid = (from + to) >>> 1;
|
||||||
invokeAll(new MergeSortActionCompBRACES(supp, array, from, mid, comp), new MergeSortActionCompBRACES(supp, array, mid, to, comp));
|
invokeAll(new MergeSortActionCompBRACES(supp, array, from, mid, comp), new MergeSortActionCompBRACES(supp, array, mid, to, comp));
|
||||||
if(comp.compare(supp[mid - 1], supp[mid]) <= 0)
|
if(comp.compare(supp[mid - 1], supp[mid]) <= 0)
|
||||||
{
|
{
|
||||||
System.arraycopy(supp, from, array, from, to - from);
|
System.arraycopy(supp, from, array, from, to - from);
|
||||||
|
|
|
@ -335,146 +335,146 @@ public class SPLIT_ITERATORS
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
static class IteratorSpliterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
static class IteratorSpliterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
||||||
static final int BATCH_UNIT = 1 << 10;
|
static final int BATCH_UNIT = 1 << 10;
|
||||||
static final int MAX_BATCH = 1 << 25;
|
static final int MAX_BATCH = 1 << 25;
|
||||||
private final COLLECTION KEY_GENERIC_TYPE collection;
|
private final COLLECTION KEY_GENERIC_TYPE collection;
|
||||||
private ITERATOR KEY_GENERIC_TYPE it;
|
private ITERATOR KEY_GENERIC_TYPE it;
|
||||||
private final int characteristics;
|
private final int characteristics;
|
||||||
private long est;
|
private long est;
|
||||||
private int batch;
|
private int batch;
|
||||||
|
|
||||||
IteratorSpliterator(COLLECTION KEY_GENERIC_TYPE collection, int characteristics) {
|
IteratorSpliterator(COLLECTION KEY_GENERIC_TYPE collection, int characteristics) {
|
||||||
this.collection = collection;
|
this.collection = collection;
|
||||||
it = null;
|
it = null;
|
||||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||||
: characteristics;
|
: characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, long size, int characteristics) {
|
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, long size, int characteristics) {
|
||||||
collection = null;
|
collection = null;
|
||||||
it = iterator;
|
it = iterator;
|
||||||
est = size;
|
est = size;
|
||||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||||
: characteristics;
|
: characteristics;
|
||||||
}
|
}
|
||||||
|
|
||||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, int characteristics) {
|
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, int characteristics) {
|
||||||
collection = null;
|
collection = null;
|
||||||
it = iterator;
|
it = iterator;
|
||||||
est = Long.MAX_VALUE;
|
est = Long.MAX_VALUE;
|
||||||
this.characteristics = characteristics & ~(Spliterator.SIZED | Spliterator.SUBSIZED);
|
this.characteristics = characteristics & ~(Spliterator.SIZED | Spliterator.SUBSIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ITERATOR KEY_GENERIC_TYPE iterator()
|
private ITERATOR KEY_GENERIC_TYPE iterator()
|
||||||
{
|
{
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
it = collection.iterator();
|
it = collection.iterator();
|
||||||
est = collection.size();
|
est = collection.size();
|
||||||
}
|
}
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
||||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||||
if (est > 1 && i.hasNext()) {
|
if (est > 1 && i.hasNext()) {
|
||||||
int n = Math.min(batch + BATCH_UNIT, Math.min((int)est, MAX_BATCH));
|
int n = Math.min(batch + BATCH_UNIT, Math.min((int)est, MAX_BATCH));
|
||||||
KEY_TYPE[] a = NEW_KEY_ARRAY(n);
|
KEY_TYPE[] a = NEW_KEY_ARRAY(n);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
do { a[j] = i.NEXT(); } while (++j < n && i.hasNext());
|
do { a[j] = i.NEXT(); } while (++j < n && i.hasNext());
|
||||||
batch = j;
|
batch = j;
|
||||||
if (est != Long.MAX_VALUE)
|
if (est != Long.MAX_VALUE)
|
||||||
est -= j;
|
est -= j;
|
||||||
return new ArraySplitIteratorBRACES(a, 0, j, characteristics);
|
return new ArraySplitIteratorBRACES(a, 0, j, characteristics);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEachRemaining(JAVA_CONSUMER action) {
|
public void forEachRemaining(JAVA_CONSUMER action) {
|
||||||
if (action == null) throw new NullPointerException();
|
if (action == null) throw new NullPointerException();
|
||||||
iterator().forEachRemaining(T -> action.accept(T));
|
iterator().forEachRemaining(T -> action.accept(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryAdvance(JAVA_CONSUMER action) {
|
public boolean tryAdvance(JAVA_CONSUMER action) {
|
||||||
if (action == null) throw new NullPointerException();
|
if (action == null) throw new NullPointerException();
|
||||||
ITERATOR KEY_GENERIC_TYPE iter = iterator();
|
ITERATOR KEY_GENERIC_TYPE iter = iterator();
|
||||||
if (iter.hasNext()) {
|
if (iter.hasNext()) {
|
||||||
action.accept(iter.NEXT());
|
action.accept(iter.NEXT());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long estimateSize() {
|
public long estimateSize() {
|
||||||
iterator();
|
iterator();
|
||||||
return est;
|
return est;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int characteristics() { return characteristics; }
|
public int characteristics() { return characteristics; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<? super JAVA_CLASS> getComparator() {
|
public Comparator<? super JAVA_CLASS> getComparator() {
|
||||||
if (hasCharacteristics(4)) //Sorted
|
|
||||||
return null;
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static final class ArraySplitIterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
|
||||||
private final KEY_TYPE[] array;
|
|
||||||
private int index;
|
|
||||||
private final int fence;
|
|
||||||
private final int characteristics;
|
|
||||||
|
|
||||||
public ArraySplitIterator(KEY_TYPE[] array, int origin, int fence, int additionalCharacteristics) {
|
|
||||||
this.array = array;
|
|
||||||
index = origin;
|
|
||||||
this.fence = fence;
|
|
||||||
characteristics = additionalCharacteristics | Spliterator.SIZED | Spliterator.SUBSIZED;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
|
||||||
int lo = index, mid = (lo + fence) >>> 1;
|
|
||||||
return (lo >= mid) ? null : new ArraySplitIteratorBRACES(array, lo, index = mid, characteristics);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void forEachRemaining(JAVA_CONSUMER action) {
|
|
||||||
if (action == null) throw new NullPointerException();
|
|
||||||
KEY_TYPE[] a; int i, hi;
|
|
||||||
if ((a = array).length >= (hi = fence) && (i = index) >= 0 && i < (index = hi)) {
|
|
||||||
do { action.accept(a[i]); } while (++i < hi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean tryAdvance(JAVA_CONSUMER action) {
|
|
||||||
if (action == null) throw new NullPointerException();
|
|
||||||
if (index >= 0 && index < fence) {
|
|
||||||
action.accept(array[index++]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long estimateSize() { return fence - index; }
|
|
||||||
@Override
|
|
||||||
public int characteristics() { return characteristics; }
|
|
||||||
@Override
|
|
||||||
public Comparator<? super JAVA_CLASS> getComparator() {
|
|
||||||
if (hasCharacteristics(4)) //Sorted
|
if (hasCharacteristics(4)) //Sorted
|
||||||
return null;
|
return null;
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static final class ArraySplitIterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
private final KEY_TYPE[] array;
|
||||||
|
private int index;
|
||||||
|
private final int fence;
|
||||||
|
private final int characteristics;
|
||||||
|
|
||||||
|
public ArraySplitIterator(KEY_TYPE[] array, int origin, int fence, int additionalCharacteristics) {
|
||||||
|
this.array = array;
|
||||||
|
index = origin;
|
||||||
|
this.fence = fence;
|
||||||
|
characteristics = additionalCharacteristics | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
||||||
|
int lo = index, mid = (lo + fence) >>> 1;
|
||||||
|
return (lo >= mid) ? null : new ArraySplitIteratorBRACES(array, lo, index = mid, characteristics);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachRemaining(JAVA_CONSUMER action) {
|
||||||
|
if (action == null) throw new NullPointerException();
|
||||||
|
KEY_TYPE[] a; int i, hi;
|
||||||
|
if ((a = array).length >= (hi = fence) && (i = index) >= 0 && i < (index = hi)) {
|
||||||
|
do { action.accept(a[i]); } while (++i < hi);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean tryAdvance(JAVA_CONSUMER action) {
|
||||||
|
if (action == null) throw new NullPointerException();
|
||||||
|
if (index >= 0 && index < fence) {
|
||||||
|
action.accept(array[index++]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long estimateSize() { return fence - index; }
|
||||||
|
@Override
|
||||||
|
public int characteristics() { return characteristics; }
|
||||||
|
@Override
|
||||||
|
public Comparator<? super JAVA_CLASS> getComparator() {
|
||||||
|
if (hasCharacteristics(4)) //Sorted
|
||||||
|
return null;
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue