More work.
-Added: BiFunction -Added: Function -Added: BiConsumer -Changed: Remapping Names to be more friendly for KEY_VALUE. -Added: A Bunch of Variables
This commit is contained in:
		
							parent
							
								
									a8318a3941
								
							
						
					
					
						commit
						42458bc4a3
					
				
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -34,11 +34,21 @@ public enum ClassType | |||||||
| 		return keyType; | 		return keyType; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public String getValueType() | ||||||
|  | 	{ | ||||||
|  | 		return this == OBJECT ? "V" : keyType; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	public String getClassType() | 	public String getClassType() | ||||||
| 	{ | 	{ | ||||||
| 		return classType; | 		return classType; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public String getClassValueType() | ||||||
|  | 	{ | ||||||
|  | 		return this == OBJECT ? "V" : classType; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	public String getNonFileType() | 	public String getNonFileType() | ||||||
| 	{ | 	{ | ||||||
| 		return this == OBJECT ? "" : fileType; | 		return this == OBJECT ? "" : fileType; | ||||||
| @ -49,6 +59,11 @@ public enum ClassType | |||||||
| 		return fileType; | 		return fileType; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public String getJavaFileType() | ||||||
|  | 	{ | ||||||
|  | 		return this == OBJECT ? "Obj" : fileType; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	public String getPathType() | 	public String getPathType() | ||||||
| 	{ | 	{ | ||||||
| 		return pathType; | 		return pathType; | ||||||
| @ -106,6 +121,43 @@ public enum ClassType | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public boolean hasFunction(ClassType other) | ||||||
|  | 	{ | ||||||
|  | 		if(this == other && this != BOOLEAN && !needsCustomJDKType() && !other.needsCustomJDKType()) return true; | ||||||
|  | 		if(this == BOOLEAN) return false; | ||||||
|  | 		if(other == BOOLEAN && !needsCustomJDKType()) return true; | ||||||
|  | 		if(!needsCustomJDKType() && !other.needsCustomJDKType()) return true; | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public boolean hasBiFunction(ClassType other) | ||||||
|  | 	{ | ||||||
|  | 		if(this == other && this != BOOLEAN && !needsCustomJDKType() && !other.needsCustomJDKType()) return true; | ||||||
|  | 		if(this == BOOLEAN) return false; | ||||||
|  | 		if(other == BOOLEAN && this == OBJECT) return true; | ||||||
|  | 		if(!other.needsCustomJDKType() && this == OBJECT) return true; | ||||||
|  | 		return false; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getFunctionClass(ClassType other) | ||||||
|  | 	{ | ||||||
|  | 		if(!hasFunction(other)) return ""; | ||||||
|  | 		if(this == other && this != BOOLEAN) return this == OBJECT ? "java.util.function.Function" : "java.util.function."+getJavaFileType()+"UnaryOperator"; | ||||||
|  | 		if(other == BOOLEAN) return this == OBJECT ? "java.util.function.Predicate" : "java.util.function."+getJavaFileType()+"Predicate"; | ||||||
|  | 		if(!needsCustomJDKType()) return other == OBJECT ? "java.util.function."+getJavaFileType()+"Function" : (this == OBJECT ? "java.util.function.To"+other.getJavaFileType()+"Function" : "java.util.function."+getJavaFileType()+"To"+other.getJavaFileType()+"Function"); | ||||||
|  | 		if(!other.needsCustomJDKType()) return this == OBJECT ? "java.util.function.To"+other.getJavaFileType()+"Function" : "java.util.function."+getJavaFileType()+"To"+other.getJavaFileType()+"Function"; | ||||||
|  | 		return ""; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public String getBiFunctionClass(ClassType other) | ||||||
|  | 	{ | ||||||
|  | 		if(!hasBiFunction(other)) return ""; | ||||||
|  | 		if(this == other && this != BOOLEAN) return this == OBJECT ? "java.util.function.BiFunction" : "java.util.function."+getJavaFileType()+"BinaryOperator"; | ||||||
|  | 		if(other == BOOLEAN && this == OBJECT) return "java.util.function.BiPredicate"; | ||||||
|  | 		if(!other.needsCustomJDKType() && this == OBJECT) return "java.util.function.To"+other.getJavaFileType()+"BiFunction"; | ||||||
|  | 		return ""; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	public ClassType getCustomJDKType() | 	public ClassType getCustomJDKType() | ||||||
| 	{ | 	{ | ||||||
| 		switch(this) | 		switch(this) | ||||||
|  | |||||||
| @ -19,24 +19,39 @@ public class GlobalVariables | |||||||
| 	List<IMapper> operators = new ArrayList<>(); | 	List<IMapper> operators = new ArrayList<>(); | ||||||
| 	Set<String> flags = new LinkedHashSet<>(); | 	Set<String> flags = new LinkedHashSet<>(); | ||||||
| 	ClassType type; | 	ClassType type; | ||||||
|  | 	ClassType valueType; | ||||||
| 	 | 	 | ||||||
| 	public GlobalVariables(ClassType type) | 	public GlobalVariables(ClassType type, ClassType subType) | ||||||
| 	{ | 	{ | ||||||
| 		this.type = type; | 		this.type = type; | ||||||
|  | 		valueType = subType; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public GlobalVariables createVariables() | 	public GlobalVariables createVariables() | ||||||
| 	{ | 	{ | ||||||
| 		addSimpleMapper("PACKAGE", type.getPathType()); | 		addSimpleMapper("PACKAGE", type.getPathType()); | ||||||
| 		addSimpleMapper("CLASS_TYPE", type.getClassType()); | 		addSimpleMapper("CLASS_TYPE", type.getClassType()); | ||||||
|  | 		addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType()); | ||||||
| 		addSimpleMapper("KEY_TYPE", type.getKeyType()); | 		addSimpleMapper("KEY_TYPE", type.getKeyType()); | ||||||
| 		addSimpleMapper("EMPTY_VALUE", type.getEmptyValue()); | 		addSimpleMapper("VALUE_TYPE", valueType.getValueType()); | ||||||
|  | 		 | ||||||
|  | 		addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue()); | ||||||
|  | 		addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue()); | ||||||
|  | 
 | ||||||
| 		addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : ""); | 		addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : ""); | ||||||
|  | 		addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : ""); | ||||||
|  | 		addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : "")); | ||||||
|  | 		addSimpleMapper(" KEY_KEY_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+", "+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : "")); | ||||||
| 		addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : ""); | 		addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : ""); | ||||||
| 		addSimpleMapper(" KEY_COMPAREABLE_TYPE", type.isObject() ? "<"+type.getKeyType()+" extends Comparable<T>>" : ""); | 		addSimpleMapper(" KEY_COMPAREABLE_TYPE", type.isObject() ? "<"+type.getKeyType()+" extends Comparable<T>>" : ""); | ||||||
| 		addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", type.isObject() ? "<? super "+type.getKeyType()+">" : ""); | 		addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", type.isObject() ? "<? super "+type.getKeyType()+">" : ""); | ||||||
| 		addSimpleMapper(" GENERIC_BRACES", type.isObject() ? " <"+type.getKeyType()+">" : ""); | 		addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getKeyType()+">" : ""); | ||||||
| 		addSimpleMapper(" COMPAREABLE_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : ""); | 		addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "")); | ||||||
|  | 		 | ||||||
|  | 		addSimpleMapper(" GENERIC_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+">" : ""); | ||||||
|  | 		addSimpleMapper(" GENERIC_VALUE_BRACES", type.isObject() ? " <"+valueType.getValueType()+">" : ""); | ||||||
|  | 		addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : "")); | ||||||
|  | 		addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : ""); | ||||||
| 		addSimpleMapper("BRACES", type.isObject() ? "<>" : ""); | 		addSimpleMapper("BRACES", type.isObject() ? "<>" : ""); | ||||||
| 		if(type.needsCustomJDKType()) | 		if(type.needsCustomJDKType()) | ||||||
| 		{ | 		{ | ||||||
| @ -52,21 +67,33 @@ public class GlobalVariables | |||||||
| 	public GlobalVariables createHelperVariables() | 	public GlobalVariables createHelperVariables() | ||||||
| 	{ | 	{ | ||||||
| 		addArgumentMapper("EQUALS_KEY_TYPE", type.isObject() ? "Objects.equals(%2$s, %1$s)" : "Objects.equals(%2$s, KEY_TO_OBJ(%1$s))").removeBraces(); | 		addArgumentMapper("EQUALS_KEY_TYPE", type.isObject() ? "Objects.equals(%2$s, %1$s)" : "Objects.equals(%2$s, KEY_TO_OBJ(%1$s))").removeBraces(); | ||||||
| 		addInjectMapper("EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() ? type.getEmptyValue() : (type.needsCast() ? type.getEmptyValue() : "0"))).removeBraces(); | 		addInjectMapper("KEY_EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() ? type.getEmptyValue() : (type.needsCast() ? type.getEmptyValue() : "0"))).removeBraces(); | ||||||
| 		addInjectMapper("EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() ? type.getEmptyValue() : (type.needsCast() ? type.getEmptyValue() : "0"))).removeBraces(); | 		addInjectMapper("KEY_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() ? type.getEmptyValue() : (type.needsCast() ? type.getEmptyValue() : "0"))).removeBraces(); | ||||||
| 		addArgumentMapper("EQUALS_NOT", type.getEquals(true)).removeBraces(); | 		addArgumentMapper("KEY_EQUALS_NOT", type.getEquals(true)).removeBraces(); | ||||||
| 		addArgumentMapper("EQUALS", type.getEquals(false)).removeBraces(); | 		addArgumentMapper("KEY_EQUALS", type.getEquals(false)).removeBraces(); | ||||||
|  | 		 | ||||||
| 		addArgumentMapper("COMPARE_TO_KEY", type.isObject() ? "((Comparable<T>)%1$s).compareTo((T)%2$s)" : type.getClassType()+".compare(%1$s, %2$s)").removeBraces(); | 		addArgumentMapper("COMPARE_TO_KEY", type.isObject() ? "((Comparable<T>)%1$s).compareTo((T)%2$s)" : type.getClassType()+".compare(%1$s, %2$s)").removeBraces(); | ||||||
| 		addArgumentMapper("COMPARE_TO", type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType()+".compare(%1$s, %2$s)").removeBraces(); | 		addArgumentMapper("COMPARE_TO", type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType()+".compare(%1$s, %2$s)").removeBraces(); | ||||||
|  | 		 | ||||||
| 		addInjectMapper("KEY_TO_OBJ", type.isObject() ? "%s" : type.getClassType()+".valueOf(%s)").removeBraces(); | 		addInjectMapper("KEY_TO_OBJ", type.isObject() ? "%s" : type.getClassType()+".valueOf(%s)").removeBraces(); | ||||||
| 		addInjectMapper("OBJ_TO_KEY", type.isObject() ? "%s" : "%s."+type.getKeyType()+"Value()").removeBraces(); | 		addInjectMapper("OBJ_TO_KEY", type.isObject() ? "%s" : "%s."+type.getKeyType()+"Value()").removeBraces(); | ||||||
| 		addInjectMapper("CLASS_TO_KEY", "(("+type.getClassType()+")%s)."+type.getKeyType()+"Value()").removeBraces(); | 		addInjectMapper("CLASS_TO_KEY", "(("+type.getClassType()+")%s)."+type.getKeyType()+"Value()").removeBraces(); | ||||||
| 		addSimpleMapper("APPLY", "applyAs"+type.getCustomJDKType().getNonFileType()); | 		 | ||||||
| 		addInjectMapper("TO_HASH", type.isObject() ? "%s.hashCode()" : type.getClassType()+".hashCode(%s)").removeBraces(); | 		addInjectMapper("VALUE_TO_OBJ", valueType.isObject() ? "%s" : valueType.getClassType()+".valueOf(%s)").removeBraces(); | ||||||
|  | 		addInjectMapper("OBJ_TO_VALUE", valueType.isObject() ? "%s" : "%s."+valueType.getKeyType()+"Value()").removeBraces(); | ||||||
|  | 		addInjectMapper("CLASS_TO_VALUE", "(("+valueType.getClassType()+")%s)."+valueType.getKeyType()+"Value()").removeBraces(); | ||||||
|  | 		 | ||||||
|  | 		addInjectMapper("KEY_TO_HASH", type.isObject() ? "%s.hashCode()" : type.getClassType()+".hashCode(%s)").removeBraces(); | ||||||
|  | 		 | ||||||
| 		addSimpleMapper("CAST_KEY_ARRAY ", type.isObject() ? "(KEY_TYPE[])" : ""); | 		addSimpleMapper("CAST_KEY_ARRAY ", type.isObject() ? "(KEY_TYPE[])" : ""); | ||||||
| 		addSimpleMapper("EMPTY_KEY_ARRAY", type.isObject() ? "(KEY_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY"); | 		addSimpleMapper("EMPTY_KEY_ARRAY", type.isObject() ? "(KEY_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY"); | ||||||
| 		addInjectMapper("NEW_KEY_ARRAY", type.isObject() ? "(KEY_TYPE[])new Object[%s]" : "new KEY_TYPE[%s]").removeBraces(); | 		addInjectMapper("NEW_KEY_ARRAY", type.isObject() ? "(KEY_TYPE[])new Object[%s]" : "new KEY_TYPE[%s]").removeBraces(); | ||||||
| 		addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces(); | 		addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces(); | ||||||
|  | 		 | ||||||
|  | 		addSimpleMapper("CAST_VALUE_ARRAY ", valueType.isObject() ? "(VALUE_TYPE[])" : ""); | ||||||
|  | 		addSimpleMapper("EMPTY_VALUE_ARRAY", valueType.isObject() ? "(VALUE_TYPE[])VALUE_ARRAYS.EMPTY_ARRAY" : "VALUE_ARRAYS.EMPTY_ARRAY"); | ||||||
|  | 		addInjectMapper("NEW_VALUE_ARRAY", valueType.isObject() ? "(VALUE_TYPE[])new Object[%s]" : "new VALUE_TYPE[%s]").removeBraces(); | ||||||
|  | 		addInjectMapper("NEW_CLASS_VALUE_ARRAY", valueType.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces(); | ||||||
| 		return this; | 		return this; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -74,6 +101,8 @@ public class GlobalVariables | |||||||
| 	{ | 	{ | ||||||
| 		addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate"); | 		addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate"); | ||||||
| 		addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer"); | 		addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer"); | ||||||
|  | 		addSimpleMapper("JAVA_FUNCTION", type.getFunctionClass(valueType)); | ||||||
|  | 		addSimpleMapper("JAVA_BI_FUNCTION", type.getBiFunctionClass(valueType)); | ||||||
| 		addSimpleMapper("UNARY_OPERATOR", type.isObject() ? "" : type == ClassType.BOOLEAN ? "BinaryOperator" : type.getCustomJDKType().getFileType()+"UnaryOperator"); | 		addSimpleMapper("UNARY_OPERATOR", type.isObject() ? "" : type == ClassType.BOOLEAN ? "BinaryOperator" : type.getCustomJDKType().getFileType()+"UnaryOperator"); | ||||||
| 		 | 		 | ||||||
| 		//Final Classes | 		//Final Classes | ||||||
| @ -105,9 +134,12 @@ public class GlobalVariables | |||||||
| 		//Interfaces | 		//Interfaces | ||||||
| 		addClassMapper("LIST_ITERATOR", "ListIterator"); | 		addClassMapper("LIST_ITERATOR", "ListIterator"); | ||||||
| 		addClassMapper("BI_ITERATOR", "BidirectionalIterator"); | 		addClassMapper("BI_ITERATOR", "BidirectionalIterator"); | ||||||
|  | 		addBiClassMapper("BI_CONSUMER", "Consumer", ""); | ||||||
|  | 		addBiClassMapper("BI_FUNCTION", "BiFunction", "2"); | ||||||
| 		addClassMapper("ITERATOR", "Iterator"); | 		addClassMapper("ITERATOR", "Iterator"); | ||||||
| 		addClassMapper("ITERABLE", "Iterable"); | 		addClassMapper("ITERABLE", "Iterable"); | ||||||
| 		addClassMapper("COLLECTION", "Collection"); | 		addClassMapper("COLLECTION", "Collection"); | ||||||
|  | 		addBiClassMapper("FUNCTION", "Function", "2"); | ||||||
| 		addClassMapper("LIST_ITER", "ListIter"); | 		addClassMapper("LIST_ITER", "ListIter"); | ||||||
| 		addClassMapper("LIST", "List"); | 		addClassMapper("LIST", "List"); | ||||||
| 		addClassMapper("NAVIGABLE_SET", "NavigableSet"); | 		addClassMapper("NAVIGABLE_SET", "NavigableSet"); | ||||||
| @ -134,9 +166,12 @@ public class GlobalVariables | |||||||
| 	 | 	 | ||||||
| 	public GlobalVariables createFunctions() | 	public GlobalVariables createFunctions() | ||||||
| 	{ | 	{ | ||||||
|  | 		addSimpleMapper("APPLY_VALUE", "applyAs"+valueType.getCustomJDKType().getNonFileType()); | ||||||
|  | 		addSimpleMapper("APPLY", "applyAs"+type.getCustomJDKType().getNonFileType()); | ||||||
| 		addFunctionMapper("NEXT", "next"); | 		addFunctionMapper("NEXT", "next"); | ||||||
| 		addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array"); | 		addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array"); | ||||||
| 		addFunctionMapper("GET_KEY", "get"); | 		addFunctionMapper("GET_KEY", "get"); | ||||||
|  | 		addFunctionValueMapper("GET_VALUE", "get"); | ||||||
| 		addFunctionMapper("ENQUEUE_FIRST", "enqueueFirst"); | 		addFunctionMapper("ENQUEUE_FIRST", "enqueueFirst"); | ||||||
| 		addFunctionMapper("ENQUEUE", "enqueue"); | 		addFunctionMapper("ENQUEUE", "enqueue"); | ||||||
| 		addFunctionMapper("DEQUEUE_LAST", "dequeueLast"); | 		addFunctionMapper("DEQUEUE_LAST", "dequeueLast"); | ||||||
| @ -161,14 +196,14 @@ public class GlobalVariables | |||||||
| 	public GlobalVariables createFlags() | 	public GlobalVariables createFlags() | ||||||
| 	{ | 	{ | ||||||
| 		flags.add("TYPE_"+type.getCapType()); | 		flags.add("TYPE_"+type.getCapType()); | ||||||
| 		if(!type.needsCustomJDKType()) | 		flags.add("VALUE_"+valueType.getCapType()); | ||||||
| 		{ | 		if(type == valueType) flags.add("SAME_TYPE"); | ||||||
| 			flags.add("JDK_CONSUMER"); | 		if(type.hasFunction(valueType)) flags.add("JDK_FUNCTION"); | ||||||
| 		} | 		if(type.hasBiFunction(valueType)) flags.add("JDK_BI_FUNCTION"); | ||||||
| 		if(!type.isPrimitiveBlocking()) | 		if(!type.needsCustomJDKType()) flags.add("JDK_TYPE"); | ||||||
| 		{ | 		if(!type.isPrimitiveBlocking()) flags.add("PRIMITIVES"); | ||||||
| 			flags.add("PRIMITIVES"); | 		if(valueType.isPrimitiveBlocking()) flags.add("VALUE_PRIMITIVES"); | ||||||
| 		} | 		if(valueType.needsCustomJDKType()) flags.add("JDK_VALUE"); | ||||||
| 		return this; | 		return this; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -181,6 +216,15 @@ public class GlobalVariables | |||||||
| 		return process; | 		return process; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public TemplateProcess createBi(String fileName, String splitter) | ||||||
|  | 	{ | ||||||
|  | 		TemplateProcess process = new TemplateProcess(String.format(fileName+".java", type.getFileType()+splitter+valueType.getFileType())); | ||||||
|  | 		process.setPathBuilder(new PathBuilder(type.getPathType())); | ||||||
|  | 		process.addFlags(flags); | ||||||
|  | 		process.addMappers(operators); | ||||||
|  | 		return process; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	public ClassType getType() | 	public ClassType getType() | ||||||
| 	{ | 	{ | ||||||
| 		return type; | 		return type; | ||||||
| @ -189,6 +233,13 @@ public class GlobalVariables | |||||||
| 	private void addClassMapper(String pattern, String replacement) | 	private void addClassMapper(String pattern, String replacement) | ||||||
| 	{ | 	{ | ||||||
| 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+replacement)); | 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+replacement)); | ||||||
|  | 		operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, valueType.getFileType()+replacement)); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	private void addBiClassMapper(String pattern, String replacement, String splitter) | ||||||
|  | 	{ | ||||||
|  | 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+splitter+valueType.getFileType()+replacement)); | ||||||
|  | 		 | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	private void addAbstractMapper(String pattern, String replacement) | 	private void addAbstractMapper(String pattern, String replacement) | ||||||
| @ -201,6 +252,11 @@ public class GlobalVariables | |||||||
| 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+type.getNonFileType())); | 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+type.getNonFileType())); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	private void addFunctionValueMapper(String pattern, String replacement) | ||||||
|  | 	{ | ||||||
|  | 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+valueType.getNonFileType())); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	private void addFunctionMappers(String pattern, String replacement) | 	private void addFunctionMappers(String pattern, String replacement) | ||||||
| 	{ | 	{ | ||||||
| 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getNonFileType())));		 | 		operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getNonFileType())));		 | ||||||
|  | |||||||
| @ -17,8 +17,10 @@ public class TestBuilder extends TemplateProcessor | |||||||
| { | { | ||||||
| 	Map<String, EnumSet<ClassType>> blocked = new HashMap<String, EnumSet<ClassType>>(); | 	Map<String, EnumSet<ClassType>> blocked = new HashMap<String, EnumSet<ClassType>>(); | ||||||
| 	Map<String, String> nameRemapper = new HashMap<String, String>(); | 	Map<String, String> nameRemapper = new HashMap<String, String>(); | ||||||
|  | 	Map<String, String> biRequired = new HashMap<String, String>(); | ||||||
| 	public static final ClassType[] TYPE = ClassType.values(); | 	public static final ClassType[] TYPE = ClassType.values(); | ||||||
| 	List<GlobalVariables> varibles = new ArrayList<GlobalVariables>(); | 	List<GlobalVariables> variables = new ArrayList<GlobalVariables>(); | ||||||
|  | 	List<GlobalVariables> biVariables = new ArrayList<>(); | ||||||
| 	 | 	 | ||||||
| 	public TestBuilder() | 	public TestBuilder() | ||||||
| 	{ | 	{ | ||||||
| @ -46,17 +48,18 @@ public class TestBuilder extends TemplateProcessor | |||||||
| 	@Override | 	@Override | ||||||
| 	protected void init() | 	protected void init() | ||||||
| 	{ | 	{ | ||||||
| 		varibles.clear(); | 		variables.clear(); | ||||||
| 		for(ClassType clzType : TYPE) | 		for(ClassType clzType : TYPE) | ||||||
| 		{ | 		{ | ||||||
| 			GlobalVariables type = new GlobalVariables(clzType); | 			for(ClassType subType : TYPE) | ||||||
| 			type.createFlags(); | 			{ | ||||||
| 			type.createHelperVariables(); | 				create(clzType, subType); | ||||||
| 			type.createVariables(); |  | ||||||
| 			type.createClassTypes(); |  | ||||||
| 			type.createFunctions(); |  | ||||||
| 			varibles.add(type); |  | ||||||
| 			} | 			} | ||||||
|  | 		} | ||||||
|  | 		biRequired.put("BiConsumer", ""); | ||||||
|  | 		biRequired.put("Function", "2"); | ||||||
|  | 		biRequired.put("BiFunction", "2"); | ||||||
|  | 		nameRemapper.put("BiConsumer", "%sConsumer"); | ||||||
| 		nameRemapper.put("IArray", "I%sArray"); | 		nameRemapper.put("IArray", "I%sArray"); | ||||||
| 		nameRemapper.put("AbstractCollection", "Abstract%sCollection"); | 		nameRemapper.put("AbstractCollection", "Abstract%sCollection"); | ||||||
| 		nameRemapper.put("AbstractSet", "Abstract%sSet"); | 		nameRemapper.put("AbstractSet", "Abstract%sSet"); | ||||||
| @ -65,6 +68,18 @@ public class TestBuilder extends TemplateProcessor | |||||||
| 		addBlockage(ClassType.BOOLEAN, "Sets", "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet"); | 		addBlockage(ClassType.BOOLEAN, "Sets", "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	protected void create(ClassType mainType, ClassType subType)  | ||||||
|  | 	{ | ||||||
|  | 		GlobalVariables type = new GlobalVariables(mainType, subType); | ||||||
|  | 		type.createFlags(); | ||||||
|  | 		type.createHelperVariables(); | ||||||
|  | 		type.createVariables(); | ||||||
|  | 		type.createClassTypes(); | ||||||
|  | 		type.createFunctions(); | ||||||
|  | 		if(mainType == subType) variables.add(type); | ||||||
|  | 		biVariables.add(type); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
| 	protected void addBlockage(ClassType type, String...args) { | 	protected void addBlockage(ClassType type, String...args) { | ||||||
| 		for(String s : args) { | 		for(String s : args) { | ||||||
| 			EnumSet<ClassType> set = blocked.get(s); | 			EnumSet<ClassType> set = blocked.get(s); | ||||||
| @ -80,9 +95,22 @@ public class TestBuilder extends TemplateProcessor | |||||||
| 	public void createProcesses(String name, Consumer<TemplateProcess> acceptor) | 	public void createProcesses(String name, Consumer<TemplateProcess> acceptor) | ||||||
| 	{ | 	{ | ||||||
| 		EnumSet<ClassType> types = blocked.get(name); | 		EnumSet<ClassType> types = blocked.get(name); | ||||||
| 		for(int i = 0,m=varibles.size();i<m;i++) | 		String splitter = biRequired.get(name); | ||||||
|  | 		if(splitter != null) | ||||||
| 		{ | 		{ | ||||||
| 			GlobalVariables type = varibles.get(i); | 			for(int i = 0,m=biVariables.size();i<m;i++) | ||||||
|  | 			{ | ||||||
|  | 				GlobalVariables type = biVariables.get(i); | ||||||
|  | 				if(types == null || !types.contains(type.getType())) | ||||||
|  | 				{ | ||||||
|  | 					acceptor.accept(type.createBi(nameRemapper.getOrDefault(name, "%s"+name), splitter)); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 		for(int i = 0,m=variables.size();i<m;i++) | ||||||
|  | 		{ | ||||||
|  | 			GlobalVariables type = variables.get(i); | ||||||
| 			if(types == null || !types.contains(type.getType())) | 			if(types == null || !types.contains(type.getType())) | ||||||
| 			{ | 			{ | ||||||
| 				acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name))); | 				acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name))); | ||||||
|  | |||||||
| @ -47,7 +47,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle | |||||||
| 	 */ | 	 */ | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean contains(KEY_TYPE e) { | 	public boolean contains(KEY_TYPE e) { | ||||||
| 		for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(EQUALS(iter.NEXT(), e)) return true; } | 		for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; } | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -129,7 +129,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle | |||||||
| 	@Override | 	@Override | ||||||
| 	public boolean REMOVE_KEY(KEY_TYPE e) { | 	public boolean REMOVE_KEY(KEY_TYPE e) { | ||||||
| 		for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { | 		for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { | ||||||
| 			if(EQUALS(iter.NEXT(), e)) { | 			if(KEY_EQUALS(iter.NEXT(), e)) { | ||||||
| 				iter.remove(); | 				iter.remove(); | ||||||
| 				return true; | 				return true; | ||||||
| 			} | 			} | ||||||
|  | |||||||
| @ -2,21 +2,13 @@ package speiger.src.collections.PACKAGE.functions; | |||||||
| 
 | 
 | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
| import java.util.function.Consumer; | import java.util.function.Consumer; | ||||||
| #if !TYPE_BOOLEAN |  | ||||||
| #if !JDK_CONSUMER |  | ||||||
| import speiger.src.collections.utils.SanityChecks; |  | ||||||
| 
 |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| /** | /** | ||||||
|  * Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface |  * Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface | ||||||
|  */ |  */ | ||||||
|  | @FunctionalInterface | ||||||
|  | #if JDK_TYPE && !TYPE_BOOLEAN | ||||||
| public interface CONSUMER extends Consumer<CLASS_TYPE>, JAVA_CONSUMER | public interface CONSUMER extends Consumer<CLASS_TYPE>, JAVA_CONSUMER | ||||||
| #else | #else | ||||||
| 
 |  | ||||||
| /** |  | ||||||
|  * Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface |  | ||||||
|  */ |  | ||||||
| public interface CONSUMER extends Consumer<CLASS_TYPE> | public interface CONSUMER extends Consumer<CLASS_TYPE> | ||||||
| #endif | #endif | ||||||
| { | { | ||||||
| @ -28,16 +20,6 @@ public interface CONSUMER extends Consumer<CLASS_TYPE> | |||||||
|      */ |      */ | ||||||
| 	void accept(KEY_TYPE t); | 	void accept(KEY_TYPE t); | ||||||
| 	 | 	 | ||||||
| #if !JDK_CONSUMER |  | ||||||
|  	/** {@inheritDoc} |  | ||||||
|  	 * <p>This default implementation delegates to the corresponding type-specific function. |  | ||||||
|  	 * @deprecated Please use the corresponding type-specific function instead.  |  | ||||||
|  	 */ |  | ||||||
| 	@Override |  | ||||||
| 	@Deprecated |  | ||||||
| 	default void accept(JAVA_TYPE t) { accept(SanityChecks.SANITY_CAST(t)); } |  | ||||||
| 	 |  | ||||||
| #endif |  | ||||||
| 	public default CONSUMER andThen(CONSUMER after) { | 	public default CONSUMER andThen(CONSUMER after) { | ||||||
| 		Objects.requireNonNull(after); | 		Objects.requireNonNull(after); | ||||||
| 		return T -> {accept(T); after.accept(T);}; | 		return T -> {accept(T); after.accept(T);}; | ||||||
| @ -61,8 +43,8 @@ public interface CONSUMER extends Consumer<CLASS_TYPE> | |||||||
| 		Objects.requireNonNull(after); | 		Objects.requireNonNull(after); | ||||||
| 		return T -> {accept(T); after.accept(KEY_TO_OBJ(T));}; | 		return T -> {accept(T); after.accept(KEY_TO_OBJ(T));}; | ||||||
| 	} | 	} | ||||||
|  | #if JDK_TYPE && PRIMITIVES | ||||||
| 	 | 	 | ||||||
| #if PRIMITIVES |  | ||||||
| 	/** {@inheritDoc} | 	/** {@inheritDoc} | ||||||
| 	  * <p>This default implementation delegates to the corresponding type-specific function. | 	  * <p>This default implementation delegates to the corresponding type-specific function. | ||||||
| 	  * @deprecated Please use the corresponding type-specific function instead.  | 	  * @deprecated Please use the corresponding type-specific function instead.  | ||||||
|  | |||||||
| @ -0,0 +1,35 @@ | |||||||
|  | package speiger.src.collections.PACKAGE.functions.consumer; | ||||||
|  | 
 | ||||||
|  | import java.util.Objects; | ||||||
|  | import java.util.function.BiConsumer; | ||||||
|  | 
 | ||||||
|  | public interface BI_CONSUMER KEY_VALUE_GENERIC_TYPE extends BiConsumer<CLASS_TYPE, CLASS_VALUE_TYPE> | ||||||
|  | { | ||||||
|  | 	void accept(KEY_TYPE k, VALUE_TYPE v); | ||||||
|  | 	 | ||||||
|  | 	public default BI_CONSUMER KEY_VALUE_GENERIC_TYPE andThen(BI_CONSUMER KEY_VALUE_GENERIC_TYPE after) { | ||||||
|  | 		Objects.requireNonNull(after); | ||||||
|  | 		return (K, V) -> {accept(K, V); after.accept(K, V);}; | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | #if !TYPE_OBJECT || !VALUE_OBJECT | ||||||
|  | 	/** {@inheritDoc} | ||||||
|  | 	 * <p>This default implementation delegates to the corresponding type-specific function. | ||||||
|  | 	 * @deprecated Please use the corresponding type-specific function instead.  | ||||||
|  | 	 */ | ||||||
|  | 	@Override | ||||||
|  | 	@Deprecated | ||||||
|  | 	default void accept(CLASS_TYPE k, CLASS_VALUE_TYPE v) { accept(OBJ_TO_KEY(k), OBJ_TO_VALUE(v)); } | ||||||
|  | 	 | ||||||
|  | 	/** {@inheritDoc} | ||||||
|  | 	 * <p>This default implementation delegates to the corresponding type-specific function. | ||||||
|  |  	 * @deprecated Please use the corresponding type-specific function instead.  | ||||||
|  |  	 */ | ||||||
|  | 	@Override | ||||||
|  | 	@Deprecated | ||||||
|  | 	default BI_CONSUMER KEY_VALUE_GENERIC_TYPE andThen(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> after) { | ||||||
|  | 		Objects.requireNonNull(after); | ||||||
|  | 		return (K, V) -> {accept(K, V); after.accept(KEY_TO_OBJ(K), VALUE_TO_OBJ(V));}; | ||||||
|  | 	} | ||||||
|  | #endif | ||||||
|  | } | ||||||
| @ -0,0 +1,26 @@ | |||||||
|  | package speiger.src.collections.PACKAGE.functions.function; | ||||||
|  | 
 | ||||||
|  | @FunctionalInterface | ||||||
|  | #if JDK_BI_FUNCTION | ||||||
|  | public interface BI_FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_BI_FUNCTION KEY_KEY_VALUE_GENERIC_TYPE | ||||||
|  | #else | ||||||
|  | public interface BI_FUNCTION KEY_VALUE_GENERIC_TYPE | ||||||
|  | #endif | ||||||
|  | { | ||||||
|  | 	public VALUE_TYPE GET_VALUE(KEY_TYPE k, KEY_TYPE v); | ||||||
|  | #if JDK_BI_FUNCTION | ||||||
|  | #if VALUE_BOOLEAN | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE test(KEY_TYPE k, KEY_TYPE v) { return GET_VALUE(k, v); } | ||||||
|  | #else if VALUE_OBJECT | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE apply(KEY_TYPE k, KEY_TYPE v) { return GET_VALUE(k, v); } | ||||||
|  | #else | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k, KEY_TYPE v) { return GET_VALUE(k, v); } | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  | } | ||||||
| @ -0,0 +1,59 @@ | |||||||
|  | package speiger.src.collections.PACKAGE.functions.function; | ||||||
|  | 
 | ||||||
|  | #if JDK_FUNCTION && VALUE_BOOLEAN | ||||||
|  | import java.util.Objects; | ||||||
|  | #endif | ||||||
|  | 
 | ||||||
|  | @FunctionalInterface | ||||||
|  | #if JDK_FUNCTION | ||||||
|  | public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE | ||||||
|  | #else | ||||||
|  | public interface FUNCTION KEY_VALUE_GENERIC_TYPE | ||||||
|  | #endif | ||||||
|  | { | ||||||
|  | 	public VALUE_TYPE GET_VALUE(KEY_TYPE k); | ||||||
|  | #if JDK_FUNCTION | ||||||
|  | #if VALUE_BOOLEAN | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); } | ||||||
|  | 	 | ||||||
|  | 	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); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	@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); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() { | ||||||
|  | 		return T -> !GET_VALUE(T); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	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); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	@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); | ||||||
|  | 	} | ||||||
|  | #else if VALUE_OBJECT | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE apply(KEY_TYPE k) { return GET_VALUE(k); } | ||||||
|  | #else | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k) { return GET_VALUE(k); } | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  | } | ||||||
| @ -125,7 +125,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| 	public int indexOf(KEY_TYPE e) { | 	public int indexOf(KEY_TYPE e) { | ||||||
| 		LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator(); | 		LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator(); | ||||||
| 		while(iter.hasNext()) { | 		while(iter.hasNext()) { | ||||||
| 			if(EQUALS(iter.NEXT(), e)) | 			if(KEY_EQUALS(iter.NEXT(), e)) | ||||||
| 				return iter.previousIndex(); | 				return iter.previousIndex(); | ||||||
| 		} | 		} | ||||||
| 		return -1; | 		return -1; | ||||||
| @ -140,7 +140,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| 	public int lastIndexOf(KEY_TYPE e) { | 	public int lastIndexOf(KEY_TYPE e) { | ||||||
| 		LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator(size()); | 		LIST_ITERATOR KEY_GENERIC_TYPE iter = listIterator(size()); | ||||||
| 		while(iter.hasPrevious()) { | 		while(iter.hasPrevious()) { | ||||||
| 			if(EQUALS(iter.PREVIOUS(), e)) | 			if(KEY_EQUALS(iter.PREVIOUS(), e)) | ||||||
| 				return iter.nextIndex(); | 				return iter.nextIndex(); | ||||||
| 		} | 		} | ||||||
| 		return -1; | 		return -1; | ||||||
| @ -164,7 +164,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| 	    	LIST_ITERATOR e1 = listIterator(); | 	    	LIST_ITERATOR e1 = listIterator(); | ||||||
| 	    	LIST_ITERATOR e2 = ((LIST)l).listIterator(); | 	    	LIST_ITERATOR e2 = ((LIST)l).listIterator(); | ||||||
| 	    	while (e1.hasNext() && e2.hasNext()) { | 	    	while (e1.hasNext() && e2.hasNext()) { | ||||||
| 	    		if(!(EQUALS(e1.NEXT(), e2.NEXT()))) | 	    		if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT()))) | ||||||
| 	    			return false; | 	    			return false; | ||||||
| 	    	} | 	    	} | ||||||
| 	    	return !(e1.hasNext() || e2.hasNext()); | 	    	return !(e1.hasNext() || e2.hasNext()); | ||||||
| @ -190,7 +190,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 			hashCode = 31 * hashCode + i.next().hashCode(); | 			hashCode = 31 * hashCode + i.next().hashCode(); | ||||||
| #else | #else | ||||||
|     		hashCode = 31 * hashCode + TO_HASH(i.NEXT()); |     		hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT()); | ||||||
| #endif | #endif | ||||||
|     	return hashCode; |     	return hashCode; | ||||||
| 	} | 	} | ||||||
| @ -217,7 +217,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public void size(int size) { | 	public void size(int size) { | ||||||
| 		while(size > size()) add(EMPTY_VALUE); | 		while(size > size()) add(EMPTY_KEY_VALUE); | ||||||
| 		while(size < size()) REMOVE(size() - 1); | 		while(size < size()) REMOVE(size() - 1); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -127,14 +127,14 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE | |||||||
| 	/** | 	/** | ||||||
| 	 * Creates a wrapped arraylist that uses the array as backing array | 	 * Creates a wrapped arraylist that uses the array as backing array | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { | 	public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { | ||||||
| 		return wrap(a, a.length); | 		return wrap(a, a.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	/** | 	/** | ||||||
| 	 * Creates a wrapped arraylist that uses the array as backing array and a custom fillsize | 	 * Creates a wrapped arraylist that uses the array as backing array and a custom fillsize | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int length) { | 	public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int length) { | ||||||
| 		SanityChecks.checkArrayCapacity(a.length, 0, length); | 		SanityChecks.checkArrayCapacity(a.length, 0, length); | ||||||
| 		ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); | 		ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); | ||||||
| 		list.data = a; | 		list.data = a; | ||||||
| @ -146,7 +146,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE | |||||||
| 	/** | 	/** | ||||||
| 	 * Creates a new ArrayList with a EmptyObject array of the Type requested | 	 * Creates a new ArrayList with a EmptyObject array of the Type requested | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) { | 	public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) { | ||||||
| 		ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); | 		ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); | ||||||
| 		list.data = (KEY_TYPE[])ObjectArrays.newArray(c.getClass().getComponentType(), 0); | 		list.data = (KEY_TYPE[])ObjectArrays.newArray(c.getClass().getComponentType(), 0); | ||||||
| 		return list; | 		return list; | ||||||
| @ -453,7 +453,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE | |||||||
| 	@Override | 	@Override | ||||||
| 	public int indexOf(KEY_TYPE e) { | 	public int indexOf(KEY_TYPE e) { | ||||||
| 		for(int i = 0;i<size;i++) { | 		for(int i = 0;i<size;i++) { | ||||||
| 			if(EQUALS(data[i], e)) return i; | 			if(KEY_EQUALS(data[i], e)) return i; | ||||||
| 		} | 		} | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| @ -466,7 +466,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE | |||||||
| 	@Override | 	@Override | ||||||
| 	public int lastIndexOf(KEY_TYPE e) { | 	public int lastIndexOf(KEY_TYPE e) { | ||||||
| 		for(int i = size - 1;i>=0;i--) { | 		for(int i = size - 1;i>=0;i--) { | ||||||
| 			if(EQUALS(data[i], e)) return i; | 			if(KEY_EQUALS(data[i], e)) return i; | ||||||
| 		} | 		} | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| @ -853,7 +853,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE | |||||||
| 		if(size > data.length) | 		if(size > data.length) | ||||||
| 			data = Arrays.copyOf(data, size); | 			data = Arrays.copyOf(data, size); | ||||||
| 		else if(size < size() && size >= 0) | 		else if(size < size() && size >= 0) | ||||||
| 			Arrays.fill(data, size, size(), EMPTY_VALUE); | 			Arrays.fill(data, size, size(), EMPTY_KEY_VALUE); | ||||||
| 		this.size = size; | 		this.size = size; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -65,22 +65,22 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY | |||||||
| 		comparator = comp; | 		comparator = comp; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {  | 	public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {  | ||||||
| 		return wrap(array, array.length); | 		return wrap(array, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) { | 	public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) { | ||||||
| 		ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(); | 		ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(); | ||||||
| 		queue.array = array; | 		queue.array = array; | ||||||
| 		queue.size = size; | 		queue.size = size; | ||||||
| 		return queue; | 		return queue; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		return wrap(array, array.length, comp); | 		return wrap(array, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp); | 		ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp); | ||||||
| 		queue.array = array; | 		queue.array = array; | ||||||
| 		queue.size = size; | 		queue.size = size; | ||||||
| @ -120,14 +120,14 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY | |||||||
| 	@Override | 	@Override | ||||||
| 	public boolean REMOVE(KEY_TYPE e) { | 	public boolean REMOVE(KEY_TYPE e) { | ||||||
| 		for(int i = 0;i<size;i++) | 		for(int i = 0;i<size;i++) | ||||||
| 			if(EQUALS(e, array[i])) return removeIndex(i); | 			if(KEY_EQUALS(e, array[i])) return removeIndex(i); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean REMOVE_LAST(KEY_TYPE e) { | 	public boolean REMOVE_LAST(KEY_TYPE e) { | ||||||
| 		for(int i = size-1;i>=0;i--) | 		for(int i = size-1;i>=0;i--) | ||||||
| 			if(EQUALS(e, array[i])) return removeIndex(i); | 			if(KEY_EQUALS(e, array[i])) return removeIndex(i); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -137,7 +137,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY | |||||||
| 		array[size] = null; | 		array[size] = null; | ||||||
| #endif | #endif | ||||||
| 		if(index == firstIndex) firstIndex = -1; | 		if(index == firstIndex) firstIndex = -1; | ||||||
| 		else if(index >= firstIndex) firstIndex--; | 		else if(firstIndex != -1 && index >= firstIndex) firstIndex--; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -190,13 +190,13 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY | |||||||
| 			int index = size-1; | 			int index = size-1; | ||||||
| 			KEY_TYPE value = array[index]; | 			KEY_TYPE value = array[index]; | ||||||
| 			if(comparator == null) { | 			if(comparator == null) { | ||||||
| 				for(int i = index;firstIndex == -1 && i>=0;i--) { | 				for(int i = index;i>=0;i--) { | ||||||
| 					if(COMPARE_TO_KEY(array[i], value) < 0)  | 					if(COMPARE_TO_KEY(array[i], value) < 0)  | ||||||
| 						value = array[index = i]; | 						value = array[index = i]; | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				for(int i = index;firstIndex == -1 && i>=0;i--) { | 				for(int i = index;i>=0;i--) { | ||||||
| 					if(comparator.compare(array[i], value) < 0)  | 					if(comparator.compare(array[i], value) < 0)  | ||||||
| 						value = array[index = i]; | 						value = array[index = i]; | ||||||
| 				} | 				} | ||||||
|  | |||||||
| @ -68,11 +68,11 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_ | |||||||
| 		ARRAYS.heapify(array, size, comp); | 		ARRAYS.heapify(array, size, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {  | 	public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {  | ||||||
| 		return wrap(array, array.length); | 		return wrap(array, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) { | 	public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) { | ||||||
| 		HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(); | 		HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(); | ||||||
| 		queue.array = array; | 		queue.array = array; | ||||||
| 		queue.size = size; | 		queue.size = size; | ||||||
| @ -80,11 +80,11 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_ | |||||||
| 		return queue; | 		return queue; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		return wrap(array, array.length, comp); | 		return wrap(array, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp); | 		HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp); | ||||||
| 		queue.array = array; | 		queue.array = array; | ||||||
| 		queue.size = size; | 		queue.size = size; | ||||||
| @ -138,14 +138,14 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_ | |||||||
| 	@Override | 	@Override | ||||||
| 	public boolean REMOVE(KEY_TYPE e) { | 	public boolean REMOVE(KEY_TYPE e) { | ||||||
| 		for(int i = 0;i<size;i++) | 		for(int i = 0;i<size;i++) | ||||||
| 			if(EQUALS(e, array[i])) return removeIndex(i); | 			if(KEY_EQUALS(e, array[i])) return removeIndex(i); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean REMOVE_LAST(KEY_TYPE e) { | 	public boolean REMOVE_LAST(KEY_TYPE e) { | ||||||
| 		for(int i = size-1;i>=0;i--) | 		for(int i = size-1;i>=0;i--) | ||||||
| 			if(EQUALS(e, array[i])) return removeIndex(i); | 			if(KEY_EQUALS(e, array[i])) return removeIndex(i); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -4,9 +4,11 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE | |||||||
| { | { | ||||||
| 	public void ENQUEUE_FIRST(KEY_TYPE e); | 	public void ENQUEUE_FIRST(KEY_TYPE e); | ||||||
| 	public KEY_TYPE DEQUEUE_LAST(); | 	public KEY_TYPE DEQUEUE_LAST(); | ||||||
|  | 	public default KEY_TYPE LAST_KEY() { return PEEK(size()-1); } | ||||||
| 	 | 	 | ||||||
| #if !TYPE_OBJECT | #if !TYPE_OBJECT | ||||||
| 	public default void enqueueFirst(CLASS_TYPE e) { ENQUEUE_FIRST(OBJ_TO_KEY(e)); } | 	public default void enqueueFirst(CLASS_TYPE e) { ENQUEUE_FIRST(OBJ_TO_KEY(e)); } | ||||||
| 	public default CLASS_TYPE dequeueLast() { return KEY_TO_OBJ(DEQUEUE_LAST()); } | 	public default CLASS_TYPE dequeueLast() { return KEY_TO_OBJ(DEQUEUE_LAST()); } | ||||||
|  | 	public default CLASS_TYPE last() { return peek(size()-1); } | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @ -24,8 +24,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ObjectPriorityQueue<CLA | |||||||
| 	public KEY_TYPE DEQUEUE(); | 	public KEY_TYPE DEQUEUE(); | ||||||
| 	 | 	 | ||||||
| 	public KEY_TYPE PEEK(int index); | 	public KEY_TYPE PEEK(int index); | ||||||
| 	public default KEY_TYPE FIRST_KEY() { return peek(0); } | 	public default KEY_TYPE FIRST_KEY() { return PEEK(0); } | ||||||
| 	public default KEY_TYPE LAST_KEY() { return peek(size()-1); } |  | ||||||
| 	 | 	 | ||||||
| 	public boolean REMOVE(KEY_TYPE e); | 	public boolean REMOVE(KEY_TYPE e); | ||||||
| 	public boolean REMOVE_LAST(KEY_TYPE e); | 	public boolean REMOVE_LAST(KEY_TYPE e); | ||||||
| @ -44,7 +43,6 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ObjectPriorityQueue<CLA | |||||||
| 	 | 	 | ||||||
| 	public default CLASS_TYPE peek(int index) { return KEY_TO_OBJ(PEEK(index)); } | 	public default CLASS_TYPE peek(int index) { return KEY_TO_OBJ(PEEK(index)); } | ||||||
| 	public default CLASS_TYPE first() { return peek(0); } | 	public default CLASS_TYPE first() { return peek(0); } | ||||||
| 	public default CLASS_TYPE last() { return peek(size()-1); } |  | ||||||
| 	 | 	 | ||||||
| 	public default boolean remove(CLASS_TYPE e) { return REMOVE(OBJ_TO_KEY(e)); } | 	public default boolean remove(CLASS_TYPE e) { return REMOVE(OBJ_TO_KEY(e)); } | ||||||
| 	public default boolean removeLast(CLASS_TYPE e) { return REMOVE_LAST(OBJ_TO_KEY(e)); } | 	public default boolean removeLast(CLASS_TYPE e) { return REMOVE_LAST(OBJ_TO_KEY(e)); } | ||||||
|  | |||||||
| @ -361,17 +361,17 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE | |||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement, boolean inclusive) { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement, boolean inclusive) { | ||||||
| 		return new AscendingSubSetBRACES(this, true, EMPTY_VALUE, true, false, toElement, inclusive); | 		return new AscendingSubSetBRACES(this, true, EMPTY_KEY_VALUE, true, false, toElement, inclusive); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement, boolean inclusive) { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement, boolean inclusive) { | ||||||
| 		return new AscendingSubSetBRACES(this, false, fromElement, inclusive, true, EMPTY_VALUE, true); | 		return new AscendingSubSetBRACES(this, false, fromElement, inclusive, true, EMPTY_KEY_VALUE, true); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet() { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet() { | ||||||
| 		return new DescendingSubSetBRACES(this, true, EMPTY_VALUE, true, true, EMPTY_VALUE, true); | 		return new DescendingSubSetBRACES(this, true, EMPTY_KEY_VALUE, true, true, EMPTY_KEY_VALUE, true); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	protected void removeNode(Entry KEY_GENERIC_TYPE entry) { | 	protected void removeNode(Entry KEY_GENERIC_TYPE entry) { | ||||||
|  | |||||||
| @ -14,7 +14,7 @@ public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
|     	int hashCode = 1; |     	int hashCode = 1; | ||||||
|     	ITERATOR KEY_GENERIC_TYPE i = iterator(); |     	ITERATOR KEY_GENERIC_TYPE i = iterator(); | ||||||
|     	while(i.hasNext()) |     	while(i.hasNext()) | ||||||
|     		hashCode = 31 * hashCode + TO_HASH(i.NEXT()); |     		hashCode = 31 * hashCode + KEY_TO_HASH(i.NEXT()); | ||||||
|     	return hashCode; |     	return hashCode; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -32,7 +32,7 @@ public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION | |||||||
| 	    	ITERATOR e1 = iterator(); | 	    	ITERATOR e1 = iterator(); | ||||||
| 	    	ITERATOR e2 = ((SET)l).iterator(); | 	    	ITERATOR e2 = ((SET)l).iterator(); | ||||||
| 	    	while (e1.hasNext() && e2.hasNext()) { | 	    	while (e1.hasNext() && e2.hasNext()) { | ||||||
| 	    		if(!(EQUALS(e1.NEXT(), e2.NEXT()))) | 	    		if(!(KEY_EQUALS(e1.NEXT(), e2.NEXT()))) | ||||||
| 	    			return false; | 	    			return false; | ||||||
| 	    	} | 	    	} | ||||||
| 	    	return !(e1.hasNext() || e2.hasNext()); | 	    	return !(e1.hasNext() || e2.hasNext()); | ||||||
|  | |||||||
| @ -164,7 +164,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 			size--; | 			size--; | ||||||
| 			if(index != size) System.arraycopy(data, index+1, data, index, size - index); | 			if(index != size) System.arraycopy(data, index+1, data, index, size - index); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 			data[size] = EMPTY_VALUE; | 			data[size] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| @ -179,7 +179,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 			size--; | 			size--; | ||||||
| 			if(index != size) System.arraycopy(data, index+1, data, index, size - index); | 			if(index != size) System.arraycopy(data, index+1, data, index, size - index); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 			data[size] = EMPTY_VALUE; | 			data[size] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 			return true; | 			return true; | ||||||
| 		} | 		} | ||||||
| @ -193,7 +193,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 		KEY_TYPE result = data[0]; | 		KEY_TYPE result = data[0]; | ||||||
| 		System.arraycopy(data, 1, data, 0, size - 1); | 		System.arraycopy(data, 1, data, 0, size - 1); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		data[size-1] = EMPTY_VALUE; | 		data[size-1] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 		return result; | 		return result; | ||||||
| 	} | 	} | ||||||
| @ -204,7 +204,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 		size--; | 		size--; | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		KEY_TYPE result = data[size]; | 		KEY_TYPE result = data[size]; | ||||||
| 		data[size] = EMPTY_VALUE; | 		data[size] = EMPTY_KEY_VALUE; | ||||||
| 		return result; | 		return result; | ||||||
| #else | #else | ||||||
| 		return data[size]; | 		return data[size]; | ||||||
| @ -214,7 +214,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| #if !TYPE_OBJECT | #if !TYPE_OBJECT | ||||||
| 	protected int findIndex(KEY_TYPE o) { | 	protected int findIndex(KEY_TYPE o) { | ||||||
| 		for(int i = size-1;i>=0;i--) | 		for(int i = size-1;i>=0;i--) | ||||||
| 			if(EQUALS(data[i], o)) return i; | 			if(KEY_EQUALS(data[i], o)) return i; | ||||||
| 		return -1; | 		return -1; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -407,7 +407,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 				length--; | 				length--; | ||||||
| 				if(index != size) System.arraycopy(data, index+1, data, index, size - index); | 				if(index != size) System.arraycopy(data, index+1, data, index, size - index); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 				data[size] = EMPTY_VALUE; | 				data[size] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 				return true; | 				return true; | ||||||
| 			} | 			} | ||||||
| @ -422,7 +422,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 			KEY_TYPE result = data[offset]; | 			KEY_TYPE result = data[offset]; | ||||||
| 			System.arraycopy(data, offset+1, data, offset, size-offset); | 			System.arraycopy(data, offset+1, data, offset, size-offset); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 			data[size] = EMPTY_VALUE; | 			data[size] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 			return result; | 			return result; | ||||||
| 		} | 		} | ||||||
| @ -435,7 +435,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| 			length--; | 			length--; | ||||||
| 			System.arraycopy(data, end()+1, data, end(), size-end()); | 			System.arraycopy(data, end()+1, data, end(), size-end()); | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 			data[size] = EMPTY_VALUE; | 			data[size] = EMPTY_KEY_VALUE; | ||||||
| #endif | #endif | ||||||
| 			return result; | 			return result; | ||||||
| 		} | 		} | ||||||
| @ -487,7 +487,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im | |||||||
| #if !TYPE_OBJECT | #if !TYPE_OBJECT | ||||||
| 		protected int findIndex(KEY_TYPE o) { | 		protected int findIndex(KEY_TYPE o) { | ||||||
| 			for(int i = length-1;i>=0;i--) | 			for(int i = length-1;i>=0;i--) | ||||||
| 				if(EQUALS(data[offset+i], o)) return i + offset; | 				if(KEY_EQUALS(data[offset+i], o)) return i + offset; | ||||||
| 			return -1; | 			return -1; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
|  | |||||||
| @ -106,7 +106,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| #endif | #endif | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean addAndMoveToFirst(KEY_TYPE o) { | 	public boolean addAndMoveToFirst(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) { | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToFirstIndex(nullIndex); | 				moveToFirstIndex(nullIndex); | ||||||
| 				return false; | 				return false; | ||||||
| @ -116,7 +116,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 			while(!strategy.equals(keys[pos], EMPTY_VALUE)) { | 			while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) { | ||||||
| 				if(strategy.equals(keys[pos], o)) { | 				if(strategy.equals(keys[pos], o)) { | ||||||
| 					moveToFirstIndex(pos); | 					moveToFirstIndex(pos); | ||||||
| 					return false; | 					return false; | ||||||
| @ -132,7 +132,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean addAndMoveToLast(KEY_TYPE o) { | 	public boolean addAndMoveToLast(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) { | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToLastIndex(nullIndex); | 				moveToLastIndex(nullIndex); | ||||||
| 				return false; | 				return false; | ||||||
| @ -142,7 +142,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 			while(!strategy.equals(keys[pos], EMPTY_VALUE)) { | 			while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) { | ||||||
| 				if(strategy.equals(keys[pos], o)) { | 				if(strategy.equals(keys[pos], o)) { | ||||||
| 					moveToLastIndex(pos); | 					moveToLastIndex(pos); | ||||||
| 					return false; | 					return false; | ||||||
| @ -159,7 +159,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 	@Override | 	@Override | ||||||
| 	public boolean moveToFirst(KEY_TYPE o) { | 	public boolean moveToFirst(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(FIRST_KEY(), o)) return false; | 		if(strategy.equals(FIRST_KEY(), o)) return false; | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) { | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToFirstIndex(nullIndex); | 				moveToFirstIndex(nullIndex); | ||||||
| 				return true; | 				return true; | ||||||
| @ -167,7 +167,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 			while(!strategy.equals(keys[pos], EMPTY_VALUE)) { | 			while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) { | ||||||
| 				if(strategy.equals(keys[pos], o)) { | 				if(strategy.equals(keys[pos], o)) { | ||||||
| 					moveToFirstIndex(pos); | 					moveToFirstIndex(pos); | ||||||
| 					return true; | 					return true; | ||||||
| @ -182,7 +182,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 	@Override | 	@Override | ||||||
| 	public boolean moveToLast(KEY_TYPE o) { | 	public boolean moveToLast(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(LAST_KEY(), o)) return false; | 		if(strategy.equals(LAST_KEY(), o)) return false; | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) { | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToLastIndex(nullIndex); | 				moveToLastIndex(nullIndex); | ||||||
| 				return true; | 				return true; | ||||||
| @ -190,7 +190,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 			while(!strategy.equals(keys[pos], EMPTY_VALUE)) { | 			while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) { | ||||||
| 				if(strategy.equals(keys[pos], o)) { | 				if(strategy.equals(keys[pos], o)) { | ||||||
| 					moveToLastIndex(pos); | 					moveToLastIndex(pos); | ||||||
| 					return true; | 					return true; | ||||||
| @ -252,9 +252,9 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L; | 		if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L; | ||||||
| 		KEY_TYPE result = keys[pos]; | 		KEY_TYPE result = keys[pos]; | ||||||
| 		size--; | 		size--; | ||||||
| 		if(strategy.equals(result, EMPTY_VALUE)) { | 		if(strategy.equals(result, EMPTY_KEY_VALUE)) { | ||||||
| 			containsNull = false; | 			containsNull = false; | ||||||
| 			keys[nullIndex] = EMPTY_VALUE; | 			keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 		else shiftKeys(pos); | 		else shiftKeys(pos); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -275,9 +275,9 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL; | 		if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL; | ||||||
| 		KEY_TYPE result = keys[pos]; | 		KEY_TYPE result = keys[pos]; | ||||||
| 		size--; | 		size--; | ||||||
| 		if(strategy.equals(result, EMPTY_VALUE)) { | 		if(strategy.equals(result, EMPTY_KEY_VALUE)) { | ||||||
| 			containsNull = false; | 			containsNull = false; | ||||||
| 			keys[nullIndex] = EMPTY_VALUE; | 			keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 		else shiftKeys(pos); | 		else shiftKeys(pos); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -350,10 +350,10 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		long[] newLinks = new long[newSize + 1]; | 		long[] newLinks = new long[newSize + 1]; | ||||||
| 		int newPrev = -1; | 		int newPrev = -1; | ||||||
| 		for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) { | 		for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) { | ||||||
| 			if(strategy.equals(keys[i], EMPTY_VALUE)) pos = newSize; | 			if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) pos = newSize; | ||||||
| 			else { | 			else { | ||||||
| 				pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask; | 				pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask; | ||||||
| 				while(!strategy.equals(newKeys[pos], EMPTY_VALUE)) pos = ++pos & newMask; | 				while(!strategy.equals(newKeys[pos], EMPTY_KEY_VALUE)) pos = ++pos & newMask; | ||||||
| 			} | 			} | ||||||
| 			newKeys[pos] = keys[i]; | 			newKeys[pos] = keys[i]; | ||||||
| 			if(prev != -1) { | 			if(prev != -1) { | ||||||
| @ -415,7 +415,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		SetIterator(KEY_TYPE from) { | 		SetIterator(KEY_TYPE from) { | ||||||
| 			if(strategy.equals(from, EMPTY_VALUE)) { | 			if(strategy.equals(from, EMPTY_KEY_VALUE)) { | ||||||
| 				if(containsNull) { | 				if(containsNull) { | ||||||
| 				    next = (int) links[nullIndex]; | 				    next = (int) links[nullIndex]; | ||||||
| 				    previous = nullIndex; | 				    previous = nullIndex; | ||||||
| @ -428,7 +428,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				int pos = HashUtil.mix(strategy.hashCode(from)) & mask; | 				int pos = HashUtil.mix(strategy.hashCode(from)) & mask; | ||||||
| 				while(!strategy.equals(keys[pos], EMPTY_VALUE)) { | 				while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) { | ||||||
| 					if(strategy.equals(keys[pos], from)) { | 					if(strategy.equals(keys[pos], from)) { | ||||||
| 						next = (int)links[pos]; | 						next = (int)links[pos]; | ||||||
| 						previous = pos; | 						previous = pos; | ||||||
| @ -481,7 +481,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 			if(current == nullIndex) { | 			if(current == nullIndex) { | ||||||
| 				current = -1; | 				current = -1; | ||||||
| 				containsNull = false; | 				containsNull = false; | ||||||
| 				keys[nullIndex] = EMPTY_VALUE; | 				keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				int slot, last, startPos = current; | 				int slot, last, startPos = current; | ||||||
| @ -490,8 +490,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY | |||||||
| 				while(true) { | 				while(true) { | ||||||
| 					startPos = ((last = startPos) + 1) & mask; | 					startPos = ((last = startPos) + 1) & mask; | ||||||
| 					while(true){ | 					while(true){ | ||||||
| 						if(strategy.equals((current = keys[startPos]), EMPTY_VALUE)) { | 						if(strategy.equals((current = keys[startPos]), EMPTY_KEY_VALUE)) { | ||||||
| 							keys[last] = EMPTY_VALUE; | 							keys[last] = EMPTY_KEY_VALUE; | ||||||
| 							return; | 							return; | ||||||
| 						} | 						} | ||||||
| 						slot = HashUtil.mix(strategy.hashCode(current)) & mask; | 						slot = HashUtil.mix(strategy.hashCode(current)) & mask; | ||||||
|  | |||||||
| @ -108,7 +108,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| #endif | #endif | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean addAndMoveToFirst(KEY_TYPE o) { | 	public boolean addAndMoveToFirst(KEY_TYPE o) { | ||||||
| 		if(EQUALS_NULL(o)) { | 		if(KEY_EQUALS_NULL(o)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToFirstIndex(nullIndex); | 				moveToFirstIndex(nullIndex); | ||||||
| 				return false; | 				return false; | ||||||
| @ -117,9 +117,9 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 			onNodeAdded(nullIndex); | 			onNodeAdded(nullIndex); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(TO_HASH(o)) & mask; | 			int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 			while(EQUALS_NOT_NULL(keys[pos])) { | 			while(KEY_EQUALS_NOT_NULL(keys[pos])) { | ||||||
| 				if(EQUALS(keys[pos], o)) { | 				if(KEY_EQUALS(keys[pos], o)) { | ||||||
| 					moveToFirstIndex(pos); | 					moveToFirstIndex(pos); | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| @ -134,7 +134,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean addAndMoveToLast(KEY_TYPE o) { | 	public boolean addAndMoveToLast(KEY_TYPE o) { | ||||||
| 		if(EQUALS_NULL(o)) { | 		if(KEY_EQUALS_NULL(o)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToLastIndex(nullIndex); | 				moveToLastIndex(nullIndex); | ||||||
| 				return false; | 				return false; | ||||||
| @ -143,9 +143,9 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 			onNodeAdded(nullIndex); | 			onNodeAdded(nullIndex); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(TO_HASH(o)) & mask; | 			int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 			while(EQUALS_NOT_NULL(keys[pos])) { | 			while(KEY_EQUALS_NOT_NULL(keys[pos])) { | ||||||
| 				if(EQUALS(keys[pos], o)) { | 				if(KEY_EQUALS(keys[pos], o)) { | ||||||
| 					moveToLastIndex(pos); | 					moveToLastIndex(pos); | ||||||
| 					return false; | 					return false; | ||||||
| 				} | 				} | ||||||
| @ -160,17 +160,17 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean moveToFirst(KEY_TYPE o) { | 	public boolean moveToFirst(KEY_TYPE o) { | ||||||
| 		if(EQUALS(FIRST_KEY(), o)) return false; | 		if(KEY_EQUALS(FIRST_KEY(), o)) return false; | ||||||
| 		if(EQUALS_NULL(o)) { | 		if(KEY_EQUALS_NULL(o)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToFirstIndex(nullIndex); | 				moveToFirstIndex(nullIndex); | ||||||
| 				return true; | 				return true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(TO_HASH(o)) & mask; | 			int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 			while(EQUALS_NOT_NULL(keys[pos])) { | 			while(KEY_EQUALS_NOT_NULL(keys[pos])) { | ||||||
| 				if(EQUALS(keys[pos], o)) { | 				if(KEY_EQUALS(keys[pos], o)) { | ||||||
| 					moveToFirstIndex(pos); | 					moveToFirstIndex(pos); | ||||||
| 					return true; | 					return true; | ||||||
| 				} | 				} | ||||||
| @ -183,17 +183,17 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean moveToLast(KEY_TYPE o) { | 	public boolean moveToLast(KEY_TYPE o) { | ||||||
| 		if(EQUALS(LAST_KEY(), o)) return false; | 		if(KEY_EQUALS(LAST_KEY(), o)) return false; | ||||||
| 		if(EQUALS_NULL(o)) { | 		if(KEY_EQUALS_NULL(o)) { | ||||||
| 			if(containsNull) { | 			if(containsNull) { | ||||||
| 				moveToLastIndex(nullIndex); | 				moveToLastIndex(nullIndex); | ||||||
| 				return true; | 				return true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(TO_HASH(o)) & mask; | 			int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 			while(EQUALS_NOT_NULL(keys[pos])) { | 			while(KEY_EQUALS_NOT_NULL(keys[pos])) { | ||||||
| 				if(EQUALS(keys[pos], o)) { | 				if(KEY_EQUALS(keys[pos], o)) { | ||||||
| 					moveToLastIndex(pos); | 					moveToLastIndex(pos); | ||||||
| 					return true; | 					return true; | ||||||
| 				} | 				} | ||||||
| @ -254,9 +254,9 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 		if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L; | 		if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L; | ||||||
| 		KEY_TYPE result = keys[pos]; | 		KEY_TYPE result = keys[pos]; | ||||||
| 		size--; | 		size--; | ||||||
| 		if(EQUALS_NULL(result)) { | 		if(KEY_EQUALS_NULL(result)) { | ||||||
| 			containsNull = false; | 			containsNull = false; | ||||||
| 			keys[nullIndex] = EMPTY_VALUE; | 			keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 		else shiftKeys(pos); | 		else shiftKeys(pos); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -277,9 +277,9 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 		if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL; | 		if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL; | ||||||
| 		KEY_TYPE result = keys[pos]; | 		KEY_TYPE result = keys[pos]; | ||||||
| 		size--; | 		size--; | ||||||
| 		if(EQUALS_NULL(result)) { | 		if(KEY_EQUALS_NULL(result)) { | ||||||
| 			containsNull = false; | 			containsNull = false; | ||||||
| 			keys[nullIndex] = EMPTY_VALUE; | 			keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 		else shiftKeys(pos); | 		else shiftKeys(pos); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -352,10 +352,10 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 		long[] newLinks = new long[newSize + 1]; | 		long[] newLinks = new long[newSize + 1]; | ||||||
| 		int newPrev = -1; | 		int newPrev = -1; | ||||||
| 		for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) { | 		for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) { | ||||||
| 			if(EQUALS_NULL(keys[i])) pos = newSize; | 			if(KEY_EQUALS_NULL(keys[i])) pos = newSize; | ||||||
| 			else { | 			else { | ||||||
| 				pos = HashUtil.mix(TO_HASH(keys[i])) & newMask; | 				pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask; | ||||||
| 				while(EQUALS_NOT_NULL(newKeys[pos])) pos = ++pos & newMask; | 				while(KEY_EQUALS_NOT_NULL(newKeys[pos])) pos = ++pos & newMask; | ||||||
| 			} | 			} | ||||||
| 			newKeys[pos] = keys[i]; | 			newKeys[pos] = keys[i]; | ||||||
| 			if(prev != -1) { | 			if(prev != -1) { | ||||||
| @ -417,21 +417,21 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		SetIterator(KEY_TYPE from) { | 		SetIterator(KEY_TYPE from) { | ||||||
| 			if(EQUALS_NULL(from)) { | 			if(KEY_EQUALS_NULL(from)) { | ||||||
| 				if(containsNull) { | 				if(containsNull) { | ||||||
| 				    next = (int) links[nullIndex]; | 				    next = (int) links[nullIndex]; | ||||||
| 				    previous = nullIndex; | 				    previous = nullIndex; | ||||||
| 				} | 				} | ||||||
| 				else throw new NoSuchElementException("The null element is not in the set"); | 				else throw new NoSuchElementException("The null element is not in the set"); | ||||||
| 			} | 			} | ||||||
| 			else if(EQUALS(keys[lastIndex], from)) { | 			else if(KEY_EQUALS(keys[lastIndex], from)) { | ||||||
| 				previous = lastIndex; | 				previous = lastIndex; | ||||||
| 				index = size; | 				index = size; | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				int pos = HashUtil.mix(TO_HASH(from)) & mask; | 				int pos = HashUtil.mix(KEY_TO_HASH(from)) & mask; | ||||||
| 				while(EQUALS_NOT_NULL(keys[pos])) { | 				while(KEY_EQUALS_NOT_NULL(keys[pos])) { | ||||||
| 					if(EQUALS(keys[pos], from)) { | 					if(KEY_EQUALS(keys[pos], from)) { | ||||||
| 						next = (int)links[pos]; | 						next = (int)links[pos]; | ||||||
| 						previous = pos; | 						previous = pos; | ||||||
| 						break; | 						break; | ||||||
| @ -483,7 +483,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 			if(current == nullIndex) { | 			if(current == nullIndex) { | ||||||
| 				current = -1; | 				current = -1; | ||||||
| 				containsNull = false; | 				containsNull = false; | ||||||
| 				keys[nullIndex] = EMPTY_VALUE; | 				keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 			} | 			} | ||||||
| 			else { | 			else { | ||||||
| 				int slot, last, startPos = current; | 				int slot, last, startPos = current; | ||||||
| @ -492,11 +492,11 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE | |||||||
| 				while(true) { | 				while(true) { | ||||||
| 					startPos = ((last = startPos) + 1) & mask; | 					startPos = ((last = startPos) + 1) & mask; | ||||||
| 					while(true){ | 					while(true){ | ||||||
| 						if(EQUALS_NULL((current = keys[startPos]))) { | 						if(KEY_EQUALS_NULL((current = keys[startPos]))) { | ||||||
| 							keys[last] = EMPTY_VALUE; | 							keys[last] = EMPTY_KEY_VALUE; | ||||||
| 							return; | 							return; | ||||||
| 						} | 						} | ||||||
| 						slot = HashUtil.mix(TO_HASH(current)) & mask; | 						slot = HashUtil.mix(KEY_TO_HASH(current)) & mask; | ||||||
| 						if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | 						if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | ||||||
| 						startPos = ++startPos & mask; | 						startPos = ++startPos & mask; | ||||||
| 					} | 					} | ||||||
|  | |||||||
| @ -118,7 +118,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean add(KEY_TYPE o) { | 	public boolean add(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) { | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) { | ||||||
| 			if(containsNull) return false; | 			if(containsNull) return false; | ||||||
| 			containsNull = true; | 			containsNull = true; | ||||||
| 			onNodeAdded(nullIndex); | 			onNodeAdded(nullIndex); | ||||||
| @ -126,9 +126,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 			int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 			KEY_TYPE current = keys[pos]; | 			KEY_TYPE current = keys[pos]; | ||||||
| 			if(!strategy.equals(current, EMPTY_VALUE)) { | 			if(!strategy.equals(current, EMPTY_KEY_VALUE)) { | ||||||
| 				if(strategy.equals(current, o)) return false; | 				if(strategy.equals(current, o)) return false; | ||||||
| 				while(!strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_VALUE)) | 				while(!strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_KEY_VALUE)) | ||||||
| 					if(strategy.equals(current, o)) return false; | 					if(strategy.equals(current, o)) return false; | ||||||
| 			} | 			} | ||||||
| 			keys[pos] = o; | 			keys[pos] = o; | ||||||
| @ -156,26 +156,26 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean contains(Object o) { | 	public boolean contains(Object o) { | ||||||
| 		if(strategy.equals((KEY_TYPE)o, EMPTY_VALUE)) return containsNull; | 		if(strategy.equals((KEY_TYPE)o, EMPTY_KEY_VALUE)) return containsNull; | ||||||
| 		int pos = HashUtil.mix(strategy.hashCode((KEY_TYPE)o)) & mask; | 		int pos = HashUtil.mix(strategy.hashCode((KEY_TYPE)o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(strategy.equals(current, EMPTY_VALUE)) return false; | 		if(strategy.equals(current, EMPTY_KEY_VALUE)) return false; | ||||||
| 		if(strategy.equals(current, (KEY_TYPE)o)) return true; | 		if(strategy.equals(current, (KEY_TYPE)o)) return true; | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_VALUE)) return false; | 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_KEY_VALUE)) return false; | ||||||
| 			else if(strategy.equals(current, (KEY_TYPE)o)) return true; | 			else if(strategy.equals(current, (KEY_TYPE)o)) return true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean remove(Object o) { | 	public boolean remove(Object o) { | ||||||
| 		if(strategy.equals((KEY_TYPE)o, EMPTY_VALUE)) return (containsNull ? removeNullIndex() : false); | 		if(strategy.equals((KEY_TYPE)o, EMPTY_KEY_VALUE)) return (containsNull ? removeNullIndex() : false); | ||||||
| 		int pos = HashUtil.mix(strategy.hashCode((KEY_TYPE)o)) & mask; | 		int pos = HashUtil.mix(strategy.hashCode((KEY_TYPE)o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(strategy.equals(current, EMPTY_VALUE)) return false; | 		if(strategy.equals(current, EMPTY_KEY_VALUE)) return false; | ||||||
| 		if(strategy.equals(current, (KEY_TYPE)o)) return removeIndex(pos); | 		if(strategy.equals(current, (KEY_TYPE)o)) return removeIndex(pos); | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_VALUE)) return false; | 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_KEY_VALUE)) return false; | ||||||
| 			else if(strategy.equals(current, (KEY_TYPE)o)) return removeIndex(pos); | 			else if(strategy.equals(current, (KEY_TYPE)o)) return removeIndex(pos); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -183,26 +183,26 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| #else | #else | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean contains(KEY_TYPE o) { | 	public boolean contains(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) return containsNull; | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) return containsNull; | ||||||
| 		int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 		int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(strategy.equals(current, EMPTY_VALUE)) return false; | 		if(strategy.equals(current, EMPTY_KEY_VALUE)) return false; | ||||||
| 		if(strategy.equals(current, o)) return true; | 		if(strategy.equals(current, o)) return true; | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_VALUE)) return false; | 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_KEY_VALUE)) return false; | ||||||
| 			else if(strategy.equals(current, o)) return true; | 			else if(strategy.equals(current, o)) return true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean remove(KEY_TYPE o) { | 	public boolean remove(KEY_TYPE o) { | ||||||
| 		if(strategy.equals(o, EMPTY_VALUE)) return (containsNull ? removeNullIndex() : false); | 		if(strategy.equals(o, EMPTY_KEY_VALUE)) return (containsNull ? removeNullIndex() : false); | ||||||
| 		int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | 		int pos = HashUtil.mix(strategy.hashCode(o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(strategy.equals(current, EMPTY_VALUE)) return false; | 		if(strategy.equals(current, EMPTY_KEY_VALUE)) return false; | ||||||
| 		if(strategy.equals(current, o)) return removeIndex(pos); | 		if(strategy.equals(current, o)) return removeIndex(pos); | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_VALUE)) return false; | 			if(strategy.equals((current = keys[pos = (++pos & mask)]), EMPTY_KEY_VALUE)) return false; | ||||||
| 			else if(strategy.equals(current, o)) return removeIndex(pos); | 			else if(strategy.equals(current, o)) return removeIndex(pos); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -234,7 +234,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 	 | 	 | ||||||
| 	protected boolean removeNullIndex() { | 	protected boolean removeNullIndex() { | ||||||
| 		containsNull = false; | 		containsNull = false; | ||||||
| 		keys[nullIndex] = EMPTY_VALUE; | 		keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		size--; | 		size--; | ||||||
| 		onNodeRemoved(nullIndex); | 		onNodeRemoved(nullIndex); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -259,8 +259,8 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 		while(true) { | 		while(true) { | ||||||
| 			startPos = ((last = startPos) + 1) & mask; | 			startPos = ((last = startPos) + 1) & mask; | ||||||
| 			while(true){ | 			while(true){ | ||||||
| 				if(strategy.equals((current = keys[startPos]), EMPTY_VALUE)) { | 				if(strategy.equals((current = keys[startPos]), EMPTY_KEY_VALUE)) { | ||||||
| 					keys[last] = EMPTY_VALUE; | 					keys[last] = EMPTY_KEY_VALUE; | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 				slot = HashUtil.mix(strategy.hashCode(current)) & mask; | 				slot = HashUtil.mix(strategy.hashCode(current)) & mask; | ||||||
| @ -276,9 +276,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 		int newMask = newSize - 1; | 		int newMask = newSize - 1; | ||||||
| 		KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1); | 		KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1); | ||||||
| 		for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) { | 		for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) { | ||||||
| 			while(strategy.equals(keys[--i], EMPTY_VALUE)); | 			while(strategy.equals(keys[--i], EMPTY_KEY_VALUE)); | ||||||
| 			if(!strategy.equals(newKeys[pos = HashUtil.mix(TO_HASH(keys[i])) & newMask], EMPTY_VALUE)) | 			if(!strategy.equals(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask], EMPTY_KEY_VALUE)) | ||||||
| 				while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_VALUE)); | 				while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_KEY_VALUE)); | ||||||
| 			newKeys[pos] = keys[i]; | 			newKeys[pos] = keys[i]; | ||||||
| 		} | 		} | ||||||
| 		nullIndex = newSize; | 		nullIndex = newSize; | ||||||
| @ -297,7 +297,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 		if(size == 0) return; | 		if(size == 0) return; | ||||||
| 		size = 0; | 		size = 0; | ||||||
| 		containsNull = false; | 		containsNull = false; | ||||||
| 		Arrays.fill(keys, EMPTY_VALUE); | 		Arrays.fill(keys, EMPTY_KEY_VALUE); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| @ -326,7 +326,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 							nextIndex = -pos - 1; | 							nextIndex = -pos - 1; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
| 						if(EQUALS_NOT_NULL(keys[pos])){ | 						if(KEY_EQUALS_NOT_NULL(keys[pos])){ | ||||||
| 							nextIndex = pos; | 							nextIndex = pos; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
| @ -355,7 +355,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 			if(lastReturned == -1) throw new IllegalStateException(); | 			if(lastReturned == -1) throw new IllegalStateException(); | ||||||
| 			if(lastReturned == nullIndex) { | 			if(lastReturned == nullIndex) { | ||||||
| 				containsNull = false; | 				containsNull = false; | ||||||
| 				keys[nullIndex] = EMPTY_VALUE; | 				keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 			} | 			} | ||||||
| 			else if(pos >= 0) shiftKeys(pos); | 			else if(pos >= 0) shiftKeys(pos); | ||||||
| 			else { | 			else { | ||||||
| @ -372,8 +372,8 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T | |||||||
| 			while(true) { | 			while(true) { | ||||||
| 				startPos = ((last = startPos) + 1) & mask; | 				startPos = ((last = startPos) + 1) & mask; | ||||||
| 				while(true){ | 				while(true){ | ||||||
| 					if(strategy.equals((current = keys[startPos]), EMPTY_VALUE)) { | 					if(strategy.equals((current = keys[startPos]), EMPTY_KEY_VALUE)) { | ||||||
| 						keys[last] = EMPTY_VALUE; | 						keys[last] = EMPTY_KEY_VALUE; | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					slot = HashUtil.mix(strategy.hashCode(current)) & mask; | 					slot = HashUtil.mix(strategy.hashCode(current)) & mask; | ||||||
|  | |||||||
| @ -111,18 +111,18 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| #endif | #endif | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean add(KEY_TYPE o) { | 	public boolean add(KEY_TYPE o) { | ||||||
| 		if(EQUALS_NULL(o)) { | 		if(KEY_EQUALS_NULL(o)) { | ||||||
| 			if(containsNull) return false; | 			if(containsNull) return false; | ||||||
| 			containsNull = true; | 			containsNull = true; | ||||||
| 			onNodeAdded(nullIndex); | 			onNodeAdded(nullIndex); | ||||||
| 		} | 		} | ||||||
| 		else { | 		else { | ||||||
| 			int pos = HashUtil.mix(TO_HASH(o)) & mask; | 			int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 			KEY_TYPE current = keys[pos]; | 			KEY_TYPE current = keys[pos]; | ||||||
| 			if(EQUALS_NOT_NULL(current)) { | 			if(KEY_EQUALS_NOT_NULL(current)) { | ||||||
| 				if(EQUALS(current, o)) return false; | 				if(KEY_EQUALS(current, o)) return false; | ||||||
| 				while(EQUALS_NOT_NULL((current = keys[pos = (++pos & mask)]))) | 				while(KEY_EQUALS_NOT_NULL((current = keys[pos = (++pos & mask)]))) | ||||||
| 					if(EQUALS(current, o)) return false; | 					if(KEY_EQUALS(current, o)) return false; | ||||||
| 			} | 			} | ||||||
| 			keys[pos] = o; | 			keys[pos] = o; | ||||||
| 			onNodeAdded(pos); | 			onNodeAdded(pos); | ||||||
| @ -151,10 +151,10 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 		if(o == null) return containsNull; | 		if(o == null) return containsNull; | ||||||
| 		int pos = HashUtil.mix(o.hashCode()) & mask; | 		int pos = HashUtil.mix(o.hashCode()) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(EQUALS_NULL(current)) return false; | 		if(KEY_EQUALS_NULL(current)) return false; | ||||||
| 		if(EQUALS_KEY_TYPE(current, o)) return true; | 		if(EQUALS_KEY_TYPE(current, o)) return true; | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | 			if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | ||||||
| 			else if(EQUALS_KEY_TYPE(current, o)) return true; | 			else if(EQUALS_KEY_TYPE(current, o)) return true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -164,10 +164,10 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 		if(o == null) return (containsNull ? removeNullIndex() : false); | 		if(o == null) return (containsNull ? removeNullIndex() : false); | ||||||
| 		int pos = HashUtil.mix(o.hashCode()) & mask; | 		int pos = HashUtil.mix(o.hashCode()) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(EQUALS_NULL(current)) return false; | 		if(KEY_EQUALS_NULL(current)) return false; | ||||||
| 		if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); | 		if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | 			if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | ||||||
| 			else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); | 			else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -175,27 +175,27 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| #if !TYPE_OBJECT | #if !TYPE_OBJECT | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean contains(KEY_TYPE o) { | 	public boolean contains(KEY_TYPE o) { | ||||||
| 		if(EQUALS_NULL(o)) return containsNull; | 		if(KEY_EQUALS_NULL(o)) return containsNull; | ||||||
| 		int pos = HashUtil.mix(TO_HASH(o)) & mask; | 		int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(EQUALS_NULL(current)) return false; | 		if(KEY_EQUALS_NULL(current)) return false; | ||||||
| 		if(EQUALS(current, o)) return true; | 		if(KEY_EQUALS(current, o)) return true; | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | 			if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | ||||||
| 			else if(EQUALS(current, o)) return true; | 			else if(KEY_EQUALS(current, o)) return true; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public boolean remove(KEY_TYPE o) { | 	public boolean remove(KEY_TYPE o) { | ||||||
| 		if(EQUALS_NULL(o)) return (containsNull ? removeNullIndex() : false); | 		if(KEY_EQUALS_NULL(o)) return (containsNull ? removeNullIndex() : false); | ||||||
| 		int pos = HashUtil.mix(TO_HASH(o)) & mask; | 		int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; | ||||||
| 		KEY_TYPE current = keys[pos]; | 		KEY_TYPE current = keys[pos]; | ||||||
| 		if(EQUALS_NULL(current)) return false; | 		if(KEY_EQUALS_NULL(current)) return false; | ||||||
| 		if(EQUALS(current, o)) return removeIndex(pos); | 		if(KEY_EQUALS(current, o)) return removeIndex(pos); | ||||||
| 		while(true) { | 		while(true) { | ||||||
| 			if(EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | 			if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; | ||||||
| 			else if(EQUALS(current, o)) return removeIndex(pos); | 			else if(KEY_EQUALS(current, o)) return removeIndex(pos); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -226,7 +226,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 	 | 	 | ||||||
| 	protected boolean removeNullIndex() { | 	protected boolean removeNullIndex() { | ||||||
| 		containsNull = false; | 		containsNull = false; | ||||||
| 		keys[nullIndex] = EMPTY_VALUE; | 		keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 		size--; | 		size--; | ||||||
| 		onNodeRemoved(nullIndex); | 		onNodeRemoved(nullIndex); | ||||||
| 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | 		if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); | ||||||
| @ -251,11 +251,11 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 		while(true) { | 		while(true) { | ||||||
| 			startPos = ((last = startPos) + 1) & mask; | 			startPos = ((last = startPos) + 1) & mask; | ||||||
| 			while(true){ | 			while(true){ | ||||||
| 				if(EQUALS_NULL((current = keys[startPos]))) { | 				if(KEY_EQUALS_NULL((current = keys[startPos]))) { | ||||||
| 					keys[last] = EMPTY_VALUE; | 					keys[last] = EMPTY_KEY_VALUE; | ||||||
| 					return; | 					return; | ||||||
| 				} | 				} | ||||||
| 				slot = HashUtil.mix(TO_HASH(current)) & mask; | 				slot = HashUtil.mix(KEY_TO_HASH(current)) & mask; | ||||||
| 				if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | 				if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | ||||||
| 				startPos = ++startPos & mask; | 				startPos = ++startPos & mask; | ||||||
| 			} | 			} | ||||||
| @ -268,9 +268,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 		int newMask = newSize - 1; | 		int newMask = newSize - 1; | ||||||
| 		KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1); | 		KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1); | ||||||
| 		for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) { | 		for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) { | ||||||
| 			while(EQUALS_NULL(keys[--i])); | 			while(KEY_EQUALS_NULL(keys[--i])); | ||||||
| 			if(EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(TO_HASH(keys[i])) & newMask])) | 			if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask])) | ||||||
| 				while(EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)])); | 				while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)])); | ||||||
| 			newKeys[pos] = keys[i]; | 			newKeys[pos] = keys[i]; | ||||||
| 		} | 		} | ||||||
| 		nullIndex = newSize; | 		nullIndex = newSize; | ||||||
| @ -289,7 +289,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 		if(size == 0) return; | 		if(size == 0) return; | ||||||
| 		size = 0; | 		size = 0; | ||||||
| 		containsNull = false; | 		containsNull = false; | ||||||
| 		Arrays.fill(keys, EMPTY_VALUE); | 		Arrays.fill(keys, EMPTY_KEY_VALUE); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| @ -319,7 +319,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 							nextIndex = -pos - 1; | 							nextIndex = -pos - 1; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
| 						if(EQUALS_NOT_NULL(keys[pos])){ | 						if(KEY_EQUALS_NOT_NULL(keys[pos])){ | ||||||
| 							nextIndex = pos; | 							nextIndex = pos; | ||||||
| 							break; | 							break; | ||||||
| 						} | 						} | ||||||
| @ -348,7 +348,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 			if(lastReturned == -1) throw new IllegalStateException(); | 			if(lastReturned == -1) throw new IllegalStateException(); | ||||||
| 			if(lastReturned == nullIndex) { | 			if(lastReturned == nullIndex) { | ||||||
| 				containsNull = false; | 				containsNull = false; | ||||||
| 				keys[nullIndex] = EMPTY_VALUE; | 				keys[nullIndex] = EMPTY_KEY_VALUE; | ||||||
| 			} | 			} | ||||||
| 			else if(pos >= 0) shiftKeys(pos); | 			else if(pos >= 0) shiftKeys(pos); | ||||||
| 			else { | 			else { | ||||||
| @ -365,11 +365,11 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp | |||||||
| 			while(true) { | 			while(true) { | ||||||
| 				startPos = ((last = startPos) + 1) & mask; | 				startPos = ((last = startPos) + 1) & mask; | ||||||
| 				while(true){ | 				while(true){ | ||||||
| 					if(EQUALS_NULL((current = keys[startPos]))) { | 					if(KEY_EQUALS_NULL((current = keys[startPos]))) { | ||||||
| 						keys[last] = EMPTY_VALUE; | 						keys[last] = EMPTY_KEY_VALUE; | ||||||
| 						return; | 						return; | ||||||
| 					} | 					} | ||||||
| 					slot = HashUtil.mix(TO_HASH(current)) & mask; | 					slot = HashUtil.mix(KEY_TO_HASH(current)) & mask; | ||||||
| 					if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | 					if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; | ||||||
| 					startPos = ++startPos & mask; | 					startPos = ++startPos & mask; | ||||||
| 				} | 				} | ||||||
|  | |||||||
| @ -363,17 +363,17 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE | |||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement, boolean inclusive) { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement, boolean inclusive) { | ||||||
| 		return new AscendingSubSetBRACES(this, true, EMPTY_VALUE, true, false, toElement, inclusive); | 		return new AscendingSubSetBRACES(this, true, EMPTY_KEY_VALUE, true, false, toElement, inclusive); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement, boolean inclusive) { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement, boolean inclusive) { | ||||||
| 		return new AscendingSubSetBRACES(this, false, fromElement, inclusive, true, EMPTY_VALUE, true); | 		return new AscendingSubSetBRACES(this, false, fromElement, inclusive, true, EMPTY_KEY_VALUE, true); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
| 	public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet() { | 	public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet() { | ||||||
| 		return new DescendingSubSetBRACES(this, true, EMPTY_VALUE, true, true, EMPTY_VALUE, true); | 		return new DescendingSubSetBRACES(this, true, EMPTY_KEY_VALUE, true, true, EMPTY_KEY_VALUE, true); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	protected void removeNode(Entry KEY_GENERIC_TYPE entry) { | 	protected void removeNode(Entry KEY_GENERIC_TYPE entry) { | ||||||
| @ -406,11 +406,11 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE | |||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	protected int compare(KEY_TYPE k, KEY_TYPE v) { return comparator != null ? comparator.compare(k, v) : COMPARE_TO_KEY(k, v);} | 	protected int compare(KEY_TYPE k, KEY_TYPE v) { return comparator != null ? comparator.compare(k, v) : COMPARE_TO_KEY(k, v);} | ||||||
| 	protected static GENERIC_BRACES boolean isBlack(Entry KEY_GENERIC_TYPE p) { return p == null || p.isBlack(); } | 	protected static GENERIC_KEY_BRACES boolean isBlack(Entry KEY_GENERIC_TYPE p) { return p == null || p.isBlack(); } | ||||||
| 	protected static GENERIC_BRACES Entry KEY_GENERIC_TYPE parentOf(Entry KEY_GENERIC_TYPE p) { return (p == null ? null : p.parent); } | 	protected static GENERIC_KEY_BRACES Entry KEY_GENERIC_TYPE parentOf(Entry KEY_GENERIC_TYPE p) { return (p == null ? null : p.parent); } | ||||||
| 	protected static GENERIC_BRACES void setBlack(Entry KEY_GENERIC_TYPE p, boolean c) { if(p != null) p.setBlack(c); } | 	protected static GENERIC_KEY_BRACES void setBlack(Entry KEY_GENERIC_TYPE p, boolean c) { if(p != null) p.setBlack(c); } | ||||||
| 	protected static GENERIC_BRACES Entry KEY_GENERIC_TYPE leftOf(Entry KEY_GENERIC_TYPE p) { return p == null ? null : p.left; } | 	protected static GENERIC_KEY_BRACES Entry KEY_GENERIC_TYPE leftOf(Entry KEY_GENERIC_TYPE p) { return p == null ? null : p.left; } | ||||||
| 	protected static GENERIC_BRACES Entry KEY_GENERIC_TYPE rightOf(Entry KEY_GENERIC_TYPE p) { return (p == null) ? null : p.right; } | 	protected static GENERIC_KEY_BRACES Entry KEY_GENERIC_TYPE rightOf(Entry KEY_GENERIC_TYPE p) { return (p == null) ? null : p.right; } | ||||||
| 	 | 	 | ||||||
| 	/** From CLR */ | 	/** From CLR */ | ||||||
| 	protected void rotateLeft(Entry KEY_GENERIC_TYPE entry) { | 	protected void rotateLeft(Entry KEY_GENERIC_TYPE entry) { | ||||||
|  | |||||||
| @ -100,13 +100,13 @@ public class ARRAYS | |||||||
| 	 * @param length the lenght the array should be. | 	 * @param length the lenght the array should be. | ||||||
| 	 * @return a Array with the requested type and length | 	 * @return a Array with the requested type and length | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES KEY_TYPE[] newArray(Class<KEY_TYPE> clz, int length) { | 	public static GENERIC_KEY_BRACES KEY_TYPE[] newArray(Class<KEY_TYPE> clz, int length) { | ||||||
| 		if(clz == Object.class) return (KEY_TYPE[])new Object[length]; | 		if(clz == Object.class) return (KEY_TYPE[])new Object[length]; | ||||||
| 		return (KEY_TYPE[]) java.lang.reflect.Array.newInstance(clz, length); | 		return (KEY_TYPE[]) java.lang.reflect.Array.newInstance(clz, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| #endif | #endif | ||||||
| 	public static GENERIC_BRACES int shiftDown(KEY_TYPE[] data, int size, int index, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES int shiftDown(KEY_TYPE[] data, int size, int index, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		int half = size >>> 1; | 		int half = size >>> 1; | ||||||
| 		KEY_TYPE value = data[index]; | 		KEY_TYPE value = data[index]; | ||||||
| 		if(comp != null) { | 		if(comp != null) { | ||||||
| @ -135,7 +135,7 @@ public class ARRAYS | |||||||
| 		return index; | 		return index; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES int shiftUp(KEY_TYPE[] data, int index, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES int shiftUp(KEY_TYPE[] data, int index, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		KEY_TYPE value = data[index]; | 		KEY_TYPE value = data[index]; | ||||||
| 		if(comp != null) { | 		if(comp != null) { | ||||||
| 			while(index > 0) { | 			while(index > 0) { | ||||||
| @ -159,16 +159,16 @@ public class ARRAYS | |||||||
| 		return index; | 		return index; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES KEY_TYPE[] heapify(KEY_TYPE[] data, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES KEY_TYPE[] heapify(KEY_TYPE[] data, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) { | ||||||
| 		for(int i = (size >>> 1) - 1;i>=0;shiftDown(data, size, i--, comp)); | 		for(int i = (size >>> 1) - 1;i>=0;shiftDown(data, size, i--, comp)); | ||||||
| 		return data; | 		return data; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array) { | 	public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array) { | ||||||
| 		return shuffle(array, SanityChecks.getRandom()); | 		return shuffle(array, SanityChecks.getRandom()); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, Random random) { | 	public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, Random random) { | ||||||
| 		for(int i = array.length-1; i>=0;i--) { | 		for(int i = array.length-1; i>=0;i--) { | ||||||
| 			int p = random.nextInt(i + 1); | 			int p = random.nextInt(i + 1); | ||||||
| 			KEY_TYPE t = array[i]; | 			KEY_TYPE t = array[i]; | ||||||
| @ -185,7 +185,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		stableSort(array, 0, array.length, comp); | 		stableSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -197,7 +197,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void stableSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		stableSort(array, 0, length, comp); | 		stableSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -210,7 +210,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void stableSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		mergeSort(array, null, from, to, comp); | 		mergeSort(array, null, from, to, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -220,7 +220,7 @@ public class ARRAYS | |||||||
| 	 * Stable sort referres to Mergesort or Insertionsort | 	 * Stable sort referres to Mergesort or Insertionsort | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void stableSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array) { | ||||||
| 		stableSort(array, 0, array.length); | 		stableSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -231,7 +231,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void stableSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array, int length) { | ||||||
| 		stableSort(array, 0, length); | 		stableSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -243,7 +243,7 @@ public class ARRAYS | |||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void stableSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void stableSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		mergeSort(array, null, from, to); | 		mergeSort(array, null, from, to); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -254,7 +254,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		unstableSort(array, 0, array.length, comp); | 		unstableSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -266,7 +266,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void unstableSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		unstableSort(array, 0, length, comp); | 		unstableSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -279,7 +279,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void unstableSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		quickSort(array, from, to, comp); | 		quickSort(array, from, to, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -289,7 +289,7 @@ public class ARRAYS | |||||||
| 	 * Unstable sort referres to QuickSort or SelectionSort | 	 * Unstable sort referres to QuickSort or SelectionSort | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void unstableSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array) { | ||||||
| 		unstableSort(array, 0, array.length); | 		unstableSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -300,7 +300,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void unstableSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array, int length) { | ||||||
| 		unstableSort(array, 0, length); | 		unstableSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -312,7 +312,7 @@ public class ARRAYS | |||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void unstableSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void unstableSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		quickSort(array, from, to); | 		quickSort(array, from, to); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -321,7 +321,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		insertionSort(array, 0, array.length, comp); | 		insertionSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -331,7 +331,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void insertionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		insertionSort(array, 0, length, comp); | 		insertionSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -342,7 +342,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void insertionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		for (int i = from+1;i<to; i++) { | 		for (int i = from+1;i<to; i++) { | ||||||
| 			KEY_TYPE current = array[i]; | 			KEY_TYPE current = array[i]; | ||||||
|     		int j = i - 1; |     		int j = i - 1; | ||||||
| @ -357,7 +357,7 @@ public class ARRAYS | |||||||
| 	 * Sorts an array according to the natural ascending order using InsertionSort,  | 	 * Sorts an array according to the natural ascending order using InsertionSort,  | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void insertionSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array) { | ||||||
| 		insertionSort(array, 0, array.length); | 		insertionSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -366,7 +366,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void insertionSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array, int length) { | ||||||
| 		insertionSort(array, 0, length); | 		insertionSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -375,7 +375,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void insertionSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		for (int i = from+1;i<to; i++) { | 		for (int i = from+1;i<to; i++) { | ||||||
| 			KEY_TYPE current = array[i]; | 			KEY_TYPE current = array[i]; | ||||||
|     		int j = i - 1; |     		int j = i - 1; | ||||||
| @ -391,7 +391,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		selectionSort(array, 0, array.length, comp); | 		selectionSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -401,7 +401,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void selectionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		selectionSort(array, 0, length, comp); | 		selectionSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -412,7 +412,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void selectionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
|     	for (int i = from; i < to; i++) { |     	for (int i = from; i < to; i++) { | ||||||
|     		KEY_TYPE min = array[i]; |     		KEY_TYPE min = array[i]; | ||||||
|         	int minId = i; |         	int minId = i; | ||||||
| @ -432,7 +432,7 @@ public class ARRAYS | |||||||
| 	 * Sorts an array according to the natural ascending order using Selection Sort,  | 	 * Sorts an array according to the natural ascending order using Selection Sort,  | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void selectionSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array) { | ||||||
| 		selectionSort(array, 0, array.length); | 		selectionSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -441,7 +441,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void selectionSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array, int length) { | ||||||
| 		selectionSort(array, 0, length); | 		selectionSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -450,7 +450,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void selectionSort(KEY_TYPE[] array, int from, int to) { | ||||||
|     	for (int i = from; i < to; i++) { |     	for (int i = from; i < to; i++) { | ||||||
|     		KEY_TYPE min = array[i]; |     		KEY_TYPE min = array[i]; | ||||||
|         	int minId = i; |         	int minId = i; | ||||||
| @ -472,7 +472,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		mergeSort(array, null, 0, array.length, comp); | 		mergeSort(array, null, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -483,7 +483,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void mergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		mergeSort(array, null, 0, length, comp); | 		mergeSort(array, null, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -495,7 +495,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		if(to - from < BASE_THRESHOLD) { | 		if(to - from < BASE_THRESHOLD) { | ||||||
| 			insertionSort(array, from, to, comp); | 			insertionSort(array, from, to, comp); | ||||||
| 			return; | 			return; | ||||||
| @ -520,7 +520,7 @@ public class ARRAYS | |||||||
| 	 * This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations | 	 * This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void mergeSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array) { | ||||||
| 		mergeSort(array, null, 0, array.length); | 		mergeSort(array, null, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -530,7 +530,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void mergeSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array, int length) { | ||||||
| 		mergeSort(array, null, 0, length); | 		mergeSort(array, null, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -541,7 +541,7 @@ public class ARRAYS | |||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void mergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) { | ||||||
| 		if(to - from < BASE_THRESHOLD) { | 		if(to - from < BASE_THRESHOLD) { | ||||||
| 			insertionSort(array, from, to); | 			insertionSort(array, from, to); | ||||||
| 			return; | 			return; | ||||||
| @ -568,7 +568,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelMergeSort(array, null, 0, array.length, comp); | 		parallelMergeSort(array, null, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -580,7 +580,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelMergeSort(array, null, 0, length, comp); | 		parallelMergeSort(array, null, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -593,7 +593,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new MergeSortActionCompBRACES(array, supp, from, to, comp)); | 			SanityChecks.invokeTask(new MergeSortActionCompBRACES(array, supp, from, to, comp)); | ||||||
| 			return; | 			return; | ||||||
| @ -607,7 +607,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMergeSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array) { | ||||||
| 		parallelMergeSort(array, null, 0, array.length); | 		parallelMergeSort(array, null, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -618,7 +618,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMergeSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, int length) { | ||||||
| 		parallelMergeSort(array, null, 0, length); | 		parallelMergeSort(array, null, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -630,7 +630,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void parallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new MergeSortActionBRACES(array, supp, from, to)); | 			SanityChecks.invokeTask(new MergeSortActionBRACES(array, supp, from, to)); | ||||||
| 			return; | 			return; | ||||||
| @ -644,7 +644,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void memFreeMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		memFreeMergeSort(array, 0, array.length, comp); | 		memFreeMergeSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -655,7 +655,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		memFreeMergeSort(array, 0, length, comp); | 		memFreeMergeSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -667,7 +667,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		if(to - from < BASE_THRESHOLD) { | 		if(to - from < BASE_THRESHOLD) { | ||||||
| 			insertionSort(array, from, to, comp); | 			insertionSort(array, from, to, comp); | ||||||
| 			return; | 			return; | ||||||
| @ -714,7 +714,7 @@ public class ARRAYS | |||||||
| 	 * @author Speiger | 	 * @author Speiger | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void memFreeMergeSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array) { | ||||||
| 		memFreeMergeSort(array, 0, array.length); | 		memFreeMergeSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -727,7 +727,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int length) { | ||||||
| 		memFreeMergeSort(array, 0, length); | 		memFreeMergeSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -741,7 +741,7 @@ public class ARRAYS | |||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		if(to - from < BASE_THRESHOLD) { | 		if(to - from < BASE_THRESHOLD) { | ||||||
| 			insertionSort(array, from, to); | 			insertionSort(array, from, to); | ||||||
| 			return; | 			return; | ||||||
| @ -790,7 +790,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelMemFreeMergeSort(array, 0, array.length, comp); | 		parallelMemFreeMergeSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -805,7 +805,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelMemFreeMergeSort(array, 0, length, comp); | 		parallelMemFreeMergeSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -821,7 +821,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new MemFreeMergeSortActionCompBRACES(array, from, to, comp)); | 			SanityChecks.invokeTask(new MemFreeMergeSortActionCompBRACES(array, from, to, comp)); | ||||||
| 			return; | 			return; | ||||||
| @ -838,7 +838,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array) { | ||||||
| 		parallelMemFreeMergeSort(array, 0, array.length); | 		parallelMemFreeMergeSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -852,7 +852,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int length) { | ||||||
| 		parallelMemFreeMergeSort(array, 0, length); | 		parallelMemFreeMergeSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -867,7 +867,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void parallelMemFreeMergeSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new MemFreeMergeSortActionBRACES(array, from, to)); | 			SanityChecks.invokeTask(new MemFreeMergeSortActionBRACES(array, from, to)); | ||||||
| 			return; | 			return; | ||||||
| @ -882,7 +882,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		quickSort(array, 0, array.length, comp); | 		quickSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -894,7 +894,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void quickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		quickSort(array, 0, length, comp); | 		quickSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -907,7 +907,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void quickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		int length = to - from; | 		int length = to - from; | ||||||
| 		if(length <= 0) return; | 		if(length <= 0) return; | ||||||
| 		if(length < BASE_THRESHOLD) { | 		if(length < BASE_THRESHOLD) { | ||||||
| @ -937,7 +937,7 @@ public class ARRAYS | |||||||
| 	 * and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages1249−1265, 1993.  | 	 * and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, “Engineering a Sort Function”, Software: Practice and Experience, 23(11), pages1249−1265, 1993.  | ||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void quickSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array) { | ||||||
| 		quickSort(array, 0, array.length); | 		quickSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -948,7 +948,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void quickSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array, int length) { | ||||||
| 		quickSort(array, 0, length); | 		quickSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -960,7 +960,7 @@ public class ARRAYS | |||||||
| 	 * @param from where the array should be sorted from | 	 * @param from where the array should be sorted from | ||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void quickSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void quickSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		int length = to - from; | 		int length = to - from; | ||||||
| 		if(length <= 0) return; | 		if(length <= 0) return; | ||||||
| 		if(length < BASE_THRESHOLD) { | 		if(length < BASE_THRESHOLD) { | ||||||
| @ -992,7 +992,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelQuickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelQuickSort(array, 0, array.length, comp); | 		parallelQuickSort(array, 0, array.length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -1005,7 +1005,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelQuickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		parallelQuickSort(array, 0, length, comp); | 		parallelQuickSort(array, 0, length, comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -1019,7 +1019,7 @@ public class ARRAYS | |||||||
| 	 * @param comp the Comparator that decides the sorting order | 	 * @param comp the Comparator that decides the sorting order | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | 	public static GENERIC_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new QuickSortActionCompBRACES(array, from, to, comp)); | 			SanityChecks.invokeTask(new QuickSortActionCompBRACES(array, from, to, comp)); | ||||||
| 			return; | 			return; | ||||||
| @ -1034,7 +1034,7 @@ public class ARRAYS | |||||||
| 	 * @param array the array that needs to be sorted | 	 * @param array the array that needs to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelQuickSort(KEY_TYPE[] array) { | 	public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array) { | ||||||
| 		parallelQuickSort(array, 0, array.length); | 		parallelQuickSort(array, 0, array.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -1046,7 +1046,7 @@ public class ARRAYS | |||||||
| 	 * @param length the maxmium size of the array to be sorted | 	 * @param length the maxmium size of the array to be sorted | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelQuickSort(KEY_TYPE[] array, int length) { | 	public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int length) { | ||||||
| 		parallelQuickSort(array, 0, length); | 		parallelQuickSort(array, 0, length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -1059,7 +1059,7 @@ public class ARRAYS | |||||||
| 	 * @param to where the array should be sorted to | 	 * @param to where the array should be sorted to | ||||||
| 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | 	 * @Note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed | ||||||
| 	 */ | 	 */ | ||||||
| 	public static COMPAREABLE_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to) { | 	public static COMPAREABLE_KEY_BRACES void parallelQuickSort(KEY_TYPE[] array, int from, int to) { | ||||||
| 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | 		if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) { | ||||||
| 			SanityChecks.invokeTask(new QuickSortActionBRACES(array, from, to)); | 			SanityChecks.invokeTask(new QuickSortActionBRACES(array, from, to)); | ||||||
| 			return; | 			return; | ||||||
| @ -1067,30 +1067,30 @@ public class ARRAYS | |||||||
| 		quickSort(array, from, to); | 		quickSort(array, from, to); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static GENERIC_BRACES void swap(KEY_TYPE[] a, int from, int to) { | 	static GENERIC_KEY_BRACES void swap(KEY_TYPE[] a, int from, int to) { | ||||||
| 		KEY_TYPE t = a[from]; | 		KEY_TYPE t = a[from]; | ||||||
| 		a[from] = a[to]; | 		a[from] = a[to]; | ||||||
| 		a[to] = t; | 		a[to] = t; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static GENERIC_BRACES void swap(KEY_TYPE[] a, int from, int to, int length) { | 	static GENERIC_KEY_BRACES void swap(KEY_TYPE[] a, int from, int to, int length) { | ||||||
| 		to -= length; | 		to -= length; | ||||||
| 		for(int i = 0;i<length;i++,swap(a, from++, to++)); | 		for(int i = 0;i<length;i++,swap(a, from++, to++)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static GENERIC_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | 	static GENERIC_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		return medium(data, medium(data, a, a + length, a + (length * 2), comp), medium(data, b - length, b, b + length, comp), medium(data, c - (length * 2), c - length, c, comp), comp); | 		return medium(data, medium(data, a, a + length, a + (length * 2), comp), medium(data, b - length, b, b + length, comp), medium(data, c - (length * 2), c - length, c, comp), comp); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static GENERIC_BRACES int medium(KEY_TYPE[] data, int a, int b, int c, COMPARATOR KEY_GENERIC_TYPE comp) { | 	static GENERIC_KEY_BRACES int medium(KEY_TYPE[] data, int a, int b, int c, COMPARATOR KEY_GENERIC_TYPE comp) { | ||||||
| 		return comp.compare(data[a], data[b]) < 0 ? (comp.compare(data[b], data[c]) < 0 ? b : comp.compare(data[a], data[c]) < 0 ? c : a) : (comp.compare(data[b], data[c]) > 0 ? b : comp.compare(data[a], data[c]) > 0 ? c : a); | 		return comp.compare(data[a], data[b]) < 0 ? (comp.compare(data[b], data[c]) < 0 ? b : comp.compare(data[a], data[c]) < 0 ? c : a) : (comp.compare(data[b], data[c]) > 0 ? b : comp.compare(data[a], data[c]) > 0 ? c : a); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static COMPAREABLE_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length) { | 	static COMPAREABLE_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length) { | ||||||
| 		return medium(data, medium(data, a, a + length, a + (length * 2)), medium(data, b - length, b, b + length), medium(data, c - (length * 2), c - length, c)); | 		return medium(data, medium(data, a, a + length, a + (length * 2)), medium(data, b - length, b, b + length), medium(data, c - (length * 2), c - length, c)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static COMPAREABLE_BRACES int medium(KEY_TYPE[] data, int a, int b, int c) { | 	static COMPAREABLE_KEY_BRACES int medium(KEY_TYPE[] data, int a, int b, int c) { | ||||||
| 		return COMPARE_TO(data[a], data[b]) < 0 ? (COMPARE_TO(data[b], data[c]) < 0 ? b : COMPARE_TO(data[a], data[c]) < 0 ? c : a) : (COMPARE_TO(data[b], data[c]) > 0 ? b : COMPARE_TO(data[a], data[c]) > 0 ? c : a); | 		return COMPARE_TO(data[a], data[b]) < 0 ? (COMPARE_TO(data[b], data[c]) < 0 ? b : COMPARE_TO(data[a], data[c]) < 0 ? c : a) : (COMPARE_TO(data[b], data[c]) > 0 ? b : COMPARE_TO(data[a], data[c]) > 0 ? c : a); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -25,7 +25,7 @@ public class COLLECTIONS | |||||||
| 	 * Returns a Immutable EmptyCollection instance that is automatically casted. | 	 * Returns a Immutable EmptyCollection instance that is automatically casted. | ||||||
| 	 * @return an empty collection | 	 * @return an empty collection | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES COLLECTION KEY_GENERIC_TYPE emptyCollection() { | 	public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE emptyCollection() { | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		return (COLLECTION<KEY_TYPE>)EMPTY; | 		return (COLLECTION<KEY_TYPE>)EMPTY; | ||||||
| #else | #else | ||||||
| @ -38,7 +38,7 @@ public class COLLECTIONS | |||||||
| 	 * @param l that should be made immutable/unmodifyable | 	 * @param l that should be made immutable/unmodifyable | ||||||
| 	 * @return a unmodifiable collection wrapper. If the Collection already a unmodifyable wrapper then it just returns itself. | 	 * @return a unmodifiable collection wrapper. If the Collection already a unmodifyable wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES COLLECTION KEY_GENERIC_TYPE unmodifiableCollection(COLLECTION KEY_GENERIC_TYPE c) { | 	public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE unmodifiableCollection(COLLECTION KEY_GENERIC_TYPE c) { | ||||||
| 		return c instanceof UnmodifiableCollection ? c : new UnmodifiableCollectionBRACES(c); | 		return c instanceof UnmodifiableCollection ? c : new UnmodifiableCollectionBRACES(c); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -47,7 +47,7 @@ public class COLLECTIONS | |||||||
| 	 * @param l that should be synchronized | 	 * @param l that should be synchronized | ||||||
| 	 * @return a synchronized collection wrapper. If the Collection already a synchronized wrapper then it just returns itself. | 	 * @return a synchronized collection wrapper. If the Collection already a synchronized wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES COLLECTION KEY_GENERIC_TYPE synchronizedCollection(COLLECTION KEY_GENERIC_TYPE c) { | 	public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE synchronizedCollection(COLLECTION KEY_GENERIC_TYPE c) { | ||||||
| 		return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c); | 		return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -57,7 +57,7 @@ public class COLLECTIONS | |||||||
| 	 * @param mutex is the controller of the synchronization block. | 	 * @param mutex is the controller of the synchronization block. | ||||||
| 	 * @return a synchronized collection wrapper. If the Collection already a synchronized wrapper then it just returns itself. | 	 * @return a synchronized collection wrapper. If the Collection already a synchronized wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES COLLECTION KEY_GENERIC_TYPE synchronizedCollection(COLLECTION KEY_GENERIC_TYPE c, Object mutex) { | 	public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE synchronizedCollection(COLLECTION KEY_GENERIC_TYPE c, Object mutex) { | ||||||
| 		return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex); | 		return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ public class ITERATORS | |||||||
| 	 * Returns a Immutable EmptyIterator instance that is automatically casted. | 	 * Returns a Immutable EmptyIterator instance that is automatically casted. | ||||||
| 	 * @return an empty iterator | 	 * @return an empty iterator | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES EmptyIterator KEY_GENERIC_TYPE emptyIterator() { | 	public static GENERIC_KEY_BRACES EmptyIterator KEY_GENERIC_TYPE emptyIterator() { | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		return (EmptyIterator<KEY_TYPE>)EMPTY; | 		return (EmptyIterator<KEY_TYPE>)EMPTY; | ||||||
| #else | #else | ||||||
| @ -29,11 +29,11 @@ public class ITERATORS | |||||||
| 	 * @param l that should be made immutable/unmodifyable | 	 * @param l that should be made immutable/unmodifyable | ||||||
| 	 * @return a unmodifiable iterator wrapper. If the Iterator already a unmodifyable wrapper then it just returns itself. | 	 * @return a unmodifiable iterator wrapper. If the Iterator already a unmodifyable wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ITERATOR KEY_GENERIC_TYPE unmodifiable(ITERATOR KEY_GENERIC_TYPE iterator) { | 	public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE unmodifiable(ITERATOR KEY_GENERIC_TYPE iterator) { | ||||||
| 		return iterator instanceof UnmodifiableIterator ? iterator : new UnmodifiableIteratorBRACES(iterator); | 		return iterator instanceof UnmodifiableIterator ? iterator : new UnmodifiableIteratorBRACES(iterator); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES BI_ITERATOR KEY_GENERIC_TYPE unmodifiable(BI_ITERATOR KEY_GENERIC_TYPE iterator) { | 	public static GENERIC_KEY_BRACES BI_ITERATOR KEY_GENERIC_TYPE unmodifiable(BI_ITERATOR KEY_GENERIC_TYPE iterator) { | ||||||
| 		return iterator instanceof UnmodifiableBiIterator ? iterator : new UnmodifiableBiIteratorBRACES(iterator); | 		return iterator instanceof UnmodifiableBiIterator ? iterator : new UnmodifiableBiIteratorBRACES(iterator); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -42,7 +42,7 @@ public class ITERATORS | |||||||
| 	 * @param l that should be made immutable/unmodifyable | 	 * @param l that should be made immutable/unmodifyable | ||||||
| 	 * @return a unmodifiable listiterator wrapper. If the ListIterator already a unmodifyable wrapper then it just returns itself. | 	 * @return a unmodifiable listiterator wrapper. If the ListIterator already a unmodifyable wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES LIST_ITERATOR KEY_GENERIC_TYPE unmodifiable(LIST_ITERATOR KEY_GENERIC_TYPE iterator) { | 	public static GENERIC_KEY_BRACES LIST_ITERATOR KEY_GENERIC_TYPE unmodifiable(LIST_ITERATOR KEY_GENERIC_TYPE iterator) { | ||||||
| 		return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator); | 		return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -57,7 +57,7 @@ public class ITERATORS | |||||||
| 	 * @param a the array that should be wrapped | 	 * @param a the array that should be wrapped | ||||||
| 	 * @return a Iterator that is wrapping a array. | 	 * @return a Iterator that is wrapping a array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { | 	public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { | ||||||
| 		return wrap(a, 0, a.length); | 		return wrap(a, 0, a.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -68,7 +68,7 @@ public class ITERATORS | |||||||
| 	 * @param end the index that should be ended. | 	 * @param end the index that should be ended. | ||||||
| 	 * @return a Iterator that is wrapping a array. | 	 * @return a Iterator that is wrapping a array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int start, int end) { | 	public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int start, int end) { | ||||||
| 		return new ArrayIteratorBRACES(a, start, end); | 		return new ArrayIteratorBRACES(a, start, end); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -78,7 +78,7 @@ public class ITERATORS | |||||||
| 	 * @param i the source iterator | 	 * @param i the source iterator | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i) { | ||||||
| 		return unwrap(a, i, 0, a.length); | 		return unwrap(a, i, 0, a.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -89,7 +89,7 @@ public class ITERATORS | |||||||
| 	 * @param offset the array offset where the start should be | 	 * @param offset the array offset where the start should be | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i, int offset) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i, int offset) { | ||||||
| 		return unwrap(a, i, offset, a.length - offset); | 		return unwrap(a, i, offset, a.length - offset); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -102,7 +102,7 @@ public class ITERATORS | |||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i, int offset, int max) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, Iterator<? extends CLASS_TYPE> i, int offset, int max) { | ||||||
| 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | ||||||
| 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | ||||||
| 		int index = 0; | 		int index = 0; | ||||||
| @ -117,7 +117,7 @@ public class ITERATORS | |||||||
| 	 * @param i the source iterator | 	 * @param i the source iterator | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i) { | ||||||
| 		return unwrap(a, i, 0, a.length); | 		return unwrap(a, i, 0, a.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -129,7 +129,7 @@ public class ITERATORS | |||||||
| 	 * @param offset the array offset where the start should be | 	 * @param offset the array offset where the start should be | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset) { | ||||||
| 		return unwrap(a, i, offset, a.length - offset); | 		return unwrap(a, i, offset, a.length - offset); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -143,7 +143,7 @@ public class ITERATORS | |||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset, int max) { | 	public static GENERIC_KEY_BRACES int unwrap(KEY_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset, int max) { | ||||||
| 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | ||||||
| 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | ||||||
| 		int index = 0; | 		int index = 0; | ||||||
| @ -159,7 +159,7 @@ public class ITERATORS | |||||||
| 	 * @param i the source iterator | 	 * @param i the source iterator | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i) { | 	public static GENERIC_KEY_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i) { | ||||||
| 		return unwrap(a, i, 0, a.length); | 		return unwrap(a, i, 0, a.length); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -171,7 +171,7 @@ public class ITERATORS | |||||||
| 	 * @param offset the array offset where the start should be | 	 * @param offset the array offset where the start should be | ||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset) { | 	public static GENERIC_KEY_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset) { | ||||||
| 		return unwrap(a, i, offset, a.length - offset); | 		return unwrap(a, i, offset, a.length - offset); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -185,7 +185,7 @@ public class ITERATORS | |||||||
| 	 * @return the amount of elements that were inserted into the array. | 	 * @return the amount of elements that were inserted into the array. | ||||||
| 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | 	 * @throws IllegalStateException if max is smaller the 0 or if the maximum index is larger then the array | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset, int max) { | 	public static GENERIC_KEY_BRACES int unwrap(CLASS_TYPE[] a, ITERATOR KEY_GENERIC_TYPE i, int offset, int max) { | ||||||
| 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | 		if(max < 0) throw new IllegalStateException("The max size is smaller then 0"); | ||||||
| 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | 		if(offset + max > a.length) throw new IllegalStateException("largest array index exceeds array size"); | ||||||
| 		int index = 0; | 		int index = 0; | ||||||
| @ -324,7 +324,7 @@ public class ITERATORS | |||||||
| 	 | 	 | ||||||
| 		@Override | 		@Override | ||||||
| 		public KEY_TYPE NEXT() { | 		public KEY_TYPE NEXT() { | ||||||
| 			return EMPTY_VALUE; | 			return EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		@Override | 		@Override | ||||||
| @ -334,7 +334,7 @@ public class ITERATORS | |||||||
| 		 | 		 | ||||||
| 		@Override | 		@Override | ||||||
| 		public KEY_TYPE PREVIOUS() { | 		public KEY_TYPE PREVIOUS() { | ||||||
| 			return EMPTY_VALUE; | 			return EMPTY_KEY_VALUE; | ||||||
| 		} | 		} | ||||||
| 		 | 		 | ||||||
| 		@Override | 		@Override | ||||||
|  | |||||||
| @ -23,7 +23,7 @@ public class LISTS | |||||||
| 	 * Returns a Immutable EmptyList instance that is automatically casted. | 	 * Returns a Immutable EmptyList instance that is automatically casted. | ||||||
| 	 * @return an empty list | 	 * @return an empty list | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES EmptyList KEY_GENERIC_TYPE emptyList() { | 	public static GENERIC_KEY_BRACES EmptyList KEY_GENERIC_TYPE emptyList() { | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		return (EmptyList<KEY_TYPE>)EMPTY; | 		return (EmptyList<KEY_TYPE>)EMPTY; | ||||||
| #else | #else | ||||||
| @ -36,7 +36,7 @@ public class LISTS | |||||||
| 	 * @param l that should be made immutable/unmodifyable | 	 * @param l that should be made immutable/unmodifyable | ||||||
| 	 * @return a unmodifiable list wrapper. If the list is implementing RandomAccess that is also transferred. If the List already a unmodifyable wrapper then it just returns itself. | 	 * @return a unmodifiable list wrapper. If the list is implementing RandomAccess that is also transferred. If the List already a unmodifyable wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES LIST KEY_GENERIC_TYPE unmodifiableList(LIST KEY_GENERIC_TYPE l) { | 	public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE unmodifiableList(LIST KEY_GENERIC_TYPE l) { | ||||||
| 		return l instanceof UnmodifiableList ? l : l instanceof RandomAccess ? new UnmodifiableRandomListBRACES(l) : new UnmodifiableListBRACES(l); | 		return l instanceof UnmodifiableList ? l : l instanceof RandomAccess ? new UnmodifiableRandomListBRACES(l) : new UnmodifiableListBRACES(l); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -45,7 +45,7 @@ public class LISTS | |||||||
| 	 * @param l that should be synchronized | 	 * @param l that should be synchronized | ||||||
| 	 * @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself. | 	 * @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES LIST KEY_GENERIC_TYPE synchronizedList(LIST KEY_GENERIC_TYPE l) { | 	public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronizedList(LIST KEY_GENERIC_TYPE l) { | ||||||
| 		return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l))); | 		return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l))); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| @ -55,7 +55,7 @@ public class LISTS | |||||||
| 	 * @param mutex is the controller of the synchronization block. | 	 * @param mutex is the controller of the synchronization block. | ||||||
| 	 * @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself. | 	 * @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself. | ||||||
| 	 */ | 	 */ | ||||||
| 	public static GENERIC_BRACES LIST KEY_GENERIC_TYPE synchronizedList(LIST KEY_GENERIC_TYPE l, Object mutex) { | 	public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronizedList(LIST KEY_GENERIC_TYPE l, Object mutex) { | ||||||
| 		return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex))); | 		return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex))); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -20,7 +20,7 @@ public class SETS | |||||||
| { | { | ||||||
| 	public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES(); | 	public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES(); | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SET KEY_GENERIC_TYPE empty() { | 	public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE empty() { | ||||||
| #if TYPE_OBJECT | #if TYPE_OBJECT | ||||||
| 		return (SET<KEY_TYPE>)EMPTY; | 		return (SET<KEY_TYPE>)EMPTY; | ||||||
| #else | #else | ||||||
| @ -28,39 +28,39 @@ public class SETS | |||||||
| #endif | #endif | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s) : new SynchronizedSetBRACES(s)); | 		return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s) : new SynchronizedSetBRACES(s)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s, Object mutex) { | 	public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE synchronizedSet(SET KEY_GENERIC_TYPE s, Object mutex) { | ||||||
| 		return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex)); | 		return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s) : new SynchronizedSortedSetBRACES(s)); | 		return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s) : new SynchronizedSortedSetBRACES(s)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s, Object mutex) { | 	public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE synchronizedSet(SORTED_SET KEY_GENERIC_TYPE s, Object mutex) { | ||||||
| 		return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex)); | 		return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s) : new SynchronizedNavigableSetBRACES(s)); | 		return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s) : new SynchronizedNavigableSetBRACES(s)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s, Object mutex) { | 	public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE synchronizedSet(NAVIGABLE_SET KEY_GENERIC_TYPE s, Object mutex) { | ||||||
| 		return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex)); | 		return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex)); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SET KEY_GENERIC_TYPE unmodifiable(SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES SET KEY_GENERIC_TYPE unmodifiable(SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof SynchronizedSet ? s : new SynchronizedSetBRACES(s); | 		return s instanceof SynchronizedSet ? s : new SynchronizedSetBRACES(s); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES SORTED_SET KEY_GENERIC_TYPE unmodifiable(SORTED_SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES SORTED_SET KEY_GENERIC_TYPE unmodifiable(SORTED_SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof SynchronizedSortedSet ? s : new SynchronizedSortedSetBRACES(s); | 		return s instanceof SynchronizedSortedSet ? s : new SynchronizedSortedSetBRACES(s); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	public static GENERIC_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE unmodifiable(NAVIGABLE_SET KEY_GENERIC_TYPE s) { | 	public static GENERIC_KEY_BRACES NAVIGABLE_SET KEY_GENERIC_TYPE unmodifiable(NAVIGABLE_SET KEY_GENERIC_TYPE s) { | ||||||
| 		return s instanceof UnmodifiableNavigableSet ? s : new UnmodifiableNavigableSetBRACES(s); | 		return s instanceof UnmodifiableNavigableSet ? s : new UnmodifiableNavigableSetBRACES(s); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -1,7 +1,5 @@ | |||||||
| package speiger.src.collections.ints.base; | package speiger.src.collections.ints.base; | ||||||
| 
 | 
 | ||||||
| import static org.junit.Assert.assertArrayEquals; |  | ||||||
| import static org.junit.Assert.assertEquals; |  | ||||||
| 
 | 
 | ||||||
| import java.util.EnumSet; | import java.util.EnumSet; | ||||||
| 
 | 
 | ||||||
| @ -9,6 +7,7 @@ import org.junit.Assert; | |||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| 
 | 
 | ||||||
| import speiger.src.collections.ints.queues.IntPriorityQueue; | import speiger.src.collections.ints.queues.IntPriorityQueue; | ||||||
|  | import speiger.src.collections.ints.utils.IntArrays; | ||||||
| import speiger.src.collections.tests.IterableTest; | import speiger.src.collections.tests.IterableTest; | ||||||
| import speiger.src.collections.tests.PriorityQueueTest; | import speiger.src.collections.tests.PriorityQueueTest; | ||||||
| 
 | 
 | ||||||
| @ -19,6 +18,7 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest | |||||||
| 	@Override | 	@Override | ||||||
| 	protected EnumSet<IterableTest> getValidIterableTests() { return EnumSet.of(IterableTest.FOR_EACH, IterableTest.ITERATOR_FOR_EACH, IterableTest.ITERATOR_LOOP, IterableTest.ITERATOR_SKIP); } | 	protected EnumSet<IterableTest> getValidIterableTests() { return EnumSet.of(IterableTest.FOR_EACH, IterableTest.ITERATOR_FOR_EACH, IterableTest.ITERATOR_LOOP, IterableTest.ITERATOR_SKIP); } | ||||||
| 	protected EnumSet<PriorityQueueTest> getValidPriorityQueueTests() { return EnumSet.allOf(PriorityQueueTest.class); } | 	protected EnumSet<PriorityQueueTest> getValidPriorityQueueTests() { return EnumSet.allOf(PriorityQueueTest.class); } | ||||||
|  | 	protected boolean isUnsortedRead() { return true; } | ||||||
| 	 | 	 | ||||||
| 	@Test | 	@Test | ||||||
| 	public void testEnqueue() { | 	public void testEnqueue() { | ||||||
| @ -26,11 +26,12 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest | |||||||
| 			IntPriorityQueue queue = create(EMPTY_ARRAY); | 			IntPriorityQueue queue = create(EMPTY_ARRAY); | ||||||
| 			for(int i = 0;i<100;i++) { | 			for(int i = 0;i<100;i++) { | ||||||
| 				queue.enqueueInt(i); | 				queue.enqueueInt(i); | ||||||
| 				Assert.assertEquals(i, queue.lastInt()); |  | ||||||
| 			} | 			} | ||||||
| 			for(int i = 0;i<100;i++) { | 			for(int i = 0;i<100;i++) { | ||||||
| 				Assert.assertEquals(i, queue.firstInt()); | 				Assert.assertEquals(i, queue.dequeueInt()); | ||||||
| 				Assert.assertEquals(99, queue.lastInt()); | 			} | ||||||
|  | 			queue = create(TEST_ARRAY); | ||||||
|  | 			for(int i = 0;i<100;i++) { | ||||||
| 				Assert.assertEquals(i, queue.dequeueInt()); | 				Assert.assertEquals(i, queue.dequeueInt()); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @ -42,10 +43,17 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest | |||||||
| 			IntPriorityQueue queue = create(EMPTY_ARRAY); | 			IntPriorityQueue queue = create(EMPTY_ARRAY); | ||||||
| 			for(int i = 0;i<100;i++) { | 			for(int i = 0;i<100;i++) { | ||||||
| 				queue.enqueueInt(i); | 				queue.enqueueInt(i); | ||||||
| 				Assert.assertEquals(i, queue.lastInt()); |  | ||||||
| 			} | 			} | ||||||
|  | 			if(isUnsortedRead()) { | ||||||
| 				for(int i = 0;i<100;i++) { | 				for(int i = 0;i<100;i++) { | ||||||
| 				assertEquals(i, queue.peekInt(i)); | 					int value = queue.peekInt(i); | ||||||
|  | 					Assert.assertTrue(value >= 0 && value < 100); | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 			else { | ||||||
|  | 				for(int i = 0;i<100;i++) { | ||||||
|  | 					Assert.assertEquals(i, queue.peekInt(i)); | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -56,21 +64,19 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest | |||||||
| 			IntPriorityQueue queue = create(EMPTY_ARRAY); | 			IntPriorityQueue queue = create(EMPTY_ARRAY); | ||||||
| 			for(int i = 0;i<100;i++) { | 			for(int i = 0;i<100;i++) { | ||||||
| 				queue.enqueueInt(i); | 				queue.enqueueInt(i); | ||||||
| 				Assert.assertEquals(i, queue.lastInt()); |  | ||||||
| 			} | 			} | ||||||
| 			queue.removeInt(40); | 			queue.removeInt(40); | ||||||
| 			for(int i = 0;i<99;i++) { | 			for(int i = 0;i<99;i++) { | ||||||
| 				if(i >= 40) assertEquals(i + 1, queue.dequeueInt()); | 				if(i >= 40) Assert.assertEquals(i + 1, queue.dequeueInt()); | ||||||
| 				else assertEquals(i, queue.dequeueInt()); | 				else Assert.assertEquals(i, queue.dequeueInt()); | ||||||
| 			} | 			} | ||||||
| 			for(int i = 0;i<100;i++) { | 			for(int i = 0;i<100;i++) { | ||||||
| 				queue.enqueueInt(i); | 				queue.enqueueInt(i); | ||||||
| 				Assert.assertEquals(i, queue.lastInt()); |  | ||||||
| 			} | 			} | ||||||
| 			queue.removeLastInt(40); | 			queue.removeLastInt(40); | ||||||
| 			for(int i = 0;i<99;i++) { | 			for(int i = 0;i<99;i++) { | ||||||
| 				if(i >= 40) assertEquals(i + 1, queue.dequeueInt()); | 				if(i >= 40) Assert.assertEquals(i + 1, queue.dequeueInt()); | ||||||
| 				else assertEquals(i, queue.dequeueInt()); | 				else Assert.assertEquals(i, queue.dequeueInt()); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -79,36 +85,45 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest | |||||||
| 	@SuppressWarnings("deprecation") | 	@SuppressWarnings("deprecation") | ||||||
| 	public void testToArray() { | 	public void testToArray() { | ||||||
| 		if(getValidPriorityQueueTests().contains(PriorityQueueTest.TO_ARRAY)) { | 		if(getValidPriorityQueueTests().contains(PriorityQueueTest.TO_ARRAY)) { | ||||||
| 			IntPriorityQueue q = create(EMPTY_ARRAY); | 			IntPriorityQueue queue = create(EMPTY_ARRAY); | ||||||
| 			Integer[] ref = new Integer[100]; | 			if(isUnsortedRead()) { | ||||||
|  | 				for(int i = 0;i<100;i++) { | ||||||
|  | 					queue.enqueueInt(i); | ||||||
|  | 				} | ||||||
|  | 				int[] array = queue.toIntArray(); | ||||||
|  | 				IntArrays.stableSort(array); | ||||||
|  | 				Assert.assertArrayEquals(TEST_ARRAY, array); | ||||||
|  | 				int[] data = queue.toIntArray(new int[100]); | ||||||
|  | 				int[] nonData = queue.toIntArray(new int[0]); | ||||||
|  | 				IntArrays.stableSort(data); | ||||||
|  | 				IntArrays.stableSort(nonData);				 | ||||||
|  | 				Assert.assertArrayEquals(array, data); | ||||||
|  | 				Assert.assertArrayEquals(array, nonData); | ||||||
|  | 			} | ||||||
|  | 			else { | ||||||
|  | 				Integer[] ref = IntArrays.wrap(TEST_ARRAY); | ||||||
| 				Integer[] shiftArray = new Integer[100]; | 				Integer[] shiftArray = new Integer[100]; | ||||||
| 			int[] primRef = new int[100]; |  | ||||||
| 				int[] shiftPrimArray = new int[100]; | 				int[] shiftPrimArray = new int[100]; | ||||||
| 				for(int i = 0; i < 100; i++) { | 				for(int i = 0; i < 100; i++) { | ||||||
| 				q.enqueue(i); | 					queue.enqueue(i); | ||||||
| 				assertEquals(i, q.lastInt()); |  | ||||||
| 				ref[i] = Integer.valueOf(i); |  | ||||||
| 				primRef[i] = i; |  | ||||||
| 					shiftPrimArray[(i+80) % 100] = i; | 					shiftPrimArray[(i+80) % 100] = i; | ||||||
| 					shiftArray[(i+80) % 100] = Integer.valueOf(i); | 					shiftArray[(i+80) % 100] = Integer.valueOf(i); | ||||||
| 				} | 				} | ||||||
| 			assertArrayEquals(q.toArray(), ref); | 				Assert.assertArrayEquals(ref, queue.toArray()); | ||||||
| 			assertArrayEquals(q.toArray(new Integer[100]), ref); | 				Assert.assertArrayEquals(ref, queue.toArray(new Integer[100])); | ||||||
| 			assertArrayEquals(q.toArray(null), ref); | 				Assert.assertArrayEquals(ref, queue.toArray(null)); | ||||||
| 			assertArrayEquals(q.toIntArray(), primRef); | 				Assert.assertArrayEquals(TEST_ARRAY, queue.toIntArray()); | ||||||
| 			assertArrayEquals(q.toIntArray(new int[100]), primRef); | 				Assert.assertArrayEquals(TEST_ARRAY, queue.toIntArray(new int[100])); | ||||||
| 			assertArrayEquals(q.toIntArray(null), primRef); | 				Assert.assertArrayEquals(TEST_ARRAY, queue.toIntArray(null)); | ||||||
| 			IntPriorityQueue other = create(q.toIntArray()); | 				IntPriorityQueue other = create(queue.toIntArray()); | ||||||
| 			for(int i = 0;i<100;i++) { |  | ||||||
| 				assertEquals(other.peekInt(i), primRef[i]); |  | ||||||
| 			} |  | ||||||
| 				for(int i = 0;i<20;i++) { | 				for(int i = 0;i<20;i++) { | ||||||
| 					other.dequeueInt(); | 					other.dequeueInt(); | ||||||
| 					other.enqueue(i); | 					other.enqueue(i); | ||||||
| 				} | 				} | ||||||
| 			assertArrayEquals(other.toIntArray(), shiftPrimArray); | 				Assert.assertArrayEquals(shiftPrimArray, other.toIntArray()); | ||||||
| 			assertArrayEquals(other.toIntArray(new int[100]), shiftPrimArray); | 				Assert.assertArrayEquals(shiftPrimArray, other.toIntArray(new int[100])); | ||||||
| 			assertArrayEquals(other.toArray(), shiftArray); | 				Assert.assertArrayEquals(shiftArray, other.toArray()); | ||||||
|  | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,4 +6,7 @@ public class IntArrayFIFOQueueTests extends BaseIntPriorityQueueTest | |||||||
| { | { | ||||||
| 	@Override | 	@Override | ||||||
| 	protected IntPriorityQueue create(int[] data){return new IntArrayFIFOQueue(data);} | 	protected IntPriorityQueue create(int[] data){return new IntArrayFIFOQueue(data);} | ||||||
|  | 	 | ||||||
|  | 	@Override | ||||||
|  | 	protected boolean isUnsortedRead() { return false; } | ||||||
| } | } | ||||||
|  | |||||||
| @ -0,0 +1,11 @@ | |||||||
|  | package speiger.src.collections.ints.queues; | ||||||
|  | 
 | ||||||
|  | import speiger.src.collections.ints.base.BaseIntPriorityQueueTest; | ||||||
|  | 
 | ||||||
|  | public class IntArrayPriorityQueueTests extends BaseIntPriorityQueueTest | ||||||
|  | { | ||||||
|  | 	@Override | ||||||
|  | 	protected IntPriorityQueue create(int[] data) { | ||||||
|  | 		return new IntArrayPriorityQueue(data); | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @ -0,0 +1,11 @@ | |||||||
|  | package speiger.src.collections.ints.queues; | ||||||
|  | 
 | ||||||
|  | import speiger.src.collections.ints.base.BaseIntPriorityQueueTest; | ||||||
|  | 
 | ||||||
|  | public class IntHeapPriorityQueueTests extends BaseIntPriorityQueueTest | ||||||
|  | { | ||||||
|  | 	@Override | ||||||
|  | 	protected IntPriorityQueue create(int[] data) { | ||||||
|  | 		return new IntHeapPriorityQueue(data); | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user