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
|
||||
/**
|
||||
* 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
|
||||
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.
|
||||
* @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
|
||||
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
|
||||
/**
|
||||
* 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()
|
||||
*/
|
||||
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.
|
||||
* @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
|
||||
* @see Collection#toArray(Object[])
|
||||
* @return an array containing all of the elements in this collection
|
||||
* @see Collection#toArray(Object[])
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||
Objects.requireNonNull(filter);
|
||||
boolean removed = false;
|
||||
final ITERATOR each = iterator();
|
||||
while (each.hasNext()) {
|
||||
if (filter.test(each.NEXT())) {
|
||||
each.remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
Objects.requireNonNull(filter);
|
||||
boolean removed = false;
|
||||
final ITERATOR each = iterator();
|
||||
while (each.hasNext()) {
|
||||
if (filter.test(each.NEXT())) {
|
||||
each.remove();
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -164,7 +164,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||
@Deprecated
|
||||
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.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
|
|
|
@ -34,25 +34,25 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
|||
@Deprecated
|
||||
public default CLASS_TYPE next() { return KEY_TO_OBJ(NEXT()); }
|
||||
|
||||
/**
|
||||
* Performs the given action for each remaining element until all elements
|
||||
* have been processed or the action throws an exception. Actions are
|
||||
* performed in the order of iteration, if that order is specified.
|
||||
* Exceptions thrown by the action are relayed to the caller.
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* while (hasNext()) action.accept(NEXT());
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
* @see Iterator#forEachRemaining(Consumer)
|
||||
*/
|
||||
/**
|
||||
* Performs the given action for each remaining element until all elements
|
||||
* have been processed or the action throws an exception. Actions are
|
||||
* performed in the order of iteration, if that order is specified.
|
||||
* Exceptions thrown by the action are relayed to the caller.
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* while (hasNext()) action.accept(NEXT());
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
* @see Iterator#forEachRemaining(Consumer)
|
||||
*/
|
||||
public default void forEachRemaining(CONSUMER action) {
|
||||
Objects.requireNonNull(action);
|
||||
while(hasNext()) { action.accept(NEXT()); }
|
||||
Objects.requireNonNull(action);
|
||||
while(hasNext()) { action.accept(NEXT()); }
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
|
@ -62,21 +62,21 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
|||
@Deprecated
|
||||
@Override
|
||||
default void forEachRemaining(Consumer<? super CLASS_TYPE> action) {
|
||||
Objects.requireNonNull(action);
|
||||
forEachRemaining(action::accept);
|
||||
Objects.requireNonNull(action);
|
||||
forEachRemaining(action::accept);
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* 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 action The action to be performed for each element
|
||||
* @param <E> the generic type of the Object
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
* @param action The action to be performed for each element
|
||||
* @param <E> the generic type of the Object
|
||||
* @throws java.lang.NullPointerException if the specified action is null
|
||||
*/
|
||||
default <E> void forEachRemaining(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||
Objects.requireNonNull(action);
|
||||
while(hasNext()) { action.accept(NEXT(), input); }
|
||||
Objects.requireNonNull(action);
|
||||
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
|
||||
* @param o1 the first 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.
|
||||
* @param o1 the first 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.
|
||||
* @see Comparator#compare(Object, Object)
|
||||
*/
|
||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
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>
|
||||
#endif
|
||||
{
|
||||
/**
|
||||
* Type-Specific function to reduce (un)boxing.
|
||||
* Performs this operation on the given argument.
|
||||
*
|
||||
* @param t the input argument
|
||||
*/
|
||||
/**
|
||||
* Type-Specific function to reduce (un)boxing.
|
||||
* Performs this operation on the given argument.
|
||||
*
|
||||
* @param t the input argument
|
||||
*/
|
||||
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>
|
||||
{
|
||||
/**
|
||||
* A Type Specific operation method to reduce boxing/unboxing
|
||||
* Performs this operation on the given arguments.
|
||||
*
|
||||
* @param k the first input argument
|
||||
* @param v the second input argument
|
||||
*/
|
||||
/**
|
||||
* A Type Specific operation method to reduce boxing/unboxing
|
||||
* Performs this operation on the given arguments.
|
||||
*
|
||||
* @param k the first input argument
|
||||
* @param v the second input argument
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.test(T);
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) && other.test(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,15 +56,15 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||
* @return a function that compares values in a or comparason
|
||||
*/
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.test(T);
|
||||
Objects.requireNonNull(other);
|
||||
return T -> GET_VALUE(T) || other.test(T);
|
||||
}
|
||||
#else if VALUE_OBJECT
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction<CLASS_
|
|||
#else
|
||||
/**
|
||||
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param k the first function argument
|
||||
* @param v the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
* Applies this function to the given arguments.
|
||||
*
|
||||
* @param k the first function argument
|
||||
* @param v the second function argument
|
||||
* @return the function result
|
||||
*/
|
||||
public VALUE_TYPE APPLY_VALUE(KEY_TYPE k, VALUE_TYPE v);
|
||||
|
||||
@Override
|
||||
|
|
|
@ -160,31 +160,31 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof List))
|
||||
return false;
|
||||
List<?> l = (List<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof List))
|
||||
return false;
|
||||
List<?> l = (List<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
#if !TYPE_OBJECT
|
||||
if(l instanceof LIST)
|
||||
{
|
||||
LIST_ITERATOR e1 = listIterator();
|
||||
LIST_ITERATOR e2 = ((LIST)l).listIterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
LIST_ITERATOR e1 = listIterator();
|
||||
LIST_ITERATOR e2 = ((LIST)l).listIterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
}
|
||||
#endif
|
||||
ListIterator<CLASS_TYPE> e1 = listIterator();
|
||||
ListIterator<?> e2 = l.listIterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!Objects.equals(e1.next(), e2.next()))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
ListIterator<CLASS_TYPE> e1 = listIterator();
|
||||
ListIterator<?> e2 = l.listIterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!Objects.equals(e1.next(), e2.next()))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,15 +192,15 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE i = listIterator();
|
||||
while(i.hasNext())
|
||||
int hashCode = 1;
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE i = listIterator();
|
||||
while(i.hasNext())
|
||||
#if TYPE_OBJECT
|
||||
hashCode = 31 * hashCode + i.next().hashCode();
|
||||
#else
|
||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||
#endif
|
||||
return hashCode;
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@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
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* for(int i = 0;i<size;i++)
|
||||
* action.accept(data[i]);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(java.util.function.Consumer)
|
||||
*/
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* for(int i = 0;i<size;i++)
|
||||
* action.accept(data[i]);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(java.util.function.Consumer)
|
||||
*/
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE 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
|
||||
*
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* for(int i = 0;i<size;i++)
|
||||
* action.accept(data[i]);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(java.util.function.Consumer)
|
||||
*/
|
||||
* @implSpec
|
||||
* <p>The default implementation behaves as if:
|
||||
* <pre>{@code
|
||||
* for(int i = 0;i<size;i++)
|
||||
* action.accept(data[i]);
|
||||
* }</pre>
|
||||
*
|
||||
* @param action The action to be performed for each element
|
||||
* @throws NullPointerException if the specified action is null
|
||||
* @see Iterable#forEach(java.util.function.Consumer)
|
||||
*/
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
Objects.requireNonNull(action);
|
||||
|
|
|
@ -877,7 +877,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#if TYPE_OBJECT
|
||||
x.value = null;
|
||||
#endif
|
||||
|
||||
if (prev == null) first = next;
|
||||
else {
|
||||
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
|
||||
{
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
LINKED_LIST KEY_GENERIC_TYPE list;
|
||||
Entry KEY_GENERIC_TYPE entry;
|
||||
int index;
|
||||
|
@ -1049,7 +1048,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1069,9 +1068,9 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
#if PRIMITIVES
|
||||
private static class SplitIterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE
|
||||
{
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
LINKED_LIST KEY_GENERIC_TYPE list;
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
LINKED_LIST KEY_GENERIC_TYPE list;
|
||||
Entry entry;
|
||||
int index;
|
||||
|
||||
|
@ -1115,7 +1114,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||
return Spliterator.ORDERED | Spliterator.SIZED | Spliterator.SUBSIZED;
|
||||
}
|
||||
|
||||
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
|
||||
* @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)
|
||||
*/
|
||||
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
|
||||
* @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
|
||||
* @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
|
||||
* @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
|
||||
*/
|
||||
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
|
||||
* @param index index of the element to replace
|
||||
* @param e element to be stored at the specified position
|
||||
* @return the element previously at the specified position
|
||||
* @param index index of the element to replace
|
||||
* @param e element to be stored at the specified position
|
||||
* @return the element previously at the specified position
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* A Type-Specific remove function to reduce (un)boxing
|
||||
* @param index the index of the element to be removed
|
||||
* @return the element previously at the specified position
|
||||
* @see List#remove(int)
|
||||
* @param index the index of the element to be removed
|
||||
* @return the element previously at the specified position
|
||||
* @see List#remove(int)
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public default void REPLACE(JAVA_UNARY_OPERATOR o) {
|
||||
Objects.requireNonNull(o);
|
||||
LIST_ITERATOR iter = listIterator();
|
||||
while (iter.hasNext())
|
||||
Objects.requireNonNull(o);
|
||||
LIST_ITERATOR iter = listIterator();
|
||||
while (iter.hasNext())
|
||||
#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
|
||||
iter.set(o.APPLY(iter.NEXT()));
|
||||
#endif
|
||||
|
@ -141,17 +141,17 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
*/
|
||||
@Override
|
||||
public default void replaceAll(UnaryOperator<CLASS_TYPE> o) {
|
||||
Objects.requireNonNull(o);
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
while (iter.hasNext()) iter.set(o.apply(iter.NEXT()));
|
||||
Objects.requireNonNull(o);
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
while (iter.hasNext()) iter.set(o.apply(iter.NEXT()));
|
||||
}
|
||||
|
||||
#endif
|
||||
/**
|
||||
* A function to fast add elements to the list
|
||||
* @param a the elements that should be added
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
*/
|
||||
/**
|
||||
* A function to fast add elements to the list
|
||||
* @param a the elements that should be added
|
||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||
*/
|
||||
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();
|
||||
if(c != null) ARRAYS.stableSort(array, c);
|
||||
else ARRAYS.stableSort(array);
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
iter.set(array[i]);
|
||||
}
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
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();
|
||||
if(c != null) ARRAYS.unstableSort(array, c);
|
||||
else ARRAYS.unstableSort(array);
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
iter.set(array[i]);
|
||||
}
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
iter.set(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -303,11 +303,11 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||
KEY_TYPE[] array = TO_ARRAY();
|
||||
if(c != null) ARRAYS.unstableSort(array, c);
|
||||
else ARRAYS.unstableSort(array);
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
iter.set(array[i]);
|
||||
}
|
||||
LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator();
|
||||
for (int i = 0,m=size();i<m && iter.hasNext();i++) {
|
||||
iter.NEXT();
|
||||
iter.set(array[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -26,9 +26,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
|||
public void add(KEY_TYPE e);
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE previous() {
|
||||
|
@ -36,9 +36,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
|||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default CLASS_TYPE next() {
|
||||
|
@ -46,9 +46,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
|||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default void set(CLASS_TYPE e) {
|
||||
|
@ -56,9 +56,9 @@ public interface LIST_ITERATOR KEY_GENERIC_TYPE extends ListIterator<CLASS_TYPE>
|
|||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||
* @deprecated Please use the corresponding type-specific function instead.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public default void add(CLASS_TYPE e) {
|
||||
|
|
|
@ -128,20 +128,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
@Override
|
||||
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) {
|
||||
VALUE_TYPE curValue = GET_VALUE(key);
|
||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||
return false;
|
||||
}
|
||||
put(key, newValue);
|
||||
return true;
|
||||
if (VALUE_EQUALS_NOT(curValue, oldValue) || (VALUE_EQUALS(curValue, getDefaultReturnValue()) && !containsKey(key))) {
|
||||
return false;
|
||||
}
|
||||
put(key, newValue);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) {
|
||||
VALUE_TYPE curValue;
|
||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
curValue = put(key, value);
|
||||
}
|
||||
return curValue;
|
||||
if (VALUE_EQUALS_NOT((curValue = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
curValue = put(key, value);
|
||||
}
|
||||
return curValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,68 +161,68 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||
remove(key);
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
put(key, newValue);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||
remove(key);
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
remove(key);
|
||||
}
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE value;
|
||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||
put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
remove(key);
|
||||
}
|
||||
return getDefaultReturnValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? value : mappingFunction.APPLY_VALUE(oldValue, value);
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
return newValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) remove(key);
|
||||
else put(key, newValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1175,8 +1175,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||
MapIterator(KEY_TYPE from) {
|
||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -523,7 +523,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
|
|
|
@ -1153,8 +1153,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||
MapIterator(KEY_TYPE from) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
|
|
|
@ -1067,8 +1067,8 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||
MapIterator(KEY_TYPE from) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -514,7 +514,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
int index = findIndex(key);
|
||||
|
|
|
@ -28,26 +28,26 @@ import speiger.src.collections.objects.sets.ObjectSet;
|
|||
public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
/** Enum Type that is being used */
|
||||
protected final Class<T> keyType;
|
||||
protected final Class<T> keyType;
|
||||
/** The Backing keys array. */
|
||||
protected transient final T[] keys;
|
||||
protected transient final T[] keys;
|
||||
/** The Backing values array */
|
||||
protected transient final VALUE_TYPE[] values;
|
||||
protected transient final VALUE_TYPE[] values;
|
||||
/** The Backing array that indicates which index is present or not */
|
||||
protected transient final long[] present;
|
||||
protected transient final long[] present;
|
||||
/** Amount of Elements stored in the ArrayMap */
|
||||
protected int size = 0;
|
||||
protected int size = 0;
|
||||
/** EntrySet cache */
|
||||
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
protected transient ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySet;
|
||||
/** KeySet cache */
|
||||
protected transient ObjectSet<T> keySet;
|
||||
protected transient ObjectSet<T> keySet;
|
||||
/** Values cache */
|
||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
public ENUM_MAP(Class<T> keyType) {
|
||||
this.keyType = keyType;
|
||||
keys = getKeyUniverse(keyType);
|
||||
|
@ -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) {
|
||||
return keyType.getEnumConstants();
|
||||
}
|
||||
}
|
||||
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
if(o instanceof Map.Entry) return containsKey(((Map.Entry<?, ?>)o).getKey());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if(o instanceof Map.Entry) {
|
||||
if(o instanceof MAP.Entry) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
||||
}
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
if(o instanceof Map.Entry) {
|
||||
if(o instanceof MAP.Entry) {
|
||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE());
|
||||
}
|
||||
Map.Entry<?, ?> entry = (java.util.Map.Entry<?, ?>)o;
|
||||
return ENUM_MAP.this.remove(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||
|
@ -259,21 +259,21 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
public void clear() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KeySet extends AbstractObjectSet<T> {
|
||||
class KeySet extends AbstractObjectSet<T> {
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return containsKey(o);
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return containsKey(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
int size = size();
|
||||
ENUM_MAP.this.remove(o);
|
||||
return size != size();
|
||||
}
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
int size = size();
|
||||
ENUM_MAP.this.remove(o);
|
||||
return size != size();
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||
|
||||
@Override
|
||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
||||
|
@ -319,34 +319,34 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
public void clear() {
|
||||
ENUM_MAP.this.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class EntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
class EntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
@Override
|
||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||
int index = nextEntry();
|
||||
return new BasicEntry<>(keys[index], values[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
||||
class KeyIterator extends MapIterator implements ObjectIterator<T> {
|
||||
@Override
|
||||
public T next() {
|
||||
return keys[nextEntry()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
||||
class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE {
|
||||
@Override
|
||||
public VALUE_TYPE VALUE_NEXT() {
|
||||
return values[nextEntry()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MapIterator {
|
||||
int index;
|
||||
int lastReturnValue = -1;
|
||||
int nextIndex = -1;
|
||||
class MapIterator {
|
||||
int index;
|
||||
int lastReturnValue = -1;
|
||||
int nextIndex = -1;
|
||||
|
||||
public boolean hasNext() {
|
||||
if(nextIndex == -1 && index < values.length) {
|
||||
|
@ -368,5 +368,5 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
clear(lastReturnValue);
|
||||
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;
|
||||
/** The Last Index in the Map */
|
||||
protected int lastIndex = -1;
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
/**
|
||||
* Default Constructor
|
||||
* @param keyType the type of Enum that should be used
|
||||
*/
|
||||
public LINKED_ENUM_MAP(Class<T> keyType) {
|
||||
super(keyType);
|
||||
links = new long[keys.length];
|
||||
|
|
|
@ -934,31 +934,31 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return descendingMap;
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1046,13 +1046,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return entry == null || !inClosedRange(key) ? null : ITERATORS.invert(new SubMapKeyIterator(entry, fromStart ? null : findLowest(), toEnd ? null : findHighest()));
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.previous();
|
||||
}
|
||||
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
return entry.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator() == null ? null : m.comparator().reversed(); }
|
||||
|
@ -1071,21 +1071,21 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1093,17 +1093,17 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
final AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||
final KEY_TYPE low;
|
||||
final KEY_TYPE high;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
this.fromStart = fromStart;
|
||||
|
@ -1112,12 +1112,12 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
this.hiInclusive = hiInclusive;
|
||||
}
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -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);
|
||||
|
||||
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? m.compare(key, low) < 0 : m.compare(key, low) <= 0); }
|
||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); }
|
||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); }
|
||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||
|
@ -1158,18 +1158,18 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||
#if TYPE_OBJECT
|
||||
|
@ -1620,9 +1620,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapEntrySetIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1640,9 +1640,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapKeyIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1660,9 +1660,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapValueIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1685,11 +1685,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
|
||||
public SubMapEntryIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
next = entry;
|
||||
|
@ -1974,15 +1974,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest();
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof AVL_TREE_MAP) return entry.next();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
||||
}
|
||||
}
|
||||
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof AVL_TREE_MAP) return entry.previous();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
|
@ -2185,10 +2185,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
}
|
||||
|
||||
abstract class MapEntryIterator {
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public MapEntryIterator(boolean descending) {
|
||||
if(descending) previous = last;
|
||||
|
|
|
@ -555,8 +555,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
|
||||
@Override
|
||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
||||
KEY_TYPE key = entry.ENTRY_KEY();
|
||||
Entry KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||
VALUE_TYPE newValue = subEntry == null ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||
|
@ -998,21 +998,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1125,21 +1125,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) {
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) {
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||
return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1147,17 +1147,17 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
final RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m;
|
||||
final KEY_TYPE low;
|
||||
final KEY_TYPE high;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
final boolean fromStart;
|
||||
final boolean toEnd;
|
||||
final boolean loInclusive;
|
||||
final boolean hiInclusive;
|
||||
transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap;
|
||||
transient SubMapEntrySet entrySet;
|
||||
transient KeySet KEY_VALUE_GENERIC_TYPE keySet;
|
||||
transient SubMapValues values;
|
||||
|
||||
NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) {
|
||||
this.m = m;
|
||||
this.low = low;
|
||||
this.high = high;
|
||||
this.fromStart = fromStart;
|
||||
|
@ -1166,12 +1166,12 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
this.hiInclusive = hiInclusive;
|
||||
}
|
||||
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending);
|
||||
abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key);
|
||||
abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||
abstract ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entryIterator();
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||
|
||||
@Override
|
||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||
|
@ -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);
|
||||
|
||||
boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? m.compare(key, low) < 0 : m.compare(key, low) <= 0); }
|
||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); }
|
||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); }
|
||||
boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); }
|
||||
boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); }
|
||||
boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); }
|
||||
|
||||
#if TYPE_OBJECT
|
||||
public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); }
|
||||
|
@ -1211,18 +1211,18 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
@Override
|
||||
public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); }
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); }
|
||||
#if TYPE_OBJECT
|
||||
|
@ -1673,9 +1673,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
|
||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapEntrySetIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapEntrySetIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1693,9 +1693,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
|
||||
final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapKeyIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapKeyIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1713,9 +1713,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
|
||||
final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
public SubMapValueIterator(boolean descending) {
|
||||
super(descending);
|
||||
}
|
||||
|
||||
public SubMapValueIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
super(entry, lowerFence, upperFence);
|
||||
|
@ -1738,11 +1738,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
int index = 0;
|
||||
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
public SubMapEntryIterator(boolean descending) {
|
||||
this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest());
|
||||
}
|
||||
|
||||
public SubMapEntryIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) {
|
||||
next = entry;
|
||||
|
@ -2027,15 +2027,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest();
|
||||
}
|
||||
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof RB_TREE_MAP) return entry.next();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry);
|
||||
}
|
||||
}
|
||||
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||
if(m instanceof RB_TREE_MAP) return entry.previous();
|
||||
return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||
|
@ -2238,10 +2238,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
}
|
||||
|
||||
abstract class MapEntryIterator {
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
Entry KEY_VALUE_GENERIC_TYPE next;
|
||||
Entry KEY_VALUE_GENERIC_TYPE previous;
|
||||
Entry KEY_VALUE_GENERIC_TYPE current;
|
||||
int index = 0;
|
||||
|
||||
public MapEntryIterator(boolean descending) {
|
||||
if(descending) previous = last;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
/** Max Possible ArraySize without the JVM Crashing */
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
/** The Minimum Capacity that is allowed */
|
||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
/** The Minimum Capacity that is allowed */
|
||||
public static final int MIN_CAPACITY = 4;
|
||||
/** The Backing 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 start() { return findHighest(); }
|
||||
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
||||
|
||||
@Override
|
||||
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;
|
||||
KEY_TYPE start;
|
||||
KEY_TYPE end;
|
||||
boolean fromStart;
|
||||
boolean toEnd;
|
||||
boolean loInclusive;
|
||||
boolean hiInclusive;
|
||||
boolean fromStart;
|
||||
boolean toEnd;
|
||||
boolean loInclusive;
|
||||
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;
|
||||
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.start = start;
|
||||
this.end = end;
|
||||
this.fromStart = fromStart;
|
||||
|
@ -851,12 +851,12 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
|
||||
#endif
|
||||
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 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 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 start() { return findLowest(); }
|
||||
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 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); }
|
||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
||||
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
||||
|
||||
@Override
|
||||
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
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
while(i.hasNext())
|
||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||
return hashCode;
|
||||
int hashCode = 1;
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
while(i.hasNext())
|
||||
hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT());
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Set))
|
||||
return false;
|
||||
Set<?> l = (Set<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
if (o == this)
|
||||
return true;
|
||||
if (!(o instanceof Set))
|
||||
return false;
|
||||
Set<?> l = (Set<?>)o;
|
||||
if(l.size() != size()) return false;
|
||||
#if !TYPE_OBJECT
|
||||
if(l instanceof SET)
|
||||
{
|
||||
ITERATOR e1 = iterator();
|
||||
ITERATOR e2 = ((SET)l).iterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
ITERATOR e1 = iterator();
|
||||
ITERATOR e2 = ((SET)l).iterator();
|
||||
while (e1.hasNext() && e2.hasNext()) {
|
||||
if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT())))
|
||||
return false;
|
||||
}
|
||||
return !(e1.hasNext() || e2.hasNext());
|
||||
}
|
||||
#endif
|
||||
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) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -618,8 +618,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||
SetIterator(KEY_TYPE from) {
|
||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -589,8 +589,8 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||
SetIterator(KEY_TYPE from) {
|
||||
if(KEY_EQUALS_NULL(from)) {
|
||||
if(containsNull) {
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
next = (int) links[nullIndex];
|
||||
previous = nullIndex;
|
||||
}
|
||||
else throw new NoSuchElementException("The null element is not in the set");
|
||||
}
|
||||
|
|
|
@ -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 start() { return findHighest(); }
|
||||
protected Entry KEY_GENERIC_TYPE start() { return findHighest(); }
|
||||
|
||||
@Override
|
||||
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;
|
||||
KEY_TYPE start;
|
||||
KEY_TYPE end;
|
||||
boolean fromStart;
|
||||
boolean toEnd;
|
||||
boolean loInclusive;
|
||||
boolean hiInclusive;
|
||||
boolean fromStart;
|
||||
boolean toEnd;
|
||||
boolean loInclusive;
|
||||
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;
|
||||
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.start = start;
|
||||
this.end = end;
|
||||
this.fromStart = fromStart;
|
||||
|
@ -912,12 +912,12 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
|
||||
#endif
|
||||
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 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 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 start() { return findLowest(); }
|
||||
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 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); }
|
||||
protected Entry KEY_GENERIC_TYPE next(Entry KEY_GENERIC_TYPE entry) { return entry.next(); }
|
||||
protected Entry KEY_GENERIC_TYPE start() { return findLowest(); }
|
||||
|
||||
@Override
|
||||
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) {
|
||||
for (int i = from+1;i<to; i++) {
|
||||
KEY_TYPE current = array[i];
|
||||
int j = i - 1;
|
||||
while(j >= from && COMPAREABLE_TO_KEY(current, array[j]) < 0) {
|
||||
array[j+1] = array[j--];
|
||||
}
|
||||
array[j+1] = current;
|
||||
int j = i - 1;
|
||||
while(j >= from && COMPAREABLE_TO_KEY(current, array[j]) < 0) {
|
||||
array[j+1] = array[j--];
|
||||
}
|
||||
array[j+1] = current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -598,19 +598,19 @@ public class ARRAYS
|
|||
* @ArrayType(T)
|
||||
*/
|
||||
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++) {
|
||||
KEY_TYPE min = array[i];
|
||||
int minId = i;
|
||||
for(int j = i+1; j < to; j++) {
|
||||
if(comp.compare(array[j], min) < 0) {
|
||||
min = array[j];
|
||||
minId = j;
|
||||
}
|
||||
}
|
||||
KEY_TYPE temp = array[i];
|
||||
array[i] = min;
|
||||
array[minId] = temp;
|
||||
}
|
||||
for (int i = from; i < to; i++) {
|
||||
KEY_TYPE min = array[i];
|
||||
int minId = i;
|
||||
for(int j = i+1; j < to; j++) {
|
||||
if(comp.compare(array[j], min) < 0) {
|
||||
min = array[j];
|
||||
minId = j;
|
||||
}
|
||||
}
|
||||
KEY_TYPE temp = array[i];
|
||||
array[i] = min;
|
||||
array[minId] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -640,19 +640,19 @@ public class ARRAYS
|
|||
* @ArrayType(T)
|
||||
*/
|
||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) {
|
||||
for (int i = from; i < to; i++) {
|
||||
KEY_TYPE min = array[i];
|
||||
int minId = i;
|
||||
for(int j = i+1; j < to; j++) {
|
||||
if(COMPAREABLE_TO_KEY(array[j], min) < 0) {
|
||||
min = array[j];
|
||||
minId = j;
|
||||
}
|
||||
}
|
||||
KEY_TYPE temp = array[i];
|
||||
array[i] = min;
|
||||
array[minId] = temp;
|
||||
}
|
||||
for (int i = from; i < to; i++) {
|
||||
KEY_TYPE min = array[i];
|
||||
int minId = i;
|
||||
for(int j = i+1; j < to; j++) {
|
||||
if(COMPAREABLE_TO_KEY(array[j], min) < 0) {
|
||||
min = array[j];
|
||||
minId = j;
|
||||
}
|
||||
}
|
||||
KEY_TYPE temp = array[i];
|
||||
array[i] = min;
|
||||
array[minId] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1431,7 +1431,7 @@ public class ARRAYS
|
|||
}
|
||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
||||
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)
|
||||
{
|
||||
System.arraycopy(supp, from, array, from, to - from);
|
||||
|
@ -1470,7 +1470,7 @@ public class ARRAYS
|
|||
}
|
||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
||||
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)
|
||||
{
|
||||
System.arraycopy(supp, from, array, from, to - from);
|
||||
|
|
|
@ -335,146 +335,146 @@ public class SPLIT_ITERATORS
|
|||
}
|
||||
|
||||
#if PRIMITIVES
|
||||
static class IteratorSpliterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
private final COLLECTION KEY_GENERIC_TYPE collection;
|
||||
private ITERATOR KEY_GENERIC_TYPE it;
|
||||
private final int characteristics;
|
||||
private long est;
|
||||
private int batch;
|
||||
static class IteratorSpliterator KEY_GENERIC_TYPE implements JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE {
|
||||
static final int BATCH_UNIT = 1 << 10;
|
||||
static final int MAX_BATCH = 1 << 25;
|
||||
private final COLLECTION KEY_GENERIC_TYPE collection;
|
||||
private ITERATOR KEY_GENERIC_TYPE it;
|
||||
private final int characteristics;
|
||||
private long est;
|
||||
private int batch;
|
||||
|
||||
IteratorSpliterator(COLLECTION KEY_GENERIC_TYPE collection, int characteristics) {
|
||||
this.collection = collection;
|
||||
it = null;
|
||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||
: characteristics;
|
||||
}
|
||||
IteratorSpliterator(COLLECTION KEY_GENERIC_TYPE collection, int characteristics) {
|
||||
this.collection = collection;
|
||||
it = null;
|
||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||
: characteristics;
|
||||
}
|
||||
|
||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, long size, int characteristics) {
|
||||
collection = null;
|
||||
it = iterator;
|
||||
est = size;
|
||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||
: characteristics;
|
||||
}
|
||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, long size, int characteristics) {
|
||||
collection = null;
|
||||
it = iterator;
|
||||
est = size;
|
||||
this.characteristics = (characteristics & Spliterator.CONCURRENT) == 0
|
||||
? characteristics | Spliterator.SIZED | Spliterator.SUBSIZED
|
||||
: characteristics;
|
||||
}
|
||||
|
||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, int characteristics) {
|
||||
collection = null;
|
||||
it = iterator;
|
||||
est = Long.MAX_VALUE;
|
||||
this.characteristics = characteristics & ~(Spliterator.SIZED | Spliterator.SUBSIZED);
|
||||
}
|
||||
IteratorSpliterator(ITERATOR KEY_GENERIC_TYPE iterator, int characteristics) {
|
||||
collection = null;
|
||||
it = iterator;
|
||||
est = Long.MAX_VALUE;
|
||||
this.characteristics = characteristics & ~(Spliterator.SIZED | Spliterator.SUBSIZED);
|
||||
}
|
||||
|
||||
private ITERATOR KEY_GENERIC_TYPE iterator()
|
||||
{
|
||||
if (it == null) {
|
||||
it = collection.iterator();
|
||||
est = collection.size();
|
||||
}
|
||||
return it;
|
||||
}
|
||||
private ITERATOR KEY_GENERIC_TYPE iterator()
|
||||
{
|
||||
if (it == null) {
|
||||
it = collection.iterator();
|
||||
est = collection.size();
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
if (est > 1 && i.hasNext()) {
|
||||
int n = Math.min(batch + BATCH_UNIT, Math.min((int)est, MAX_BATCH));
|
||||
KEY_TYPE[] a = NEW_KEY_ARRAY(n);
|
||||
int j = 0;
|
||||
do { a[j] = i.NEXT(); } while (++j < n && i.hasNext());
|
||||
batch = j;
|
||||
if (est != Long.MAX_VALUE)
|
||||
est -= j;
|
||||
return new ArraySplitIteratorBRACES(a, 0, j, characteristics);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public JAVA_SPLIT_ITERATOR KEY_GENERIC_TYPE trySplit() {
|
||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||
if (est > 1 && i.hasNext()) {
|
||||
int n = Math.min(batch + BATCH_UNIT, Math.min((int)est, MAX_BATCH));
|
||||
KEY_TYPE[] a = NEW_KEY_ARRAY(n);
|
||||
int j = 0;
|
||||
do { a[j] = i.NEXT(); } while (++j < n && i.hasNext());
|
||||
batch = j;
|
||||
if (est != Long.MAX_VALUE)
|
||||
est -= j;
|
||||
return new ArraySplitIteratorBRACES(a, 0, j, characteristics);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(JAVA_CONSUMER action) {
|
||||
if (action == null) throw new NullPointerException();
|
||||
iterator().forEachRemaining(T -> action.accept(T));
|
||||
}
|
||||
@Override
|
||||
public void forEachRemaining(JAVA_CONSUMER action) {
|
||||
if (action == null) throw new NullPointerException();
|
||||
iterator().forEachRemaining(T -> action.accept(T));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean tryAdvance(JAVA_CONSUMER action) {
|
||||
if (action == null) throw new NullPointerException();
|
||||
ITERATOR KEY_GENERIC_TYPE iter = iterator();
|
||||
if (iter.hasNext()) {
|
||||
action.accept(iter.NEXT());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean tryAdvance(JAVA_CONSUMER action) {
|
||||
if (action == null) throw new NullPointerException();
|
||||
ITERATOR KEY_GENERIC_TYPE iter = iterator();
|
||||
if (iter.hasNext()) {
|
||||
action.accept(iter.NEXT());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
iterator();
|
||||
return est;
|
||||
}
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
iterator();
|
||||
return est;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int characteristics() { return characteristics; }
|
||||
@Override
|
||||
public int characteristics() { return characteristics; }
|
||||
|
||||
@Override
|
||||
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() {
|
||||
@Override
|
||||
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
|
||||
return null;
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue