diff --git a/Changelog.md b/Changelog.md index 9725396c..05c6ed12 100644 --- a/Changelog.md +++ b/Changelog.md @@ -5,6 +5,10 @@ - Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons) - Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays. - Fixed: putIfAbsent now replaces defaultValues +- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations. +- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant. +- 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 ### Version 0.7.0 - Added: Over 11 Million Unit Tests to this library to ensure quality. diff --git a/ModulSettings.json b/ModulSettings.json new file mode 100644 index 00000000..9ea747b7 --- /dev/null +++ b/ModulSettings.json @@ -0,0 +1,2624 @@ +{ + "Async": true, + "Base": true, + "Collection": true, + "Function": true, + "List": true, + "Map": true, + "Pair": true, + "PriorityQueue": true, + "Set": true, + "Boolean": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Byte": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Short": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Character": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Integer": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Long": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Float": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Double": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + }, + "Object": { + "Enabled": true, + "Base": { + "Enabled": true + }, + "Boolean": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Byte": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Short": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Character": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Integer": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Long": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Float": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Double": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Object": { + "Enabled": true, + "Function": { + "Enabled": true + }, + "Map": { + "Enabled": true, + "AVLTreeMap": true, + "ArrayMap": true, + "ConcurrentMap": true, + "CustomHashMap": true, + "EnumMap": true, + "HashMap": true, + "ImmutableMap": true, + "Implementations": true, + "LinkedCustomHashMap": true, + "LinkedEnumMap": true, + "LinkedHashMap": true, + "OrderedMap": true, + "RBTreeMap": true, + "SortedMap": true, + "Wrappers": true + }, + "Pair": { + "Enabled": true, + "Immutable": true, + "Mutable": true + } + }, + "Collection": { + "Enabled": true, + "IArray": true, + "Splititerators": true, + "Strategy": true, + "Streams": true + }, + "PriorityQueue": { + "Enabled": true, + "ArrayPrioQueue": true, + "Dequeue": true, + "FiFoQueue": true, + "HeapQueue": true, + "Implementations": true, + "Wrappers": true + }, + "List": { + "Enabled": true, + "ArrayList": true, + "CopyOnWriteList": true, + "ImmutableList": true, + "Implementations": true, + "LinkedList": true, + "Wrappers": true + }, + "Set": { + "Enabled": true, + "AVLTreeSet": true, + "ArraySet": true, + "CustomHashSet": true, + "HashSet": true, + "ImmutableSet": true, + "Implementations": true, + "LinkedCustomHashSet": true, + "LinkedHashSet": true, + "OrderedSet": true, + "RBTreeSet": true, + "SortedSet": true, + "Wrappers": true + }, + "Async": { + "Enabled": true + } + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle index c848ad5b..bbddc89a 100644 --- a/build.gradle +++ b/build.gradle @@ -45,6 +45,7 @@ configurations { } dependencies { + builderImplementation 'com.google.code.gson:gson:2.10' builderImplementation 'de.speiger:Simple-Code-Generator:1.1.4' testImplementation 'junit:junit:4.12' testImplementation 'com.google.guava:guava-testlib:31.0.1-jre' diff --git a/src/builder/java/speiger/src/builder/ClassType.java b/src/builder/java/speiger/src/builder/ClassType.java index f799e726..b015fc0d 100644 --- a/src/builder/java/speiger/src/builder/ClassType.java +++ b/src/builder/java/speiger/src/builder/ClassType.java @@ -52,6 +52,11 @@ public enum ClassType return classType; } + public String getClassPath() + { + return this == OBJECT ? "Object" : classType; + } + public String getClassType(boolean value) { return value && this == OBJECT ? "V" : classType; @@ -128,6 +133,12 @@ public enum ClassType } } + public String getApply(ClassType other) { + if(other == BOOLEAN) return "test"; + if(other == ClassType.OBJECT) return "apply"; + return "applyAs"+other.getFileType(); + } + public String getEquals(boolean not) { switch(this) diff --git a/src/builder/java/speiger/src/builder/ModulePackage.java b/src/builder/java/speiger/src/builder/ModulePackage.java new file mode 100644 index 00000000..84933cdc --- /dev/null +++ b/src/builder/java/speiger/src/builder/ModulePackage.java @@ -0,0 +1,149 @@ +package speiger.src.builder; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; + +import speiger.src.builder.mappers.IMapper; +import speiger.src.builder.processor.TemplateProcess; + +@SuppressWarnings("javadoc") +public class ModulePackage +{ + private static final BiConsumer VOID = (K, V) -> {}; + public static final ClassType[] TYPE = ClassType.values(); + final ClassType keyType; + final ClassType valueType; + Set blocked = new HashSet<>(); + Map nameRemapper = new HashMap<>(); + Map splitters = new HashMap<>(); + List> blockedFilters = new ArrayList<>(); + List mappers = new ArrayList<>(); + Set flags = new LinkedHashSet<>(); + Set globalFlags; + BiConsumer requirements = VOID; + + public ModulePackage(Set globalFlags, ClassType keyType, ClassType valueType) { + this.globalFlags = globalFlags; + this.keyType = keyType; + this.valueType = valueType; + } + + public void finish() { + requirements = VOID; + mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed())); + mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort)); + } + + public void setRequirements(BiConsumer requirements) { + this.requirements = requirements; + } + + public boolean isSame() { + return keyType == valueType; + } + + public boolean isEnumValid() { + return keyType == ClassType.OBJECT; + } + + public ClassType getKeyType() { + return keyType; + } + + public ClassType getValueType() { + return valueType; + } + + public void addFlag(String flag) { + flags.add(flag); + } + + public void addGlobalFlag(String flag) { + globalFlags.add(flag); + } + + public void addRequirement(String fileName, RequiredType type) { + requirements.accept(fileName, type); + } + + public void addMapper(IMapper mapper) { + mappers.add(mapper); + } + + public void addBlockedFilter(Predicate filter) { + blockedFilters.add(filter); + } + + public void addBlockedFiles(String... names) { + blocked.addAll(Arrays.asList(names)); + } + + public void addSplitter(String fileName, String splitter) { + splitters.put(fileName, splitter); + } + + public void addRemapper(String fileName, String actualName) { + nameRemapper.put(fileName, actualName); + } + + public void process(String fileName, Consumer result) { + if(isBlocked(fileName)) return; + String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType()); + String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter); + TemplateProcess process = new TemplateProcess(newName+".java"); + process.setPathBuilder(new PathBuilder(keyType.getPathType())); + process.addFlags(flags); + process.addFlags(globalFlags); + process.addMappers(mappers); + result.accept(process); + } + + private boolean isBlocked(String fileName) { + if(blocked.contains(fileName)) return true; + for(int i = 0,m=blockedFilters.size();i createPackages(Set globalFlags) { + List list = new ArrayList<>(); + for(ClassType key : TYPE) { + for(ClassType value : TYPE) { + list.add(new ModulePackage(globalFlags, key, value)); + } + } + return list; + } + + private int sort(String key, String value) { + if(value.contains(key)) return 1; + else if(key.contains(value)) return -1; + return 0; + } + + class PathBuilder implements UnaryOperator { + String before; + + public PathBuilder(String before) { + this.before = before; + } + + @Override + public Path apply(Path t) { + return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount())); + } + } +} diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index 396162ad..8ab7a343 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -7,8 +7,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.EnumMap; -import java.util.EnumSet; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -16,25 +15,35 @@ import java.util.Map; import java.util.Set; import java.util.StringJoiner; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Stream; +import speiger.src.builder.modules.AsyncModule; +import speiger.src.builder.modules.BaseModule; +import speiger.src.builder.modules.CollectionModule; +import speiger.src.builder.modules.FunctionModule; +import speiger.src.builder.modules.JavaModule; +import speiger.src.builder.modules.ListModule; +import speiger.src.builder.modules.MapModule; +import speiger.src.builder.modules.PairModule; +import speiger.src.builder.modules.PrioQueueModule; +import speiger.src.builder.modules.SetModule; import speiger.src.builder.processor.TemplateProcess; import speiger.src.builder.processor.TemplateProcessor; @SuppressWarnings("javadoc") public class PrimitiveCollectionsBuilder extends TemplateProcessor { - Map> blocked = new HashMap<>(); - EnumMap>> blockedPredicate = new EnumMap<>(ClassType.class); - Map nameRemapper = new HashMap<>(); - Map biRequired = new HashMap<>(); - Set enumRequired = new HashSet<>(); - public static final ClassType[] TYPE = ClassType.values(); - List variables = new ArrayList<>(); - List biVariables = new ArrayList<>(); - List enumVariables = new ArrayList<>(); - boolean special = false; + private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests + private static final int LOAD = 0x2; //If Configs should be loaded + private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time. + private static final int SAVE = 0x4; //if the configuration should be created + Set globalFlags = new HashSet<>(); + List simplePackages = new ArrayList<>(); + List biPackages = new ArrayList<>(); + List enumPackages = new ArrayList<>(); + Map requirements = new HashMap<>(); + SettingsManager manager = new SettingsManager(); + int flags; public PrimitiveCollectionsBuilder() { @@ -56,17 +65,26 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor super(silencedSuccess, sourceFolder, outputFolder, dataFolder); } - private PrimitiveCollectionsBuilder setSpecial() { - special = true; + private PrimitiveCollectionsBuilder setFlags(int flags) { + this.flags = flags; + if((flags & ANTI_SAVE) != 0) { + this.flags &= ~SAVE; + } return this; } - private static PrimitiveCollectionsBuilder createTests(boolean silent) { - return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/tests/templates/"), Paths.get("src/test/java/speiger/src/tests/"), Paths.get("src/builder/resources/speiger/assets/tests/")).setSpecial(); + private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) { + return new PrimitiveCollectionsBuilder(silent, + Paths.get("src/builder/resources/speiger/assets/tests/templates/"), + Paths.get("src/test/java/speiger/src/tests/"), + Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL); } - private static PrimitiveCollectionsBuilder createTesters(boolean silent) { - return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/testers/templates/"), Paths.get("src/test/java/speiger/src/testers/"), Paths.get("src/builder/resources/speiger/assets/testers/")).setSpecial(); + private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) { + return new PrimitiveCollectionsBuilder(silent, + Paths.get("src/builder/resources/speiger/assets/testers/templates/"), + Paths.get("src/test/java/speiger/src/testers/"), + Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL); } @Override @@ -90,7 +108,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor @Override protected void afterFinish() { - if(!special && getVersion() > 8) + if((flags & SPECIAL) == 0 && getVersion() > 8) { Path basePath = Paths.get("src/main/java"); try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java"))) @@ -104,171 +122,77 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor } } + public List createModules() + { + List modules = new ArrayList<>(); + modules.add(JavaModule.INSTANCE); + modules.add(FunctionModule.INSTANCE); + modules.add(CollectionModule.INSTANCE); + modules.add(PrioQueueModule.INSTANCE); + modules.add(ListModule.INSTANCE); + modules.add(SetModule.INSTANCE); + modules.add(MapModule.INSTANCE); + modules.add(PairModule.INSTANCE); + modules.add(AsyncModule.INSTANCE); + return modules; + } + + @Override - protected void init() + protected void init() { - variables.clear(); - for(ClassType clzType : TYPE) + prepPackages(); + //Init Modules here + addModules(createModules()); + finishPackages(); + } + + public void addModules(List modules) + { + for(int i = 0,m=modules.size();i T.endsWith("Tester") && (T.startsWith("Iterable") ||T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap"))); - } - - protected void create(ClassType mainType, ClassType subType) - { - GlobalVariables type = new GlobalVariables(mainType, subType); - type.createFlags(); - type.createHelperVariables(); - type.createVariables(); - type.createPreFunctions(); - type.createClassTypes(); - type.createFunctions(); - if(mainType == subType) variables.add(type); - biVariables.add(type); - if(mainType.isObject()) enumVariables.add(type); - } - - protected void addBiClass(String...classNames) - { - for(String s : classNames) - { - biRequired.put(s, "2"); - } - } - - protected void addBlockage(ClassType type, Predicate filter) - { - blockedPredicate.computeIfAbsent(type, T -> new ArrayList<>()).add(filter); - } - - protected void addBlockage(ClassType type, String...args) - { - for(String s : args) - { - EnumSet set = blocked.get(s); - if(set == null) - { - set = EnumSet.noneOf(ClassType.class); - blocked.put(s, set); - } - set.add(type); - } - } - - public void test() throws InterruptedException, IOException - { - init(); - List keys = new ArrayList<>(); - List values = new ArrayList<>(); - for(int i = 0,m=variables.size();i acceptor) + public void createProcesses(String fileName, Consumer process) { - String splitter = biRequired.get(name); - boolean valueRequired = enumRequired.contains(name); - List vars = getVariablesByClass(name, splitter != null); - for(int i = 0,m=vars.size();i packages = getPackagesByRequirement(requirements.get(fileName)); + for(int i = 0,m=packages.size();i types = blocked.get(fileName); - if(types != null && types.contains(type)) return false; - List> list = blockedPredicate.get(type); - if(list != null) { - for(int i = 0,m=list.size();i getVariablesByClass(String name, boolean bi) { - if(enumRequired.contains(name)) return enumVariables; - if(bi) return biVariables; - return variables; + protected List getPackagesByRequirement(RequiredType type) { + if(type == null) return simplePackages; + if(type == RequiredType.BI_CLASS) return biPackages; + if(type == RequiredType.ENUM) return enumPackages; + return Collections.emptyList(); } private String getModuleInfo(Path basePath) { @@ -329,11 +253,13 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor boolean force = flags.contains("force"); boolean tests = flags.contains("tests"); boolean forceTests = flags.contains("force-tests"); -// new PrimitiveCollectionsBuilder(silent).test(); - new PrimitiveCollectionsBuilder(silent).process(force); + boolean load = flags.contains("load"); + boolean save = flags.contains("save"); + int flag = (load ? LOAD : 0) | (save ? SAVE : 0); + new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force); if(tests) { - createTests(silent).process(force || forceTests); - createTesters(silent).process(force || forceTests); + createTests(silent, flag).process(force || forceTests); + createTesters(silent, flag).process(force || forceTests); } } catch(InterruptedException | IOException e) diff --git a/src/builder/java/speiger/src/builder/RequiredType.java b/src/builder/java/speiger/src/builder/RequiredType.java new file mode 100644 index 00000000..0a11cbd1 --- /dev/null +++ b/src/builder/java/speiger/src/builder/RequiredType.java @@ -0,0 +1,8 @@ +package speiger.src.builder; + +@SuppressWarnings("javadoc") +public enum RequiredType +{ + BI_CLASS, + ENUM +} diff --git a/src/builder/java/speiger/src/builder/SettingsManager.java b/src/builder/java/speiger/src/builder/SettingsManager.java new file mode 100644 index 00000000..1fcfd3c1 --- /dev/null +++ b/src/builder/java/speiger/src/builder/SettingsManager.java @@ -0,0 +1,125 @@ +package speiger.src.builder; + +import java.io.BufferedReader; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Set; +import java.util.TreeSet; + +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import com.google.gson.internal.Streams; +import com.google.gson.stream.JsonWriter; + +import speiger.src.builder.modules.BaseModule; + +@SuppressWarnings("javadoc") +public class SettingsManager +{ + boolean loaded; + JsonObject data = new JsonObject(); + Set moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + + public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType) { + if(!loaded) return true; + if(!isEnabled(data, base.getModuleName())) return false; + JsonObject result = getObject(data, keyType.getClassPath(), false); + if(!isEnabled(result, "Enabled")) return false; + if(base.isBiModule()) { + result = getObject(result, valueType.getClassPath(), false); + if(!isEnabled(result, "Enabled")) return false; + } + result = getObject(result, base.getModuleName(), false); + return (result.size() <= 0 || isEnabled(result, "Enabled")) && base.areDependenciesLoaded(); + } + + public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry) + { + if(!loaded) return true; + if(!isEnabled(data, base.getModuleName())) return false; + JsonObject result = getObject(data, keyType.getClassPath(), false); + if(!isEnabled(result, "Enabled")) return false; + if(base.isBiModule()) { + result = getObject(result, valueType.getClassPath(), false); + if(!isEnabled(result, "Enabled")) return false; + } + result = getObject(result, base.getModuleName(), false); + return (result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry))) && base.areDependenciesLoaded(); + } + + public void addModule(BaseModule module) { + if(loaded) return; + String moduleName = module.getModuleName(); + moduleNames.add(moduleName); + data.addProperty(moduleName, true); + if(module.isBiModule()) { + for(ClassType keyType : ModulePackage.TYPE) { + for(ClassType valueType : ModulePackage.TYPE) { + if(!module.isModuleValid(keyType, valueType)) continue; + JsonObject obj = new JsonObject(); + obj.addProperty("Enabled", true); + for(String key : module.getModuleKeys(keyType, valueType)) { + obj.addProperty(key, true); + } + addModule(keyType, valueType, true, moduleName, obj); + } + } + return; + } + for(ClassType keyType : ModulePackage.TYPE) { + if(!module.isModuleValid(keyType, keyType)) continue; + JsonObject obj = new JsonObject(); + obj.addProperty("Enabled", true); + for(String key : module.getModuleKeys(keyType, keyType)) { + obj.addProperty(key, true); + } + addModule(keyType, keyType, false, moduleName, obj); + } + } + + public void load() { + try(BufferedReader reader = Files.newBufferedReader(Paths.get("ModulSettings.json"))) { + data = JsonParser.parseReader(reader).getAsJsonObject(); + loaded = true; + } + catch(Exception e) { e.printStackTrace(); } + } + + public void save() { + data.asMap().keySet().removeAll(moduleNames); + JsonObject result = new JsonObject(); + for(String s : moduleNames) { + result.addProperty(s, true); + } + result.asMap().putAll(data.asMap()); + + try(JsonWriter writer = new JsonWriter(Files.newBufferedWriter(Paths.get("ModulSettings.json")))) { + writer.setIndent("\t"); + Streams.write(result, writer); + } + catch(Exception e) { e.printStackTrace(); } + } + + private void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) { + JsonObject result = getObject(data, keyType.getClassPath(), true); + if(bi) { + result = getObject(result, valueType.getClassPath(), true); + } + result.add(moduleName, obj); + } + + private JsonObject getObject(JsonObject data, String name, boolean create) { + JsonObject obj = data.getAsJsonObject(name); + if(obj == null) { + obj = new JsonObject(); + data.add(name, obj); + if(create) obj.addProperty("Enabled", true); + } + return obj; + } + + private boolean isEnabled(JsonObject obj, String key) { + if(obj.has(key)) return obj.getAsJsonPrimitive(key).getAsBoolean(); + return true; + } +} diff --git a/src/builder/java/speiger/src/builder/modules/AsyncModule.java b/src/builder/java/speiger/src/builder/modules/AsyncModule.java new file mode 100644 index 00000000..75a0eb57 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/AsyncModule.java @@ -0,0 +1,45 @@ +package speiger.src.builder.modules; + +@SuppressWarnings("javadoc") +public class AsyncModule extends BaseModule +{ + public static final BaseModule INSTANCE = new AsyncModule(); + + @Override + public String getModuleName() { return "Async"; } + @Override + protected void loadVariables() {} + @Override + protected void loadRemappers() {} + @Override + protected void loadTestClasses() {} + @Override + protected void loadFunctions() {} + @Override + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + @Override + protected void loadBlockades() { + if(!isModuleEnabled()) { + addBlockedFiles("AsyncBuilder", "Task"); + } + } + @Override + protected void loadFlags() { + if(isModuleEnabled()) { + addKeyFlag("ASYNC_MODULE"); + } + } + + @Override + protected void loadClasses() + { + //Implementation Classes + addClassMapper("ASYNC_BUILDER", "AsyncBuilder"); + + //Abstract Classes + addAbstractMapper("BASE_TASK", "Base%sTask"); + + //Interfaces + addClassMapper("TASK", "Task"); + } +} diff --git a/src/builder/java/speiger/src/builder/modules/BaseModule.java b/src/builder/java/speiger/src/builder/modules/BaseModule.java new file mode 100644 index 00000000..a3ffc0d8 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/BaseModule.java @@ -0,0 +1,201 @@ +package speiger.src.builder.modules; + +import java.util.Collections; +import java.util.Set; +import java.util.function.Predicate; + +import speiger.src.builder.ClassType; +import speiger.src.builder.ModulePackage; +import speiger.src.builder.RequiredType; +import speiger.src.builder.SettingsManager; +import speiger.src.builder.mappers.ArgumentMapper; +import speiger.src.builder.mappers.InjectMapper; +import speiger.src.builder.mappers.LineMapper; +import speiger.src.builder.mappers.SimpleMapper; + +@SuppressWarnings("javadoc") +public abstract class BaseModule +{ + SettingsManager manager; + ModulePackage entry; + protected ClassType keyType; + protected ClassType valueType; + + public final void setManager(SettingsManager manager) { + this.manager = manager; + manager.addModule(this); + } + + public final void init(ModulePackage entry) { + this.entry = entry; + keyType = entry.getKeyType(); + valueType = entry.getValueType(); + loadVariables(); + loadClasses(); + loadTestClasses(); + loadFunctions(); + loadRemappers(); + loadBlockades(); + loadFlags(); + } + + public final void cleanup() { + entry = null; + keyType = null; + valueType = null; + manager = null; + } + + protected abstract void loadVariables(); + protected abstract void loadClasses(); + protected abstract void loadTestClasses(); + protected abstract void loadFunctions(); + protected abstract void loadRemappers(); + protected abstract void loadBlockades(); + protected abstract void loadFlags(); + + public abstract String getModuleName(); + public boolean isBiModule() { return false; } + public Set getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); } + public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; } + + protected boolean isModuleEnabled() { + return manager == null || manager.isModuleEnabled(this, keyType, valueType); + } + + protected boolean isModuleEnabled(String name) { + return manager == null || manager.isModuleEnabled(this, keyType, valueType, name); + } + + protected boolean isDependencyLoaded(BaseModule module) { + return isDependencyLoaded(module, true); + } + + protected boolean isDependencyLoaded(BaseModule module, boolean key) { + return manager == null || (module.isBiModule() ? manager.isModuleEnabled(module, keyType, valueType) : (key ? manager.isModuleEnabled(module, keyType, keyType) : manager.isModuleEnabled(module, valueType, valueType))); + } + + public boolean areDependenciesLoaded() { + return true; + } + + protected void addFlag(String name) { + entry.addFlag(name); + } + + protected void addKeyFlag(String name) { + entry.addFlag(name); + entry.addGlobalFlag(keyType.getCapType()+"_"+name); + } + + protected void addBiRequirement(String fileName) { + entry.addRequirement(fileName, RequiredType.BI_CLASS); + entry.addSplitter(fileName, "%1$s2%2$s"); + } + + protected void addEnumRequirement(String fileName) { + entry.addRequirement(fileName, RequiredType.ENUM); + entry.addSplitter(fileName, "%2$s"); + + } + + protected void addBiRequirement(String fileName, String splitter) { + entry.addRequirement(fileName, RequiredType.BI_CLASS); + entry.addSplitter(fileName, "%1$s"+splitter+"%2$s"); + } + + protected void addRequirement(String fileName, String splitter, RequiredType type) { + entry.addRequirement(fileName, type); + entry.addSplitter(fileName, splitter); + } + + protected void addRemapper(String fileName, String actualName) { + entry.addRemapper(fileName, actualName); + } + + protected void addBlockedFiles(String... name) { + entry.addBlockedFiles(name); + } + + protected void addBlockedFilter(Predicate filter) { + entry.addBlockedFilter(filter); + } + + protected void addClassMapper(String pattern, String replacement) { + entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+replacement)); + entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+replacement)); + } + + protected void addBiClassMapper(String pattern, String replacement, String splitter) { + entry.addMapper(new SimpleMapper("KEY_"+pattern, "KEY_"+pattern, keyType.getFileType()+splitter+keyType.getFileType()+replacement)); + entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement)); + entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+splitter+valueType.getFileType()+replacement)); + } + + protected void addAbstractMapper(String pattern, String replacement) { + entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getFileType()))); + entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType()))); + } + + protected void addAbstractBiMapper(String pattern, String replacement, String splitter) { + entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType()+splitter+valueType.getFileType()))); + } + + protected void addFunctionMapper(String pattern, String replacement) { + entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, replacement+valueType.getNonFileType())); + entry.addMapper(new SimpleMapper(pattern, pattern, replacement+keyType.getNonFileType())); + } + + protected void addFunctionValueMapper(String pattern, String replacement) { + entry.addMapper(new SimpleMapper(pattern, pattern, replacement+valueType.getNonFileType())); + } + + protected void addFunctionMappers(String pattern, String replacement) { + entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType()))); + entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getNonFileType()))); + } + + protected void addFunctionValueMappers(String pattern, String replacement) { + entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, valueType.getNonFileType()))); + } + + protected void addSimpleMapper(String pattern, String replacement) { + entry.addMapper(new SimpleMapper(pattern, pattern, replacement)); + } + + protected void addAnnontion(String pattern, String value) { + if(keyType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern)); + else entry.addMapper(new SimpleMapper(pattern, pattern, value)); + } + + protected void addValueAnnontion(String pattern, String value) { + if(valueType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern)); + else entry.addMapper(new SimpleMapper(pattern, pattern, value)); + } + + protected void addComment(String pattern, String value) { + if(keyType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces()); + else entry.addMapper(new LineMapper(pattern, pattern)); + } + + protected void addValueComment(String pattern, String value) { + if(valueType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces()); + else entry.addMapper(new LineMapper(pattern, pattern)); + } + + protected InjectMapper addInjectMapper(String pattern, String replacement) { + InjectMapper mapper = new InjectMapper(pattern, pattern, replacement); + entry.addMapper(mapper); + return mapper; + } + + protected ArgumentMapper addArgumentMapper(String pattern, String replacement) { + return addArgumentMapper(pattern, replacement, ", "); + } + + protected ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter) { + ArgumentMapper mapper = new ArgumentMapper(pattern, pattern, replacement, splitter); + entry.addMapper(mapper); + return mapper; + } +} diff --git a/src/builder/java/speiger/src/builder/modules/CollectionModule.java b/src/builder/java/speiger/src/builder/modules/CollectionModule.java new file mode 100644 index 00000000..4987a423 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/CollectionModule.java @@ -0,0 +1,128 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class CollectionModule extends BaseModule +{ + public static final BaseModule INSTANCE = new CollectionModule(); + + @Override + public String getModuleName() { return "Collection"; } + @Override + protected void loadVariables() {} + @Override + public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); } + + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) + { + return new TreeSet<>(Arrays.asList("Streams", "Splititerators", "IArray", "Strategy")); + } + + @Override + protected void loadFlags() { + if(isModuleEnabled()) addKeyFlag("COLLECTION_MODULE"); + if(isModuleEnabled("Streams")) addKeyFlag("STREAM_FEATURE"); + if(isModuleEnabled("Splititerators")) addKeyFlag("SPLIT_ITERATOR_FEATURE"); + if(isModuleEnabled("IArray")) addKeyFlag("IARRAY_FEATURE"); + } + + @Override + protected void loadBlockades() { + if(!isModuleEnabled()) { + addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator"); + addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack"); + } + if(!isModuleEnabled("Splititerators")) addBlockedFiles("Splititerator", "Splititerators"); + if(!isModuleEnabled("IArray")) addBlockedFiles("IArray"); + if(!isModuleEnabled("Strategy")) addBlockedFiles("Strategy"); + + if(keyType.isObject()) { + addBlockedFiles("Stack"); + addBlockedFiles("CollectionStreamTester"); + } + if(keyType == ClassType.BOOLEAN) { + addBlockedFiles("CollectionRemoveIfTester", "CollectionStreamTester"); + addBlockedFilter(T -> T.endsWith("Tester") && T.startsWith("Iterable")); + } + } + + @Override + protected void loadRemappers() + { + //Main Classes + addRemapper("IArray", "I%sArray"); + addRemapper("AbstractCollection", "Abstract%sCollection"); + + //Test Classes + addRemapper("AbstractIteratorTester", "Abstract%sIteratorTester"); + addRemapper("MinimalCollection", "Minimal%sCollection"); + addRemapper("TestCollectionGenerator", "Test%sCollectionGenerator"); + addRemapper("AbstractContainerTester", "Abstract%sContainerTester"); + addRemapper("AbstractCollectionTester", "Abstract%sCollectionTester"); + addRemapper("SimpleTestGenerator", "Simple%sTestGenerator"); + } + + @Override + protected void loadFunctions() + { + addFunctionMapper("NEXT", "next"); + addSimpleMapper("NEW_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getKeyType()+"Stream"); + addFunctionMapper("PREVIOUS", "previous"); + addFunctionMapper("REMOVE_KEY", "rem"); + addSimpleMapper("TO_ARRAY", "to"+keyType.getNonFileType()+"Array"); + addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array"); + } + + @Override + protected void loadClasses() + { + //Abstract Classes + addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection"); + + //Helper Classes + addClassMapper("ARRAYS", "Arrays"); + addClassMapper("COLLECTIONS", "Collections"); + addClassMapper("ITERABLES", "Iterables"); + addClassMapper("SPLIT_ITERATORS", "Splititerators"); + addClassMapper("ITERATORS", "Iterators"); + + //Interfaces + addClassMapper("COLLECTION", "Collection"); + addClassMapper("ITERABLE", "Iterable"); + addClassMapper("SPLIT_ITERATOR", "Splititerator"); + addClassMapper("LIST_ITERATOR", "ListIterator"); + addClassMapper("BI_ITERATOR", "BidirectionalIterator"); + addClassMapper("ITERATOR", "Iterator"); + if(keyType.isObject()) addSimpleMapper("STACK", "Stack"); + else addClassMapper("STACK", "Stack"); + addClassMapper("STRATEGY", "Strategy"); + } + + @Override + protected void loadTestClasses() + { + //Implementation Classes + addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection"); + addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester"); + addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester"); + addClassMapper("ITERATOR_TESTER", "IteratorTester"); + addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder"); + addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester"); + addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester"); + addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester"); + + //Helper Classes + addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator"); + addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator"); + + } +} diff --git a/src/builder/java/speiger/src/builder/modules/FunctionModule.java b/src/builder/java/speiger/src/builder/modules/FunctionModule.java new file mode 100644 index 00000000..2633e8ad --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/FunctionModule.java @@ -0,0 +1,73 @@ +package speiger.src.builder.modules; + +@SuppressWarnings("javadoc") +public class FunctionModule extends BaseModule +{ + public static final BaseModule INSTANCE = new FunctionModule(); + + @Override + public String getModuleName() { return "Function"; } + @Override + public boolean isBiModule() { return true; } + @Override + protected void loadVariables() {} + @Override + protected void loadFlags() {} + @Override + protected void loadTestClasses() {} + + @Override + protected void loadBlockades() + { + if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator"); + } + + @Override + protected void loadRemappers() + { + addBiRequirement("BiConsumer", ""); + addBiRequirement("UnaryOperator", ""); + addBiRequirement("Function"); + addRemapper("BiConsumer", "%sConsumer"); + } + + @Override + protected void loadFunctions() + { + addSimpleMapper("APPLY", keyType.getApply(valueType)); + } + + @Override + protected void loadClasses() + { + //Interfaces + addBiClassMapper("BI_CONSUMER", "Consumer", ""); + addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer"); + addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer"); + addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction"); + addBiClassMapper("FUNCTION", "Function", "2"); + addClassMapper("PREDICATE", "2BooleanFunction"); + addClassMapper("SUPPLIER", "Supplier"); + addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator"); + addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", ""); + if(keyType.isObject()) + { + if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer"); + else addSimpleMapper("VALUE_CONSUMER", "Consumer"); + addSimpleMapper("CONSUMER", "Consumer"); + addSimpleMapper("IARRAY", "IObjectArray"); + } + else + { + if(valueType.isObject()) + { + addSimpleMapper("VALUE_CONSUMER", "Consumer"); + addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer"); + } + else addClassMapper("CONSUMER", "Consumer"); + addFunctionMappers("IARRAY", "I%sArray"); + } + addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType())); + addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType())); + } +} \ No newline at end of file diff --git a/src/builder/java/speiger/src/builder/modules/JavaModule.java b/src/builder/java/speiger/src/builder/modules/JavaModule.java new file mode 100644 index 00000000..59e95844 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/JavaModule.java @@ -0,0 +1,204 @@ +package speiger.src.builder.modules; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class JavaModule extends BaseModule +{ + public static final BaseModule INSTANCE = new JavaModule(); + + @Override + public String getModuleName() { return "Base"; } + @Override + protected void loadVariables() + { + createHelperVars(keyType, false, "KEY"); + createHelperVars(valueType, true, "VALUE"); + loadBaseVariables(); + } + + @Override + protected void loadFlags() + { + addFlag("TYPE_"+keyType.getCapType()); + addFlag("VALUE_"+valueType.getCapType()); + if(keyType == valueType) addFlag("SAME_TYPE"); + if(keyType.hasFunction(valueType)) addFlag("JDK_FUNCTION"); + if(!keyType.needsCustomJDKType()) addFlag("JDK_TYPE"); + if(!keyType.isPrimitiveBlocking()) addFlag("PRIMITIVES"); + if(!valueType.isPrimitiveBlocking()) addFlag("VALUE_PRIMITIVES"); + if(valueType.needsCustomJDKType()) addFlag("JDK_VALUE"); + } + + @Override + protected void loadRemappers() {} + @Override + protected void loadBlockades() {} + + @Override + protected void loadFunctions() + { + addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType()); + addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType()); + addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType()); + + //Shared by Maps and Pairs so moved to java. + addFunctionMappers("ENTRY_KEY", "get%sKey"); + addFunctionValueMappers("ENTRY_VALUE", "get%sValue"); + addFunctionMappers("KEY_ENTRY", "set%sKey"); + addFunctionValueMappers("VALUE_ENTRY", "set%sValue"); + } + + @Override + protected void loadClasses() + { + addSimpleMapper("JAVA_PREDICATE", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Predicate"); + addSimpleMapper("JAVA_CONSUMER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Consumer"); + addSimpleMapper("JAVA_SUPPLIER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Supplier"); + addSimpleMapper("JAVA_FUNCTION", keyType.getFunctionClass(valueType)); + addSimpleMapper("JAVA_BINARY_OPERATOR", keyType == ClassType.BOOLEAN ? "" : (keyType.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"BinaryOperator")); + addSimpleMapper("JAVA_UNARY_OPERATOR", keyType.isObject() ? "BinaryOperator" : keyType == ClassType.BOOLEAN ? "" : keyType.getCustomJDKType().getFileType()+"UnaryOperator"); + addSimpleMapper("JAVA_SPLIT_ITERATOR", keyType.isPrimitiveBlocking() ? "Spliterator" : "Of"+keyType.getCustomJDKType().getFileType()); + addSimpleMapper("JAVA_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Stream"); + addSimpleMapper("JAVA_BUFFER", keyType.getFileType()+"Buffer"); + } + + @Override + protected void loadTestClasses() + { + addClassMapper("HELPERS", "Helpers"); + addClassMapper("SAMPLE_ELEMENTS", "Samples"); + } + + private void loadBaseVariables() + { + addSimpleMapper("VALUE_PACKAGE", valueType.getPathType()); + addSimpleMapper("PACKAGE", keyType.getPathType()); + addSimpleMapper("CLASS_TYPE", keyType.getClassType()); + addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType()); + addSimpleMapper("KEY_TYPE", keyType.getKeyType()); + addSimpleMapper("KEY_OBJECT_TYPE", keyType.isObject() ? "Object" : keyType.getKeyType()); + addSimpleMapper("KEY_STRING_TYPE", keyType.isObject() ? "String" : keyType.getKeyType()); + addSimpleMapper("KEY_SPECIAL_TYPE", keyType.isObject() ? "E" : keyType.getKeyType()); + addSimpleMapper("CLASS_OBJECT_TYPE", keyType.getClassType()); + addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType()); + addSimpleMapper("CLASS_STRING_TYPE", keyType.isObject() ? "String" : keyType.getClassType()); + addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType()); + addSimpleMapper("VALUE_TYPE", valueType.getValueType()); + addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType()); + addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType()); + addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType()); + addSimpleMapper("KEY_JAVA_TYPE", keyType.getCustomJDKType().getKeyType()); + addSimpleMapper("VALUE_JAVA_TYPE", keyType.getCustomJDKType().getKeyType()); + + addSimpleMapper("EMPTY_KEY_VALUE", keyType.getEmptyValue()); + addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue()); + + addSimpleMapper("INVALID_KEY_VALUE", keyType.getInvalidValue()); + addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue()); + + addSimpleMapper(" KEY_STRING_GENERIC_TYPE", keyType.isObject() ? "" : ""); + addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "" : ""); + addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "" : "") : (valueType.isObject() ? "" : "")); + + + addSimpleMapper(" KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+">" : ""); + addSimpleMapper(" KEY_KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", "+keyType.getKeyType()+">" : ""); + addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getClassType()+">" : ""); + + + addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : ""); + addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""); + addSimpleMapper(" VALUE_CLASS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getClassValueType()+">" : ""); + + addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : "")); + addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "")); + addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+keyType.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces(); + + addSimpleMapper(" NO_GENERIC_TYPE", keyType.isObject() ? "" : ""); + addSimpleMapper(" NO_KV_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "" : "") : valueType.isObject() ? "" : ""); + addSimpleMapper(" KEY_COMPAREABLE_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+" extends Comparable>" : ""); + + addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "" : ""); + addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "" : ""); + addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "" : "") : (valueType.isObject() ? "" : "")); + + addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? "" : ""); + addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "" : ""); + addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "" : "") : (valueType.isObject() ? "" : "")); + + addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : "")); + addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "")); + + addInjectMapper(" KEY_SPECIAL_GENERIC_TYPE", keyType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>"); + addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>"); + addInjectMapper(" KSK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>"); + addInjectMapper(" KKS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "<%s>").removeBraces().setBraceType("<>"); + addArgumentMapper(" KSS_GENERIC_TYPE", keyType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>"); + addInjectMapper(" VSV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "<%s>").removeBraces().setBraceType("<>"); + addInjectMapper(" VVS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>").removeBraces().setBraceType("<>"); + addArgumentMapper(" VSS_GENERIC_TYPE", valueType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>"); + + addSimpleMapper(" GENERIC_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+">" : ""); + addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : ""); + addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", keyType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>"); + addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>"); + addSimpleMapper(" GENERIC_KEY_ENUM_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : "")); + + addInjectMapper(" GENERIC_KEY_SPECIAL_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>"); + addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>"); + + addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+", "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : "")); + addSimpleMapper(" COMPAREABLE_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+" extends Comparable>" : ""); + addSimpleMapper("KV_BRACES", keyType.isObject() || valueType.isObject() ? "<>" : ""); + addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : ""); + addSimpleMapper("BRACES", keyType.isObject() ? "<>" : ""); + if(keyType.needsCustomJDKType()) + { + addSimpleMapper("JAVA_TYPE", keyType.getCustomJDKType().getKeyType()); + addSimpleMapper("SANITY_CAST", "castTo"+keyType.getFileType()); + } + addSimpleMapper("JAVA_CLASS", keyType.getCustomJDKType().getClassType()); + if(valueType.needsCustomJDKType()) + { + addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType()); + } + addSimpleMapper("[SPACE]", " "); + addComment("@ArrayType", "@param <%s> the keyType of array that the operation should be applied"); + addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection"); + addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied"); + addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection"); + addAnnontion("@PrimitiveOverride", "@Override"); + addSimpleMapper("@PrimitiveDoc", ""); + addAnnontion("@Primitive", "@Deprecated"); + addValueAnnontion("@ValuePrimitiveOverride", "@Override"); + addValueAnnontion("@ValuePrimitive", "@Deprecated"); + } + + private void createHelperVars(ClassType type, boolean value, String fix) + { + addArgumentMapper("EQUALS_"+fix+"_TYPE", "Objects.equals(%2$s, "+(type.isObject() ? "%1$s" : fix+"_TO_OBJ(%1$s)")+")").removeBraces(); + addInjectMapper(fix+"_EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces(); + addInjectMapper(fix+"_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces(); + addArgumentMapper(fix+"_EQUALS_NOT", type.getEquals(true)).removeBraces(); + addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces(); + addSimpleMapper("FILE_"+fix+"_TYPE", type.getFileType()); + + addArgumentMapper("COMPAREABLE_TO_"+fix, type.isObject() ? "((Comparable<"+type.getKeyType(value)+">)%1$s).compareTo(("+type.getKeyType(value)+")%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces(); + addArgumentMapper("COMPARE_TO_"+fix, type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces(); + + addInjectMapper(fix+"_TO_OBJ", type.isObject() ? "%s" : type.getClassType(value)+".valueOf(%s)").removeBraces(); + addInjectMapper("OBJ_TO_"+fix, type.isObject() ? "%s" : "%s."+type.getKeyType(value)+"Value()").removeBraces(); + addInjectMapper("CLASS_TO_"+fix, type.isObject() ? "("+type.getKeyType(value)+")%s" : "(("+type.getClassType(value)+")%s)."+type.getKeyType(value)+"Value()").removeBraces(); + + addInjectMapper(fix+"_TO_HASH", type.isObject() ? "Objects.hashCode(%s)" : type.getClassType(value)+".hashCode(%s)").removeBraces(); + addInjectMapper(fix+"_TO_STRING", type.isObject() ? "Objects.toString(%s)" : type.getClassType(value)+".toString(%s)").removeBraces(); + + addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : ""); + addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY"); + addInjectMapper("NEW_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces(); + addInjectMapper("NEW_SPECIAL_"+fix+"_ARRAY", type.isObject() ? "(E[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces(); + if(value) addInjectMapper("NEW_CLASS_VALUE_ARRAY", type.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces(); + else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces(); + } +} diff --git a/src/builder/java/speiger/src/builder/modules/ListModule.java b/src/builder/java/speiger/src/builder/modules/ListModule.java new file mode 100644 index 00000000..ef53f845 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/ListModule.java @@ -0,0 +1,115 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class ListModule extends BaseModule +{ + public static final BaseModule INSTANCE = new ListModule(); + + @Override + public String getModuleName() { return "List"; } + @Override + protected void loadVariables() {} + @Override + protected void loadFlags() { + if(isModuleEnabled()) addKeyFlag("LIST_MODULE"); + if(isModuleEnabled("Wrappers")) addKeyFlag("LISTS_FEATURE"); + boolean implementations = isModuleEnabled("Implementations"); + if(implementations && isModuleEnabled("ArrayList")) addKeyFlag("ARRAY_LIST_FEATURE"); + if(implementations && isModuleEnabled("LinkedList")) addKeyFlag("LINKED_LIST_FEATURE"); + if(implementations && isModuleEnabled("ImmutableList")) addKeyFlag("IMMUTABLE_LIST_FEATURE"); + if(implementations && isModuleEnabled("CopyOnWriteList")) addKeyFlag("COPY_ON_WRITE_LIST_FEATURE"); + } + + @Override + protected void loadBlockades() + { + if(!isModuleEnabled("Wrappers")) addBlockedFiles("Lists"); + boolean implementations = !isModuleEnabled("Implementations"); + if(implementations || !isModuleEnabled("ArrayList")) addBlockedFiles("ArrayList"); + if(implementations || !isModuleEnabled("LinkedList")) addBlockedFiles("LinkedList"); + if(implementations || !isModuleEnabled("ImmutableList")) addBlockedFiles("ImmutableList"); + if(implementations || !isModuleEnabled("CopyOnWriteList")) addBlockedFiles("CopyOnWriteList"); + if(!isModuleEnabled()) addBlockedFiles("List", "AbstractList"); + + if(keyType.isObject()) addBlockedFiles("ListFillBufferTester"); + if(keyType == ClassType.BOOLEAN) addBlockedFiles("ListFillBufferTester", "ListReplaceAllTester"); + } + + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { + return new TreeSet<>(Arrays.asList("Implementations", "Wrappers", "ArrayList", "LinkedList", "ImmutableList", "CopyOnWriteList")); + } + + @Override + public boolean areDependenciesLoaded() { + return isDependencyLoaded(CollectionModule.INSTANCE); + } + + @Override + protected void loadRemappers() + { + //Main Classes + addRemapper("AbstractList", "Abstract%sList"); + addRemapper("ImmutableList", "Immutable%sList"); + addRemapper("CopyOnWriteList", "CopyOnWrite%sArrayList"); + + //Test Classes + addRemapper("AbstractListTester", "Abstract%sListTester"); + addRemapper("AbstractListIndexOfTester", "Abstract%sListIndexOfTester"); + addRemapper("TestListGenerator", "Test%sListGenerator"); + } + + @Override + protected void loadFunctions() + { + addFunctionMapper("GET_KEY", "get"); + addFunctionMapper("REMOVE_LAST", "removeLast"); + addFunctionMapper("REMOVE_SWAP", "swapRemove"); + addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss"); + addFunctionMappers("SORT", "sort%ss"); + } + + @Override + protected void loadClasses() + { + //Implementation Classes + addClassMapper("ARRAY_LIST", "ArrayList"); + addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList"); + addClassMapper("LINKED_LIST", "LinkedList"); + addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_LIST", "Abstract%sList"); + + //SubClasses + addClassMapper("SUB_LIST", "SubList"); + addClassMapper("LIST_ITER", "ListIter"); + + //Helper Classes + addClassMapper("LISTS", "Lists"); + + //Interfaces + addClassMapper("LIST", "List"); + } + + @Override + protected void loadTestClasses() + { + //Implementation Classes + addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder"); + addClassMapper("LIST_TESTS", "ListTests"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester"); + addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester"); + + //Helper classes + addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator"); + } +} \ No newline at end of file diff --git a/src/builder/java/speiger/src/builder/modules/MapModule.java b/src/builder/java/speiger/src/builder/modules/MapModule.java new file mode 100644 index 00000000..f325adc2 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/MapModule.java @@ -0,0 +1,282 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class MapModule extends BaseModule +{ + public static final BaseModule INSTANCE = new MapModule(); + + @Override + public String getModuleName() { return "Map"; } + @Override + public boolean isBiModule() { return true; } + @Override + protected void loadVariables() {} + @Override + public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } + @Override + public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); } + + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { + Set sets = new TreeSet<>(); + sets.addAll(Arrays.asList("Wrappers", "Implementations")); + sets.addAll(Arrays.asList("OrderedMap", "SortedMap")); + sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap")); + sets.addAll(Arrays.asList("HashMap", "LinkedHashMap")); + sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap")); + sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap")); + sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap")); + return sets; + } + + @Override + protected void loadFlags() + { + if(isModuleEnabled()) addFlag("MAP_MODULE"); + if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE"); + boolean implementations = isModuleEnabled("Implementations"); + boolean hashMap = implementations && isModuleEnabled("HashMap"); + boolean customHashMap = implementations && isModuleEnabled("CustomHashMap"); + boolean enumMap = implementations && isModuleEnabled("EnumMap"); + + if(isModuleEnabled("OrderedMap")) { + addFlag("ORDERED_MAP_FEATURE"); + if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE"); + if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE"); + if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE"); + if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE"); + } + if(isModuleEnabled("SortedMap")) { + addFlag("SORTED_MAP_FEATURE"); + if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE"); + if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE"); + } + if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE"); + if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE"); + if(hashMap) addFlag("HASH_MAP_FEATURE"); + if(customHashMap) addFlag("CUSTOM_HASH_MAP_FEATURE"); + if(enumMap) addFlag("ENUM_MAP_FEATURE"); + } + + @Override + protected void loadBlockades() + { + if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap"); + if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps"); + boolean implementations = !isModuleEnabled("Implementations"); + if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap"); + if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap"); + + boolean ordered = !isModuleEnabled("OrderedMap"); + if(ordered) addBlockedFiles("OrderedMap"); + boolean hashMap = implementations || !isModuleEnabled("HashMap"); + if(hashMap) addBlockedFiles("OpenHashMap"); + if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap"); + + boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap"); + if(customHashMap) addBlockedFiles("OpenCustomHashMap"); + if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap"); + + boolean enumMap = implementations || !isModuleEnabled("EnumMap"); + if(enumMap) addBlockedFiles("EnumMap"); + if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap"); + + if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap"); + + boolean sorted = !isModuleEnabled("SortedMap"); + if(sorted) addBlockedFiles("SortedMap", "NavigableMap"); + if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap"); + if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap"); + + if(keyType == ClassType.BOOLEAN) + { + //Main Classes + addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap"); + addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap"); + addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap"); + addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap"); + + //Test Classes + addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester"); + addBlockedFiles("TestSortedMapGenerator", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder"); + addBlockedFiles("TestOrderedMapGenerator"); + addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap"))); + } + } + + @Override + protected void loadRemappers() + { + //Main Classes + addBiRequirement("Map"); + addBiRequirement("SortedMap"); + addBiRequirement("OrderedMap"); + addBiRequirement("NavigableMap"); + addBiRequirement("ConcurrentMap"); + addBiRequirement("AbstractMap"); + addEnumRequirement("EnumMap"); + addEnumRequirement("LinkedEnumMap"); + addBiRequirement("ConcurrentOpenHashMap"); + addBiRequirement("ImmutableOpenHashMap"); + addBiRequirement("OpenHashMap"); + addBiRequirement("LinkedOpenHashMap"); + addBiRequirement("OpenCustomHashMap"); + addBiRequirement("LinkedOpenCustomHashMap"); + addBiRequirement("ArrayMap"); + addBiRequirement("RBTreeMap"); + addBiRequirement("AVLTreeMap"); + addBiRequirement("Maps"); + + addRemapper("AbstractMap", "Abstract%sMap"); + addRemapper("EnumMap", "Enum2%sMap"); + addRemapper("LinkedEnumMap", "LinkedEnum2%sMap"); + addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap"); + + //Test Classes + addBiRequirement("TestMapGenerator"); + addBiRequirement("TestSortedMapGenerator"); + addBiRequirement("TestOrderedMapGenerator"); + addBiRequirement("SimpleMapTestGenerator"); + addBiRequirement("DerivedMapGenerators"); + addBiRequirement("AbstractMapTester"); + addBiRequirement("MapTestSuiteBuilder"); + addBiRequirement("SortedMapTestSuiteBuilder"); + addBiRequirement("NavigableMapTestSuiteBuilder"); + addBiRequirement("OrderedMapTestSuiteBuilder"); + addBiRequirement("MapTests"); + addBiRequirement("MapConstructorTests"); + addBiRequirement("TestMap"); + addBiRequirement("MapAddToTester"); + addBiRequirement("MapSubFromTester"); + addBiRequirement("MapClearTester"); + addBiRequirement("MapComputeIfAbsentTester"); + addBiRequirement("MapComputeIfPresentTester"); + addBiRequirement("MapComputeTester"); + addBiRequirement("MapCopyTester"); + addBiRequirement("MapContainsTester"); + addBiRequirement("MapContainsKeyTester"); + addBiRequirement("MapContainsValueTester"); + addBiRequirement("MapCreatorTester"); + addBiRequirement("MapEntrySetTester"); + addBiRequirement("MapEqualsTester"); + addBiRequirement("MapForEachTester"); + addBiRequirement("MapGetOrDefaultTester"); + addBiRequirement("MapGetTester"); + addBiRequirement("MapHashCodeTester"); + addBiRequirement("MapIsEmptyTester"); + addBiRequirement("MapMergeTester"); + addBiRequirement("MapMergeBulkTester"); + addBiRequirement("MapPutAllArrayTester"); + addBiRequirement("MapPutAllTester"); + addBiRequirement("MapPutIfAbsentTester"); + addBiRequirement("MapPutTester"); + addBiRequirement("MapRemoveEntryTester"); + addBiRequirement("MapRemoveOrDefaultTester"); + addBiRequirement("MapRemoveTester"); + addBiRequirement("MapReplaceAllTester"); + addBiRequirement("MapReplaceEntryTester"); + addBiRequirement("MapReplaceTester"); + addBiRequirement("MapSizeTester"); + addBiRequirement("MapSupplyIfAbsentTester"); + addBiRequirement("MapToStringTester"); + addBiRequirement("NavigableMapNavigationTester"); + addBiRequirement("SortedMapNavigationTester"); + addBiRequirement("OrderedMapNavigationTester"); + addBiRequirement("OrderedMapMoveTester"); + addBiRequirement("MapConstructorTester"); + + addRemapper("TestMapGenerator", "Test%sMapGenerator"); + addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator"); + addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator"); + addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator"); + addRemapper("DerivedMapGenerators", "Derived%sMapGenerators"); + addRemapper("AbstractMapTester", "Abstract%sMapTester"); + addRemapper("TestMap", "Test%sMap"); + } + + @Override + protected void loadFunctions() + { + addFunctionValueMapper("BULK_MERGE", "mergeAll"); + addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent"); + addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent"); + addFunctionValueMapper("COMPUTE", "compute"); + addFunctionMapper("DEQUEUE_LAST", "dequeueLast"); + addFunctionMapper("DEQUEUE", "dequeue"); + addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet"); + addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey"); + addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue"); + if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get"); + else addSimpleMapper("GET_VALUE", "get"); + addSimpleMapper("GET_JAVA", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType()); + addFunctionMappers("LAST_ENTRY_KEY", "last%sKey"); + addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue"); + addFunctionValueMapper("MERGE", "merge"); + addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey"); + addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey"); + if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem"); + else addSimpleMapper("REMOVE_VALUE", "remove"); + addFunctionMapper("REMOVE", "remove"); + addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss"); + addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent"); + } + + @Override + protected void loadClasses() + { + //Implementation Classes + addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2"); + addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2"); + addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2"); + addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2"); + addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2"); + addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2"); + addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2"); + addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap"); + addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap"); + addBiClassMapper("HASH_MAP", "OpenHashMap", "2"); + addBiClassMapper("ARRAY_MAP", "ArrayMap", "2"); + + //Abstract Classes + addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2"); + + //Helper Classes + addBiClassMapper("MAPS", "Maps", "2"); + + //Interfaces + addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2"); + addBiClassMapper("ORDERED_MAP", "OrderedMap", "2"); + addBiClassMapper("SORTED_MAP", "SortedMap", "2"); + addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2"); + addBiClassMapper("MAP", "Map", "2"); + } + + @Override + protected void loadTestClasses() + { + //Implementation Classes + addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2"); + addBiClassMapper("MAP_TESTS", "MapTests", "2"); + addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2"); + addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2"); + addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2"); + addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2"); + + //Abstract Classes + addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2"); + + //Helper Classes + addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2"); + addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2"); + addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2"); + addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2"); + addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2"); + addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2"); + } +} \ No newline at end of file diff --git a/src/builder/java/speiger/src/builder/modules/PairModule.java b/src/builder/java/speiger/src/builder/modules/PairModule.java new file mode 100644 index 00000000..b17efbc7 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/PairModule.java @@ -0,0 +1,60 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class PairModule extends BaseModule +{ + public static final BaseModule INSTANCE = new PairModule(); + @Override + public String getModuleName() { return "Pair"; } + @Override + public boolean isBiModule() { return true; } + @Override + protected void loadVariables() {} + @Override + protected void loadFunctions() {} + @Override + protected void loadTestClasses() {} + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { return new TreeSet<>(Arrays.asList("Mutable", "Immutable")); } + + @Override + protected void loadFlags() { + if(isModuleEnabled()) addFlag("PAIR_MODULE"); + if(isModuleEnabled("Mutable")) addFlag("MUTABLE_PAIR"); + if(isModuleEnabled("Immutable")) addFlag("IMMUTABLE_PAIR"); + } + + @Override + protected void loadBlockades() { + if(!isModuleEnabled()) addBlockedFiles("Pair"); + if(!isModuleEnabled("Mutable")) addBlockedFiles("MutablePair"); + if(!isModuleEnabled("Immutable")) addBlockedFiles("ImmutablePair"); + } + + @Override + protected void loadRemappers() { + //Main Classes + addBiRequirement("Pair", ""); + addBiRequirement("MutablePair", ""); + addBiRequirement("ImmutablePair", ""); + + //Test Classes + addBiRequirement("PairTester", ""); + } + + @Override + protected void loadClasses() { + //Implementations + addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", ""); + addBiClassMapper("MUTABLE_PAIR", "MutablePair", ""); + + //Interfaces + addBiClassMapper("PAIR", "Pair", ""); + } +} \ No newline at end of file diff --git a/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java new file mode 100644 index 00000000..d8cba687 --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/PrioQueueModule.java @@ -0,0 +1,101 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class PrioQueueModule extends BaseModule +{ + public static final BaseModule INSTANCE = new PrioQueueModule(); + + @Override + public String getModuleName() { return "PriorityQueue"; } + @Override + protected void loadVariables() {} + @Override + protected void loadFunctions() {} + @Override + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { + return new TreeSet<>(Arrays.asList("Wrappers", "Implementations", "Dequeue", "FiFoQueue", "HeapQueue", "ArrayPrioQueue")); + } + + @Override + protected void loadFlags() { + if(isModuleEnabled()) addFlag("QUEUE_MODULE"); + if(isModuleEnabled("Wrappers")) addKeyFlag("QUEUES_FEATURE"); + boolean implementations = isModuleEnabled("Implementations"); + if(isModuleEnabled("Dequeue")) { + addKeyFlag("DEQUEUE_FEATURE"); + if(implementations && isModuleEnabled("FiFoQueue")) addKeyFlag("FIFO_QUEUE_FEATURE"); + } + if(implementations && isModuleEnabled("HeapQueue")) addKeyFlag("HEAP_QUEUE_FEATURE"); + if(implementations && isModuleEnabled("ArrayPrioQueue")) addKeyFlag("ARRAY_QUEUE_FEATURE"); + } + + @Override + protected void loadBlockades() { + if(!isModuleEnabled()) addBlockedFiles("PriorityQueue", "AbstractPriorityQueue"); + if(!isModuleEnabled("Wrappers")) addBlockedFiles("PriorityQueues"); + boolean implementations = !isModuleEnabled("Implementations"); + boolean dequeue = !isModuleEnabled("Dequeue"); + if(dequeue) addBlockedFiles("PriorityDequeue"); + if(dequeue || implementations || !isModuleEnabled("FiFoQueue")) addBlockedFiles("ArrayFIFOQueue"); + if(implementations || !isModuleEnabled("HeapQueue")) addBlockedFiles("HeapPriorityQueue"); + if(implementations || !isModuleEnabled("ArrayPrioQueue")) addBlockedFiles("ArrayPriorityQueue"); + + if(keyType == ClassType.BOOLEAN) { + addBlockedFiles("QueueTests"); + } + } + + @Override + protected void loadRemappers() { + //Main Classes + addRemapper("AbstractPriorityQueue", "Abstract%sPriorityQueue"); + + //Test Classes + addRemapper("TestQueueGenerator", "Test%sQueueGenerator"); + addRemapper("AbstractQueueTester", "Abstract%sQueueTester"); + addRemapper("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator"); + } + + @Override + protected void loadClasses() { + //Implementation Classes + addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue"); + addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue"); + addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue"); + + //Helper Classes + addClassMapper("PRIORITY_QUEUES", "PriorityQueues"); + + //Interfaces + addClassMapper("PRIORITY_QUEUE", "PriorityQueue"); + addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue"); + } + + @Override + protected void loadTestClasses() + { + //Implementation Classes + addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder"); + addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder"); + addClassMapper("QUEUE_TESTS", "QueueTests"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester"); + + //Helper Classes + addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator"); + addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator"); + } +} diff --git a/src/builder/java/speiger/src/builder/modules/SetModule.java b/src/builder/java/speiger/src/builder/modules/SetModule.java new file mode 100644 index 00000000..6e06b98b --- /dev/null +++ b/src/builder/java/speiger/src/builder/modules/SetModule.java @@ -0,0 +1,173 @@ +package speiger.src.builder.modules; + +import java.util.Arrays; +import java.util.Set; +import java.util.TreeSet; + +import speiger.src.builder.ClassType; + +@SuppressWarnings("javadoc") +public class SetModule extends BaseModule +{ + public static final BaseModule INSTANCE = new SetModule(); + + @Override + public String getModuleName() { return "Set"; } + @Override + protected void loadVariables() {} + + @Override + public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; } + @Override + public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); } + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) { + Set sets = new TreeSet<>(); + sets.addAll(Arrays.asList("Wrappers", "Implementations")); + sets.addAll(Arrays.asList("OrderedSet", "SortedSet")); + sets.addAll(Arrays.asList("ArraySet", "ImmutableSet")); + sets.addAll(Arrays.asList("HashSet", "LinkedHashSet")); + sets.addAll(Arrays.asList("CustomHashSet", "LinkedCustomHashSet")); + sets.addAll(Arrays.asList("AVLTreeSet", "RBTreeSet")); + return sets; + } + + @Override + protected void loadFlags() + { + if(isModuleEnabled()) addFlag("SET_MODULE"); + if(isModuleEnabled("Wrappers")) addFlag("SETS_FEATURE"); + boolean implementations = isModuleEnabled("Implementations"); + boolean hashSet = implementations && isModuleEnabled("HashSet"); + boolean customHashSet = implementations && isModuleEnabled("CustomHashSet"); + + if(isModuleEnabled("OrderedSet")) { + addFlag("ORDERED_SET_FEATURE"); + if(implementations && isModuleEnabled("ArraySet")) addFlag("ARRAY_SET_FEATURE"); + if(hashSet && isModuleEnabled("LinkedHashSet")) addFlag("LINKED_SET_FEATURE"); + if(customHashSet && isModuleEnabled("LinkedCustomHashSet")) addFlag("LINKED_CUSTOM_SET_FEATURE"); + } + if(isModuleEnabled("SortedSet")) { + addFlag("SORTED_SET_FEATURE"); + if(implementations && isModuleEnabled("AVLTreeSet")) addFlag("AVL_TREE_SET_FEATURE"); + if(implementations && isModuleEnabled("RBTreeSet")) addFlag("RB_TREE_SET_FEATURE"); + } + if(implementations && isModuleEnabled("ImmutableSet")) addFlag("IMMUTABLE_SET_FEATURE"); + if(hashSet) addFlag("HASH_SET_FEATURE"); + if(customHashSet) addFlag("CUSTOM_HASH_SET_FEATURE"); + } + + @Override + protected void loadBlockades() + { + if(!isModuleEnabled()) addBlockedFiles("Set", "AbstractSet"); + if(!isModuleEnabled("Wrappers")) addBlockedFiles("Sets"); + boolean implementations = !isModuleEnabled("Implementations"); + if(implementations || !isModuleEnabled("ImmutableSet")) addBlockedFiles("ImmutableOpenHashSet"); + + boolean ordered = !isModuleEnabled("OrderedSet"); + if(ordered) addBlockedFiles("OrderedSet"); + boolean hashSet = implementations || !isModuleEnabled("HashSet"); + if(hashSet) addBlockedFiles("OpenHashSet"); + if(hashSet || ordered || !isModuleEnabled("LinkedHashSet")) addBlockedFiles("LinkedOpenHashSet"); + + boolean customHashSet = implementations || !isModuleEnabled("CustomHashSet"); + if(customHashSet) addBlockedFiles("OpenCustomHashSet"); + if(customHashSet || ordered || !isModuleEnabled("LinkedCustomHashSet")) addBlockedFiles("LinkedOpenCustomHashSet"); + + if(implementations || ordered || !isModuleEnabled("ArraySet")) addBlockedFiles("ArraySet"); + + boolean sorted = !isModuleEnabled("SortedSet"); + if(sorted) addBlockedFiles("SortedSet", "NavigableSet"); + if(implementations || sorted || !isModuleEnabled("AVLTreeSet")) addBlockedFiles("AVLTreeSet"); + if(implementations || sorted || !isModuleEnabled("RBTreeSet")) addBlockedFiles("RBTreeSet"); + + if(keyType == ClassType.BOOLEAN) + { + //Main Classes + addBlockedFiles("SortedSet", "NavigableSet", "AVLTreeSet", "RBTreeSet"); + addBlockedFiles("OrderedSet", "ArraySet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet"); + addBlockedFiles("Set", "Sets", "AbstractSet", "OpenHashSet", "OpenCustomHashSet", "ImmutableOpenHashSet"); + + //Test Classes + addBlockedFiles("SetTests", "SetTestSuiteBuilder"); + addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedSetIterationTester"); + addBlockedFiles("SortedSetTestSuiteBuilder", "TestSortedSetGenerator", "SortedSetNaviationTester", "SortedSetSubsetTestSetGenerator", "SortedSetIterationTester", "SortedSetNaviationTester"); + addBlockedFiles("NavigableSetTestSuiteBuilder", "TestNavigableSetGenerator", "NavigableSetNavigationTester"); + } + } + + @Override + protected void loadRemappers() + { + //Main Classes + addRemapper("AbstractSet", "Abstract%sSet"); + addRemapper("ImmutableOpenHashSet", "Immutable%sOpenHashSet"); + + //Test Classes + addRemapper("MinimalSet", "Minimal%sSet"); + addRemapper("TestNavigableSetGenerator", "Test%sNavigableSetGenerator"); + addRemapper("TestSortedSetGenerator", "Test%sSortedSetGenerator"); + addRemapper("TestOrderedSetGenerator", "Test%sOrderedSetGenerator"); + addRemapper("TestSetGenerator", "Test%sSetGenerator"); + addRemapper("AbstractSetTester", "Abstract%sSetTester"); + } + + @Override + protected void loadFunctions() + { + addFunctionMapper("POLL_FIRST_KEY", "pollFirst"); + addFunctionMapper("POLL_LAST_KEY", "pollLast"); + addFunctionMapper("FIRST_KEY", "first"); + addFunctionMapper("LAST_KEY", "last"); + } + + @Override + protected void loadTestClasses() + { + //Implementation Classes + addAbstractMapper("MINIMAL_SET", "Minimal%sSet"); + addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder"); + addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder"); + addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder"); + addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder"); + addClassMapper("SET_TESTS", "SetTests"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester"); + + //Helper Classes + addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator"); + addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator"); + addAbstractMapper("TEST_NAVIGABLE_SET_GENERATOR", "Test%sNavigableSetGenerator"); + addAbstractMapper("TEST_SORTED_SET_GENERATOR", "Test%sSortedSetGenerator"); + addAbstractMapper("TEST_ORDERED_SET_GENERATOR", "Test%sOrderedSetGenerator"); + addAbstractMapper("TEST_SET_GENERATOR", "Test%sSetGenerator"); + } + + @Override + protected void loadClasses() + { + //Implementation Classes + addClassMapper("LINKED_CUSTOM_HASH_SET", "LinkedOpenCustomHashSet"); + addClassMapper("LINKED_HASH_SET", "LinkedOpenHashSet"); + addAbstractMapper("IMMUTABLE_HASH_SET", "Immutable%sOpenHashSet"); + addClassMapper("CUSTOM_HASH_SET", "OpenCustomHashSet"); + addClassMapper("HASH_SET", "OpenHashSet"); + addClassMapper("RB_TREE_SET", "RBTreeSet"); + addClassMapper("AVL_TREE_SET", "AVLTreeSet"); + addClassMapper("ARRAY_SET", "ArraySet"); + + //Abstract Classes + addAbstractMapper("ABSTRACT_SET", "Abstract%sSet"); + + //Helper Classes + addClassMapper("SETS", "Sets"); + + //Interfaces + addClassMapper("NAVIGABLE_SET", "NavigableSet"); + addClassMapper("SORTED_SET", "SortedSet"); + addClassMapper("ORDERED_SET", "OrderedSet"); + addClassMapper("SET", "Set"); + } +} diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template index f3154cb9..efcbf6b8 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Collection.template @@ -5,16 +5,20 @@ import java.util.Collection; import java.util.Objects; import java.util.function.JAVA_PREDICATE; import java.util.function.Predicate; +#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE import java.util.stream.JAVA_STREAM; import java.util.stream.StreamSupport; #endif +#endif #if TYPE_OBJECT import java.util.function.Consumer; import speiger.src.collections.ints.functions.function.Int2ObjectFunction; #else import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif +#if SPLIT_ITERATOR_FEATURE import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; +#endif import speiger.src.collections.PACKAGE.utils.COLLECTIONS; import speiger.src.collections.utils.ISizeProvider; import speiger.src.collections.utils.SanityChecks; @@ -179,7 +183,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection, ITE * @see Collection#toArray(Object[]) */ default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction action) { - return TO_ARRAY(action.get(size())); + return TO_ARRAY(action.apply(size())); } #else @@ -291,6 +295,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection, ITE */ public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); } +#if SPLIT_ITERATOR_FEATURE #if PRIMITIVES /** * Returns a Java-Type-Specific Stream to reduce boxing/unboxing. @@ -303,11 +308,15 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection, ITE * @return a Stream of the closest java type */ default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); } + #endif +#if STREAM_FEATURE /** * A Type Specific Type Splititerator to reduce boxing/unboxing * @return type specific splititerator */ @Override default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); } +#endif +#endif } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template index 38ac2290..0c0fd314 100644 --- a/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template +++ b/src/builder/resources/speiger/assets/collections/templates/collections/Iterable.template @@ -17,16 +17,46 @@ import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE import speiger.src.collections.PACKAGE.lists.LIST; +#if ARRAY_LIST_FEATURE import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -#if !TYPE_BOOLEAN -import speiger.src.collections.PACKAGE.sets.SET; -import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; +#else +import speiger.src.collections.PACKAGE.lists.LINKED_LIST; #endif +#endif +#if SET_MODULE && !TYPE_BOOLEAN +#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.SET; +#if LINKED_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; +#else if LINKED_CUSTOM_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET; +#else if SET_FEATURE +import speiger.src.collections.PACKAGE.sets.HASH_SET; +#else if CUSTOM_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET; +#else if RB_TREE_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.RB_TREE_SET; +#else if AVL_TREE_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET; +#else if ARRAY_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.ARRAY_SET; +#endif +#endif +#endif +import speiger.src.collections.PACKAGE.utils.ARRAYS; +#if ASYNC_MODULE import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER; +#endif +#if SPLIT_ITERATOR_FEATURE import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; +#endif import speiger.src.collections.PACKAGE.utils.ITERABLES; import speiger.src.collections.PACKAGE.utils.ITERATORS; +#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE +import speiger.src.collections.PACKAGE.utils.STRATEGY; +#endif import speiger.src.collections.utils.ISizeProvider; /** @@ -86,6 +116,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable iterator().forEachRemaining(input, action); } +#if SPLIT_ITERATOR_FEATURE /** * A Type Specific Type Splititerator to reduce boxing/unboxing * @return type specific splititerator @@ -93,6 +124,8 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable @Override default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); } +#endif +#if ASYNC_MODULE /** * Creates a Async Builder for moving work of the thread. * It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread. @@ -103,6 +136,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable return new ASYNC_BUILDERBRACES(this); } +#endif /** * A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else. * @param mapper the mapping function @@ -202,25 +236,46 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable return collection; } +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE /** * A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList * @return a new ArrayList of all elements */ default LIST KEY_GENERIC_TYPE pourAsList() { - return pour(new ARRAY_LISTBRACES()); +#if ARRAY_LIST_FEATURE + return pour(new ARRAY_LISTBRACES()); +#else + return pour(new LINKED_LISTBRACES()); +#endif } -#if !TYPE_BOOLEAN +#endif +#if !TYPE_BOOLEAN && SET_MODULE +#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE /** * A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet * @return a new LinkedHashSet of all elements */ default SET KEY_GENERIC_TYPE pourAsSet() { - return pour(new LINKED_HASH_SETBRACES()); +#if LINKED_SET_FEATURE + return pour(new LINKED_HASH_SETBRACES()); +#else if LINKED_CUSTOM_SET_FEATURE + return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy())); +#else if SET_FEATURE + return pour(new HASH_SETBRACES()); +#else if CUSTOM_SET_FEATURE + return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy())); +#else if RB_TREE_SET_FEATURE + return pour(new RB_Tree_SETBRACES()); +#else if AVL_TREE_SET_FEATURE + return pour(new AVL_Tree_SETBRACES()); +#else if ARRAY_SET_FEATURE + return pour(new ARRAY_SETBRACES()); +#endif } #endif - +#endif #if TYPE_OBJECT /** * A Helper function that reduces the usage of streams and allows to collect all elements as a Array @@ -232,12 +287,12 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable if(prov != null) { int size = prov.size(); if(size >= 0) { - KEY_TYPE[] array = action.get(size); + KEY_TYPE[] array = action.apply(size); ITERATORS.unwrap(array, iterator()); return array; } } - return ITERATORS.pour(iterator()).TO_ARRAY(action); + return ARRAYS.pour(iterator(), action); } #else /** @@ -254,7 +309,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable return array; } } - return ITERATORS.pour(iterator()).TO_ARRAY(); + return ARRAYS.pour(iterator()); } #endif @@ -266,7 +321,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { - if(filter.TEST_VALUE(iter.NEXT())) return true; + if(filter.test(iter.NEXT())) return true; } return false; } @@ -279,7 +334,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { - if(filter.TEST_VALUE(iter.NEXT())) return false; + if(filter.test(iter.NEXT())) return false; } return true; } @@ -292,7 +347,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { - if(!filter.TEST_VALUE(iter.NEXT())) return false; + if(!filter.test(iter.NEXT())) return false; } return true; } @@ -306,7 +361,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable Objects.requireNonNull(filter); for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { KEY_TYPE entry = iter.NEXT(); - if(filter.TEST_VALUE(entry)) return entry; + if(filter.test(entry)) return entry; } return EMPTY_VALUE; } @@ -377,7 +432,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable Objects.requireNonNull(filter); int result = 0; for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { - if(filter.TEST_VALUE(iter.NEXT())) result++; + if(filter.test(iter.NEXT())) result++; } return result; } diff --git a/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template b/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template index e43c825a..d7ed74c3 100644 --- a/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template +++ b/src/builder/resources/speiger/assets/collections/templates/functions/function/Function.template @@ -21,12 +21,9 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE * @param k the value that should be processed * @return the result of the function */ - public VALUE_TYPE GET_VALUE(KEY_TYPE k); + public VALUE_TYPE APPLY(KEY_TYPE k); -#if JDK_FUNCTION -#if VALUE_BOOLEAN - @Override - public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); } +#if JDK_FUNCTION && VALUE_BOOLEAN /** * A Type specific and-function helper function that reduces boxing/unboxing @@ -35,19 +32,19 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE */ 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); + return T -> APPLY(T) && other.APPLY(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); + return T -> APPLY(T) && other.APPLY(T); } @Override public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() { - return T -> !GET_VALUE(T); + return T -> !APPLY(T); } /** @@ -57,23 +54,14 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE */ 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); + return T -> APPLY(T) || other.APPLY(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); + return T -> APPLY(T) || other.APPLY(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 } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template index 1ec1b2b6..020f9dbd 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/ArrayList.template @@ -8,7 +8,10 @@ import java.util.Collection; import java.util.Iterator; import java.util.Objects; #if TYPE_OBJECT +#if IARRAY_FEATURE || TYPE_OBJECT import java.util.function.Consumer; +#endif + import java.util.function.BiFunction; #endif import java.util.function.Predicate; @@ -38,33 +41,38 @@ import speiger.src.collections.utils.Stack; #else import speiger.src.collections.objects.utils.ObjectArrays; #endif -#if PRIMITIVES +#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE import java.util.stream.JAVA_STREAM; import java.util.stream.StreamSupport; #endif +#if IARRAY_FEATURE import speiger.src.collections.PACKAGE.utils.IARRAY; +#endif +#if SPLIT_ITERATOR_FEATURE import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; +#endif +#if !IARRAY_FEATURE +import speiger.src.collections.utils.IArray; +#endif import speiger.src.collections.utils.SanityChecks; -#if TYPE_OBJECT /** * A Type-Specific Array-based implementation of list that is written to reduce (un)boxing * - *

