diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template index d6b3a72..e52c6a8 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/AbstractCollection.template @@ -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) { diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template index e72b505..7df7ed1 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template @@ -97,7 +97,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection, 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, 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, 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, ITE @Deprecated public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); } - /** {@inheritDoc} + /** {@inheritDoc} *

This default implementation delegates to the corresponding type-specific function. * @deprecated Please use the corresponding type-specific function instead. */ diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Iterator.template b/src/builder/resources/speiger/assets/collections/templates/collections/Iterator.template index 3cfbebc..bd6e414 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterator.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterator.template @@ -34,25 +34,25 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator @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 - *

The default implementation behaves as if: - *

{@code
-     *     while (hasNext()) action.accept(NEXT());
-     * }
- * - * @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 + *

The default implementation behaves as if: + *

{@code
+	 *	while (hasNext()) action.accept(NEXT());
+	 * }
+ * + * @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 @Deprecated @Override default void forEachRemaining(Consumer 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 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 the generic type of the Object + * @throws java.lang.NullPointerException if the specified action is null */ default void forEachRemaining(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE action) { - Objects.requireNonNull(action); - while(hasNext()) { action.accept(NEXT(), input); } + Objects.requireNonNull(action); + while(hasNext()) { action.accept(NEXT(), input); } } /** diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/Comparator.template b/src/builder/resources/speiger/assets/collections/templates/functions/Comparator.template index ec8ccde..124c030 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/Comparator.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/Comparator.template @@ -10,17 +10,17 @@ public interface COMPARATOR extends Comparator { /** * 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} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ + *

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) { diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/Consumer.template b/src/builder/resources/speiger/assets/collections/templates/functions/Consumer.template index 806c928..2ff0cad 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/Consumer.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/Consumer.template @@ -12,12 +12,12 @@ public interface CONSUMER extends Consumer, JAVA_CONSUMER public interface CONSUMER extends Consumer #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); /** diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/consumer/BiConsumer.template b/src/builder/resources/speiger/assets/collections/templates/functions/consumer/BiConsumer.template index 3716b13..7f225ce 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/consumer/BiConsumer.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/consumer/BiConsumer.template @@ -10,13 +10,13 @@ import java.util.function.BiConsumer; */ public interface BI_CONSUMER KEY_VALUE_GENERIC_TYPE extends BiConsumer { - /** - * 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); /** diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template b/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template index a3a7f7e..e43c825 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template @@ -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 diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/function/UnaryOperator.template b/src/builder/resources/speiger/assets/collections/templates/functions/function/UnaryOperator.template index 3556157..92c53b5 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/function/UnaryOperator.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/function/UnaryOperator.template @@ -24,12 +24,12 @@ public interface UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE extends BiFunction l = (List)o; - if(l.size() != size()) return false; -#if !TYPE_OBJECT + 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 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 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 diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template index 27518d7..13bb249 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template @@ -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 - *

The default implementation behaves as if: - *

{@code
-     *     for(int i = 0;i
-     *
-     * @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
+	 * 

The default implementation behaves as if: + *

{@code
+	 * 	for(int i = 0;i
+	 *
+	 * @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);
diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template b/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template
index 6fb0a2d..80a543b 100644
--- a/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template
+++ b/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template
@@ -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
-     * 

The default implementation behaves as if: - *

{@code
-     *     for(int i = 0;i
-     *
-     * @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
+	 * 

The default implementation behaves as if: + *

{@code
+	 * 	for(int i = 0;i
+	 *
+	 * @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);
diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/LinkedList.template b/src/builder/resources/speiger/assets/collections/templates/lists/LinkedList.template
index e55ae57..12bb812 100644
--- a/src/builder/resources/speiger/assets/collections/templates/lists/LinkedList.template
+++ b/src/builder/resources/speiger/assets/collections/templates/lists/LinkedList.template
@@ -352,7 +352,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 		for(int i = size-1;entry != null;entry = entry.prev) {
 			if(KEY_EQUALS(entry.value, e)) return i;
 		}
-		return -1;	
+		return -1;
 	}
 	
 #endif
@@ -640,7 +640,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 		size = j;
 		return modified;
 	}
-
+	
 	@Override
 	@Primitive
 	public boolean retainAll(Collection c) {
@@ -665,7 +665,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 		size = j;
 		return modified;
 	}
-
+	
 	@Override
 	public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
 		if(c.isEmpty()) return false;
@@ -685,7 +685,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 		size = j;
 		return modified;
 	}
-
+	
 	@Override
 	public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
 		if(c.isEmpty()) {
@@ -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;
@@ -930,22 +929,22 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 		public boolean hasNext() {
 			return node != null;
 		}
-
+		
 		@Override
 		public boolean hasPrevious() {
 			return node != null;
 		}
-
+		
 		@Override
 		public int nextIndex() {
 			return index;
 		}
-
+		
 		@Override
 		public int previousIndex() {
 			return index-1;
 		}
-
+		
 		@Override
 		public void remove() {
 			if(lastReturned == null) throw new IllegalStateException();
@@ -953,7 +952,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 			unlink(lastReturned);
 			lastReturned = null;
 		}
-
+		
 		@Override
 		public KEY_TYPE PREVIOUS() {
 			lastReturned = node;
@@ -961,7 +960,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 			index--;
 			return lastReturned.value;
 		}
-
+		
 		@Override
 		public KEY_TYPE NEXT() {
 			lastReturned = node;
@@ -969,13 +968,13 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
 			index++;
 			return lastReturned.value;
 		}
-
+		
 		@Override
 		public void set(KEY_TYPE e) {
 			if(lastReturned == null) throw new IllegalStateException();
 			lastReturned.value = e;
 		}
-
+		
 		@Override
 		public void add(KEY_TYPE e) {
 			if(lastReturned == null) throw new IllegalStateException();
@@ -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() {
diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/List.template b/src/builder/resources/speiger/assets/collections/templates/lists/List.template
index 4754e3c..fec3652 100644
--- a/src/builder/resources/speiger/assets/collections/templates/lists/List.template
+++ b/src/builder/resources/speiger/assets/collections/templates/lists/List.template
@@ -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 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
 	public void add(KEY_TYPE e);
 	
 	/** {@inheritDoc}
- 	* 

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ + *

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 } /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ + *

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 } /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ + *

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 } /** {@inheritDoc} - *

This default implementation delegates to the corresponding type-specific function. - * @deprecated Please use the corresponding type-specific function instead. - */ + *

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) { diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template index f9c92c0..897a931 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/abstracts/AbstractMap.template @@ -128,20 +128,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap keyType; + protected final Class 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 entrySet; + protected transient ObjectSet entrySet; /** KeySet cache */ - protected transient ObjectSet keySet; + protected transient ObjectSet 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 keyType) { this.keyType = keyType; keys = getKeyUniverse(keyType); @@ -219,32 +219,32 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE onNodeRemoved(index); } protected boolean isSet(int index) { return (present[index >> 6] & (1L << index)) != 0; } - + private static > K[] getKeyUniverse(Class keyType) { return keyType.getEnumConstants(); - } - - class EntrySet extends AbstractObjectSet { - - @Override - public boolean contains(Object o) { - if(o instanceof Map.Entry) return containsKey(((Map.Entry)o).getKey()); - return false; - } - - @Override - public boolean remove(Object o) { - if(o instanceof Map.Entry) { - if(o instanceof MAP.Entry) { - MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o; - return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE()); - } - Map.Entry entry = (java.util.Map.Entry)o; - return ENUM_MAP.this.remove(entry.getKey(), entry.getValue()); - } - return false; - } - + } + + class EntrySet extends AbstractObjectSet { + + @Override + public boolean contains(Object o) { + if(o instanceof Map.Entry) return containsKey(((Map.Entry)o).getKey()); + return false; + } + + @Override + public boolean remove(Object o) { + if(o instanceof Map.Entry) { + if(o instanceof MAP.Entry) { + MAP.Entry KEY_VALUE_GENERIC_TYPE entry = (MAP.Entry KEY_VALUE_GENERIC_TYPE)o; + return ENUM_MAP.this.remove(entry.getKey(), entry.ENTRY_VALUE()); + } + Map.Entry entry = (java.util.Map.Entry)o; + return ENUM_MAP.this.remove(entry.getKey(), entry.getValue()); + } + return false; + } + @Override public ObjectIterator iterator() { return new EntryIterator(); @@ -259,22 +259,22 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE public void clear() { ENUM_MAP.this.clear(); } - } - - class KeySet extends AbstractObjectSet { - - @Override - public boolean contains(Object o) { - return containsKey(o); - } - - @Override - public boolean remove(Object o) { - int size = size(); - ENUM_MAP.this.remove(o); - return size != size(); - } - + } + + class KeySet extends AbstractObjectSet { + + @Override + public boolean contains(Object o) { + return containsKey(o); + } + + @Override + public boolean remove(Object o) { + int size = size(); + ENUM_MAP.this.remove(o); + return size != size(); + } + @Override public ObjectIterator iterator() { return new KeyIterator(); @@ -284,14 +284,14 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE public int size() { return ENUM_MAP.this.size(); } - + @Override public void clear() { ENUM_MAP.this.clear(); } - } - - class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE { + } + + class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE { @Override public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); } @@ -314,40 +314,40 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE public int size() { return ENUM_MAP.this.size(); } - + @Override public void clear() { ENUM_MAP.this.clear(); } - } - - class EntryIterator extends MapIterator implements ObjectIterator { + } + + class EntryIterator extends MapIterator implements ObjectIterator { @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 { + } + + class KeyIterator extends MapIterator implements ObjectIterator { @Override public T next() { return keys[nextEntry()]; } - } - - class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE { + } + + class ValueIterator extends MapIterator implements VALUE_ITERATOR VALUE_GENERIC_TYPE { @Override public VALUE_TYPE VALUE_NEXT() { return values[nextEntry()]; } - } - - class MapIterator { - int index; - int lastReturnValue = -1; - int nextIndex = -1; - + } + + class MapIterator { + int index; + int lastReturnValue = -1; + int nextIndex = -1; + public boolean hasNext() { if(nextIndex == -1 && index < values.length) { while(index < values.length && !isSet(index++)); @@ -368,5 +368,5 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE clear(lastReturnValue); values[lastReturnValue] = EMPTY_VALUE; } - } + } } diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/LinkedEnumMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/LinkedEnumMap.template index 4580e4d..995dc37 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/LinkedEnumMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/LinkedEnumMap.template @@ -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 keyType) { super(keyType); links = new long[keys.length]; diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template index 8486ede..7433383 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/AVLTreeMap.template @@ -934,31 +934,31 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ return descendingMap; } - AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { - return entry.next(); - } - - AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { - return entry.previous(); - } + AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + return entry.next(); + } + + AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + return entry.previous(); + } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { - if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); - if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); - return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); + if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); + if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); + return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) { - if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); - return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); + if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); + return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) { - if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); - return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); + if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); + return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); } } @@ -1046,13 +1046,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ return entry == null || !inClosedRange(key) ? null : ITERATORS.invert(new SubMapKeyIterator(entry, fromStart ? null : findLowest(), toEnd ? null : findHighest())); } - AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { - return entry.previous(); - } - - AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { - return entry.next(); - } + AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + return entry.previous(); + } + + AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + return entry.next(); + } @Override public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator() == null ? null : m.comparator().reversed(); } @@ -1071,21 +1071,21 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { - if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); - if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); - return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); + if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); + if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); + return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) { - if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); - return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); + if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); + return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) { - if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); - return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); + if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); + return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); } } @@ -1093,17 +1093,17 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ final AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m; final KEY_TYPE low; final KEY_TYPE high; - final boolean fromStart; - final boolean toEnd; - final boolean loInclusive; - final boolean hiInclusive; - transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap; - transient SubMapEntrySet entrySet; - transient KeySet KEY_VALUE_GENERIC_TYPE keySet; - transient SubMapValues values; - - NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) { - this.m = m; + final boolean fromStart; + final boolean toEnd; + final boolean loInclusive; + final boolean hiInclusive; + transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap; + transient SubMapEntrySet entrySet; + transient KeySet KEY_VALUE_GENERIC_TYPE keySet; + transient SubMapValues values; + + NavigableSubMap(AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) { + this.m = m; this.low = low; this.high = high; this.fromStart = fromStart; @@ -1111,15 +1111,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ this.loInclusive = loInclusive; this.hiInclusive = hiInclusive; } - - abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending); - abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key); - abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator(); - abstract ObjectListIterator 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 entryIterator(); + abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry); + abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry); + + @Override public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap(); @Override @@ -1130,11 +1130,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive); boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? m.compare(key, low) < 0 : m.compare(key, low) <= 0); } - boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); } - boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); } - boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); } - boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); } - + boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); } + boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); } + boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); } + boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); } + #if TYPE_OBJECT public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); } public KEY_TYPE getDefaultMinValue() { return m.getDefaultMinValue(); } @@ -1158,18 +1158,18 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ @Override public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); } - @Override - public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } - @Override - public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } + @Override + public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } @Override public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); } #if TYPE_OBJECT @@ -1620,9 +1620,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator { - public SubMapEntrySetIterator(boolean descending) { - super(descending); - } + public SubMapEntrySetIterator(boolean descending) { + super(descending); + } public SubMapEntrySetIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1640,9 +1640,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE { - public SubMapKeyIterator(boolean descending) { - super(descending); - } + public SubMapKeyIterator(boolean descending) { + super(descending); + } public SubMapKeyIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1660,9 +1660,9 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE { - public SubMapValueIterator(boolean descending) { - super(descending); - } + public SubMapValueIterator(boolean descending) { + super(descending); + } public SubMapValueIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1685,11 +1685,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next; AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous; AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current; - int index = 0; - - public SubMapEntryIterator(boolean descending) { - this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest()); - } + int index = 0; + + public SubMapEntryIterator(boolean descending) { + this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest()); + } public SubMapEntryIterator(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { next = entry; @@ -1697,7 +1697,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ this.lowerFence = lowerFence != null ? KEY_TO_OBJ(lowerFence.key) : null; this.upperFence = upperFence != null ? KEY_TO_OBJ(upperFence.key) : null; } - + public boolean hasNext() { return next != null && (upperFence == null || KEY_EQUALS(next.key, OBJ_TO_KEY(upperFence))); } @@ -1713,7 +1713,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ public int previousIndex() { return index - 1; } - + protected void updateNext() { next = current.next(); } @@ -1974,15 +1974,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest(); } - protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { if(m instanceof AVL_TREE_MAP) return entry.next(); return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry); - } - - protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + } + + protected AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { if(m instanceof AVL_TREE_MAP) return entry.previous(); return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry); - } + } @Override public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { @@ -2185,11 +2185,11 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ } abstract class MapEntryIterator { - Entry KEY_VALUE_GENERIC_TYPE next; - Entry KEY_VALUE_GENERIC_TYPE previous; - Entry KEY_VALUE_GENERIC_TYPE current; - int index = 0; - + Entry KEY_VALUE_GENERIC_TYPE next; + Entry KEY_VALUE_GENERIC_TYPE previous; + Entry KEY_VALUE_GENERIC_TYPE current; + int index = 0; + public MapEntryIterator(boolean descending) { if(descending) previous = last; else next = first; @@ -2199,7 +2199,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ next = entry; previous = entry.previous(); } - + public boolean hasNext() { return next != null; } @@ -2215,7 +2215,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_ public int previousIndex() { return index - 1; } - + protected void updateNext() { next = current.next(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template index 00168e2..d34efa7 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/tree/RBTreeMap.template @@ -555,8 +555,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G @Override public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { - Objects.requireNonNull(mappingFunction); - for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) { + Objects.requireNonNull(mappingFunction); + for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) { KEY_TYPE key = entry.ENTRY_KEY(); Entry KEY_VALUE_GENERIC_TYPE subEntry = findNode(key); VALUE_TYPE newValue = subEntry == null ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE()); @@ -998,21 +998,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { - if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); - if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); - return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); + if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); + if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); + return new AscendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) { - if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); - return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); + if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); + return new AscendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) { - if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); - return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); + if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); + return new AscendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); } } @@ -1125,21 +1125,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) { - if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); - if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); - return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); + if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range"); + if (!inRange(toKey, toInclusive)) throw new IllegalArgumentException("toKey out of range"); + return new DescendingSubMapKV_BRACES(m, false, fromKey, fromInclusive, false, toKey, toInclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive) { - if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); - return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); + if (!inRange(toKey, inclusive)) throw new IllegalArgumentException("toKey out of range"); + return new DescendingSubMapKV_BRACES(m, fromStart, low, loInclusive, false, toKey, inclusive); } @Override public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive) { - if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); - return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); + if (!inRange(fromKey, inclusive)) throw new IllegalArgumentException("fromKey out of range"); + return new DescendingSubMapKV_BRACES(m, false, fromKey, inclusive, toEnd, high, hiInclusive); } } @@ -1147,17 +1147,17 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G final RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m; final KEY_TYPE low; final KEY_TYPE high; - final boolean fromStart; - final boolean toEnd; - final boolean loInclusive; - final boolean hiInclusive; - transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap; - transient SubMapEntrySet entrySet; - transient KeySet KEY_VALUE_GENERIC_TYPE keySet; - transient SubMapValues values; - - NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) { - this.m = m; + final boolean fromStart; + final boolean toEnd; + final boolean loInclusive; + final boolean hiInclusive; + transient NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap; + transient SubMapEntrySet entrySet; + transient KeySet KEY_VALUE_GENERIC_TYPE keySet; + transient SubMapValues values; + + NavigableSubMap(RB_TREE_MAP KEY_VALUE_GENERIC_TYPE m, boolean fromStart, KEY_TYPE low, boolean loInclusive, boolean toEnd, KEY_TYPE high, boolean hiInclusive) { + this.m = m; this.low = low; this.high = high; this.fromStart = fromStart; @@ -1165,14 +1165,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G this.loInclusive = loInclusive; this.hiInclusive = hiInclusive; } - - abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(boolean descending); - abstract LIST_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE key); - abstract VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE valueIterator(); - abstract ObjectListIterator 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 entryIterator(); + abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry); + abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry); + @Override public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap(); @Override @@ -1181,13 +1181,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE headMap(KEY_TYPE toKey, boolean inclusive); @Override public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey, boolean inclusive); - + boolean tooLow(KEY_TYPE key) { return !fromStart && (loInclusive ? m.compare(key, low) < 0 : m.compare(key, low) <= 0); } - boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); } - boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); } - boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); } - boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); } - + boolean tooHigh(KEY_TYPE key) { return !toEnd && (hiInclusive ? m.compare(key, high) > 0 : m.compare(key, high) >= 0); } + boolean inRange(KEY_TYPE key) { return !tooLow(key) && !tooHigh(key); } + boolean inClosedRange(KEY_TYPE key) { return (fromStart || m.compare(key, low) >= 0) && (toEnd || m.compare(high, key) >= 0); } + boolean inRange(KEY_TYPE key, boolean inclusive) { return inclusive ? inRange(key) : inClosedRange(key); } + #if TYPE_OBJECT public KEY_TYPE getDefaultMaxValue() { return m.getDefaultMaxValue(); } public KEY_TYPE getDefaultMinValue() { return m.getDefaultMinValue(); } @@ -1211,18 +1211,18 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G @Override public VALUE_TYPE getDefaultReturnValue() { return m.getDefaultReturnValue(); } - @Override - public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } - @Override - public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } - @Override - public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } + @Override + public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); } + @Override + public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); } @Override public COMPARATOR KEY_GENERIC_TYPE comparator() { return m.comparator(); } #if TYPE_OBJECT @@ -1673,9 +1673,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G } final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator { - public SubMapEntrySetIterator(boolean descending) { - super(descending); - } + public SubMapEntrySetIterator(boolean descending) { + super(descending); + } public SubMapEntrySetIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1693,9 +1693,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G } final class SubMapKeyIterator extends SubMapEntryIterator implements LIST_ITERATOR KEY_GENERIC_TYPE { - public SubMapKeyIterator(boolean descending) { - super(descending); - } + public SubMapKeyIterator(boolean descending) { + super(descending); + } public SubMapKeyIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1713,9 +1713,9 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G } final class SubMapValueIterator extends SubMapEntryIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE { - public SubMapValueIterator(boolean descending) { - super(descending); - } + public SubMapValueIterator(boolean descending) { + super(descending); + } public SubMapValueIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { super(entry, lowerFence, upperFence); @@ -1738,11 +1738,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next; RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous; RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE current; - int index = 0; - - public SubMapEntryIterator(boolean descending) { - this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest()); - } + int index = 0; + + public SubMapEntryIterator(boolean descending) { + this(descending ? findHighest() : findLowest(), fromStart ? null : findLowest(), toEnd ? null : findHighest()); + } public SubMapEntryIterator(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE lowerFence, RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE upperFence) { next = entry; @@ -1750,7 +1750,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G this.lowerFence = lowerFence != null ? KEY_TO_OBJ(lowerFence.key) : null; this.upperFence = upperFence != null ? KEY_TO_OBJ(upperFence.key) : null; } - + public boolean hasNext() { return next != null && (upperFence == null || KEY_EQUALS(next.key, OBJ_TO_KEY(upperFence))); } @@ -1766,7 +1766,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G public int previousIndex() { return index - 1; } - + protected void updateNext() { next = current.next(); } @@ -2027,15 +2027,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).findLowest(); } - protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { if(m instanceof RB_TREE_MAP) return entry.next(); return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).next(entry); - } - - protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { + } + + protected RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { if(m instanceof RB_TREE_MAP) return entry.previous(); return ((NavigableSubMap KEY_VALUE_GENERIC_TYPE)m).previous(entry); - } + } @Override public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { @@ -2238,11 +2238,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G } abstract class MapEntryIterator { - Entry KEY_VALUE_GENERIC_TYPE next; - Entry KEY_VALUE_GENERIC_TYPE previous; - Entry KEY_VALUE_GENERIC_TYPE current; - int index = 0; - + Entry KEY_VALUE_GENERIC_TYPE next; + Entry KEY_VALUE_GENERIC_TYPE previous; + Entry KEY_VALUE_GENERIC_TYPE current; + int index = 0; + public MapEntryIterator(boolean descending) { if(descending) previous = last; else next = first; @@ -2252,7 +2252,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G next = entry; previous = entry.previous(); } - + public boolean hasNext() { return next != null; } @@ -2268,7 +2268,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G public int previousIndex() { return index - 1; } - + protected void updateNext() { next = current.next(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template index 5c714ba..33f0f3d 100644 --- a/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template +++ b/src/builder/resources/speiger/assets/collections/templates/queues/ArrayFIFOQueue.template @@ -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; diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template index 6def463..f7e0ef0 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template @@ -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; @@ -830,7 +830,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE this.loInclusive = loInclusive; this.hiInclusive = hiInclusive; } - + #if !TYPE_OBJECT @Override public void setDefaultMaxValue(KEY_TYPE value) { throw new UnsupportedOperationException(); } @@ -851,13 +851,13 @@ 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(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/AbstractSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/AbstractSet.template index 2d401fa..ba6249a 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/AbstractSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/AbstractSet.template @@ -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 !TYPE_OBJECT + 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 e1 = iterator(); diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template index bdb40ef..66efd4f 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/ImmutableOpenHashSet.template @@ -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"); } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template index a95c18f..f065397 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenCustomHashSet.template @@ -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"); } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template index 8655082..36b8769 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/LinkedOpenHashSet.template @@ -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"); } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template index 315e742..049026b 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template @@ -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; @@ -891,7 +891,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE this.loInclusive = loInclusive; this.hiInclusive = hiInclusive; } - + #if !TYPE_OBJECT @Override public void setDefaultMaxValue(KEY_TYPE value) { set.setDefaultMaxValue(value); } @@ -912,13 +912,13 @@ 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(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template b/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template index 50f676e..f0eca5e 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template @@ -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= 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); diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Splititerators.template b/src/builder/resources/speiger/assets/collections/templates/utils/Splititerators.template index 8be299f..ed5d825 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Splititerators.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Splititerators.template @@ -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, 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; - } - - @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)); - } + 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); + } + + 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 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 long estimateSize() { - iterator(); - return est; - } + @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 int characteristics() { return characteristics; } - - @Override - public Comparator 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 getComparator() { + @Override + public int characteristics() { return characteristics; } + + @Override + public Comparator 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 getComparator() { + if (hasCharacteristics(4)) //Sorted + return null; + throw new IllegalStateException(); + } } #endif }