Changed that function names are closer to javas names.

This commit is contained in:
Speiger 2022-12-15 16:07:44 +01:00
parent 127eb71968
commit d6d2c0a396
7 changed files with 32 additions and 14 deletions

View File

@ -12,6 +12,7 @@
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways. - Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
- Breaking Change: Function classes now use the "apply/applyAs/test" format from Java itself, instead of the "get" format. This cleans up a lot of things. But will break existing function class implementations - Breaking Change: Function classes now use the "apply/applyAs/test" format from Java itself, instead of the "get" format. This cleans up a lot of things. But will break existing function class implementations
- Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat. - Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat.
- Breaking Change: Some function classes now get closer to javas terms. (Predicate/UnaryOperator etc)
### Version 0.7.0 ### Version 0.7.0
- Added: Over 11 Million Unit Tests to this library to ensure quality. - Added: Over 11 Million Unit Tests to this library to ensure quality.

View File

@ -34,6 +34,18 @@ public class FunctionModule extends BaseModule
addRequirement("Function", "%1$s", RequiredType.BI_CLASS); addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate"); addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate");
} }
else if(keyType.isObject() && !valueType.isObject()) {
addRequirement("Function", "%2$s", RequiredType.BI_CLASS);
addRemapper("Function", "To%sFunction");
}
else if(keyType == valueType) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"UnaryOperator");
}
else if(valueType.isObject()) {
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
addRemapper("Function", "%sFunction");
}
else addBiRequirement("Function"); else addBiRequirement("Function");
addRemapper("BiConsumer", "%sConsumer"); addRemapper("BiConsumer", "%sConsumer");
} }
@ -51,8 +63,12 @@ public class FunctionModule extends BaseModule
addBiClassMapper("BI_CONSUMER", "Consumer", ""); addBiClassMapper("BI_CONSUMER", "Consumer", "");
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer"); addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer"); addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction"); if(keyType.isObject()) addFunctionMappers("TO_OBJECT_FUNCTION", "UnaryOperator");
else addClassMapper("TO_OBJECT_FUNCTION", "Function");
if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate"); if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate");
else if(keyType.isObject() && !valueType.isObject()) addFunctionValueMappers("FUNCTION", "To%sFunction");
else if(keyType == valueType) addFunctionMappers("FUNCTION", "%sUnaryOperator");
else if(valueType.isObject()) addFunctionMappers("FUNCTION", "%sFunction");
else addBiClassMapper("FUNCTION", "Function", "2"); else addBiClassMapper("FUNCTION", "Function", "2");
addFunctionMappers("PREDICATE", "%sPredicate"); addFunctionMappers("PREDICATE", "%sPredicate");

View File

@ -12,7 +12,7 @@ import java.util.stream.StreamSupport;
#endif #endif
#if TYPE_OBJECT #if TYPE_OBJECT
import java.util.function.Consumer; import java.util.function.Consumer;
import speiger.src.collections.ints.functions.function.Int2ObjectFunction; import java.util.function.IntFunction;
#else #else
import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.PACKAGE.functions.CONSUMER;
#endif #endif
@ -182,7 +182,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
* @return an array containing all of the elements in this collection * @return an array containing all of the elements in this collection
* @see Collection#toArray(Object[]) * @see Collection#toArray(Object[])
*/ */
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) { default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
return TO_ARRAY(action.apply(size())); return TO_ARRAY(action.apply(size()));
} }

View File

@ -13,8 +13,8 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
import speiger.src.collections.objects.collections.ObjectIterable; import speiger.src.collections.objects.collections.ObjectIterable;
#else #else
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.IntFunction;
import java.util.Comparator; import java.util.Comparator;
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
#endif #endif
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
@ -288,7 +288,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
* @param action is the creator function of said Array to ensure type is kept. * @param action is the creator function of said Array to ensure type is kept.
* @return a new Array of all elements * @return a new Array of all elements
*/ */
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) { default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
ISizeProvider prov = ISizeProvider.of(this); ISizeProvider prov = ISizeProvider.of(this);
if(prov != null) { if(prov != null) {
int size = prov.size(); int size = prov.size();

View File

@ -4,6 +4,7 @@ package speiger.src.collections.PACKAGE.lists;
#if DEQUEUE_FEATURE #if DEQUEUE_FEATURE
import java.util.Comparator; import java.util.Comparator;
#endif #endif
import java.util.function.BiFunction; import java.util.function.BiFunction;
#else if PRIMITIVES #else if PRIMITIVES
import java.nio.JAVA_BUFFER; import java.nio.JAVA_BUFFER;
@ -18,6 +19,9 @@ import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
#endif #endif
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
#if TYPE_OBJECT
import java.util.function.IntFunction;
#endif
#if !TYPE_OBJECT && JDK_FUNCTION #if !TYPE_OBJECT && JDK_FUNCTION
import java.util.function.PREDICATE; import java.util.function.PREDICATE;
#endif #endif
@ -36,8 +40,6 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.COLLECTION;
#if !TYPE_OBJECT #if !TYPE_OBJECT
import speiger.src.collections.PACKAGE.collections.STACK; import speiger.src.collections.PACKAGE.collections.STACK;
#else
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
#endif #endif
import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.collections.ITERATOR;
#if DEQUEUE_FEATURE #if DEQUEUE_FEATURE
@ -990,7 +992,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
#else #else
@Override @Override
public T[] toArray(Int2ObjectFunction<T[]> action) { public T[] toArray(IntFunction<T[]> action) {
return super.toArray(action); return super.toArray(action);
} }

View File

@ -4,8 +4,7 @@ package speiger.src.collections.PACKAGE.queues;
import java.util.Comparator; import java.util.Comparator;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.function.IntFunction;
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
#else #else
import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#endif #endif
@ -189,7 +188,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
* @return an array containing all of the elements in this collection * @return an array containing all of the elements in this collection
* @see Collection#toArray(Object[]) * @see Collection#toArray(Object[])
*/ */
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) { default KEY_TYPE[] TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
return TO_ARRAY(action.apply(size())); return TO_ARRAY(action.apply(size()));
} }
#endif #endif

View File

@ -8,8 +8,8 @@ import java.util.concurrent.RecursiveAction;
import speiger.src.collections.PACKAGE.functions.COMPARATOR; import speiger.src.collections.PACKAGE.functions.COMPARATOR;
#else #else
import java.util.Comparator; import java.util.Comparator;
import java.util.function.IntFunction;
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
#endif #endif
import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.collections.ITERATOR;
import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.utils.ITERATORS;
@ -146,7 +146,7 @@ public class ARRAYS
* @param action that is creating the Array to be poured into * @param action that is creating the Array to be poured into
* @return array with all elements of the iterator * @return array with all elements of the iterator
*/ */
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, Int2ObjectFunction<KEY_TYPE[]> action) { public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, IntFunction<KEY_TYPE[]> action) {
return pour(iter, Integer.MAX_VALUE, action); return pour(iter, Integer.MAX_VALUE, action);
} }
@ -158,7 +158,7 @@ public class ARRAYS
* @ArrayType(T) * @ArrayType(T)
* @return array with all requested elements of the iterator * @return array with all requested elements of the iterator
*/ */
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, Int2ObjectFunction<KEY_TYPE[]> action) { public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, IntFunction<KEY_TYPE[]> action) {
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper(); COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
ITERATORS.pour(iter, list, max); ITERATORS.pour(iter, list, max);
return list.TO_ARRAY(action.apply(list.size())); return list.TO_ARRAY(action.apply(list.size()));