This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link Stack} +#if IARRAY_FEATURE + *

This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK} +#else + *

This implementation is optimized to improve how data is processed with interfaces like {@link IArray}, {@link STACK} +#endif * and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions. - * + * * @Type(T) */ -public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY, Stack +#if IARRAY_FEATURE +public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE #else -/** - * A Type-Specific Array-based implementation of list that is written to reduce (un)boxing - * - *

This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK} - * and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions. - */ -public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY, STACK +public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IArray, STACK KEY_GENERIC_TYPE #endif { static final int DEFAULT_ARRAY_SIZE = 10; @@ -587,6 +595,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE return data[(size() - 1) - index]; } +#if IARRAY_FEATURE /** * Provides the Underlying Array in the Implementation * @return underlying Array @@ -606,6 +615,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE return data.getClass() != Object[].class; } +#endif #endif /** * A Type Specific foreach function that reduces (un)boxing @@ -639,7 +649,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(int i = 0;i c) { - ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); + public static GENERIC_KEY_BRACES COPY_ON_WRITE_LIST KEY_GENERIC_TYPE of(Class c) { + COPY_ON_WRITE_LIST KEY_GENERIC_TYPE list = new COPY_ON_WRITE_LISTBRACES(); list.data = (KEY_TYPE[])ObjectArrays.newArray(c, 0); return list; } @@ -773,7 +775,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER Objects.requireNonNull(filter); KEY_TYPE[] data = this.data; for(int i = 0,m=data.length;i data.length) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length); } - -#if PRIMITIVES + +#if SPLIT_ITERATOR_FEATURE +#if PRIMITIVES && STREAM_FEATURE /** * Returns a Java-Type-Specific Stream to reduce boxing/unboxing. * @return a Stream of the closest java type @@ -1427,6 +1430,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER @Override public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); } +#endif static final class COWIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE { KEY_TYPE[] data; @@ -2080,9 +2084,11 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER } } +#if SPLIT_ITERATOR_FEATURE @Override public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 16464); } +#endif @Override public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) { if(index < 0 || index > size()) throw new IndexOutOfBoundsException(); diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template b/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template index 6476bafd..9c3de975 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/ImmutableList.template @@ -29,12 +29,14 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE; import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; import speiger.src.collections.objects.utils.ObjectArrays; import speiger.src.collections.PACKAGE.utils.ITERATORS; -#if PRIMITIVES +#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE import java.util.stream.JAVA_STREAM; import java.util.stream.StreamSupport; #endif +#if SPLIT_ITERATOR_FEATURE import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; +#endif import speiger.src.collections.utils.SanityChecks; #if TYPE_OBJECT @@ -301,7 +303,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(int i = 0,m=data.length;i getFastIterable(MAP KEY_VALUE_GENERIC_TYPE map) { +#if MAPS_FEATURE + return MAPS.fastIterable(map); +#else + return map.ENTRY_SET(); +#endif + } + + protected ObjectIterator getFastIterator(MAP KEY_VALUE_GENERIC_TYPE map) { +#if MAPS_FEATURE + return MAPS.fastIterator(map); +#else + return map.ENTRY_SET().iterator(); +#endif + } + @Override public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); @@ -63,14 +82,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(m);iter.hasNext();) { + for(ObjectIterator iter = getFastIterator(m);iter.hasNext();) { MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next(); put(entry.ENTRY_KEY(), entry.ENTRY_VALUE()); } @@ -101,7 +120,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(this);iter.hasNext();) { + for(ObjectIterator iter = getFastIterator(this);iter.hasNext();) { MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next(); entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE())); } @@ -195,7 +214,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(this);iter.hasNext();) { + for(ObjectIterator iter = getFastIterator(this);iter.hasNext();) { MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next(); action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE()); } @@ -332,7 +351,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(ABSTRACT_MAP.this); + ObjectIterator iter = getFastIterator(ABSTRACT_MAP.this); @Override public boolean hasNext() { return iter.hasNext(); @@ -383,7 +402,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(ABSTRACT_MAP.this); + ObjectIterator iter = getFastIterator(ABSTRACT_MAP.this); @Override public boolean hasNext() { return iter.hasNext(); @@ -423,7 +442,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap iter = MAPS.fastIterator(this); + ObjectIterator iter = getFastIterator(this); while(iter.hasNext()) hash += iter.next().hashCode(); return hash; } diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/concurrent/ConcurrentOpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/concurrent/ConcurrentOpenHashMap.template index bc61dcca..412d63e4 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/concurrent/ConcurrentOpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/concurrent/ConcurrentOpenHashMap.template @@ -698,7 +698,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY int index = seg.firstIndex; while(index != -1) { entry.set(seg.keys[index], seg.values[index]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; index = (int)seg.links[index]; } } @@ -720,7 +720,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY int index = seg.firstIndex; while(index != -1) { entry.set(seg.keys[index], seg.values[index]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; index = (int)seg.links[index]; } } @@ -742,7 +742,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY int index = seg.firstIndex; while(index != -1) { entry.set(seg.keys[index], seg.values[index]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; index = (int)seg.links[index]; } } @@ -813,7 +813,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { while(index != -1) { entry.set(seg.keys[index], seg.values[index]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; index = (int)seg.links[index]; } } @@ -836,7 +836,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY int index = seg.firstIndex; while(index != -1) { entry.set(seg.keys[index], seg.values[index]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; index = (int)seg.links[index]; } } @@ -1005,7 +1005,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.TEST_VALUE(seg.keys[index])) return true; + if(filter.test(seg.keys[index])) return true; index = (int)seg.links[index]; } } @@ -1025,7 +1025,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.TEST_VALUE(seg.keys[index])) return false; + if(filter.test(seg.keys[index])) return false; index = (int)seg.links[index]; } } @@ -1045,7 +1045,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(!filter.TEST_VALUE(seg.keys[index])) return false; + if(!filter.test(seg.keys[index])) return false; index = (int)seg.links[index]; } } @@ -1138,7 +1138,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.TEST_VALUE(seg.keys[index])) return seg.keys[index]; + if(filter.test(seg.keys[index])) return seg.keys[index]; index = (int)seg.links[index]; } } @@ -1159,7 +1159,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.TEST_VALUE(seg.keys[index])) result++; + if(filter.test(seg.keys[index])) result++; index = (int)seg.links[index]; } } @@ -1253,7 +1253,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(seg.values[index])) return true; + if(filter.test(seg.values[index])) return true; index = (int)seg.links[index]; } } @@ -1273,7 +1273,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1) { - if(filter.VALUE_TEST_VALUE(seg.values[index])) return false; + if(filter.test(seg.values[index])) return false; index = (int)seg.links[index]; } } @@ -1293,7 +1293,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1) { - if(!filter.VALUE_TEST_VALUE(seg.values[index])) return false; + if(!filter.test(seg.values[index])) return false; index = (int)seg.links[index]; } } @@ -1387,7 +1387,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(seg.values[index])) return seg.values[index]; + if(filter.test(seg.values[index])) return seg.values[index]; index = (int)seg.links[index]; } } @@ -1408,7 +1408,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = seg.firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(seg.values[index])) result++; + if(filter.test(seg.values[index])) result++; index = (int)seg.links[index]; } } @@ -2141,14 +2141,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY try { int index = findIndex(hash, key); if(index < 0) { - VALUE_TYPE newValue = mappingFunction.GET_VALUE(key); + VALUE_TYPE newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; insert(-index-1, key, newValue); return newValue; } VALUE_TYPE newValue = values[index]; if(VALUE_EQUALS(newValue, getDefaultReturnValue())) { - newValue = mappingFunction.GET_VALUE(key); + newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; values[index] = newValue; } diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template index 913c3aff..a515eb83 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/LinkedOpenCustomHashMap.template @@ -702,7 +702,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; index = (int)links[index]; } return false; @@ -716,7 +716,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -730,7 +730,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -775,7 +775,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; index = (int)links[index]; } return null; @@ -790,7 +790,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; index = (int)links[index]; } return result; @@ -961,7 +961,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return true; + if(filter.test(keys[index])) return true; index = (int)links[index]; } return false; @@ -973,7 +973,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return false; + if(filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -985,7 +985,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(!filter.TEST_VALUE(keys[index])) return false; + if(!filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -1043,7 +1043,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return EMPTY_KEY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return keys[index]; + if(filter.test(keys[index])) return keys[index]; index = (int)links[index]; } return EMPTY_KEY_VALUE; @@ -1056,7 +1056,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int result = 0; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) result++; + if(filter.test(keys[index])) result++; index = (int)links[index]; } return result; @@ -1124,7 +1124,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return true; + if(filter.test(values[index])) return true; index = (int)links[index]; } return false; @@ -1136,7 +1136,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return false; + if(filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1148,7 +1148,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(!filter.VALUE_TEST_VALUE(values[index])) return false; + if(!filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1206,7 +1206,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M if(size() <= 0) return EMPTY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return values[index]; + if(filter.test(values[index])) return values[index]; index = (int)links[index]; } return EMPTY_VALUE; @@ -1219,7 +1219,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M int result = 0; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) result++; + if(filter.test(values[index])) result++; index = (int)links[index]; } return result; diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template index 1d67e8b5..ff50bd7c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/customHash/OpenCustomHashMap.template @@ -22,11 +22,8 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR; #if !TYPE_OBJECT && !VALUE_BOOLEAN import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -import speiger.src.collections.PACKAGE.lists.LIST; import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.MAP; -import speiger.src.collections.PACKAGE.utils.maps.MAPS; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.SET; @@ -542,14 +539,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL Objects.requireNonNull(mappingFunction); int index = findIndex(key); if(index < 0) { - VALUE_TYPE newValue = mappingFunction.GET_VALUE(key); + VALUE_TYPE newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; insert(-index-1, key, newValue); return newValue; } VALUE_TYPE newValue = values[index]; if(VALUE_EQUALS(newValue, getDefaultReturnValue())) { - newValue = mappingFunction.GET_VALUE(key); + newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; values[index] = newValue; } @@ -609,7 +606,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL @Override public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { Objects.requireNonNull(mappingFunction); - for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) { + for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) { KEY_TYPE key = entry.ENTRY_KEY(); int index = findIndex(key); VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE()); @@ -886,12 +883,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; } for(int i = nullIndex-1;i>=0;i--) { if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; } } return false; @@ -904,12 +901,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; } for(int i = nullIndex-1;i>=0;i--) { if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; } } return true; @@ -922,12 +919,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; } for(int i = nullIndex-1;i>=0;i--) { if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) { entry.set(keys[i], values[i]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; } } return true; @@ -973,12 +970,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; } for(int i = nullIndex-1;i>=0;i--) { if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; } } return null; @@ -992,12 +989,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL int result = 0; if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; } for(int i = nullIndex-1;i>=0;i--) { if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; } } return result; @@ -1120,9 +1117,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true; + if(containsNull && filter.test(keys[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true; } return false; } @@ -1131,9 +1128,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false; } return true; } @@ -1142,9 +1139,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && !filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false; } return true; } @@ -1201,9 +1198,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_KEY_VALUE; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex]; + if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i]; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i]; } return EMPTY_KEY_VALUE; } @@ -1213,9 +1210,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++; + if(containsNull && filter.test(keys[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++; } return result; } @@ -1276,9 +1273,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true; + if(containsNull && filter.test(values[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return true; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return true; } return false; } @@ -1287,9 +1284,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false; + if(containsNull && filter.test(values[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return false; } return true; } @@ -1298,9 +1295,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false; + if(containsNull && !filter.test(values[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.VALUE_TEST_VALUE(values[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(values[i])) return false; } return true; } @@ -1357,9 +1354,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_VALUE; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex]; + if(containsNull && filter.test(values[nullIndex])) return values[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return values[i]; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return values[i]; } return EMPTY_VALUE; } @@ -1369,9 +1366,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++; + if(containsNull && filter.test(values[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) result++; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) result++; } return result; } @@ -1420,7 +1417,8 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL int lastReturned = -1; int nextIndex = Integer.MIN_VALUE; boolean returnNull = containsNull; - LIST KEY_GENERIC_TYPE wrapped = null; + KEY_TYPE[] wrapped = null; + int wrappedIndex = 0; public boolean hasNext() { if(nextIndex == Integer.MIN_VALUE) { @@ -1432,7 +1430,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL { while(true) { if(--pos < 0) { - if(wrapped == null || wrapped.size() <= -pos - 1) break; + if(wrapped == null || wrappedIndex <= -pos - 1) break; nextIndex = -pos - 1; break; } @@ -1451,7 +1449,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL returnedPos = pos; if(nextIndex < 0){ lastReturned = Integer.MAX_VALUE; - int value = findIndex(wrapped.GET_KEY(nextIndex)); + int value = findIndex(wrapped[nextIndex]); if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration"); nextIndex = Integer.MIN_VALUE; return value; @@ -1470,7 +1468,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL } else if(returnedPos >= 0) shiftKeys(returnedPos); else { - CUSTOM_HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1)); + CUSTOM_HASH_MAP.this.remove(wrapped[-returnedPos - 1]); lastReturned = -1; return; } @@ -1493,13 +1491,20 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; startPos = ++startPos & mask; } - if(startPos < last) { - if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2); - wrapped.add(keys[startPos]); - } + if(startPos < last) addWrapper(keys[startPos]); keys[last] = current; values[last] = values[startPos]; } } + + private void addWrapper(KEY_TYPE value) { + if(wrapped == null) wrapped = NEW_KEY_ARRAY(2); + else if(wrappedIndex >= wrapped.length) { + KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2); + System.arraycopy(wrapped, 0, newArray, 0, wrapped.length); + wrapped = newArray; + } + wrapped[wrappedIndex++] = value; + } } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template index f52b091a..d32ad5dc 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/LinkedOpenHashMap.template @@ -706,7 +706,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; index = (int)links[index]; } return false; @@ -720,7 +720,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -734,7 +734,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -779,7 +779,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; index = (int)links[index]; } return null; @@ -794,7 +794,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; index = (int)links[index]; } return result; @@ -960,7 +960,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return true; + if(filter.test(keys[index])) return true; index = (int)links[index]; } return false; @@ -972,7 +972,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return false; + if(filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -984,7 +984,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return true; int index = firstIndex; while(index != -1) { - if(!filter.TEST_VALUE(keys[index])) return false; + if(!filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -1042,7 +1042,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return EMPTY_KEY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return keys[index]; + if(filter.test(keys[index])) return keys[index]; index = (int)links[index]; } return EMPTY_KEY_VALUE; @@ -1055,7 +1055,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int result = 0; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) result++; + if(filter.test(keys[index])) result++; index = (int)links[index]; } return result; @@ -1124,7 +1124,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return true; + if(filter.test(values[index])) return true; index = (int)links[index]; } return false; @@ -1136,7 +1136,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return true; int index = firstIndex; while(index != -1) { - if(filter.VALUE_TEST_VALUE(values[index])) return false; + if(filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1148,7 +1148,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return true; int index = firstIndex; while(index != -1) { - if(!filter.VALUE_TEST_VALUE(values[index])) return false; + if(!filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1206,7 +1206,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G if(size() <= 0) return EMPTY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return values[index]; + if(filter.test(values[index])) return values[index]; index = (int)links[index]; } return EMPTY_VALUE; @@ -1219,7 +1219,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G int result = 0; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) result++; + if(filter.test(values[index])) result++; index = (int)links[index]; } return result; diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template index ce267135..165ac32f 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/hash/OpenHashMap.template @@ -22,11 +22,8 @@ import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR; #if !TYPE_OBJECT && !VALUE_BOOLEAN import speiger.src.collections.PACKAGE.functions.function.PREDICATE; #endif -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -import speiger.src.collections.PACKAGE.lists.LIST; import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.MAP; -import speiger.src.collections.PACKAGE.utils.maps.MAPS; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.SET; @@ -503,14 +500,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE Objects.requireNonNull(mappingFunction); int index = findIndex(key); if(index < 0) { - VALUE_TYPE newValue = mappingFunction.GET_VALUE(key); + VALUE_TYPE newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; insert(-index-1, key, newValue); return newValue; } VALUE_TYPE newValue = values[index]; if(VALUE_EQUALS(newValue, getDefaultReturnValue())) { - newValue = mappingFunction.GET_VALUE(key); + newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; values[index] = newValue; } @@ -570,7 +567,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE @Override public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { Objects.requireNonNull(mappingFunction); - for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) { + for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) { KEY_TYPE key = entry.ENTRY_KEY(); int index = findIndex(key); VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE()); @@ -846,12 +843,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; } for(int i = nullIndex-1;i>=0;i--) { if(KEY_EQUALS_NOT_NULL(keys[i])) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; } } return false; @@ -864,12 +861,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; } for(int i = nullIndex-1;i>=0;i--) { if(KEY_EQUALS_NOT_NULL(keys[i])) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; } } return true; @@ -882,12 +879,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; } for(int i = nullIndex-1;i>=0;i--) { if(KEY_EQUALS_NOT_NULL(keys[i])) { entry.set(keys[i], values[i]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; } } return true; @@ -933,12 +930,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; } for(int i = nullIndex-1;i>=0;i--) { if(KEY_EQUALS_NOT_NULL(keys[i])) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; } } return null; @@ -952,12 +949,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE int result = 0; if(containsNull) { entry.set(keys[nullIndex], values[nullIndex]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; } for(int i = nullIndex-1;i>=0;i--) { if(KEY_EQUALS_NOT_NULL(keys[i])) { entry.set(keys[i], values[i]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; } } return result; @@ -1076,9 +1073,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true; + if(containsNull && filter.test(keys[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true; } return false; } @@ -1087,9 +1084,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false; } return true; } @@ -1098,9 +1095,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && !filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false; } return true; } @@ -1157,9 +1154,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_KEY_VALUE; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex]; + if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i]; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i]; } return EMPTY_KEY_VALUE; } @@ -1169,9 +1166,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++; + if(containsNull && filter.test(keys[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++; } return result; } @@ -1232,9 +1229,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true; + if(containsNull && filter.test(values[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return true; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return true; } return false; } @@ -1243,9 +1240,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false; + if(containsNull && filter.test(values[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return false; } return true; } @@ -1254,9 +1251,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false; + if(containsNull && !filter.test(values[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.VALUE_TEST_VALUE(values[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(values[i])) return false; } return true; } @@ -1313,9 +1310,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_VALUE; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex]; + if(containsNull && filter.test(values[nullIndex])) return values[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return values[i]; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return values[i]; } return EMPTY_VALUE; } @@ -1325,9 +1322,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++; + if(containsNull && filter.test(values[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) result++; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) result++; } return result; } @@ -1376,7 +1373,8 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE int lastReturned = -1; int nextIndex = Integer.MIN_VALUE; boolean returnNull = containsNull; - LIST KEY_GENERIC_TYPE wrapped = null; + KEY_TYPE[] wrapped = null; + int wrappedIndex = 0; public boolean hasNext() { if(nextIndex == Integer.MIN_VALUE) { @@ -1388,7 +1386,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE { while(true) { if(--pos < 0) { - if(wrapped == null || wrapped.size() <= -pos - 1) break; + if(wrapped == null || wrappedIndex <= -pos - 1) break; nextIndex = -pos - 1; break; } @@ -1407,7 +1405,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE returnedPos = pos; if(nextIndex < 0){ lastReturned = Integer.MAX_VALUE; - int value = findIndex(wrapped.GET_KEY(nextIndex)); + int value = findIndex(wrapped[nextIndex]); if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration"); nextIndex = Integer.MIN_VALUE; return value; @@ -1426,7 +1424,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE } else if(returnedPos >= 0) shiftKeys(returnedPos); else { - HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1)); + HASH_MAP.this.remove(wrapped[-returnedPos - 1]); lastReturned = -1; return; } @@ -1449,13 +1447,20 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; startPos = ++startPos & mask; } - if(startPos < last) { - if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2); - wrapped.add(keys[startPos]); - } + if(startPos < last) addWrapper(keys[startPos]); keys[last] = current; values[last] = values[startPos]; } } + + private void addWrapper(KEY_TYPE value) { + if(wrapped == null) wrapped = NEW_KEY_ARRAY(2); + else if(wrappedIndex >= wrapped.length) { + KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2); + System.arraycopy(wrapped, 0, newArray, 0, wrapped.length); + wrapped = newArray; + } + wrapped[wrappedIndex++] = value; + } } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template index 780cac6c..82e6d214 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/immutable/ImmutableOpenHashMap.template @@ -28,7 +28,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.sets.ORDERED_SET; #endif -import speiger.src.collections.PACKAGE.utils.maps.MAPS; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.utils.ARRAYS; #endif @@ -215,7 +214,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ KEY_TYPE[] keys = NEW_KEY_ARRAY(map.size()); VALUE_TYPE[] values = NEW_VALUE_ARRAY(keys.length); int index = 0; - for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(map)) { + for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(map)) { keys[index] = entry.ENTRY_KEY(); values[index] = entry.ENTRY_VALUE(); index++; @@ -678,7 +677,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return true; + if(filter.test(entry)) return true; index = (int)links[index]; } return false; @@ -692,7 +691,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return false; + if(filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -706,7 +705,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(!filter.getBoolean(entry)) return false; + if(!filter.test(entry)) return false; index = (int)links[index]; } return true; @@ -751,7 +750,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) return entry; + if(filter.test(entry)) return entry; index = (int)links[index]; } return null; @@ -766,7 +765,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; while(index != -1) { entry.set(keys[index], values[index]); - if(filter.getBoolean(entry)) result++; + if(filter.test(entry)) result++; index = (int)links[index]; } return result; @@ -904,7 +903,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return true; + if(filter.test(keys[index])) return true; index = (int)links[index]; } return false; @@ -916,7 +915,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return false; + if(filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -928,7 +927,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(!filter.TEST_VALUE(keys[index])) return false; + if(!filter.test(keys[index])) return false; index = (int)links[index]; } return true; @@ -986,7 +985,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return EMPTY_KEY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) return keys[index]; + if(filter.test(keys[index])) return keys[index]; index = (int)links[index]; } return EMPTY_KEY_VALUE; @@ -999,7 +998,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int index = firstIndex; int result = 0; while(index != -1){ - if(filter.TEST_VALUE(keys[index])) result++; + if(filter.test(keys[index])) result++; index = (int)links[index]; } return result; @@ -1065,7 +1064,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return false; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return true; + if(filter.test(values[index])) return true; index = (int)links[index]; } return false; @@ -1077,7 +1076,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return false; + if(filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1089,7 +1088,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return true; int index = firstIndex; while(index != -1){ - if(!filter.VALUE_TEST_VALUE(values[index])) return false; + if(!filter.test(values[index])) return false; index = (int)links[index]; } return true; @@ -1147,7 +1146,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ if(size() <= 0) return EMPTY_VALUE; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) return values[index]; + if(filter.test(values[index])) return values[index]; index = (int)links[index]; } return EMPTY_VALUE; @@ -1160,7 +1159,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_ int result = 0; int index = firstIndex; while(index != -1){ - if(filter.VALUE_TEST_VALUE(values[index])) result++; + if(filter.test(values[index])) result++; index = (int)links[index]; } return result; diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template index fdc3af20..c99c3e6c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/impl/misc/ArrayMap.template @@ -27,7 +27,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP; import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP; import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.ORDERED_SET; -import speiger.src.collections.PACKAGE.utils.maps.MAPS; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION; import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR; @@ -176,7 +175,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN */ public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) { this(map.size()); - for(ObjectIterator iter = MAPS.fastIterator(map);iter.hasNext();size++) { + for(ObjectIterator iter = getFastIterator(map);iter.hasNext();size++) { MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next(); keys[size] = entry.ENTRY_KEY(); values[size] = entry.ENTRY_VALUE(); @@ -499,14 +498,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN Objects.requireNonNull(mappingFunction); int index = findIndex(key); if(index == -1) { - VALUE_TYPE newValue = mappingFunction.GET_VALUE(key); + VALUE_TYPE newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; insertIndex(size++, key, newValue); return newValue; } VALUE_TYPE newValue = values[index]; if(VALUE_EQUALS(newValue, getDefaultReturnValue())) { - newValue = mappingFunction.GET_VALUE(key); + newValue = mappingFunction.APPLY(key); if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue; values[index] = newValue; } @@ -566,7 +565,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN @Override public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { Objects.requireNonNull(mappingFunction); - for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) { + for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) { KEY_TYPE key = entry.ENTRY_KEY(); int index = findIndex(key); VALUE_TYPE newValue = index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE()); @@ -803,7 +802,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(); for(int i = 0;i ENTRY_SET(); -#if !TYPE_BOOLEAN +#if MAPS_FEATURE /** * Creates a Wrapped Map that is Synchronized * @return a new Map that is synchronized @@ -658,6 +695,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map map, COMPARATOR KEY_GENERIC_TYPE comp) { return new AVL_TREE_MAPKV_BRACES(map, comp); } +#endif } /** @@ -1454,7 +1511,11 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map E putElements(E e){ e.putAll(keys, values, 0, size); return e; } +#endif +#if MAP_FEATURE /** * Builds the Keys and Values into a Hash Map * @return a HASH_MAP @@ -1496,6 +1560,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map ENTRY_SET(); +#if MAPS_FEATURE /** * Creates a Wrapped SortedMap that is Synchronized * @return a new SortedMap that is synchronized @@ -127,6 +130,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI @Override public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); } +#endif /** * Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value * @Type(T) diff --git a/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/SortedMap.template b/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/SortedMap.template index d186f366..4cabf571 100644 --- a/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/SortedMap.template +++ b/src/builder/resources/speiger/assets/collections/templates/maps/interfaces/SortedMap.template @@ -10,7 +10,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION; import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif import speiger.src.collections.PACKAGE.sets.SORTED_SET; +#if MAPS_FEATURE import speiger.src.collections.PACKAGE.utils.maps.MAPS; +#endif #if !TYPE_OBJECT import speiger.src.collections.objects.sets.ObjectSortedSet; #endif @@ -37,6 +39,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap action) { - return TO_ARRAY(action.get(size())); + return TO_ARRAY(action.apply(size())); } #endif } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template index 89c3f789..c35d1712 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/AVLTreeSet.template @@ -364,7 +364,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return true; + if(filter.test(entry.key)) return true; } return false; } @@ -373,7 +373,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return false; + if(filter.test(entry.key)) return false; } return true; } @@ -382,7 +382,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(!filter.TEST_VALUE(entry.key)) return false; + if(!filter.test(entry.key)) return false; } return true; } @@ -391,7 +391,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return entry.key; + if(filter.test(entry.key)) return entry.key; } return EMPTY_VALUE; } @@ -440,7 +440,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE Objects.requireNonNull(filter); int result = 0; for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) result++; + if(filter.test(entry.key)) result++; } return result; } @@ -1203,7 +1203,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return true; + if(filter.test(entry.key)) return true; } return false; } @@ -1212,7 +1212,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return false; + if(filter.test(entry.key)) return false; } return true; } @@ -1221,7 +1221,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(!filter.TEST_VALUE(entry.key)) return false; + if(!filter.test(entry.key)) return false; } return true; } @@ -1269,7 +1269,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return entry.key; + if(filter.test(entry.key)) return entry.key; } return EMPTY_VALUE; } @@ -1279,7 +1279,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE Objects.requireNonNull(filter); int result = 0; for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) result++; + if(filter.test(entry.key)) result++; } return result; } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template index 31cf0c90..f3cfaf65 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/ArraySet.template @@ -402,7 +402,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(int i = 0;i @Override public NAVIGABLE_SET KEY_GENERIC_TYPE copy(); -#if !TYPE_BOOLEAN +#if SETS_FEATURE /** * Creates a Wrapped NavigableSet that is Synchronized * @return a new NavigableSet that is synchronized diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template index b1e7a9d9..801001f4 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/OpenCustomHashSet.template @@ -13,8 +13,6 @@ import java.util.function.BiFunction; import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.ITERATOR; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -import speiger.src.collections.PACKAGE.lists.LIST; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.functions.CONSUMER; @@ -524,9 +522,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true; + if(containsNull && filter.test(keys[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true; } return false; } @@ -535,9 +533,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false; } return true; } @@ -546,9 +544,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && !filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false; } return true; } @@ -605,9 +603,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_VALUE; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex]; + if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i]; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i]; } return EMPTY_VALUE; } @@ -617,9 +615,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++; + if(containsNull && filter.test(keys[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++; + if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++; } return result; } @@ -630,7 +628,8 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T int lastReturned = -1; int nextIndex = Integer.MIN_VALUE; boolean returnNull = containsNull; - LIST KEY_GENERIC_TYPE wrapped = null; + KEY_TYPE[] wrapped = null; + int wrappedIndex = 0; @Override public boolean hasNext() { @@ -642,7 +641,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T else { while(true) { if(--pos < 0) { - if(wrapped == null || wrapped.size() <= -pos - 1) break; + if(wrapped == null || wrappedIndex <= -pos - 1) break; nextIndex = -pos - 1; break; } @@ -662,7 +661,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T returnedPos = pos; if(nextIndex < 0){ lastReturned = Integer.MAX_VALUE; - KEY_TYPE value = wrapped.GET_KEY(nextIndex); + KEY_TYPE value = wrapped[nextIndex]; nextIndex = Integer.MIN_VALUE; return value; } @@ -680,7 +679,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T } else if(returnedPos >= 0) shiftKeys(returnedPos); else { - CUSTOM_HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1)); + CUSTOM_HASH_SET.this.remove(wrapped[-returnedPos - 1]); lastReturned = -1; return; } @@ -702,12 +701,19 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; startPos = ++startPos & mask; } - if(startPos < last) { - if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2); - wrapped.add(keys[startPos]); - } + if(startPos < last) addWrapper(keys[startPos]); keys[last] = current; } } + + private void addWrapper(KEY_TYPE value) { + if(wrapped == null) wrapped = NEW_KEY_ARRAY(2); + else if(wrappedIndex >= wrapped.length) { + KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2); + System.arraycopy(wrapped, 0, newArray, 0, wrapped.length); + wrapped = newArray; + } + wrapped[wrappedIndex++] = value; + } } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template index 5cac2a92..507131b5 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/OpenHashSet.template @@ -13,8 +13,6 @@ import java.util.function.BiFunction; import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.ITERATOR; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -import speiger.src.collections.PACKAGE.lists.LIST; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.utils.ITERATORS; import speiger.src.collections.PACKAGE.functions.CONSUMER; @@ -387,9 +385,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return false; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true; + if(containsNull && filter.test(keys[nullIndex])) return true; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true; } return false; } @@ -398,9 +396,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false; } return true; } @@ -409,9 +407,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return true; - if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false; + if(containsNull && !filter.test(keys[nullIndex])) return false; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false; + if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false; } return true; } @@ -468,9 +466,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); if(size() <= 0) return EMPTY_VALUE; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex]; + if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex]; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i]; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i]; } return EMPTY_VALUE; } @@ -480,9 +478,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp Objects.requireNonNull(filter); if(size() <= 0) return 0; int result = 0; - if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++; + if(containsNull && filter.test(keys[nullIndex])) result++; for(int i = nullIndex-1;i>=0;i--) { - if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++; + if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++; } return result; } @@ -597,7 +595,8 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp int lastReturned = -1; int nextIndex = Integer.MIN_VALUE; boolean returnNull = containsNull; - LIST KEY_GENERIC_TYPE wrapped = null; + KEY_TYPE[] wrapped = null; + int wrappedIndex = 0; @Override public boolean hasNext() { @@ -610,7 +609,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp { while(true) { if(--pos < 0) { - if(wrapped == null || wrapped.size() <= -pos - 1) break; + if(wrapped == null || wrappedIndex <= -pos - 1) break; nextIndex = -pos - 1; break; } @@ -630,7 +629,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp returnedPos = pos; if(nextIndex < 0){ lastReturned = Integer.MAX_VALUE; - KEY_TYPE value = wrapped.GET_KEY(nextIndex); + KEY_TYPE value = wrapped[nextIndex]; nextIndex = Integer.MIN_VALUE; return value; } @@ -648,7 +647,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp } else if(returnedPos >= 0) shiftKeys(returnedPos); else { - HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1)); + HASH_SET.this.remove(wrapped[-returnedPos - 1]); lastReturned = -1; return; } @@ -670,12 +669,19 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; startPos = ++startPos & mask; } - if(startPos < last) { - if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2); - wrapped.add(keys[startPos]); - } + if(startPos < last) addWrapper(keys[startPos]); keys[last] = current; } } + + private void addWrapper(KEY_TYPE value) { + if(wrapped == null) wrapped = NEW_KEY_ARRAY(2); + else if(wrappedIndex >= wrapped.length) { + KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2); + System.arraycopy(wrapped, 0, newArray, 0, wrapped.length); + wrapped = newArray; + } + wrapped[wrappedIndex++] = value; + } } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/OrderedSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/OrderedSet.template index 03ca7039..f98bf742 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/OrderedSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/OrderedSet.template @@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.sets; import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; +#if SETS_FEATURE import speiger.src.collections.PACKAGE.utils.SETS; +#endif import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; /** @@ -87,7 +89,7 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE */ public KEY_TYPE POLL_LAST_KEY(); -#if !TYPE_BOOLEAN +#if SETS_FEATURE /** * Creates a Wrapped OrderedSet that is Synchronized * @return a new OrderedSet that is synchronized diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template index b6cc387e..cddc6689 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/RBTreeSet.template @@ -364,7 +364,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return true; + if(filter.test(entry.key)) return true; } return false; } @@ -373,7 +373,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return false; + if(filter.test(entry.key)) return false; } return true; } @@ -382,7 +382,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(!filter.TEST_VALUE(entry.key)) return false; + if(!filter.test(entry.key)) return false; } return true; } @@ -430,7 +430,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) return entry.key; + if(filter.test(entry.key)) return entry.key; } return EMPTY_VALUE; } @@ -440,7 +440,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE Objects.requireNonNull(filter); int result = 0; for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) { - if(filter.TEST_VALUE(entry.key)) result++; + if(filter.test(entry.key)) result++; } return result; } @@ -1264,7 +1264,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return true; + if(filter.test(entry.key)) return true; } return false; } @@ -1273,7 +1273,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return false; + if(filter.test(entry.key)) return false; } return true; } @@ -1282,7 +1282,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(!filter.TEST_VALUE(entry.key)) return false; + if(!filter.test(entry.key)) return false; } return true; } @@ -1330,7 +1330,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { Objects.requireNonNull(filter); for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) return entry.key; + if(filter.test(entry.key)) return entry.key; } return EMPTY_VALUE; } @@ -1340,7 +1340,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE Objects.requireNonNull(filter); int result = 0; for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) { - if(filter.TEST_VALUE(entry.key)) result++; + if(filter.test(entry.key)) result++; } return result; } diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/Set.template b/src/builder/resources/speiger/assets/collections/templates/sets/Set.template index 97681f1d..a83e5c6e 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/Set.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/Set.template @@ -5,7 +5,7 @@ import java.util.Set; import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR; -#if !TYPE_BOOLEAN +#if SETS_FEATURE import speiger.src.collections.PACKAGE.utils.SETS; #endif import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; @@ -64,7 +64,7 @@ public interface SET KEY_GENERIC_TYPE extends Set, COLLECTION KEY_GE public KEY_TYPE addOrGet(KEY_TYPE o); #endif -#if !TYPE_BOOLEAN +#if SETS_FEATURE /** * Creates a Wrapped Set that is Synchronized * @return a new Set that is synchronized diff --git a/src/builder/resources/speiger/assets/collections/templates/sets/SortedSet.template b/src/builder/resources/speiger/assets/collections/templates/sets/SortedSet.template index 884505d5..01cc4f91 100644 --- a/src/builder/resources/speiger/assets/collections/templates/sets/SortedSet.template +++ b/src/builder/resources/speiger/assets/collections/templates/sets/SortedSet.template @@ -9,7 +9,9 @@ import java.util.Comparator; #else import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif +#if SETS_FEATURE import speiger.src.collections.PACKAGE.utils.SETS; +#endif import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS; /** @@ -41,7 +43,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte */ public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement); -#if !TYPE_BOOLEAN +#if SETS_FEATURE /** * Creates a Wrapped SortedSet that is Synchronized * @return a new SortedSet that is synchronized diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template b/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template index 44937fb2..68065f4e 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Arrays.template @@ -9,10 +9,11 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR; #else import java.util.Comparator; +import speiger.src.collections.ints.functions.function.Int2ObjectFunction; #endif import speiger.src.collections.PACKAGE.collections.ITERATOR; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; import speiger.src.collections.PACKAGE.utils.ITERATORS; +import speiger.src.collections.PACKAGE.utils.COLLECTIONS; import speiger.src.collections.utils.SanityChecks; /** @@ -132,10 +133,39 @@ public class ARRAYS * @return array with all requested elements of the iterator */ public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max) { - ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); + COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper(); ITERATORS.pour(iter, list, max); return list.TO_ARRAY(NEW_KEY_ARRAY(list.size())); } + +#if TYPE_OBJECT + /** + * A Helper function that pours all elements of a iterator into a Array + * @param iter the elements that should be gathered. + * @ArrayType(T) + * @param action that is creating the Array to be poured into + * @return array with all elements of the iterator + */ + public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, Int2ObjectFunction action) { + return pour(iter, Integer.MAX_VALUE, action); + } + + /** + * A Helper function that pours all elements of a iterator into a Array + * @param iter the elements that should be gathered. + * @param max how many elements should be added + * @param action that is creating the Array to be poured into + * @ArrayType(T) + * @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 action) { + COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper(); + ITERATORS.pour(iter, list, max); + return list.TO_ARRAY(action.apply(list.size())); + } + +#endif + /** * Method to validate if the current value is the lowest value in the heap * @param data the current heap. diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template b/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template index 2de567ec..3538fb04 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/AsyncBuilder.template @@ -17,27 +17,55 @@ import java.util.Comparator; #endif import speiger.src.collections.PACKAGE.collections.ITERABLE; +#if OBJECT_ASYNC_MODULE import speiger.src.collections.PACKAGE.collections.COLLECTION; +#endif import speiger.src.collections.PACKAGE.collections.ITERATOR; import speiger.src.collections.PACKAGE.functions.TASK; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; +#if OBJECT_ASYNC_MODULE import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; -import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; -import speiger.src.collections.PACKAGE.lists.LIST; -#if !TYPE_BOOLEAN -import speiger.src.collections.PACKAGE.sets.SET; -import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; #endif -#if !TYPE_BOOLEAN +import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE +import speiger.src.collections.PACKAGE.lists.LIST; +#if ARRAY_LIST_FEATURE +import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; +#else if LINKED_LIST_FEATURE +import speiger.src.collections.PACKAGE.lists.LINKED_LIST; +#endif +#endif +#if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE +#if SET_MODULE +#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.SET; +#if LINKED_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET; +#else if LINKED_CUSTOM_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET; +#else if SET_FEATURE +import speiger.src.collections.PACKAGE.sets.HASH_SET; +#else if CUSTOM_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET; +#else if RB_TREE_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.RB_TREE_SET; +#else if AVL_TREE_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET; +#else if ARRAY_SET_FEATURE +import speiger.src.collections.PACKAGE.sets.ARRAY_SET; +#endif +#endif +#endif +#endif +#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE import speiger.src.collections.booleans.utils.BooleanAsyncBuilder; import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask; #endif -#if !TYPE_OBJECT +#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE import speiger.src.collections.objects.utils.ObjectAsyncBuilder; import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask; #endif -#if !TYPE_INT +#if !TYPE_INT && INT_ASYNC_MODULE import speiger.src.collections.ints.utils.IntAsyncBuilder; import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask; #endif @@ -113,6 +141,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable)); } +#if ARRAY_LIST_FEATURE /** * Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable. * @param values that should be wrapped @@ -123,6 +152,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values)); } +#endif +#if OBJECT_ASYNC_MODULE /** * Maps the elements to something else * @param mapper the mapping function @@ -154,6 +185,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper)); } +#endif /** * Filters out the unwanted elements out of the Iterable * @param filter the elements that should be kept @@ -214,6 +246,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return this; } +#if OBJECT_ASYNC_MODULE /** * Iterates over the Iterable with a desired action * @param action that should be applied @@ -223,6 +256,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action)); } +#endif /** * Reduces the elements inside of the Iterable down to one element * @param operator that reduces the elements. @@ -257,23 +291,46 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } #endif +#if OBJECT_ASYNC_MODULE +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE /** * Pours all elements into a List that can be later * @return a new Builder with the pour function applied */ public ObjectAsyncBuilder pourAsList() { +#if ARRAY_LIST_FEATURE return pour(new ARRAY_LISTBRACES()); +#else + return pour(new LINKED_LISTBRACES()); +#endif } -#if !TYPE_BOOLEAN +#endif +#if !TYPE_BOOLEAN && SET_MODULE +#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE /** * Pours all elements into a Set that can be later * @return a new Builder with the pour function applied */ public ObjectAsyncBuilder pourAsSet() { +#if LINKED_SET_FEATURE return pour(new LINKED_HASH_SETBRACES()); +#else if LINKED_CUSTOM_SET_FEATURE + return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy())); +#else if SET_FEATURE + return pour(new HASH_SETBRACES()); +#else if CUSTOM_SET_FEATURE + return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy())); +#else if RB_TREE_SET_FEATURE + return pour(new RB_Tree_SETBRACES()); +#else if AVL_TREE_SET_FEATURE + return pour(new AVL_Tree_SETBRACES()); +#else if ARRAY_SET_FEATURE + return pour(new ARRAY_SETBRACES()); +#endif } +#endif #endif /** * Pours all elements into a collection that can be later @@ -285,6 +342,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection)); } +#endif +#if BOOLEAN_ASYNC_MODULE /** * Searches through the elements of the Iterable to find if the desired element is present. * @param filter that decides the desired elements @@ -312,6 +371,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2)); } +#endif /** * Searches through the elements of the Iterable to find if the desired element. * If not present it will return the default value of the type @@ -323,6 +383,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return this; } +#if INT_ASYNC_MODULE /** * Counts all desired elements inside the Iterable * @param filter that decides the desired elements @@ -332,6 +393,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter)); } +#endif /** * Optional way to add a custom executor that runs this offthread task. * Can only be set after the action was decided on. @@ -512,6 +574,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#if BOOLEAN_ASYNC_MODULE private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask { ITERATOR KEY_GENERIC_TYPE iter; @@ -530,11 +593,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE switch(type) { case 0: while(shouldRun() && iter.hasNext()) { -#if TYPE_OBJECT - if(filter.getBoolean(iter.NEXT())) { -#else - if(filter.GET_VALUE(iter.NEXT())) { -#endif + if(filter.test(iter.NEXT())) { setResult(true); return true; } @@ -542,11 +601,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE break; case 1: while(shouldRun() && iter.hasNext()) { -#if TYPE_OBJECT - if(filter.getBoolean(iter.NEXT())) { -#else - if(filter.GET_VALUE(iter.NEXT())) { -#endif + if(filter.test(iter.NEXT())) { setResult(false); return true; } @@ -554,11 +609,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE break; case 2: while(shouldRun() && iter.hasNext()) { -#if TYPE_OBJECT - if(!filter.getBoolean(iter.NEXT())) { -#else - if(!filter.GET_VALUE(iter.NEXT())) { -#endif + if(!filter.test(iter.NEXT())) { setResult(false); return true; } @@ -580,6 +631,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE { ITERATOR KEY_GENERIC_TYPE iter; @@ -594,11 +646,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE protected boolean execute() throws Exception { while(shouldRun() && iter.hasNext()) { KEY_TYPE entry = iter.NEXT(); -#if TYPE_OBJECT - if(filter.getBoolean(iter.NEXT())) { -#else - if(filter.GET_VALUE(iter.NEXT())) { -#endif + if(filter.test(iter.NEXT())) { setResult(entry); return true; } @@ -614,6 +662,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#if INT_ASYNC_MODULE private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask { ITERATOR KEY_GENERIC_TYPE iter; @@ -628,7 +677,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE @Override protected boolean execute() throws Exception { while(shouldRun() && iter.hasNext()) { - if(filter.TEST_VALUE(iter.NEXT())) { + if(filter.test(iter.NEXT())) { counted++; } } @@ -648,6 +697,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif +#if OBJECT_ASYNC_MODULE private static class CollectTask KSS_GENERIC_TYPE> extends BaseObjectTask { ITERATOR KEY_SPECIAL_GENERIC_TYPE iter; @@ -704,6 +755,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE } } +#endif /** * Base Task of the Actions that can be performed. * Allows to simplify the actions that get executed. diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template index d9222893..7b13c5d4 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template @@ -1,7 +1,14 @@ package speiger.src.collections.PACKAGE.utils; +import java.util.Arrays; import java.util.Collection; +#if !TYPE_BOOLEAN +import java.util.ConcurrentModificationException; +#endif +import java.util.NoSuchElementException; +import java.util.Objects; #if TYPE_OBJECT +import java.util.Comparator; import java.util.function.BiFunction; #endif import java.util.function.Predicate; @@ -13,6 +20,9 @@ import java.util.function.Consumer; import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION; import speiger.src.collections.PACKAGE.collections.COLLECTION; import speiger.src.collections.PACKAGE.collections.ITERATOR; +#if !TYPE_OBJECT +import speiger.src.collections.PACKAGE.functions.COMPARATOR; +#endif import speiger.src.collections.objects.utils.ObjectArrays; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.CONSUMER; @@ -21,6 +31,12 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER; +#if !TYPE_BOOLEAN +import speiger.src.collections.utils.HashUtil; +#endif +import speiger.src.collections.utils.ITrimmable; +import speiger.src.collections.utils.SanityChecks; + /** * A Helper class for Collections */ @@ -75,6 +91,557 @@ public class COLLECTIONS return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex); } + /** + * Creates a Singleton Collection of a given element + * @param element the element that should be converted into a singleton collection + * @Type(T) + * @return a singletoncollection of the given element + */ + public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE singleton(KEY_TYPE element) { + return new SingletonCollectionBRACES(element); + } + + protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() { + return new CollectionWrapperBRACES(); + } + + protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper(int size) { + return new CollectionWrapperBRACES(size); + } + +#if !TYPE_BOOLEAN + protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper() { + return new DistinctCollectionWrapperBRACES(); + } + + protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper(int size) { + return new DistinctCollectionWrapperBRACES(size); + } + +#endif + protected static class CollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements ITrimmable { + KEY_TYPE[] elements; + int size = 0; + + public CollectionWrapper() { + this(10); + } + + public CollectionWrapper(int size) { + if(size < 0) throw new IllegalStateException("Size has to be 0 or greater"); + elements = NEW_KEY_ARRAY(size); + } + + @Override + public boolean add(KEY_TYPE o) { + if(size >= elements.length) elements = Arrays.copyOf(elements, (int)Math.min((long)elements.length + (elements.length >> 1), SanityChecks.MAX_ARRAY_SIZE)); + elements[size++] = o; + return true; + } + + public KEY_TYPE GET_KEY(int index) { + if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); + return elements[index]; + } + +#if TYPE_OBJECT + @Override + public boolean remove(Object e) { + for(int i = 0;i= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); + size--; + if(index != size) System.arraycopy(elements, index+1, elements, index, size - index); + } + + @Override + public ITERATOR KEY_GENERIC_TYPE iterator() { + return new ITERATOR KEY_GENERIC_TYPE() { + int index = 0; + int lastReturned = -1; + + @Override + public boolean hasNext() { + return index < size; + } + + @Override + public KEY_TYPE NEXT() { + int i = index++; + return elements[(lastReturned = i)]; + } + + @Override + public void remove() { + if(lastReturned == -1) throw new IllegalStateException(); + removeIndex(lastReturned); + index = lastReturned; + lastReturned = -1; + } + }; + } + + @Override + public int size() { + return size; + } + + @Override + public void clear() { +#if TYPE_OBJECT + for(int i = 0;i c) { + if(c != null) ARRAYS.stableSort(elements, size, c); + else ARRAYS.stableSort(elements, size); + } + + public void unstableSort(Comparator c) { + if(c != null) ARRAYS.unstableSort(elements, size, c); + else ARRAYS.unstableSort(elements, size); + } + +#else + public void sort(COMPARATOR c) { + if(c != null) ARRAYS.stableSort(elements, size, c); + else ARRAYS.stableSort(elements, size); + } + + public void unstableSort(COMPARATOR c) { + if(c != null) ARRAYS.unstableSort(elements, size, c); + else ARRAYS.unstableSort(elements, size); + } + +#endif + @Override + public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { + Objects.requireNonNull(action); + for(int i = 0;i void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE action) { + Objects.requireNonNull(action); + for(int i = 0;i size() || size() == elements.length) return false; + int value = Math.max(size, size()); + elements = value == 0 ? EMPTY_KEY_ARRAY : Arrays.copyOf(elements, value); + return true; + } + + @Override + public void clearAndTrim(int size) { + if(elements.length <= size) { + clear(); + return; + } + elements = size == 0 ? EMPTY_KEY_ARRAY : NEW_KEY_ARRAY(size); + this.size = size; + } + + @Override + @Primitive + public Object[] toArray() { + Object[] obj = new Object[size]; + for(int i = 0;i E[] toArray(E[] a) { + if(a == null) a = (E[])new Object[size]; + else if(a.length < size) a = (E[])ObjectArrays.newArray(a.getClass().getComponentType(), size); + #if TYPE_OBJECT + System.arraycopy(elements, 0, a, 0, size); + #else + for(int i = 0;i size) a[size] = null; + return a; + } + +#if !TYPE_OBJECT + @Override + public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) { + if(a.length < size) a = new KEY_TYPE[size]; + System.arraycopy(elements, 0, a, 0, size); + if (a.length > size) a[size] = EMPTY_KEY_VALUE; + return a; + } +#endif + } + +#if !TYPE_BOOLEAN + protected static class DistinctCollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE { + KEY_TYPE[] keys; + boolean containsNull; + int minCapacity; + int nullIndex; + int maxFill; + int mask; + int size; + + public DistinctCollectionWrapper() { + this(HashUtil.DEFAULT_MIN_CAPACITY); + } + + public DistinctCollectionWrapper(int size) { + if(minCapacity < 0) throw new IllegalStateException("Minimum Capacity is negative. This is not allowed"); + minCapacity = nullIndex = HashUtil.arraySize(minCapacity, HashUtil.DEFAULT_LOAD_FACTOR); + mask = nullIndex - 1; + maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1); + keys = NEW_KEY_ARRAY(nullIndex + 1); + } + + @Override + public boolean add(KEY_TYPE o) { + if(KEY_EQUALS_NULL(o)) { + if(containsNull) return false; + containsNull = true; + } + else { + int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; + KEY_TYPE current = keys[pos]; + if(KEY_EQUALS_NOT_NULL(current)) { + if(KEY_EQUALS(current, o)) return false; + while(KEY_EQUALS_NOT_NULL((current = keys[pos = (++pos & mask)]))) + if(KEY_EQUALS(current, o)) return false; + } + keys[pos] = o; + } + if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, HashUtil.DEFAULT_LOAD_FACTOR)); + return true; + } + + @Override + public boolean contains(Object o) { +#if TYPE_OBJECT + if(o == null) return containsNull; +#else + if(o == null) return false; + if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return containsNull; +#endif + int pos = HashUtil.mix(o.hashCode()) & mask; + KEY_TYPE current = keys[pos]; + if(KEY_EQUALS_NULL(current)) return false; + if(EQUALS_KEY_TYPE(current, o)) return true; + while(true) { + if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; + else if(EQUALS_KEY_TYPE(current, o)) return true; + } + } + + @Override + public boolean remove(Object o) { +#if TYPE_OBJECT + if(o == null) return (containsNull ? removeNullIndex() : false); +#else + if(o == null) return false; + if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return (containsNull ? removeNullIndex() : false); +#endif + int pos = HashUtil.mix(o.hashCode()) & mask; + KEY_TYPE current = keys[pos]; + if(KEY_EQUALS_NULL(current)) return false; + if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); + while(true) { + if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; + else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos); + } + } + +#if !TYPE_OBJECT + @Override + public boolean contains(KEY_TYPE o) { + if(KEY_EQUALS_NULL(o)) return containsNull; + int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; + KEY_TYPE current = keys[pos]; + if(KEY_EQUALS_NULL(current)) return false; + if(KEY_EQUALS(current, o)) return true; + while(true) { + if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; + else if(KEY_EQUALS(current, o)) return true; + } + } + + @Override + public boolean REMOVE_KEY(KEY_TYPE o) { + if(KEY_EQUALS_NULL(o)) return containsNull ? removeNullIndex() : false; + int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask; + KEY_TYPE current = keys[pos]; + if(KEY_EQUALS_NULL(current)) return false; + if(KEY_EQUALS(current, o)) return removeIndex(pos); + while(true) { + if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false; + else if(KEY_EQUALS(current, o)) return removeIndex(pos); + } + } + +#endif + protected boolean removeIndex(int pos) { + if(pos == nullIndex) return containsNull ? removeNullIndex() : false; + keys[pos] = EMPTY_KEY_VALUE; + size--; + shiftKeys(pos); + if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); + return true; + } + + protected boolean removeNullIndex() { + containsNull = false; + keys[nullIndex] = EMPTY_KEY_VALUE; + size--; + if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2); + return true; + } + + @Override + public ITERATOR KEY_GENERIC_TYPE iterator() { + return new SetIterator(); + } + + @Override + public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { + if(size() <= 0) return; + if(containsNull) action.accept(keys[nullIndex]); + for(int i = nullIndex-1;i>=0;i--) { + if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]); + } + } + + @Override + public DistinctCollectionWrapper KEY_GENERIC_TYPE copy() { + DistinctCollectionWrapper KEY_GENERIC_TYPE set = new DistinctCollectionWrapperBRACES(0); + set.minCapacity = minCapacity; + set.mask = mask; + set.maxFill = maxFill; + set.nullIndex = nullIndex; + set.containsNull = containsNull; + set.size = size; + set.keys = Arrays.copyOf(keys, keys.length); + return set; + } + + protected void shiftKeys(int startPos) { + int slot, last; + KEY_TYPE current; + while(true) { + startPos = ((last = startPos) + 1) & mask; + while(true){ + if(KEY_EQUALS_NULL((current = keys[startPos]))) { + keys[last] = EMPTY_KEY_VALUE; + return; + } + slot = HashUtil.mix(KEY_TO_HASH(current)) & mask; + if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; + startPos = ++startPos & mask; + } + keys[last] = current; + } + } + + protected void rehash(int newSize) { + int newMask = newSize - 1; + KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1); + for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) { + while(true) { + if(--i < 0) throw new ConcurrentModificationException("Set was modified during rehash"); + if(KEY_EQUALS_NOT_NULL(keys[i])) break; + } + if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask])) + while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)])); + newKeys[pos] = keys[i]; + } + nullIndex = newSize; + mask = newMask; + maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1); + keys = newKeys; + } + + @Override + public void clear() { + if(size == 0) return; + size = 0; + containsNull = false; + Arrays.fill(keys, EMPTY_KEY_VALUE); + } + + @Override + public int size() { + return size; + } + + private class SetIterator implements ITERATOR KEY_GENERIC_TYPE { + int pos = nullIndex; + int returnedPos = -1; + int lastReturned = -1; + int nextIndex = Integer.MIN_VALUE; + boolean returnNull = containsNull; + KEY_TYPE[] wrapped = null; + int wrappedIndex = 0; + + @Override + public boolean hasNext() { + if(nextIndex == Integer.MIN_VALUE) { + if(returnNull) { + returnNull = false; + nextIndex = nullIndex; + } + else + { + while(true) { + if(--pos < 0) { + if(wrapped == null || wrappedIndex <= -pos - 1) break; + nextIndex = -pos - 1; + break; + } + if(KEY_EQUALS_NOT_NULL(keys[pos])){ + nextIndex = pos; + break; + } + } + } + } + return nextIndex != Integer.MIN_VALUE; + } + + @Override + public KEY_TYPE NEXT() { + if(!hasNext()) throw new NoSuchElementException(); + returnedPos = pos; + if(nextIndex < 0){ + lastReturned = Integer.MAX_VALUE; + KEY_TYPE value = wrapped[nextIndex]; + nextIndex = Integer.MIN_VALUE; + return value; + } + KEY_TYPE value = keys[(lastReturned = nextIndex)]; + nextIndex = Integer.MIN_VALUE; + return value; + } + + @Override + public void remove() { + if(lastReturned == -1) throw new IllegalStateException(); + if(lastReturned == nullIndex) { + containsNull = false; + keys[nullIndex] = EMPTY_KEY_VALUE; + } + else if(returnedPos >= 0) shiftKeys(returnedPos); + else { +#if TYPE_OBJECT + DistinctCollectionWrapper.this.remove(wrapped[-returnedPos - 1]); +#else + DistinctCollectionWrapper.this.REMOVE_KEY(wrapped[-returnedPos - 1]); +#endif + lastReturned = -1; + return; + } + size--; + lastReturned = -1; + } + + private void shiftKeys(int startPos) { + int slot, last; + KEY_TYPE current; + while(true) { + startPos = ((last = startPos) + 1) & mask; + while(true){ + if(KEY_EQUALS_NULL((current = keys[startPos]))) { + keys[last] = EMPTY_KEY_VALUE; + return; + } + slot = HashUtil.mix(KEY_TO_HASH(current)) & mask; + if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break; + startPos = ++startPos & mask; + } + if(startPos < last) addWrapper(keys[startPos]); + keys[last] = current; + } + } + + private void addWrapper(KEY_TYPE value) { + if(wrapped == null) wrapped = NEW_KEY_ARRAY(2); + else if(wrappedIndex >= wrapped.length) { + KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2); + System.arraycopy(wrapped, 0, newArray, 0, wrapped.length); + wrapped = newArray; + } + wrapped[wrappedIndex++] = value; + } + } + } + +#endif + private static class SingletonCollection KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE + { + KEY_TYPE element; + + SingletonCollection(KEY_TYPE element) { + this.element = element; + } + +#if !TYPE_OBJECT + @Override + public boolean REMOVE_KEY(KEY_TYPE o) { throw new UnsupportedOperationException(); } +#endif + @Override + public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); } + @Override + public ITERATOR KEY_GENERIC_TYPE iterator() + { + return new ITERATOR KEY_GENERIC_TYPE() { + boolean next = true; + @Override + public boolean hasNext() { return next; } + @Override + public KEY_TYPE NEXT() { + if(!hasNext()) throw new NoSuchElementException(); + next = false; + return element; + } + }; + } + @Override + public int size() { return 1; } + + @Override + public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); } + } + /** * Synchronized Collection Wrapper for the synchronizedCollection function * @Type(T) diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/IArray.template b/src/builder/resources/speiger/assets/collections/templates/utils/IArray.template index ff040f0a..3193973d 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/IArray.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/IArray.template @@ -7,7 +7,9 @@ import speiger.src.collections.utils.IArray; /** * Type-Specific Helper class to get the underlying array of array implementations. +#if ARRAY_LIST_FEATURE * @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST +#endif * @Type(T) */ public interface IARRAY KEY_GENERIC_TYPE extends IArray diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Iterables.template b/src/builder/resources/speiger/assets/collections/templates/utils/Iterables.template index de74496b..d5f02be6 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Iterables.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Iterables.template @@ -10,6 +10,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.function.Consumer; import speiger.src.collections.PACKAGE.collections.ITERABLE; +import speiger.src.collections.PACKAGE.collections.COLLECTION; #if !TYPE_OBJECT import speiger.src.collections.objects.collections.ObjectIterable; import speiger.src.collections.objects.collections.ObjectIterator; @@ -17,14 +18,8 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif import speiger.src.collections.PACKAGE.collections.ITERATOR; -import speiger.src.collections.PACKAGE.lists.LIST; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; -#if !TYPE_BOOLEAN -import speiger.src.collections.PACKAGE.sets.HASH_SET; -import speiger.src.collections.PACKAGE.sets.SET; -#endif import speiger.src.collections.utils.ISizeProvider; /** @@ -303,7 +298,7 @@ public class ITERABLES @Override public void forEach(Consumer action) { Objects.requireNonNull(action); - iterable.forEach(E -> action.accept(mapper.GET_VALUE(E))); + iterable.forEach(E -> action.accept(mapper.apply(E))); } } @@ -325,7 +320,7 @@ public class ITERABLES @Override public void forEach(Consumer action) { Objects.requireNonNull(action); - iterable.forEach(E -> mapper.GET_VALUE(E).forEach(action)); + iterable.forEach(E -> mapper.apply(E).forEach(action)); } } @@ -349,7 +344,7 @@ public class ITERABLES public void forEach(Consumer action) { Objects.requireNonNull(action); iterable.forEach(E -> { - T[] array = mapper.GET_VALUE(E); + T[] array = mapper.apply(E); for(int i = 0,m=array.length;i action) { Objects.requireNonNull(action); - LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); - iterable.forEach(T -> {action.accept(T); list.add(T);}); + COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper(); + iterable.forEach(T -> {action.accept(T); repeater.add(T);}); for(int i = 0;i { if(!filter.TEST_VALUE(T)) action.accept(T); } ); + iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } ); } #else public void forEach(Consumer action) { Objects.requireNonNull(action); - iterable.forEach(T -> { if(!filter.TEST_VALUE(T)) action.accept(T); } ); + iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } ); } #endif } @@ -496,19 +491,19 @@ public class ITERABLES @Override public void forEach(CONSUMER action) { Objects.requireNonNull(action); - LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); - iterable.forEach(list::add); - list.unstableSort(sorter); - list.forEach(action); + COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper(); + iterable.forEach(wrapper::add); + wrapper.unstableSort(sorter); + wrapper.forEach(action); } #else @Override public void forEach(Consumer action) { Objects.requireNonNull(action); - LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); - iterable.forEach(list::add); - list.unstableSort(sorter); - list.forEach(action); + COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper(); + iterable.forEach(wrapper::add); + wrapper.unstableSort(sorter); + wrapper.forEach(action); } #endif } @@ -538,14 +533,14 @@ public class ITERABLES action.accept(T); }); #else - SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES(); + COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper(); iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); }); #endif } #else public void forEach(Consumer action) { Objects.requireNonNull(action); - SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES(); + COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper(); iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); }); } #endif diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template index e9c0f3a8..805d18f2 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template @@ -16,15 +16,18 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION; import speiger.src.collections.PACKAGE.functions.function.PREDICATE; -import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE import speiger.src.collections.PACKAGE.lists.LIST; +#if ARRAY_LIST_FEATURE +import speiger.src.collections.PACKAGE.lists.ARRAY_LIST; +#else if LINKED_LIST_FEATURE +import speiger.src.collections.PACKAGE.lists.LINKED_LIST; +#endif + +#endif import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR; import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; import speiger.src.collections.PACKAGE.collections.COLLECTION; -#if !TYPE_BOOLEAN -import speiger.src.collections.PACKAGE.sets.HASH_SET; -import speiger.src.collections.PACKAGE.sets.SET; -#endif /** * A Helper class for Iterators @@ -468,6 +471,8 @@ public class ITERATORS } #endif +#if LIST_MODULE +#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE /** * A Helper function to pours all elements of a Iterator into a List * @param iter the elements that should be poured into list. @@ -486,12 +491,20 @@ public class ITERATORS * @return A list of all requested elements of the Iterator */ public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE pour(ITERATOR KEY_GENERIC_TYPE iter, int max) { +#if ARRAY_LIST_FEATURE ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); +#else + LINKED_LIST KEY_GENERIC_TYPE list = new LINKED_LISTBRACES(); +#endif pour(iter, list, max); +#if ARRAY_LIST_FEATURE list.trim(); +#endif return list; } +#endif +#endif /** * A Helper function to pours all elements of a Iterator into a Collection * @param iter the elements that should be poured into list. @@ -624,7 +637,7 @@ public class ITERATORS @Override public void remove() { it.remove(); } } - + private static class ReverseListIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE { LIST_ITERATOR KEY_GENERIC_TYPE it; @@ -747,45 +760,25 @@ public class ITERATORS return iterator.NEXT(); } } - + private static class EmptyIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE { @Override - public boolean hasNext() { - return false; - } - + public boolean hasNext() { return false; } @Override - public KEY_TYPE NEXT() { - throw new NoSuchElementException(); - } - + public KEY_TYPE NEXT() { throw new NoSuchElementException(); } @Override - public boolean hasPrevious() { - return false; - } - + public boolean hasPrevious() { return false; } @Override - public KEY_TYPE PREVIOUS() { - throw new NoSuchElementException(); - } - + public KEY_TYPE PREVIOUS() { throw new NoSuchElementException(); } @Override - public int nextIndex() { - return 0; - } - + public int nextIndex() { return 0; } @Override - public int previousIndex() { - return -1; - } - + public int previousIndex() { return -1; } @Override public void remove() { throw new UnsupportedOperationException(); } - @Override public void set(KEY_TYPE e) { throw new UnsupportedOperationException(); } - @Override public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); } } @@ -839,7 +832,7 @@ public class ITERATORS @Override public T next() { - return mapper.GET_VALUE(iterator.NEXT()); + return mapper.apply(iterator.NEXT()); } @Override @@ -865,7 +858,7 @@ public class ITERATORS foundNext = true; while(iterator.hasNext()) { if(last != null && last.hasNext()) return; - last = mapper.GET_VALUE(iterator.NEXT()).iterator(); + last = mapper.apply(iterator.NEXT()).iterator(); } } @@ -901,7 +894,7 @@ public class ITERATORS foundNext = true; while(iterator.hasNext()) { if(last != null && last.hasNext()) return; - last = ObjectIterators.wrap(mapper.GET_VALUE(iterator.NEXT())); + last = ObjectIterators.wrap(mapper.apply(iterator.NEXT())); } } @@ -925,7 +918,7 @@ public class ITERATORS final int repeats; int index = 0; ITERATOR KEY_GENERIC_TYPE iter; - LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(); + COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper(); public RepeatingIterator(ITERATOR KEY_GENERIC_TYPE iter, int repeat) { this.iter = iter; @@ -937,7 +930,7 @@ public class ITERATORS if(iter.hasNext()) return true; if(index < repeats) { index++; - iter = list.iterator(); + iter = repeater.iterator(); return iter.hasNext(); } return false; @@ -947,7 +940,7 @@ public class ITERATORS public KEY_TYPE NEXT() { if(!hasNext()) throw new NoSuchElementException(); KEY_TYPE value = iter.NEXT(); - if(index == 0) list.add(value); + if(index == 0) repeater.add(value); return value; } } @@ -956,7 +949,7 @@ public class ITERATORS { ITERATOR KEY_GENERIC_TYPE iterator; COMPARATOR KEY_GENERIC_TYPE sorter; - LIST KEY_GENERIC_TYPE sortedElements = null; + COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE sortedElements = null; int index = 0; public SortedIterator(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE sorter) { @@ -968,7 +961,11 @@ public class ITERATORS public boolean hasNext() { if(sortedElements == null) { boolean hasNext = iterator.hasNext(); - sortedElements = hasNext ? pour(iterator) : LISTS.empty(); + if(hasNext) { + sortedElements = COLLECTIONS.wrapper(); + pour(iterator, sortedElements); + } + else sortedElements = COLLECTIONS.wrapper(); if(hasNext) sortedElements.unstableSort(sorter); } return index < sortedElements.size(); @@ -987,7 +984,7 @@ public class ITERATORS #if TYPE_BOOLEAN int filtered; #else - SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES(); + COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper(); #endif KEY_TYPE lastFound; boolean foundNext = false; @@ -1048,7 +1045,7 @@ public class ITERATORS if(foundNext) return; while(iterator.hasNext()) { lastFound = iterator.NEXT(); - if(filter.TEST_VALUE(lastFound)) { + if(filter.test(lastFound)) { foundNext = true; break; } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template b/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template index 2663a000..19f2d53b 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template @@ -2,10 +2,14 @@ package speiger.src.collections.PACKAGE.utils; import java.util.Collection; import java.util.List; +#if IARRAY_FEATURE import java.util.Objects; +#endif import java.util.Random; import java.util.RandomAccess; +#if IARRAY_FEATURE || TYPE_OBJECT import java.util.function.Consumer; +#endif #if PRIMITIVES import java.nio.JAVA_BUFFER; #endif @@ -17,7 +21,9 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER; import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST; import speiger.src.collections.PACKAGE.lists.LIST; import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR; +#if IARRAY_FEATURE import speiger.src.collections.PACKAGE.utils.ARRAYS; +#endif import speiger.src.collections.utils.SanityChecks; /** @@ -60,7 +66,11 @@ public class LISTS * @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_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l) { +#if IARRAY_FEATURE return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l))); +#else + return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l)); +#endif } /** @@ -71,7 +81,11 @@ public class LISTS * @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_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l, Object mutex) { +#if IARRAY_FEATURE return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex))); +#else + return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex)); +#endif } /** @@ -92,6 +106,7 @@ public class LISTS */ public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE reverse(LIST KEY_GENERIC_TYPE list) { int size = list.size(); +#if IARRAY_FEATURE if(list instanceof IARRAY) { IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list; #if TYPE_OBJECT @@ -106,6 +121,7 @@ public class LISTS return list; #endif } +#endif if(list instanceof RandomAccess) { for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--) { KEY_TYPE t = list.GET_KEY(i); @@ -143,6 +159,7 @@ public class LISTS */ public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE shuffle(LIST KEY_GENERIC_TYPE list, Random random) { int size = list.size(); +#if IARRAY_FEATURE if(list instanceof IARRAY) { IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list; #if TYPE_OBJECT @@ -164,7 +181,8 @@ public class LISTS #endif return list; } - for(int i = list.size(); i-- != 0;) { +#endif + for(int i = size; i-- != 0;) { int p = random.nextInt(i + 1); KEY_TYPE t = list.GET_KEY(i); list.set(i, list.GET_KEY(p)); @@ -231,6 +249,7 @@ public class LISTS public SingletonList KEY_GENERIC_TYPE copy() { return new SingletonListBRACES(element); } } +#if IARRAY_FEATURE private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE { IARRAY KEY_GENERIC_TYPE l; @@ -271,6 +290,7 @@ public class LISTS } } +#endif private static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess { SynchronizedRandomAccessList(LIST KEY_GENERIC_TYPE l) { diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/PriorityQueues.template b/src/builder/resources/speiger/assets/collections/templates/utils/PriorityQueues.template index 61f7d325..03ba1276 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/PriorityQueues.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/PriorityQueues.template @@ -11,7 +11,9 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif +#if DEQUEUE_FEATURE import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE; +#endif import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE; #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.functions.CONSUMER; @@ -46,6 +48,7 @@ public class PRIORITY_QUEUES return queue instanceof SynchronizedPriorityQueue ? (SynchronizedPriorityQueue KEY_GENERIC_TYPE)queue : new SynchronizedPriorityQueueBRACES(queue, mutex); } +#if DEQUEUE_FEATURE /** * Returns a synchronized PriorityDequeue instance based on the instance given. * @param dequeue that should be synchronized @@ -67,6 +70,7 @@ public class PRIORITY_QUEUES return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex); } +#endif /** * Wrapper class for synchronization * @Type(T) @@ -134,6 +138,7 @@ public class PRIORITY_QUEUES public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } } } +#if DEQUEUE_FEATURE /** * Wrapper class for synchronization * @Type(T) @@ -166,4 +171,5 @@ public class PRIORITY_QUEUES @Override public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } } } +#endif } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template b/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template index 8d63b4c5..14e62c05 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template @@ -2,31 +2,30 @@ package speiger.src.collections.PACKAGE.utils; import java.util.NoSuchElementException; import java.util.Set; -#if TYPE_BOOLEAN -import speiger.src.collections.booleans.collections.BooleanIterator; -import speiger.src.collections.booleans.sets.AbstractBooleanSet; -import speiger.src.collections.booleans.sets.BooleanSet; -import speiger.src.collections.booleans.utils.BooleanCollections.EmptyCollection; -#else -#if TYPE_OBJECT +#if TYPE_OBJECT && SORTED_SET_FEATURE import java.util.Comparator; #endif import speiger.src.collections.PACKAGE.collections.BI_ITERATOR; -#if !TYPE_OBJECT +#if !TYPE_OBJECT && SORTED_SET_FEATURE import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif import speiger.src.collections.PACKAGE.collections.ITERATOR; +#if SORTED_SET_FEATURE import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; +#endif import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET; import speiger.src.collections.PACKAGE.sets.SET; +#if ORDERED_SET_FEATURE import speiger.src.collections.PACKAGE.sets.ORDERED_SET; +#endif +#if SORTED_SET_FEATURE import speiger.src.collections.PACKAGE.sets.SORTED_SET; +#endif import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection; import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection; import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection; import speiger.src.collections.utils.ITrimmable; -#endif /** * A Helper class for sets @@ -51,7 +50,6 @@ public class SETS #endif } -#if !TYPE_BOOLEAN /** * Creates a Synchronized set while preserving the ITrimmable interface * @param s the set that should be synchronized @@ -75,6 +73,7 @@ public class SETS return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex)); } +#if SORTED_SET_FEATURE /** * Creates a Synchronized SortedSet while preserving the ITrimmable interface * @param s the set that should be synchronized @@ -98,6 +97,8 @@ public class SETS return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex)); } +#endif +#if ORDERED_SET_FEATURE /** * Creates a Synchronized OrderedSet while preserving the ITrimmable interface * @param s the set that should be synchronized @@ -121,6 +122,8 @@ public class SETS return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex)); } +#endif +#if SORTED_SET_FEATURE /** * Creates a Synchronized NavigableSet while preserving the ITrimmable interface * @param s the set that should be synchronized @@ -144,6 +147,7 @@ public class SETS return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex)); } +#endif /** * Creates Unmodifyable Set wrapper * @param s set that should be made unmodifiable @@ -154,6 +158,7 @@ public class SETS return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s); } +#if SORTED_SET_FEATURE /** * Creates Unmodifyable SortedSet wrapper * @param s sortedSet that should be made unmodifiable @@ -164,6 +169,8 @@ public class SETS return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s); } +#endif +#if ORDERED_SET_FEATURE /** * Creates Unmodifyable OrderedSet wrapper * @param s OrderedSet that should be made unmodifiable @@ -174,6 +181,8 @@ public class SETS return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s); } +#endif +#if SORTED_SET_FEATURE /** * Creates Unmodifyable NavigableSet wrapper * @param s navigableSet that should be made unmodifiable @@ -254,7 +263,7 @@ public class SETS public EmptySet KEY_GENERIC_TYPE copy() { return this; } } -#if !TYPE_BOOLEAN +#if SORTED_SET_FEATURE private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE { NAVIGABLE_SET KEY_GENERIC_TYPE n; @@ -340,6 +349,8 @@ public class SETS public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); } } +#endif +#if ORDERED_SET_FEATURE private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE { ORDERED_SET KEY_GENERIC_TYPE s; @@ -373,6 +384,8 @@ public class SETS public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); } } +#endif +#if SORTED_SET_FEATURE private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE { SORTED_SET KEY_GENERIC_TYPE s; @@ -406,6 +419,7 @@ public class SETS public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); } } +#endif /** * Unmodifyable Set wrapper that helps is used with unmodifyableSet function * @Type(T) @@ -434,6 +448,7 @@ public class SETS #endif } +#if SORTED_SET_FEATURE private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable { ITrimmable trim; @@ -597,6 +612,8 @@ public class SETS public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } } } +#endif +#if ORDERED_SET_FEATURE private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable { ITrimmable trim; @@ -656,6 +673,7 @@ public class SETS public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } } } +#endif private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable { ITrimmable trim; @@ -704,5 +722,4 @@ public class SETS public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } } #endif } -#endif } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Strategy.template b/src/builder/resources/speiger/assets/collections/templates/utils/Strategy.template index 8fc4af5b..b49581b9 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Strategy.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Strategy.template @@ -1,5 +1,7 @@ package speiger.src.collections.PACKAGE.utils; +import java.util.Objects; + /** * A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps * @Type(T) @@ -19,6 +21,17 @@ public interface STRATEGY KEY_GENERIC_TYPE public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY)IDENTITY; } #endif + /** + * Normal Strategy + */ + public static final STRATEGY NO_GENERIC_TYPE NORMAL = new NormalStrategyBRACES(); + + /** + * @Type(T) + * @return a Normal Strategy that is behaving exactly like the normal Hash Strategy in the Hash Collections + */ + public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE normalStrategy() { return (STRATEGY KEY_GENERIC_TYPE)NORMAL; } + /** * Type Specific HashCode function * @param o the element that the hashcode is requested for (if object may be null) @@ -47,5 +60,18 @@ public interface STRATEGY KEY_GENERIC_TYPE @Override public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; } } + #endif + /** + * A Strategy that simulates the normal Hash Collection Behavior if you want to use Hash Control Collections to replace normal ones. + * Only real reason to do that is you have to use this and want to get rid of implementations. + * @Type(T) + */ + public static class NormalStrategy KEY_GENERIC_TYPE implements STRATEGY KEY_GENERIC_TYPE + { + @Override + public int hashCode(KEY_TYPE o) { return KEY_TO_HASH(o); } + @Override + public boolean equals(KEY_TYPE key, KEY_TYPE value) { return EQUALS_KEY_TYPE(key, value); } + } } \ No newline at end of file diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template b/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template index efa8f5a5..d60338cf 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template @@ -3,9 +3,9 @@ package speiger.src.collections.PACKAGE.utils.maps; #if !TYPE_BOOLEAN import java.util.Map; import java.util.Objects; -#if TYPE_OBJECT +#if TYPE_OBJECT && SORTED_MAP_FEATURE import java.util.Comparator; -#else +#else if !TYPE_OBJECT import java.util.function.BiConsumer; import java.util.function.BiFunction; #endif @@ -18,27 +18,34 @@ import java.util.function.Function; import speiger.src.collections.objects.collections.ObjectIterable; import speiger.src.collections.objects.collections.ObjectIterator; import speiger.src.collections.objects.sets.ObjectSet; -#if !TYPE_BOOLEAN import speiger.src.collections.objects.collections.ObjectBidirectionalIterator; import speiger.src.collections.objects.utils.ObjectIterators; import speiger.src.collections.objects.utils.ObjectSets; #if !TYPE_OBJECT import speiger.src.collections.objects.sets.ObjectOrderedSet; +#if SORTED_MAP_FEATURE import speiger.src.collections.PACKAGE.functions.COMPARATOR; #endif +#endif import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER; import speiger.src.collections.PACKAGE.functions.function.FUNCTION; import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR; import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP; -#endif import speiger.src.collections.PACKAGE.maps.interfaces.MAP; -#if !TYPE_BOOLEAN +#if SORTED_MAP_FEATURE import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP; import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP; +#endif +#if ORDERED_MAP_FEATURE import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP; +#endif +#if SORTED_MAP_FEATURE import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET; import speiger.src.collections.PACKAGE.sets.SORTED_SET; +#endif +#if ORDERED_MAP_FEATURE import speiger.src.collections.PACKAGE.sets.ORDERED_SET; +#endif #if !TYPE_OBJECT import speiger.src.collections.PACKAGE.sets.SET; import speiger.src.collections.PACKAGE.utils.SETS; @@ -49,10 +56,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER #endif import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER; import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS; -#if !SAME_TYPE && !VALUE_OBJECT -import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS; -#endif -#endif /** * A Helper class that provides you with Singleton/Empty/Synchronized/Unmodifyable Maps @@ -123,8 +126,6 @@ public class MAPS else entries.forEach(action); } -#if !TYPE_BOOLEAN - /** * Helper function that creates a Helper wrapper to synchronize access into the map. * @param map the map that should be synchronized @@ -147,6 +148,7 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE synchronize(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedMap ? map : new SynchronizedMapKV_BRACES(map, mutex); } +#if SORTED_MAP_FEATURE /** * Helper function that creates a Helper wrapper to synchronize access into the SortedMap. * @param map the SortedMap that should be synchronized @@ -169,6 +171,8 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); } +#endif +#if ORDERED_MAP_FEATURE /** * Helper function that creates a Helper wrapper to synchronize access into the OrderedMap. * @param map the OrderedMap that should be synchronized @@ -191,6 +195,8 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); } +#endif +#if SORTED_MAP_FEATURE /** * Helper function that creates a Helper wrapper to synchronize access into the NavigableMap. * @param map the NavigableMap that should be synchronized @@ -213,6 +219,7 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE synchronize(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedNavigableMap ? map : new SynchronizedNavigableMapKV_BRACES(map, mutex); } +#endif /** * A Helper function that creates a Helper wrapper to only allow Read Access into the Map * @param map the map that should be made Unmodifiable @@ -223,6 +230,7 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); } +#if ORDERED_MAP_FEATURE /** * A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap * @param map the OrderedMap that should be made Unmodifiable @@ -233,6 +241,8 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); } +#endif +#if SORTED_MAP_FEATURE /** * A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap * @param map the SortedMap that should be made Unmodifiable @@ -253,6 +263,7 @@ public class MAPS */ public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); } +#endif /** * A Helper function that creates a Unmodifyable Entry * @param entry the Entry that should be made unmodifiable @@ -344,7 +355,7 @@ public class MAPS @Override public VALUE_COLLECTION VALUE_GENERIC_TYPE values() { - if(values == null) values = VALUE_SETS.singleton(value); + if(values == null) values = VALUE_COLLECTIONS.singleton(value); return values; } @Override @@ -425,6 +436,7 @@ public class MAPS public void set(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); } } +#if SORTED_MAP_FEATURE /** * The Unmodifyable Navigable Map implementation that is sued for the unmodifyableMap function * @Type(T) @@ -496,6 +508,8 @@ public class MAPS public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); } } +#endif +#if ORDERED_MAP_FEATURE /** * The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function * @Type(T) @@ -548,6 +562,8 @@ public class MAPS } } +#endif +#if SORTED_MAP_FEATURE /** * The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function * @Type(T) @@ -587,6 +603,7 @@ public class MAPS public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); } } +#endif /** * The Unmodifyable Map implementation that is sued for the unmodifyableMap function * @Type(T) @@ -669,7 +686,7 @@ public class MAPS } } - +#if ORDERED_MAP_FEATURE /** * The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation * @Type(T) @@ -708,6 +725,7 @@ public class MAPS public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); } } +#endif /** * The Unmodifyable Set implementation for the Unmodifyable Map implementation * @Type(T) @@ -741,6 +759,7 @@ public class MAPS } +#if SORTED_MAP_FEATURE /** * The Synchronized Navigable Map implementation used by the synchronizedMap helper function * @Type(T) @@ -859,6 +878,8 @@ public class MAPS #endif } +#endif +#if ORDERED_MAP_FEATURE /** * The Synchronized Ordered Map implementation used by the synchronizedMap helper function * @Type(T) @@ -916,6 +937,8 @@ public class MAPS } } +#endif +#if SORTED_MAP_FEATURE /** * The Synchronized Sorted Map implementation used by the synchronizedMap helper function * @Type(T) @@ -977,6 +1000,7 @@ public class MAPS #endif } +#endif /** * The Synchronized Map implementation used by the synchronizedMap helper function * @Type(T) @@ -1148,5 +1172,4 @@ public class MAPS public void forEach(BiConsumer action) { synchronized(mutex) { map.forEach(action); } } #endif } -#endif } \ No newline at end of file