Compare commits
54
Commits
99e9afe7b1
...
0.9.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6afed5e174 | ||
|
|
640a1a8161 | ||
|
|
274d37c4d6 | ||
|
|
a89c812c06 | ||
|
|
6af0656216 | ||
|
|
e76db94136 | ||
|
|
7011101b05 | ||
|
|
d0599b99ec | ||
|
|
d7c5b9ad7d | ||
|
|
d2c81e7779 | ||
|
|
ef5fdbd377 | ||
|
|
5e67e45910 | ||
|
|
63ef68fb95 | ||
|
|
0f9751bf70 | ||
|
|
bcc2ffdc13 | ||
|
|
2da4588430 | ||
|
|
ed9ce60af4 | ||
|
|
4dd3a4a6e8 | ||
|
|
efd29bbe7e | ||
|
|
96458bd8b6 | ||
|
|
477f3c9f40 | ||
|
|
3f6e7fbb88 | ||
|
|
5650c6e69b | ||
|
|
61df32b7b2 | ||
|
|
859d00da16 | ||
|
|
9df95c0fc3 | ||
|
|
d6d2c0a396 | ||
|
|
127eb71968 | ||
|
|
6005d0fd39 | ||
|
|
290e626f07 | ||
|
|
e30d011273 | ||
|
|
4c52636c23 | ||
|
|
aa580c1772 | ||
|
|
8f7d49b280 | ||
|
|
342b0cece9 | ||
|
|
3ce52668df | ||
|
|
ce9343348e | ||
|
|
8d9f7a6761 | ||
|
|
1b1ec4b87a | ||
|
|
cc92ef953a | ||
|
|
8d8c30c9a7 | ||
|
|
d44ad2d42e | ||
|
|
2ed090e989 | ||
|
|
dafb162797 | ||
|
|
57280b8285 | ||
|
|
c9fc963670 | ||
|
|
cc87cae145 | ||
|
|
f53d61a5bc | ||
|
|
b29874189c | ||
|
|
6722f399db | ||
|
|
8e39acef45 | ||
|
|
b065ebe9ba | ||
|
|
25a7cd060a | ||
|
|
21f330260e |
@@ -1,32 +1,33 @@
|
|||||||
name: Latest Build
|
name: Latest Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
jdk: [8, 11, 14, 16, 17, 18]
|
jdk: [8, 11, 16, 17, 18, 19, 20]
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Set up JDK ${{ matrix.jdk }}
|
- name: Set up JDK ${{ matrix.jdk }}
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.jdk }}
|
distribution: 'temurin'
|
||||||
|
java-version: ${{ matrix.jdk }}
|
||||||
- name: Validate Gradle wrapper
|
|
||||||
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
- name: Validate Gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
- name: Make gradlew executable
|
|
||||||
run: chmod +x ./gradlew
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
- name: Build with Gradle
|
|
||||||
run: ./gradlew build
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
name: Unit Tests
|
name: Unit Tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
name: Measure coverage
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ debug ]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Code Quality Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: 'temurin'
|
||||||
|
java-version: 11
|
||||||
|
cache: 'gradle'
|
||||||
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
- name: Build and analyze
|
||||||
|
run: ./gradlew generateTestSource test jacocoTestReport --info -Dfull_test_suite=true
|
||||||
|
- name: Upload to CodeCov
|
||||||
|
env:
|
||||||
|
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
run: bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN
|
||||||
+279
-245
@@ -1,246 +1,280 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
### Version 0.7.1 (Unreleased)
|
### Version 0.8.1
|
||||||
- Added: ISizeProvider interface (Optimization Helper)
|
- Added: getFirst/getLast/removeFirst/removeLast to List.class.
|
||||||
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
|
- Added: Dedicated Set toArray implementations.
|
||||||
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
- Added: ToArray/pushTop functions to Stack.class.
|
||||||
- Fixed: putIfAbsent now replaces defaultValues
|
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
||||||
|
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
||||||
### Version 0.7.0
|
- Added: Iterators.infinite as an option that will create a Infinite Iterator based on the inputed one.
|
||||||
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
- Added: List.indexedIterator which allows you to create a iterator with a customized iteration indecies. Useful if you want to transform lists output.
|
||||||
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
- Added: PriorityQueue.contains is now a function
|
||||||
- Added: EnumMap specialized forEach implementation.
|
- Added: Iterators/Async Builders now support MapToPrimitiveType function on the object variant. So more processing can be done. (Will be expanded upon later versions)
|
||||||
- Added: AbstractMap.remove now delegates to its primitive counterpart.
|
- Fixed: SetValue wasn't working on forEach implementations.
|
||||||
- Added: ConcurrentHashMap now implements ITrimmable
|
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
||||||
- Refactor: Removed a lot of disabled code from ArraySet.
|
- Fixed: Supplier was using the wrong dataType in their function name.
|
||||||
- Removed: LinkedList.addAll(index, List) now delegates to LinkedList.addAll(index, Collection) due to no special optimization required.
|
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
||||||
- Fixed: AbstractList.SubList.get/set/swapRemove didn't calculate their List index Properly
|
|
||||||
- Fixed: AbstractList.SubList chains now properly if you create SubLists within SubLists.
|
### Version 0.8.0
|
||||||
- Fixed: AbstractList.Iterator.add now respects Immutable/UnmodifiableLists.
|
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
||||||
- Fixed: AbstractList.Iterator.skip/back now keep track of the last returned value for remove function to work properly.
|
- Added: Dedicated implementations for toArray into TreeSets
|
||||||
- Fixed: CopyOnWriteArrayList.extract/removeElements(int, int) does now proper range checks and remove elements properly.
|
- Fixed: forEach methods in Maps now can use "setValue" functions.
|
||||||
- Fixed: CopyOnWriteArrayList.SubList now works properly. (Reimplemented entirely)
|
|
||||||
- Fixed: CopyOnWriteArrayList.Iterator.previous() was returning the wrong values.
|
### Version 0.8.0
|
||||||
- Fixed: CopyOnWriteArrayList.Iterator.skip now skips the right amount of elements and stops where it should.
|
- Added: ISizeProvider interface (Optimization Helper)
|
||||||
- Fixed: LinkedList.first/last/dequeue/dequeueLast now throws NoSuchElementException when empty instead of IllegalStateException.
|
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
|
||||||
- Fixed: LinkedList had an edge case where the entire reverse iterator would break if the wrong element was removed.
|
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
||||||
- Fixed: LinkedList.extractElement now returns the correct values.
|
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
||||||
- Fixed: AbstractMap.entrySet().remove(Object) now returns true if defaultReturnValue elements were removed.
|
- Added: Functions of a BooleanValue have now alwaysTrue/False function.
|
||||||
- Fixed: ConcurrentHashMap.remove(Object, Object) checks if the type matches before comparing against null Values.
|
- Added: ForEachIndexed for all Iterable implementations
|
||||||
- Fixed: LinkedHashMap.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
- Added: RandomGenerator support (Java17), though requires self compilation
|
||||||
- Fixed: HashMap.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
- Added: Optimizations for HashUtils next power of function.
|
||||||
- Fixed: HashMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
- Added: toArray() now returns a cached empty array if the collection is empty.
|
||||||
- Fixed: ImmutableMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
- Added: toArray function for AsyncBuilder
|
||||||
- Fixed: ArrayMap.iterator(key) now throws NoSuchElementException when the element wasn't found.
|
- Added: Modularization to the library where feature can be disabled as needed. (Requires Self-Compilation)
|
||||||
- Fixed: Linked/EnumMap array constructor was creating the wrong size values array.
|
- Fixed: putIfAbsent now replaces defaultValues
|
||||||
- Fixed: LinkedEnumMap.getAndMoveToFirst/Last was moving elements even if the element wasn't present.
|
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
||||||
- Fixed: AVL/RBTreeMap.getFirst/LastKey was not throwing a NoSuchElementException if the map was empty.
|
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
||||||
- Fixed: Map.Builder wasn't throwing a IllegalStateException when creating a negative size builder.
|
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
|
||||||
- Fixed: AVL/RBTreeSet.DecendingSet.subSet(from, fromInclusive, to, toInclusive) was creating a corrupt asending subset.
|
- 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
|
||||||
- Fixed: ArraySet throws now a IllegalStateException when trying to create it with a negative size.
|
- Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat.
|
||||||
- Fixed: ArraySet.addMoveToLast(key) was crashing when a key was already present.
|
- Breaking Change: Some function classes now get closer to javas terms. (Predicate/UnaryOperator etc)
|
||||||
- Fixed: Immutable/LinkedHashSet now keep track of their iteration index properly.
|
|
||||||
- Fixed: LinkedHashSet.moveToFirst/Last(key) would crash if the Set was empty.
|
### Version 0.7.0
|
||||||
- Fixed: LinkedHashSet.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
||||||
- Fixed: HashSet.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
||||||
|
- Added: EnumMap specialized forEach implementation.
|
||||||
|
- Added: AbstractMap.remove now delegates to its primitive counterpart.
|
||||||
### Version 0.6.2
|
- Added: ConcurrentHashMap now implements ITrimmable
|
||||||
- Added: Array only sorting function return the inputed array. This was done to allow for static final references to use the method in one go without having to make lambda wrappers. Cleaner code.
|
- Refactor: Removed a lot of disabled code from ArraySet.
|
||||||
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
- Removed: LinkedList.addAll(index, List) now delegates to LinkedList.addAll(index, Collection) due to no special optimization required.
|
||||||
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
- Fixed: AbstractList.SubList.get/set/swapRemove didn't calculate their List index Properly
|
||||||
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
- Fixed: AbstractList.SubList chains now properly if you create SubLists within SubLists.
|
||||||
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
- Fixed: AbstractList.Iterator.add now respects Immutable/UnmodifiableLists.
|
||||||
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
- Fixed: AbstractList.Iterator.skip/back now keep track of the last returned value for remove function to work properly.
|
||||||
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
- Fixed: CopyOnWriteArrayList.extract/removeElements(int, int) does now proper range checks and remove elements properly.
|
||||||
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
- Fixed: CopyOnWriteArrayList.SubList now works properly. (Reimplemented entirely)
|
||||||
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
- Fixed: CopyOnWriteArrayList.Iterator.previous() was returning the wrong values.
|
||||||
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
- Fixed: CopyOnWriteArrayList.Iterator.skip now skips the right amount of elements and stops where it should.
|
||||||
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
- Fixed: LinkedList.first/last/dequeue/dequeueLast now throws NoSuchElementException when empty instead of IllegalStateException.
|
||||||
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
- Fixed: LinkedList had an edge case where the entire reverse iterator would break if the wrong element was removed.
|
||||||
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
- Fixed: LinkedList.extractElement now returns the correct values.
|
||||||
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
- Fixed: AbstractMap.entrySet().remove(Object) now returns true if defaultReturnValue elements were removed.
|
||||||
- Fixed: ArrayList/LinkedList extractElements crashing when 0 or less elements are desired.
|
- Fixed: ConcurrentHashMap.remove(Object, Object) checks if the type matches before comparing against null Values.
|
||||||
- Fixed: TreeMap pollFirst/LastKey should return the defaultMin/max value instead of a Empty value.
|
- Fixed: LinkedHashMap.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
||||||
- Fixed: TreeMap keySet implementation was missing the class type implementations to pass keySet tests.
|
- Fixed: HashMap.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
||||||
- Fixed: TreeMap.SubMap Iterator (primitive Keys) was crashing because a Null was set on to a primitive.
|
- Fixed: HashMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
|
- Fixed: ImmutableMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
|
- Fixed: ArrayMap.iterator(key) now throws NoSuchElementException when the element wasn't found.
|
||||||
### Version 0.6.1
|
- Fixed: Linked/EnumMap array constructor was creating the wrong size values array.
|
||||||
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
- Fixed: LinkedEnumMap.getAndMoveToFirst/Last was moving elements even if the element wasn't present.
|
||||||
- Fixed: FIFO queue only clears the array if it was in use.
|
- Fixed: AVL/RBTreeMap.getFirst/LastKey was not throwing a NoSuchElementException if the map was empty.
|
||||||
- Added: Sorted Method for the stream replacing functions.
|
- Fixed: Map.Builder wasn't throwing a IllegalStateException when creating a negative size builder.
|
||||||
|
- Fixed: AVL/RBTreeSet.DecendingSet.subSet(from, fromInclusive, to, toInclusive) was creating a corrupt asending subset.
|
||||||
### Version 0.6.0
|
- Fixed: ArraySet throws now a IllegalStateException when trying to create it with a negative size.
|
||||||
- Added: addOrGet for sets.
|
- Fixed: ArraySet.addMoveToLast(key) was crashing when a key was already present.
|
||||||
- Added: Async API which allows to easily execute Iterables/Collections offthread without the complexity.
|
- Fixed: Immutable/LinkedHashSet now keep track of their iteration index properly.
|
||||||
- Added: CopyOnWriteArrayList and tests for it
|
- Fixed: LinkedHashSet.moveToFirst/Last(key) would crash if the Set was empty.
|
||||||
- Added: Support up to Java17.
|
- Fixed: LinkedHashSet.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
||||||
- Added: Build System now adds module-info if the Running JVM is 9 or higher
|
- Fixed: HashSet.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
||||||
- Added: ArrayList.of(Class, size) that allows you to allocate a size right at the creation of the List without having to create a wrapper array.
|
|
||||||
- Added: A ConcurrentHashMap implementation.
|
|
||||||
- Fixed: containsValue in the HashMap wouldn't check the nullKey
|
### Version 0.6.2
|
||||||
- Removed: Deprecated functions from SortedMaps/Sets
|
- Added: Array only sorting function return the inputed array. This was done to allow for static final references to use the method in one go without having to make lambda wrappers. Cleaner code.
|
||||||
|
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
||||||
### Version 0.5.3
|
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
||||||
- Added: OrderedMap/Set
|
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
||||||
- Added: Deprecation to Functions that are specific to Ordered interfaces in the SortedMap/Set
|
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
||||||
- Added: subFrom to Maps which is the counterpart of the addTo method
|
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
||||||
- Added: pourAsList and pourAsSet (booleans excluded for sets) to Iterable
|
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
||||||
- Fixed: ArrayList.grow had a small bug where it would trigger to early causing performance problems with exact sized collections.
|
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
||||||
- Fixed: FIFOQueue size constructor had a small bug where it would trigger a array enlargement when all elements were inserted.
|
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
||||||
|
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
||||||
### Version 0.5.2
|
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
||||||
- Fixed: Bugs with Queues starting with the wrong size
|
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
||||||
- Fixed: ArrayGrowth for Queues was +1 instead of +50%
|
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
||||||
- Added: Benchmarks with java and FastUtil
|
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
||||||
|
- Fixed: ArrayList/LinkedList extractElements crashing when 0 or less elements are desired.
|
||||||
### Version 0.5.1
|
- Fixed: TreeMap pollFirst/LastKey should return the defaultMin/max value instead of a Empty value.
|
||||||
- Fixed: Reworked the NavigableSet/Map implementations of RBTree/AVLTree/Array Sets/Maps so they are now deemed stable.
|
- Fixed: TreeMap keySet implementation was missing the class type implementations to pass keySet tests.
|
||||||
- Added: Another 150k Unit tests.
|
- Fixed: TreeMap.SubMap Iterator (primitive Keys) was crashing because a Null was set on to a primitive.
|
||||||
- Added: List and Set Unit tests for Integer (or Primitives in this case) to ensure basic stability there. (Now covering all sets and lists)
|
|
||||||
- Fixed: Bugs with null values for primitive collections.
|
|
||||||
- Removed: ArraySet/Map subSet/subMap implementation was removed.
|
### Version 0.6.1
|
||||||
|
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
||||||
### Version 0.5.0
|
- Fixed: FIFO queue only clears the array if it was in use.
|
||||||
- Added: 2 Helper functions to find out how many bits are required to store a Number.
|
- Added: Sorted Method for the stream replacing functions.
|
||||||
- Added: pour function directly into Iterable which allows to collect all elements in the Iterable directly.
|
|
||||||
- Added: The new ToArray method from Java9 and newer into the library. Using a functional interface. (Just a backport)
|
### Version 0.6.0
|
||||||
- Changed: Reworked how the Map Builder functions are created. They are now in a SubClass that moves them out of the way. Less Clutter. (This might break things if that was used before)
|
- Added: addOrGet for sets.
|
||||||
- Added: Map Builder that allows now to Build Maps like Guava ImmutableMaps can be build. Note: This has a slight performance overhead.
|
- Added: Async API which allows to easily execute Iterables/Collections offthread without the complexity.
|
||||||
- Added: Unmodifiable and Synchronize wrapper functions direclty into Collection Interfaces. This is mostly a quality of life thing.
|
- Added: CopyOnWriteArrayList and tests for it
|
||||||
- Added: Unmodifiable and Synchronized Wrapper Collections can now be cloned. They clone the underlying map which doesn't break functionality. (Had a usecase for it)
|
- Added: Support up to Java17.
|
||||||
- Added: A boxed putAll array variant.
|
- Added: Build System now adds module-info if the Running JVM is 9 or higher
|
||||||
- Fixed: EnumMaps didn't keep track of their size and now got proper care and implementations as needed. There might be more work required but at least the core functionality is now up to date.
|
- Added: ArrayList.of(Class, size) that allows you to allocate a size right at the creation of the List without having to create a wrapper array.
|
||||||
- Added: Tests for the new Stream replace functions to ensure no bugs are left.
|
- Added: A ConcurrentHashMap implementation.
|
||||||
- Fixed: Custom HashSet reduce function with a default value was checking incorrectly for present keys.
|
- Fixed: containsValue in the HashMap wouldn't check the nullKey
|
||||||
- Added: Guava TestSuit
|
- Removed: Deprecated functions from SortedMaps/Sets
|
||||||
- Fixed: HashCode and toString method would crash if the Object Key/Value was null
|
|
||||||
- Added: AbstractTypeCollection now delegates the contains check to type-specific Collections if it detects it.
|
### Version 0.5.3
|
||||||
- Fixed: Map.Entry toString wasn't writing values not like it should do.
|
- Added: OrderedMap/Set
|
||||||
- Fixed: Set.hashCode now is the sum of the elements instead of a Unique HashCode based on the elements.
|
- Added: Deprecation to Functions that are specific to Ordered interfaces in the SortedMap/Set
|
||||||
- Fixed: Added missing NonNull Checks.
|
- Added: subFrom to Maps which is the counterpart of the addTo method
|
||||||
- Fixed: Custom/OpenHashMap.containsValue implementation was wrong.
|
- Added: pourAsList and pourAsSet (booleans excluded for sets) to Iterable
|
||||||
- Fixed: Custom/OpenHashMap.compute/present/absent now works how it is specified in the Java Documentation
|
- Fixed: ArrayList.grow had a small bug where it would trigger to early causing performance problems with exact sized collections.
|
||||||
- Fixed: Custom/OpenHashMap.merge/BulkMerge now works how it is specified in the Java Documentation
|
- Fixed: FIFOQueue size constructor had a small bug where it would trigger a array enlargement when all elements were inserted.
|
||||||
- Fixed: Custom/Linked/OpenHashMap.keySet.remove was causing a infinite loop.
|
|
||||||
- Fixed: Custom/Linked/OpenHashMap.entrySet.contains was not correctly comparing the entry.
|
### Version 0.5.2
|
||||||
- Fixed: Custom/OpenHashMap.mapIterator now no longer crashes in certain cases.
|
- Fixed: Bugs with Queues starting with the wrong size
|
||||||
- Added: Custom/LinkedOpenHashMap now takes use of the improved Iterator it has for containsValue
|
- Fixed: ArrayGrowth for Queues was +1 instead of +50%
|
||||||
- Fixed: CustomOpenHashMap.keySet.forEach was basically putting out keys even if they were present
|
- Added: Benchmarks with java and FastUtil
|
||||||
- Fixed: ImmutableMaps issues thanks to the tests. Roughly the same as the rest of the maps
|
|
||||||
- Fixed: RB/AVLTreeMaps issues. Roughly the same as the rest of the maps
|
### Version 0.5.1
|
||||||
- Fixed: SubLists are now properly implemented.
|
- Fixed: Reworked the NavigableSet/Map implementations of RBTree/AVLTree/Array Sets/Maps so they are now deemed stable.
|
||||||
- Fixed: HashSet Iterator bugs now fixed... That was Painful.
|
- Added: Another 150k Unit tests.
|
||||||
- Added: Tests for Lists and Sets
|
- Added: List and Set Unit tests for Integer (or Primitives in this case) to ensure basic stability there. (Now covering all sets and lists)
|
||||||
|
- Fixed: Bugs with null values for primitive collections.
|
||||||
### Version 0.4.5
|
- Removed: ArraySet/Map subSet/subMap implementation was removed.
|
||||||
- Added: removeAll/retainAll(Collection c, Consumer r) which receives all the elements that got deleted from the collection
|
|
||||||
- Fixed: Supplier get function wasn't referencing original function.
|
### Version 0.5.0
|
||||||
- Added: addIfPresent/Absent to lists
|
- Added: 2 Helper functions to find out how many bits are required to store a Number.
|
||||||
- Added: distinct, limit and peek iterators
|
- Added: pour function directly into Iterable which allows to collect all elements in the Iterable directly.
|
||||||
- Added: Iterable's can now reduce its contents
|
- Added: The new ToArray method from Java9 and newer into the library. Using a functional interface. (Just a backport)
|
||||||
- Added: Better ForEach support for IterableWrappers so a Iterator chain is not created
|
- Changed: Reworked how the Map Builder functions are created. They are now in a SubClass that moves them out of the way. Less Clutter. (This might break things if that was used before)
|
||||||
- Added: SwapRemove to Lists which moves the last element into the desired space to be deleted
|
- Added: Map Builder that allows now to Build Maps like Guava ImmutableMaps can be build. Note: This has a slight performance overhead.
|
||||||
- Added: More Test cases
|
- Added: Unmodifiable and Synchronize wrapper functions direclty into Collection Interfaces. This is mostly a quality of life thing.
|
||||||
|
- Added: Unmodifiable and Synchronized Wrapper Collections can now be cloned. They clone the underlying map which doesn't break functionality. (Had a usecase for it)
|
||||||
### Version 0.4.4
|
- Added: A boxed putAll array variant.
|
||||||
- Fixed: ObjectArrayList.of was causing crashes because of a Poor implementation.
|
- Fixed: EnumMaps didn't keep track of their size and now got proper care and implementations as needed. There might be more work required but at least the core functionality is now up to date.
|
||||||
- Added: Unsorted HashMaps/Sets now throw Concurrent exceptions if they were modified during a rehash.
|
- Added: Tests for the new Stream replace functions to ensure no bugs are left.
|
||||||
- Added: Array/Collection version of enqueue and enqueueFirst to PriorityQueues.
|
- Fixed: Custom HashSet reduce function with a default value was checking incorrectly for present keys.
|
||||||
- Added: fillBuffer function into PrimitiveLists which allow to optimize JavaNio buffers if needed.
|
- Added: Guava TestSuit
|
||||||
|
- Fixed: HashCode and toString method would crash if the Object Key/Value was null
|
||||||
### Version 0.4.3
|
- Added: AbstractTypeCollection now delegates the contains check to type-specific Collections if it detects it.
|
||||||
- Added: Wrapper now support the Optimized Lambda replacer functions to improve performance.
|
- Fixed: Map.Entry toString wasn't writing values not like it should do.
|
||||||
- Added: FIFO Queue has now a minimum capacity and that is now checked more consistently.
|
- Fixed: Set.hashCode now is the sum of the elements instead of a Unique HashCode based on the elements.
|
||||||
|
- Fixed: Added missing NonNull Checks.
|
||||||
### Version 0.4.2
|
- Fixed: Custom/OpenHashMap.containsValue implementation was wrong.
|
||||||
- Added: Lists/Sets/Maps/PriorityQueues are now copy-able. with the new copy() function.
|
- Fixed: Custom/OpenHashMap.compute/present/absent now works how it is specified in the Java Documentation
|
||||||
Note: subLists/subMaps/subSets or synchronize/unmodifyable wrappers do not support that function.
|
- Fixed: Custom/OpenHashMap.merge/BulkMerge now works how it is specified in the Java Documentation
|
||||||
- Fixed: PriorityQueues didn't implement: hashCode/equals/toString
|
- Fixed: Custom/Linked/OpenHashMap.keySet.remove was causing a infinite loop.
|
||||||
|
- Fixed: Custom/Linked/OpenHashMap.entrySet.contains was not correctly comparing the entry.
|
||||||
### Version 0.4.1
|
- Fixed: Custom/OpenHashMap.mapIterator now no longer crashes in certain cases.
|
||||||
- Changed: ForEach with input now provides input, value instead of value, input, this improves the usage of method references greatly
|
- Added: Custom/LinkedOpenHashMap now takes use of the improved Iterator it has for containsValue
|
||||||
- Added: addAll with Array-types in collections.
|
- Fixed: CustomOpenHashMap.keySet.forEach was basically putting out keys even if they were present
|
||||||
- Added: Java Iterator/Iterable support for Stream replacing methods
|
- Fixed: ImmutableMaps issues thanks to the tests. Roughly the same as the rest of the maps
|
||||||
- Added: Suppliers.
|
- Fixed: RB/AVLTreeMaps issues. Roughly the same as the rest of the maps
|
||||||
- Added: SupplyIfAbsent. It is ComputeIfAbsent but using suppliers
|
- Fixed: SubLists are now properly implemented.
|
||||||
- Added: Count feature into Iterable
|
- Fixed: HashSet Iterator bugs now fixed... That was Painful.
|
||||||
- Fixed: A couple bugs with the new StreamReplacing functions in LinkedCollections Iterating to Infinity
|
- Added: Tests for Lists and Sets
|
||||||
|
|
||||||
### Version 0.4.0
|
### Version 0.4.5
|
||||||
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
- Added: removeAll/retainAll(Collection c, Consumer r) which receives all the elements that got deleted from the collection
|
||||||
- Added: New Stream replacing functions: findFirst, matchesAny/All/None
|
- Fixed: Supplier get function wasn't referencing original function.
|
||||||
- Fixed: Compute/ComputeIfAbsent/ComputeIfPresent/Merge/BulkMerge in maps now behave like they should.
|
- Added: addIfPresent/Absent to lists
|
||||||
- Added: Implementations for New Stream replacing functions.
|
- Added: distinct, limit and peek iterators
|
||||||
- Changed: Removed a lot of duplicated forEach implementations
|
- Added: Iterable's can now reduce its contents
|
||||||
- Added: Flat/Mapping functions (to object) are now accessible to primitive maps.
|
- Added: Better ForEach support for IterableWrappers so a Iterator chain is not created
|
||||||
- Added: Filter function to Iterators/Iterables (Iterable implements it by default)
|
- Added: SwapRemove to Lists which moves the last element into the desired space to be deleted
|
||||||
- Changed: Cleanup of some variables/mappers
|
- Added: More Test cases
|
||||||
- Added/Fixed: AVL/RBTreeMap got reworked and SubMaps work more properly now. Also forEach support got improved a lot
|
|
||||||
- Added/Fixed: TreeSubSets (RB/AVL) got their functional implementations improved too.
|
### Version 0.4.4
|
||||||
- Added: Pairs are now a thing. In Mutable/Immutable Form
|
- Fixed: ObjectArrayList.of was causing crashes because of a Poor implementation.
|
||||||
|
- Added: Unsorted HashMaps/Sets now throw Concurrent exceptions if they were modified during a rehash.
|
||||||
### Version 0.3.6
|
- Added: Array/Collection version of enqueue and enqueueFirst to PriorityQueues.
|
||||||
- Fixed: addAll non Type Specific Lists was causing crashes.
|
- Added: fillBuffer function into PrimitiveLists which allow to optimize JavaNio buffers if needed.
|
||||||
- Fixed/Changed: clearAndTrim's implementation was all over the place. In some cases causing crash scenarios.
|
|
||||||
- Fixed: Wrappers didn't implement toString/equals/hashCode
|
### Version 0.4.3
|
||||||
- Added: Tests for addAll Bug
|
- Added: Wrapper now support the Optimized Lambda replacer functions to improve performance.
|
||||||
- Changed: Cleaned up CodeStyle as bugs were fixed.
|
- Added: FIFO Queue has now a minimum capacity and that is now checked more consistently.
|
||||||
|
|
||||||
### Version 0.3.5
|
### Version 0.4.2
|
||||||
- Fixed: Simple Code Generator dependency was declared wrong. Its only needed for runtime. Not for Compilation.
|
- Added: Lists/Sets/Maps/PriorityQueues are now copy-able. with the new copy() function.
|
||||||
- Fixed: ObjectLists Crashed when a null was provided as a Comparator. (Unless the List was Initialized with the ClassType)
|
Note: subLists/subMaps/subSets or synchronize/unmodifyable wrappers do not support that function.
|
||||||
- Fixed: LinkedLists didn't implement add(Object)
|
- Fixed: PriorityQueues didn't implement: hashCode/equals/toString
|
||||||
- Fixed: Object Collections did have the JavaCollections deprecated as the Constructor. This should only be deprecated for Primitives
|
|
||||||
- Added: Tests with 5k Random names for Object sorting.
|
### Version 0.4.1
|
||||||
- Changed: Object Arrays no longer require a Comparable[] it just assumes now that the elements in the Array are Comparable
|
- Changed: ForEach with input now provides input, value instead of value, input, this improves the usage of method references greatly
|
||||||
- Fixed: Dependency to SimpleCodeGenerator should be no longer a thing. Because the resulting library doesn't need it only the builder does.
|
- Added: addAll with Array-types in collections.
|
||||||
|
- Added: Java Iterator/Iterable support for Stream replacing methods
|
||||||
### Version 0.3.4
|
- Added: Suppliers.
|
||||||
- Fixed: ArrayLists didn't resize properly if they were empty.
|
- Added: SupplyIfAbsent. It is ComputeIfAbsent but using suppliers
|
||||||
|
- Added: Count feature into Iterable
|
||||||
|
- Fixed: A couple bugs with the new StreamReplacing functions in LinkedCollections Iterating to Infinity
|
||||||
### Version 0.3.3
|
|
||||||
- Added: Flat/Mapping function for Iterables/Iterators to help avoid streams for cleaner looking code
|
### Version 0.4.0
|
||||||
- Fixed: AVLTrees pollFirst/Last is now keeping orders and is fixed
|
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
||||||
- Fixed: AbstractCollection bulk adding methods now link to the specialized implementations.
|
- Added: New Stream replacing functions: findFirst, matchesAny/All/None
|
||||||
- Fixed: A bug with getElements in ArrayList.
|
- Fixed: Compute/ComputeIfAbsent/ComputeIfPresent/Merge/BulkMerge in maps now behave like they should.
|
||||||
- Fixed: PriorityQueue remove/toArray function were renamed so they fit better with other interfaces. (remove => removeFirst and toArray uses a different genericType)
|
- Added: Implementations for New Stream replacing functions.
|
||||||
- Added: LinkedList which is a List/PriorityDequeue/Stack which allows for more optimized use-cases and reduced boxing/unboxing.
|
- Changed: Removed a lot of duplicated forEach implementations
|
||||||
- Added: Tests for LinkedList
|
- Added: Flat/Mapping functions (to object) are now accessible to primitive maps.
|
||||||
|
- Added: Filter function to Iterators/Iterables (Iterable implements it by default)
|
||||||
### Version 0.3.2
|
- Changed: Cleanup of some variables/mappers
|
||||||
- Fixed: Map.put wasn't referring to primitive variants.
|
- Added/Fixed: AVL/RBTreeMap got reworked and SubMaps work more properly now. Also forEach support got improved a lot
|
||||||
- Added: ImmutableList.
|
- Added/Fixed: TreeSubSets (RB/AVL) got their functional implementations improved too.
|
||||||
- Added: Iterator pour function into a List or Array
|
- Added: Pairs are now a thing. In Mutable/Immutable Form
|
||||||
- Changed: Arrays Wrap is now accessible to Objects and now is ? extends TYPE instead of TYPE.
|
|
||||||
- Added: OpenHashSets now implement foreach and have less overhead.
|
### Version 0.3.6
|
||||||
- Added: ImmutableOpenHashSet that is not editable (is linked by default for fast iteration)
|
- Fixed: addAll non Type Specific Lists was causing crashes.
|
||||||
- Added: CustomOpenHashSets now implement foreach and have less overhead.
|
- Fixed/Changed: clearAndTrim's implementation was all over the place. In some cases causing crash scenarios.
|
||||||
- Added: ImmutableOpenHashMap that is not editable (is linked by default for fast iteration)
|
- Fixed: Wrappers didn't implement toString/equals/hashCode
|
||||||
- Added: Maps can now be created through the interface.
|
- Added: Tests for addAll Bug
|
||||||
- Fixed: Lists.addElements(T...elements) was adding elements at the beginning of a list instead of the end.
|
- Changed: Cleaned up CodeStyle as bugs were fixed.
|
||||||
- Fixed: Bugs with the AVLTreeSet. And marked bugs with AVLTreeX that are still present.
|
|
||||||
|
### Version 0.3.5
|
||||||
### Version 0.3.1
|
- Fixed: Simple Code Generator dependency was declared wrong. Its only needed for runtime. Not for Compilation.
|
||||||
- Fixed: containsKey & containsValue in HashMaps were deprecated for Object Variants.
|
- Fixed: ObjectLists Crashed when a null was provided as a Comparator. (Unless the List was Initialized with the ClassType)
|
||||||
- Fixed: HashMap wasn't deleting Keys & Values references when removing a Object
|
- Fixed: LinkedLists didn't implement add(Object)
|
||||||
- Fixed: AVLTreeMap didn't balance properly.
|
- Fixed: Object Collections did have the JavaCollections deprecated as the Constructor. This should only be deprecated for Primitives
|
||||||
- Changed: EnumMap no longer tries to access SharedSecrets since its gone in java11
|
- Added: Tests with 5k Random names for Object sorting.
|
||||||
- Added: HashMaps now implement ITrimmable
|
- Changed: Object Arrays no longer require a Comparable[] it just assumes now that the elements in the Array are Comparable
|
||||||
- Added: AVLTreeSet didn't balance properly
|
- Fixed: Dependency to SimpleCodeGenerator should be no longer a thing. Because the resulting library doesn't need it only the builder does.
|
||||||
- Fixed: HashMaps & LinkedMaps weren't clearing references properly.
|
|
||||||
|
### Version 0.3.4
|
||||||
### Version 0.3.0 (Breaking 0.2.0)
|
- Fixed: ArrayLists didn't resize properly if they were empty.
|
||||||
- Added: Stack.isEmpty was missing
|
|
||||||
- Changed: remove/removeLast/enqueue/enqueueFirst no longer use Type Suffixes
|
|
||||||
- Removed: Suffixes for unmodifiable & synchronize functions.
|
### Version 0.3.3
|
||||||
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
|
- Added: Flat/Mapping function for Iterables/Iterators to help avoid streams for cleaner looking code
|
||||||
- Changed: PriorityQueues no longer extends Object Variant.
|
- Fixed: AVLTrees pollFirst/Last is now keeping orders and is fixed
|
||||||
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
|
- Fixed: AbstractCollection bulk adding methods now link to the specialized implementations.
|
||||||
- Changed: Maps.remove function is no longer using Suffixes unless its absolutely necessary.
|
- Fixed: A bug with getElements in ArrayList.
|
||||||
- Changed: ObjectList methods are no longer marked Deprecated even so it was for primitive ones.
|
- Fixed: PriorityQueue remove/toArray function were renamed so they fit better with other interfaces. (remove => removeFirst and toArray uses a different genericType)
|
||||||
- Added: Shuffle & Reverse Methods.
|
- Added: LinkedList which is a List/PriorityDequeue/Stack which allows for more optimized use-cases and reduced boxing/unboxing.
|
||||||
- Added: Concat Iterators.
|
- Added: Tests for LinkedList
|
||||||
|
|
||||||
|
### Version 0.3.2
|
||||||
|
- Fixed: Map.put wasn't referring to primitive variants.
|
||||||
|
- Added: ImmutableList.
|
||||||
|
- Added: Iterator pour function into a List or Array
|
||||||
|
- Changed: Arrays Wrap is now accessible to Objects and now is ? extends TYPE instead of TYPE.
|
||||||
|
- Added: OpenHashSets now implement foreach and have less overhead.
|
||||||
|
- Added: ImmutableOpenHashSet that is not editable (is linked by default for fast iteration)
|
||||||
|
- Added: CustomOpenHashSets now implement foreach and have less overhead.
|
||||||
|
- Added: ImmutableOpenHashMap that is not editable (is linked by default for fast iteration)
|
||||||
|
- Added: Maps can now be created through the interface.
|
||||||
|
- Fixed: Lists.addElements(T...elements) was adding elements at the beginning of a list instead of the end.
|
||||||
|
- Fixed: Bugs with the AVLTreeSet. And marked bugs with AVLTreeX that are still present.
|
||||||
|
|
||||||
|
### Version 0.3.1
|
||||||
|
- Fixed: containsKey & containsValue in HashMaps were deprecated for Object Variants.
|
||||||
|
- Fixed: HashMap wasn't deleting Keys & Values references when removing a Object
|
||||||
|
- Fixed: AVLTreeMap didn't balance properly.
|
||||||
|
- Changed: EnumMap no longer tries to access SharedSecrets since its gone in java11
|
||||||
|
- Added: HashMaps now implement ITrimmable
|
||||||
|
- Added: AVLTreeSet didn't balance properly
|
||||||
|
- Fixed: HashMaps & LinkedMaps weren't clearing references properly.
|
||||||
|
|
||||||
|
### Version 0.3.0 (Breaking 0.2.0)
|
||||||
|
- Added: Stack.isEmpty was missing
|
||||||
|
- Changed: remove/removeLast/enqueue/enqueueFirst no longer use Type Suffixes
|
||||||
|
- Removed: Suffixes for unmodifiable & synchronize functions.
|
||||||
|
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
|
||||||
|
- Changed: PriorityQueues no longer extends Object Variant.
|
||||||
|
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
|
||||||
|
- Changed: Maps.remove function is no longer using Suffixes unless its absolutely necessary.
|
||||||
|
- Changed: ObjectList methods are no longer marked Deprecated even so it was for primitive ones.
|
||||||
|
- Added: Shuffle & Reverse Methods.
|
||||||
|
- Added: Concat Iterators.
|
||||||
- Added: PriorityQueues
|
- Added: PriorityQueues
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
### Extra Features
|
||||||
|
|
||||||
|
Primitive Collections comes with a few extra features that are disabled by default.
|
||||||
|
These will be enabled as soon they become relevant or never at all.
|
||||||
|
|
||||||
|
But some of these can be already unlocked when the target version changes.
|
||||||
|
|
||||||
|
If you compile the library for yourself you will automatically gain access to said features.
|
||||||
|
|
||||||
|
### Java17 Exclusive Features
|
||||||
|
Java17 has some new features that can sadly not really be back-ported but the library still supports them if it is compiled with java17
|
||||||
|
|
||||||
|
- RandomGenerator: Java17 has added [RandomGenerator.class](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/RandomGenerator.html).
|
||||||
|
This allows to use custom random implementations without having to re-implement them yourselves.
|
||||||
|
|
||||||
|
|
||||||
|
### ModuleSettings
|
||||||
|
Primitive Collections is a huge library.
|
||||||
|
But maybe you only use like 5-10 different classes.
|
||||||
|
Normally you would use tools like "Proguard" to get rid of classes that you don't use.
|
||||||
|
But since a lot of classes have dependencies on each other this would only do so much.
|
||||||
|
|
||||||
|
This is where the [ModuleSettings](ModuleSettings.json) come into play.
|
||||||
|
It allows you to turn of implementations as you wish and adjusts the code that everything still works.
|
||||||
|
|
||||||
|
There is 3 layers of control inside of the ModuleSettings.
|
||||||
|
- Modules directly at the top that turn off everything.
|
||||||
|
- Type Specific configurations, where you can for example turn of everything thats "Long" based.
|
||||||
|
- And then there is each type specific module settings.
|
||||||
|
|
||||||
|
Allowing for greater control without having to edit hundreds of lines of code.
|
||||||
|
On top of that:
|
||||||
|
Any Setting that isn't "Present" is counted as "Enabled".
|
||||||
|
So if you want to disable just 1 thing you can keep that 1 thing and delete the rest of the Setting.
|
||||||
|
It will still work as the same.
|
||||||
|
The default settings just come with everything so you can see what is controllable.
|
||||||
|
|
||||||
|
How to compile the Code with the ModuleSettings enabled:
|
||||||
|
```
|
||||||
|
/gradlew.bat generateLimitSource build -x test
|
||||||
|
```
|
||||||
+2624
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,10 @@ Benchmarks can be found here: [[Charts]](https://github.com/Speiger/Primitive-Co
|
|||||||
[Here](features.md) you find a set of features added to Primitive Collections.
|
[Here](features.md) you find a set of features added to Primitive Collections.
|
||||||
These are designed to improve performance or to provide Quality of Life.
|
These are designed to improve performance or to provide Quality of Life.
|
||||||
|
|
||||||
|
[Here](EXTRAS.md) you also find features that can be used when you compile the library for yourself.
|
||||||
|
These features are not used by default to have a wider range of compat, or require self compilation.
|
||||||
|
Such as pruning classes that are not needed in your code.
|
||||||
|
|
||||||
## Main Features:
|
## Main Features:
|
||||||
- ArrayLists / LinkedLists / CopyOnWriteLists
|
- ArrayLists / LinkedLists / CopyOnWriteLists
|
||||||
- HashSets/Maps (Linked & HashControl)
|
- HashSets/Maps (Linked & HashControl)
|
||||||
@@ -46,7 +50,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.Speiger:Primitive-Collections:0.7.0'
|
implementation 'com.github.Speiger:Primitive-Collections:0.9.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -71,7 +75,11 @@ Please if you want to contribute follow the [Rule-Sheet](RuleSheet.md). It keeps
|
|||||||
# How to Build
|
# How to Build
|
||||||
|
|
||||||
The SourceCode can be generated via:
|
The SourceCode can be generated via:
|
||||||
|
```
|
||||||
/gradlew.bat generateSource
|
/gradlew.bat generateSource
|
||||||
|
```
|
||||||
|
|
||||||
to generate SourceCode and build the jar:
|
to generate SourceCode and build the jar:
|
||||||
/gradlew.bat build
|
```
|
||||||
|
/gradlew.bat build
|
||||||
|
```
|
||||||
|
|||||||
+42
-25
@@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.7.0';
|
version = '0.9.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
@@ -45,7 +45,8 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.1.4'
|
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||||
|
builderImplementation 'de.speiger:Simple-Code-Generator:1.3.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
||||||
|
|
||||||
@@ -82,14 +83,30 @@ task generateTestSource(type: JavaExec) {
|
|||||||
args = ['tests', 'silent']
|
args = ['tests', 'silent']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task forceGenerateTestSource(type: JavaExec) {
|
||||||
|
group = 'internal'
|
||||||
|
description = 'Builds the sourcecode for the Tests'
|
||||||
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
|
args = ['tests', 'silent', 'force']
|
||||||
|
}
|
||||||
|
|
||||||
|
task generateLimitSource(type: JavaExec) {
|
||||||
|
group = 'internal'
|
||||||
|
description = 'Builds the Sourcecode with the ModuleSettings.json applied'
|
||||||
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
|
args = ['silent', 'load']
|
||||||
|
}
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
from javadoc
|
from javadoc
|
||||||
classifier = 'javadoc'
|
archiveClassifier = 'javadoc'
|
||||||
}
|
}
|
||||||
|
|
||||||
task srcJar(type: Jar) {
|
task srcJar(type: Jar) {
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
classifier = 'sources'
|
archiveClassifier = 'sources'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.dependsOn generateGithubSource
|
compileJava.dependsOn generateGithubSource
|
||||||
@@ -112,7 +129,7 @@ task testBooleans(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
}
|
}
|
||||||
|
|
||||||
task testBytes(type: Test) {
|
task testBytes(type: Test) {
|
||||||
@@ -124,8 +141,8 @@ task testBytes(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testShorts(type: Test) {
|
task testShorts(type: Test) {
|
||||||
@@ -137,8 +154,8 @@ task testShorts(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testChars(type: Test) {
|
task testChars(type: Test) {
|
||||||
@@ -150,8 +167,8 @@ task testChars(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testInts(type: Test) {
|
task testInts(type: Test) {
|
||||||
@@ -163,8 +180,8 @@ task testInts(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testLongs(type: Test) {
|
task testLongs(type: Test) {
|
||||||
@@ -176,8 +193,8 @@ task testLongs(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testFloats(type: Test) {
|
task testFloats(type: Test) {
|
||||||
@@ -189,8 +206,8 @@ task testFloats(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testDoubles(type: Test) {
|
task testDoubles(type: Test) {
|
||||||
@@ -202,8 +219,8 @@ task testDoubles(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
task testObjects(type: Test) {
|
task testObjects(type: Test) {
|
||||||
@@ -215,8 +232,8 @@ task testObjects(type: Test) {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
maxParallelForks = 2
|
maxParallelForks = testThreads as Integer
|
||||||
}
|
}
|
||||||
|
|
||||||
if(System.getProperty("full_test_suite", "false").toBoolean()) {
|
if(System.getProperty("full_test_suite", "false").toBoolean()) {
|
||||||
@@ -239,15 +256,15 @@ test {
|
|||||||
}
|
}
|
||||||
useJUnit()
|
useJUnit()
|
||||||
ignoreFailures = true
|
ignoreFailures = true
|
||||||
maxHeapSize = "1024m"
|
maxHeapSize = maxMemory
|
||||||
}
|
}
|
||||||
|
|
||||||
jacocoTestReport {
|
jacocoTestReport {
|
||||||
executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
|
executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
|
||||||
reports {
|
reports {
|
||||||
xml.enabled true
|
xml.required = true
|
||||||
html.enabled = true
|
html.required = true
|
||||||
csv.enabled true
|
csv.required = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-1
@@ -1 +1,4 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
|
||||||
|
maxMemory = 1024m
|
||||||
|
testThreads = 2
|
||||||
+5
-5
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ public enum ClassType
|
|||||||
return classType;
|
return classType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassPath()
|
||||||
|
{
|
||||||
|
return this == OBJECT ? "Object" : classType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassType(boolean value)
|
public String getClassType(boolean value)
|
||||||
{
|
{
|
||||||
return value && this == OBJECT ? "V" : classType;
|
return value && this == OBJECT ? "V" : classType;
|
||||||
@@ -109,7 +114,7 @@ public enum ClassType
|
|||||||
|
|
||||||
public boolean needsCustomJDKType()
|
public boolean needsCustomJDKType()
|
||||||
{
|
{
|
||||||
return this == BYTE || this == SHORT || this == CHAR || this == FLOAT;
|
return this == BOOLEAN || this == BYTE || this == SHORT || this == CHAR || this == FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsCast()
|
public boolean needsCast()
|
||||||
@@ -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)
|
public String getEquals(boolean not)
|
||||||
{
|
{
|
||||||
switch(this)
|
switch(this)
|
||||||
|
|||||||
@@ -1,536 +0,0 @@
|
|||||||
package speiger.src.builder;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
import speiger.src.builder.mappers.ArgumentMapper;
|
|
||||||
import speiger.src.builder.mappers.IMapper;
|
|
||||||
import speiger.src.builder.mappers.InjectMapper;
|
|
||||||
import speiger.src.builder.mappers.LineMapper;
|
|
||||||
import speiger.src.builder.mappers.SimpleMapper;
|
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class GlobalVariables
|
|
||||||
{
|
|
||||||
List<IMapper> operators = new ArrayList<>();
|
|
||||||
Set<String> flags = new LinkedHashSet<>();
|
|
||||||
ClassType type;
|
|
||||||
ClassType valueType;
|
|
||||||
|
|
||||||
public GlobalVariables(ClassType type, ClassType subType)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
valueType = subType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createVariables()
|
|
||||||
{
|
|
||||||
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
|
||||||
addSimpleMapper("PACKAGE", type.getPathType());
|
|
||||||
addSimpleMapper("CLASS_TYPE", type.getClassType());
|
|
||||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
|
||||||
addSimpleMapper("KEY_TYPE", type.getKeyType());
|
|
||||||
addSimpleMapper("KEY_OBJECT_TYPE", type.isObject() ? "Object" : type.getKeyType());
|
|
||||||
addSimpleMapper("KEY_STRING_TYPE", type.isObject() ? "String" : type.getKeyType());
|
|
||||||
addSimpleMapper("KEY_SPECIAL_TYPE", type.isObject() ? "E" : type.getKeyType());
|
|
||||||
addSimpleMapper("CLASS_OBJECT_TYPE", type.getClassType());
|
|
||||||
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
|
||||||
addSimpleMapper("CLASS_STRING_TYPE", type.isObject() ? "String" : type.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", type.getCustomJDKType().getKeyType());
|
|
||||||
addSimpleMapper("VALUE_JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
|
||||||
|
|
||||||
addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue());
|
|
||||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
|
||||||
|
|
||||||
addSimpleMapper("INVALID_KEY_VALUE", type.getInvalidValue());
|
|
||||||
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", type.isObject() ? "<String>" : "");
|
|
||||||
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
|
||||||
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
|
||||||
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", type.isObject() ? "<"+type.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", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
|
||||||
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
|
||||||
addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+type.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces();
|
|
||||||
|
|
||||||
addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : "");
|
|
||||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
|
||||||
addSimpleMapper(" KEY_COMPAREABLE_TYPE", type.isObject() ? "<"+type.getKeyType()+" extends Comparable<T>>" : "");
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", type.isObject() ? "<? super "+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", type.isObject() ? "<? extends "+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? extends "+type.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+type.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
|
||||||
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
|
||||||
|
|
||||||
addInjectMapper(" KEY_SPECIAL_GENERIC_TYPE", type.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" KSK_GENERIC_TYPE", type.isObject() ? "<%s, "+type.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" KKS_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addArgumentMapper(" KSS_GENERIC_TYPE", type.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", type.isObject() ? " <"+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
|
||||||
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", type.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addSimpleMapper(" GENERIC_KEY_ENUM_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : " <"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
|
||||||
|
|
||||||
addInjectMapper(" GENERIC_KEY_SPECIAL_BRACES", type.isObject() ? " <"+type.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
|
||||||
|
|
||||||
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
|
||||||
addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : "");
|
|
||||||
addSimpleMapper("KV_BRACES", type.isObject() || valueType.isObject() ? "<>" : "");
|
|
||||||
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
|
||||||
addSimpleMapper("BRACES", type.isObject() ? "<>" : "");
|
|
||||||
if(type.needsCustomJDKType())
|
|
||||||
{
|
|
||||||
addSimpleMapper("JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
|
||||||
addSimpleMapper("SANITY_CAST", "castTo"+type.getFileType());
|
|
||||||
}
|
|
||||||
addSimpleMapper("JAVA_CLASS", type.getCustomJDKType().getClassType());
|
|
||||||
if(valueType.needsCustomJDKType())
|
|
||||||
{
|
|
||||||
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
|
||||||
}
|
|
||||||
addComment("@ArrayType", "@param <%s> the type of array that the operation should be applied");
|
|
||||||
addComment("@Type", "@param <%s> the type of elements maintained by this Collection");
|
|
||||||
addValueComment("@ValueArrayType", "@param <%s> the type of array that the operation should be applied");
|
|
||||||
addValueComment("@ValueType", "@param <%s> the type of elements maintained by this Collection");
|
|
||||||
addAnnontion("@PrimitiveOverride", "@Override");
|
|
||||||
addSimpleMapper("@PrimitiveDoc", "");
|
|
||||||
addAnnontion("@Primitive", "@Deprecated");
|
|
||||||
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
|
||||||
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createHelperVariables()
|
|
||||||
{
|
|
||||||
createHelperVars(type, false, "KEY");
|
|
||||||
createHelperVars(valueType, true, "VALUE");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createPreFunctions()
|
|
||||||
{
|
|
||||||
addSimpleMapper("ENTRY_SET", type.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createClassTypes()
|
|
||||||
{
|
|
||||||
addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate");
|
|
||||||
addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer");
|
|
||||||
addSimpleMapper("JAVA_SUPPLIER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Supplier");
|
|
||||||
addSimpleMapper("JAVA_FUNCTION", type.getFunctionClass(valueType));
|
|
||||||
addSimpleMapper("JAVA_BINARY_OPERATOR", type == ClassType.BOOLEAN ? "" : (type.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+type.getCustomJDKType().getFileType()+"BinaryOperator"));
|
|
||||||
addSimpleMapper("JAVA_UNARY_OPERATOR", type.isObject() ? "BinaryOperator" : type == ClassType.BOOLEAN ? "" : type.getCustomJDKType().getFileType()+"UnaryOperator");
|
|
||||||
addSimpleMapper("JAVA_SPLIT_ITERATOR", type.isPrimitiveBlocking() ? "Spliterator" : "Of"+type.getCustomJDKType().getFileType());
|
|
||||||
addSimpleMapper("JAVA_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Stream");
|
|
||||||
addSimpleMapper("JAVA_BUFFER", type.getFileType()+"Buffer");
|
|
||||||
|
|
||||||
//Final Classes
|
|
||||||
addClassMapper("ARRAY_LIST", "ArrayList");
|
|
||||||
addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList");
|
|
||||||
addClassMapper("ASYNC_BUILDER", "AsyncBuilder");
|
|
||||||
addClassMapper("LINKED_LIST", "LinkedList");
|
|
||||||
addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList");
|
|
||||||
addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue");
|
|
||||||
addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue");
|
|
||||||
addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue");
|
|
||||||
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");
|
|
||||||
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");
|
|
||||||
addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", "");
|
|
||||||
addBiClassMapper("MUTABLE_PAIR", "MutablePair", "");
|
|
||||||
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
|
||||||
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
|
||||||
addClassMapper("ARRAY_SET", "ArraySet");
|
|
||||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
|
||||||
|
|
||||||
//Final UnitTest Classes
|
|
||||||
addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection");
|
|
||||||
addAbstractMapper("MINIMAL_SET", "Minimal%sSet");
|
|
||||||
addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester");
|
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester");
|
|
||||||
addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester");
|
|
||||||
addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester");
|
|
||||||
addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester");
|
|
||||||
addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester");
|
|
||||||
addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester");
|
|
||||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
|
||||||
addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester");
|
|
||||||
addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester");
|
|
||||||
addClassMapper("ITERATOR_TESTER", "IteratorTester");
|
|
||||||
addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder");
|
|
||||||
addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder");
|
|
||||||
addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder");
|
|
||||||
addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder");
|
|
||||||
addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder");
|
|
||||||
addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder");
|
|
||||||
addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder");
|
|
||||||
addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder");
|
|
||||||
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");
|
|
||||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
|
||||||
addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests");
|
|
||||||
addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator");
|
|
||||||
addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator");
|
|
||||||
addClassMapper("LIST_TESTS", "ListTests");
|
|
||||||
addClassMapper("SET_TESTS", "SetTests");
|
|
||||||
addClassMapper("QUEUE_TESTS", "QueueTests");
|
|
||||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
|
||||||
|
|
||||||
//Abstract Classes
|
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
|
||||||
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
|
||||||
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
|
||||||
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
|
||||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
|
||||||
addClassMapper("SUB_LIST", "SubList");
|
|
||||||
addAbstractMapper("BASE_TASK", "Base%sTask");
|
|
||||||
|
|
||||||
//Helper Classes
|
|
||||||
addClassMapper("LISTS", "Lists");
|
|
||||||
addClassMapper("SETS", "Sets");
|
|
||||||
addClassMapper("COLLECTIONS", "Collections");
|
|
||||||
addClassMapper("ARRAYS", "Arrays");
|
|
||||||
addClassMapper("PRIORITY_QUEUES", "PriorityQueues");
|
|
||||||
addClassMapper("SPLIT_ITERATORS", "Splititerators");
|
|
||||||
addClassMapper("ITERATORS", "Iterators");
|
|
||||||
addClassMapper("ITERABLES", "Iterables");
|
|
||||||
addBiClassMapper("MAPS", "Maps", "2");
|
|
||||||
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
|
||||||
|
|
||||||
//UnitTest Helper Classes
|
|
||||||
addClassMapper("HELPERS", "Helpers");
|
|
||||||
addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator");
|
|
||||||
addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator");
|
|
||||||
addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator");
|
|
||||||
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");
|
|
||||||
addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator");
|
|
||||||
addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator");
|
|
||||||
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");
|
|
||||||
|
|
||||||
//Interfaces
|
|
||||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
|
||||||
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
|
||||||
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
|
||||||
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
|
||||||
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
|
||||||
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
|
||||||
addClassMapper("ITERATOR", "Iterator");
|
|
||||||
addClassMapper("ITERABLE", "Iterable");
|
|
||||||
addClassMapper("COLLECTION", "Collection");
|
|
||||||
addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction");
|
|
||||||
addBiClassMapper("FUNCTION", "Function", "2");
|
|
||||||
addClassMapper("LIST_ITER", "ListIter");
|
|
||||||
addClassMapper("LIST", "List");
|
|
||||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
|
||||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
|
||||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
|
||||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
|
||||||
addBiClassMapper("MAP", "Map", "2");
|
|
||||||
addClassMapper("NAVIGABLE_SET", "NavigableSet");
|
|
||||||
addBiClassMapper("PAIR", "Pair", "");
|
|
||||||
addClassMapper("PRIORITY_QUEUE", "PriorityQueue");
|
|
||||||
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
|
|
||||||
addClassMapper("PREDICATE", "2BooleanFunction");
|
|
||||||
addClassMapper("SORTED_SET", "SortedSet");
|
|
||||||
addClassMapper("ORDERED_SET", "OrderedSet");
|
|
||||||
addClassMapper("SET", "Set");
|
|
||||||
addClassMapper("STRATEGY", "Strategy");
|
|
||||||
addClassMapper("STACK", "Stack");
|
|
||||||
addClassMapper("SUPPLIER", "Supplier");
|
|
||||||
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
|
||||||
addClassMapper("TASK", "Task");
|
|
||||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
|
||||||
if(type.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", type.getFileType()+"Consumer");
|
|
||||||
}
|
|
||||||
else addClassMapper("CONSUMER", "Consumer");
|
|
||||||
addFunctionMappers("IARRAY", "I%sArray");
|
|
||||||
}
|
|
||||||
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
|
|
||||||
addSimpleMapper("COMPARATOR", type.isObject() ? "Comparator" : String.format("%sComparator", type.getNonFileType()));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createFunctions()
|
|
||||||
{
|
|
||||||
addSimpleMapper("APPLY_KEY_VALUE", type.isObject() ? "apply" : "applyAs"+type.getNonFileType());
|
|
||||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
|
||||||
addSimpleMapper("APPLY_CAST", "applyAs"+type.getCustomJDKType().getNonFileType());
|
|
||||||
addSimpleMapper("APPLY", type.isObject() ? "apply" : "applyAs"+type.getNonFileType());
|
|
||||||
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");
|
|
||||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
|
||||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
|
||||||
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
|
||||||
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
|
||||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
|
||||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
|
||||||
addFunctionMapper("FIRST_KEY", "first");
|
|
||||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
|
||||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
|
||||||
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
|
||||||
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
|
||||||
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
|
||||||
addFunctionMapper("GET_KEY", "get");
|
|
||||||
if(type.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
|
||||||
else addSimpleMapper("GET_VALUE", "get");
|
|
||||||
addSimpleMapper("GET_JAVA", type.isObject() ? "get" : "getAs"+type.getCustomJDKType().getNonFileType());
|
|
||||||
addFunctionMapper("LAST_KEY", "last");
|
|
||||||
addFunctionValueMapper("MERGE", "merge");
|
|
||||||
addFunctionMapper("NEXT", "next");
|
|
||||||
addFunctionMapper("PREVIOUS", "previous");
|
|
||||||
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
|
||||||
if(type.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
|
||||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
|
||||||
addFunctionMapper("REMOVE_KEY", "rem");
|
|
||||||
addFunctionMapper("REMOVE_LAST", "removeLast");
|
|
||||||
addFunctionMapper("REMOVE", "remove");
|
|
||||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
|
||||||
addFunctionMappers("REPLACE", type.isObject() ? "replaceObjects" : "replace%ss");
|
|
||||||
addFunctionMappers("SORT", "sort%ss");
|
|
||||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
|
||||||
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
|
||||||
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
|
||||||
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
|
||||||
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
|
|
||||||
addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array");
|
|
||||||
addSimpleMapper("[SPACE]", " ");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createFlags()
|
|
||||||
{
|
|
||||||
flags.add("TYPE_"+type.getCapType());
|
|
||||||
flags.add("VALUE_"+valueType.getCapType());
|
|
||||||
if(type == valueType) flags.add("SAME_TYPE");
|
|
||||||
if(type.hasFunction(valueType)) flags.add("JDK_FUNCTION");
|
|
||||||
if(!type.needsCustomJDKType()) flags.add("JDK_TYPE");
|
|
||||||
if(!type.isPrimitiveBlocking()) flags.add("PRIMITIVES");
|
|
||||||
if(!valueType.isPrimitiveBlocking()) flags.add("VALUE_PRIMITIVES");
|
|
||||||
if(valueType.needsCustomJDKType()) flags.add("JDK_VALUE");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateProcess create(String fileName, String splitter, boolean valueOnly)
|
|
||||||
{
|
|
||||||
TemplateProcess process = new TemplateProcess(String.format(fileName+".java", (splitter != null ? type.getFileType()+splitter+valueType.getFileType() : (valueOnly ? valueType : type).getFileType())));
|
|
||||||
process.setPathBuilder(new PathBuilder(type.getPathType()));
|
|
||||||
process.addFlags(flags);
|
|
||||||
process.addMappers(operators);
|
|
||||||
return process;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassType getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addClassMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, valueType.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addBiClassMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[KEY_"+pattern+"]", "KEY_"+pattern, type.getFileType()+splitter+type.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+splitter+valueType.getFileType()+replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAbstractMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, String.format(replacement, valueType.getFileType())));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAbstractBiMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getFileType()+splitter+valueType.getFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, replacement+valueType.getNonFileType()));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+type.getNonFileType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionValueMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+valueType.getNonFileType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionMappers(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType())));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getNonFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionValueMappers(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, valueType.getNonFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSimpleMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAnnontion(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(type == ClassType.OBJECT) operators.add(new LineMapper(type.name()+"["+pattern+"]", pattern));
|
|
||||||
else operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addValueAnnontion(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(valueType == ClassType.OBJECT) operators.add(new LineMapper(valueType.name()+"["+pattern+"]", pattern));
|
|
||||||
else operators.add(new SimpleMapper(valueType.name()+"["+pattern+"]", pattern, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addComment(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(type == ClassType.OBJECT) operators.add(new InjectMapper(type.name()+"["+pattern+"]", pattern, value).removeBraces());
|
|
||||||
else operators.add(new LineMapper(type.name()+"["+pattern+"]", pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addValueComment(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(valueType == ClassType.OBJECT) operators.add(new InjectMapper(valueType.name()+"["+pattern+"]", pattern, value).removeBraces());
|
|
||||||
else operators.add(new LineMapper(valueType.name()+"["+pattern+"]", pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
private InjectMapper addInjectMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
InjectMapper mapper = new InjectMapper(type.name()+"["+pattern+"]", pattern, replacement);
|
|
||||||
operators.add(mapper);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArgumentMapper addArgumentMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
return addArgumentMapper(pattern, replacement, ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
ArgumentMapper mapper = new ArgumentMapper(type.name()+"["+pattern+"]", pattern, replacement, splitter);
|
|
||||||
operators.add(mapper);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
class PathBuilder implements UnaryOperator<Path>
|
|
||||||
{
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
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<String, RequiredType> VOID = (K, V) -> {};
|
||||||
|
public static final ClassType[] TYPE = ClassType.values();
|
||||||
|
final ClassType keyType;
|
||||||
|
final ClassType valueType;
|
||||||
|
Set<String> blocked = new HashSet<>();
|
||||||
|
Map<String, String> nameRemapper = new HashMap<>();
|
||||||
|
Map<String, String> splitters = new HashMap<>();
|
||||||
|
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||||
|
List<IMapper> mappers = new ArrayList<>();
|
||||||
|
Set<String> flags = new LinkedHashSet<>();
|
||||||
|
Set<String> globalFlags;
|
||||||
|
Map<String, Integer> flaggedValues = new HashMap<>();
|
||||||
|
BiConsumer<String, RequiredType> requirements = VOID;
|
||||||
|
|
||||||
|
public ModulePackage(Set<String> 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<String, RequiredType> 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 addValue(String key, int value) {
|
||||||
|
flaggedValues.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRequirement(String fileName, RequiredType type) {
|
||||||
|
requirements.accept(fileName, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMapper(IMapper mapper) {
|
||||||
|
mappers.add(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBlockedFilter(Predicate<String> 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<TemplateProcess> 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);
|
||||||
|
process.addValues(flaggedValues);
|
||||||
|
result.accept(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBlocked(String fileName) {
|
||||||
|
if(blocked.contains(fileName)) return true;
|
||||||
|
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||||
|
if(blockedFilters.get(i).test(fileName)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||||
|
List<ModulePackage> 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<Path> {
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,332 +1,229 @@
|
|||||||
package speiger.src.builder;
|
package speiger.src.builder;
|
||||||
|
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.EnumMap;
|
import java.util.Collections;
|
||||||
import java.util.EnumSet;
|
import java.util.HashMap;
|
||||||
import java.util.HashMap;
|
import java.util.HashSet;
|
||||||
import java.util.HashSet;
|
import java.util.List;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
import java.util.Map;
|
import java.util.Set;
|
||||||
import java.util.Set;
|
import java.util.StringJoiner;
|
||||||
import java.util.StringJoiner;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.stream.Stream;
|
||||||
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.processor.TemplateProcess;
|
import speiger.src.builder.modules.CollectionModule;
|
||||||
import speiger.src.builder.processor.TemplateProcessor;
|
import speiger.src.builder.modules.FunctionModule;
|
||||||
|
import speiger.src.builder.modules.JavaModule;
|
||||||
@SuppressWarnings("javadoc")
|
import speiger.src.builder.modules.ListModule;
|
||||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
import speiger.src.builder.modules.MapModule;
|
||||||
{
|
import speiger.src.builder.modules.PairModule;
|
||||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
import speiger.src.builder.modules.PrioQueueModule;
|
||||||
EnumMap<ClassType, List<Predicate<String>>> blockedPredicate = new EnumMap<>(ClassType.class);
|
import speiger.src.builder.modules.SetModule;
|
||||||
Map<String, String> nameRemapper = new HashMap<>();
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
Map<String, String> biRequired = new HashMap<>();
|
import speiger.src.builder.processor.TemplateProcessor;
|
||||||
Set<String> enumRequired = new HashSet<>();
|
|
||||||
public static final ClassType[] TYPE = ClassType.values();
|
@SuppressWarnings("javadoc")
|
||||||
List<GlobalVariables> variables = new ArrayList<>();
|
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||||
List<GlobalVariables> biVariables = new ArrayList<>();
|
{
|
||||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||||
boolean special = false;
|
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.
|
||||||
public PrimitiveCollectionsBuilder()
|
private static final int SAVE = 0x4; //if the configuration should be created
|
||||||
{
|
Set<String> globalFlags = new HashSet<>();
|
||||||
this(false);
|
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||||
}
|
List<ModulePackage> biPackages = new ArrayList<>();
|
||||||
|
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess)
|
Map<String, RequiredType> requirements = new HashMap<>();
|
||||||
{
|
SettingsManager manager = new SettingsManager();
|
||||||
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
int flags;
|
||||||
}
|
|
||||||
|
public PrimitiveCollectionsBuilder() {
|
||||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
this(false);
|
||||||
{
|
}
|
||||||
this(false, sourceFolder, outputFolder, dataFolder);
|
|
||||||
}
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess) {
|
||||||
|
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
}
|
||||||
{
|
|
||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
}
|
this(false, sourceFolder, outputFolder, dataFolder);
|
||||||
|
}
|
||||||
private PrimitiveCollectionsBuilder setSpecial() {
|
|
||||||
special = true;
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
return this;
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PrimitiveCollectionsBuilder createTests(boolean silent) {
|
private PrimitiveCollectionsBuilder setFlags(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/")).setSpecial();
|
this.flags = flags;
|
||||||
}
|
if((flags & ANTI_SAVE) != 0) {
|
||||||
|
this.flags &= ~SAVE;
|
||||||
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();
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||||
protected boolean isFileValid(Path fileName)
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
{
|
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||||
return true;
|
Paths.get("src/test/java/speiger/src/tests/"),
|
||||||
}
|
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected boolean relativePackages()
|
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||||
{
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
return true;
|
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
|
}
|
||||||
protected boolean debugUnusedMappers()
|
|
||||||
{
|
@Override
|
||||||
return false;
|
protected boolean isFileValid(Path fileName) { return true; }
|
||||||
}
|
@Override
|
||||||
|
protected boolean relativePackages() { return true; }
|
||||||
@Override
|
@Override
|
||||||
protected void afterFinish()
|
protected boolean debugUnusedMappers() { return false; }
|
||||||
{
|
|
||||||
if(!special && getVersion() > 8)
|
@Override
|
||||||
{
|
protected void afterFinish() {
|
||||||
Path basePath = Paths.get("src/main/java");
|
if((flags & SPECIAL) == 0 && getVersion() > 8) {
|
||||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
Path basePath = Paths.get("src/main/java");
|
||||||
{
|
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java"))) {
|
||||||
writer.write(getModuleInfo(basePath));
|
writer.write(getModuleInfo(basePath));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
{
|
}
|
||||||
e.printStackTrace();
|
}
|
||||||
}
|
|
||||||
}
|
public List<BaseModule> createModules() {
|
||||||
}
|
List<BaseModule> modules = new ArrayList<>();
|
||||||
|
modules.add(JavaModule.INSTANCE);
|
||||||
@Override
|
modules.add(FunctionModule.INSTANCE);
|
||||||
protected void init()
|
modules.add(CollectionModule.INSTANCE);
|
||||||
{
|
modules.add(PrioQueueModule.INSTANCE);
|
||||||
variables.clear();
|
modules.add(ListModule.INSTANCE);
|
||||||
for(ClassType clzType : TYPE)
|
modules.add(SetModule.INSTANCE);
|
||||||
{
|
modules.add(MapModule.INSTANCE);
|
||||||
for(ClassType subType : TYPE)
|
modules.add(PairModule.INSTANCE);
|
||||||
{
|
modules.add(AsyncModule.INSTANCE);
|
||||||
create(clzType, subType);
|
return modules;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
enumRequired.add("EnumMap");
|
|
||||||
enumRequired.add("LinkedEnumMap");
|
@Override
|
||||||
biRequired.put("BiConsumer", "");
|
protected void init() {
|
||||||
biRequired.put("UnaryOperator", "");
|
prepPackages();
|
||||||
biRequired.put("Pair", "");
|
//Init Modules here
|
||||||
biRequired.put("MutablePair", "");
|
addModules(createModules());
|
||||||
biRequired.put("ImmutablePair", "");
|
finishPackages();
|
||||||
addBiClass("Function", "Maps", "Map", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "AbstractMap", "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
}
|
||||||
nameRemapper.put("BiConsumer", "%sConsumer");
|
|
||||||
nameRemapper.put("IArray", "I%sArray");
|
public void addModules(List<BaseModule> modules) {
|
||||||
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
nameRemapper.put("AbstractCollection", "Abstract%sCollection");
|
modules.get(i).setManager(manager);
|
||||||
nameRemapper.put("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
}
|
||||||
nameRemapper.put("AbstractSet", "Abstract%sSet");
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
nameRemapper.put("AbstractList", "Abstract%sList");
|
biPackages.forEach(modules.get(i)::init);
|
||||||
nameRemapper.put("EnumMap", "Enum2%sMap");
|
}
|
||||||
nameRemapper.put("LinkedEnumMap", "LinkedEnum2%sMap");
|
modules.forEach(BaseModule::cleanup);
|
||||||
nameRemapper.put("ImmutableList", "Immutable%sList");
|
}
|
||||||
nameRemapper.put("CopyOnWriteList", "CopyOnWrite%sArrayList");
|
|
||||||
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
private void finishPackages() {
|
||||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
biPackages.forEach(ModulePackage::finish);
|
||||||
|
if((flags & SAVE) != 0) manager.save();
|
||||||
|
}
|
||||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
|
||||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
private void prepPackages() {
|
||||||
addBlockage(ClassType.BOOLEAN, "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
if((flags & LOAD) != 0) manager.load();
|
||||||
|
for(ModulePackage entry : ModulePackage.createPackages(globalFlags)) {
|
||||||
//UnitTesters
|
entry.setRequirements(requirements::put);
|
||||||
nameRemapper.put("AbstractIteratorTester", "Abstract%sIteratorTester");
|
biPackages.add(entry);
|
||||||
nameRemapper.put("MinimalCollection", "Minimal%sCollection");
|
if(entry.isSame()) simplePackages.add(entry);
|
||||||
nameRemapper.put("MinimalSet", "Minimal%sSet");
|
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||||
nameRemapper.put("TestCollectionGenerator", "Test%sCollectionGenerator");
|
}
|
||||||
nameRemapper.put("TestQueueGenerator", "Test%sQueueGenerator");
|
}
|
||||||
nameRemapper.put("TestListGenerator", "Test%sListGenerator");
|
|
||||||
nameRemapper.put("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
@Override
|
||||||
nameRemapper.put("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
public void createProcesses(String fileName, Consumer<TemplateProcess> process) {
|
||||||
nameRemapper.put("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||||
nameRemapper.put("TestSetGenerator", "Test%sSetGenerator");
|
for(int i = 0,m=packages.size();i<m;i++) {
|
||||||
nameRemapper.put("AbstractContainerTester", "Abstract%sContainerTester");
|
packages.get(i).process(fileName, process);
|
||||||
nameRemapper.put("AbstractCollectionTester", "Abstract%sCollectionTester");
|
}
|
||||||
nameRemapper.put("AbstractQueueTester", "Abstract%sQueueTester");
|
}
|
||||||
nameRemapper.put("AbstractListTester", "Abstract%sListTester");
|
|
||||||
nameRemapper.put("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||||
nameRemapper.put("AbstractSetTester", "Abstract%sSetTester");
|
if(type == null) return simplePackages;
|
||||||
nameRemapper.put("SimpleTestGenerator", "Simple%sTestGenerator");
|
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||||
nameRemapper.put("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
if(type == RequiredType.ENUM) return enumPackages;
|
||||||
nameRemapper.put("TestMapGenerator", "Test%sMapGenerator");
|
return Collections.emptyList();
|
||||||
nameRemapper.put("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
}
|
||||||
nameRemapper.put("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
|
||||||
nameRemapper.put("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
private String getModuleInfo(Path basePath) {
|
||||||
nameRemapper.put("DerivedMapGenerators", "Derived%sMapGenerators");
|
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||||
nameRemapper.put("AbstractMapTester", "Abstract%sMapTester");
|
try(Stream<Path> stream = Files.walk(getOutputFolder())) {
|
||||||
nameRemapper.put("TestMap", "Test%sMap");
|
stream.filter(Files::isDirectory)
|
||||||
biRequired.put("PairTester", "");
|
.filter(this::containsFiles)
|
||||||
|
.map(basePath::relativize)
|
||||||
addBiClass("TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "OrderedMapTestSuiteBuilder", "MapTests", "MapConstructorTests", "TestMap");
|
.map(Path::toString)
|
||||||
addBiClass("MapAddToTester", "MapSubFromTester", "MapClearTester", "MapComputeIfAbsentTester", "MapComputeIfPresentTester", "MapComputeTester", "MapCopyTester", "MapContainsTester", "MapContainsKeyTester", "MapContainsValueTester", "MapCreatorTester", "MapEntrySetTester",
|
.map(this::sanitize)
|
||||||
"MapEqualsTester", "MapForEachTester", "MapGetOrDefaultTester", "MapGetTester", "MapHashCodeTester", "MapIsEmptyTester", "MapMergeTester", "MapMergeBulkTester", "MapPutAllArrayTester", "MapPutAllTester", "MapPutIfAbsentTester", "MapPutTester",
|
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||||
"MapRemoveEntryTester", "MapRemoveOrDefaultTester", "MapRemoveTester", "MapReplaceAllTester", "MapReplaceEntryTester", "MapReplaceTester", "MapSizeTester", "MapSupplyIfAbsentTester", "MapToStringTester",
|
}
|
||||||
"NavigableMapNavigationTester", "SortedMapNavigationTester", "OrderedMapNavigationTester", "OrderedMapMoveTester", "MapConstructorTester");
|
catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
addBlockage(ClassType.OBJECT, "CollectionStreamTester", "ListFillBufferTester");
|
throw new RuntimeException(e);
|
||||||
addBlockage(ClassType.BOOLEAN, "TestOrderedSetGenerator", "TestSortedSetGenerator", "TestNavigableSetGenerator", "CollectionRemoveIfTester", "CollectionStreamTester", "ListFillBufferTester", "ListReplaceAllTester", "NavigableSetNavigationTester", "SetTests", "MapConstructorTests", "TestMap", "QueueTests");
|
}
|
||||||
addBlockage(ClassType.BOOLEAN, "OrderedSetMoveTester", "OrderedSetNavigationTester", "SortedSetNaviationTester", "SetTestSuiteBuilder", "OrderedSetTestSuiteBuilder", "SortedSetTestSuiteBuilder", "NavigableSetTestSuiteBuilder", "SortedSetSubsetTestSetGenerator", "OrderedMapNavigationTester", "OrderedMapTestSuiteBuilder", "OrderedSetIterationTester", "SortedSetIterationTester");
|
StringBuilder builder = new StringBuilder();
|
||||||
addBlockage(ClassType.BOOLEAN, "TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "MapTests");
|
builder.append("/** @author Speiger */\n");
|
||||||
addBlockage(ClassType.BOOLEAN, T -> T.endsWith("Tester") && (T.startsWith("Iterable") ||T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
||||||
}
|
builder.append(joiner.toString()).append("}");
|
||||||
|
return builder.toString();
|
||||||
protected void create(ClassType mainType, ClassType subType)
|
}
|
||||||
{
|
|
||||||
GlobalVariables type = new GlobalVariables(mainType, subType);
|
private String sanitize(String input) {
|
||||||
type.createFlags();
|
return input.replace("\\", ".").replace("/", ".");
|
||||||
type.createHelperVariables();
|
}
|
||||||
type.createVariables();
|
|
||||||
type.createPreFunctions();
|
private boolean containsFiles(Path path) {
|
||||||
type.createClassTypes();
|
try(Stream<Path> stream = Files.walk(path, 1)) {
|
||||||
type.createFunctions();
|
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||||
if(mainType == subType) variables.add(type);
|
}
|
||||||
biVariables.add(type);
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
if(mainType.isObject()) enumVariables.add(type);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addBiClass(String...classNames)
|
private int getVersion() {
|
||||||
{
|
String version = System.getProperty("java.version");
|
||||||
for(String s : classNames)
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
{
|
int dot = version.indexOf(".");
|
||||||
biRequired.put(s, "2");
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static void main(String...args) {
|
||||||
protected void addBlockage(ClassType type, Predicate<String> filter)
|
try
|
||||||
{
|
{
|
||||||
blockedPredicate.computeIfAbsent(type, T -> new ArrayList<>()).add(filter);
|
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||||
}
|
boolean silent = flags.contains("silent");
|
||||||
|
boolean force = flags.contains("force");
|
||||||
protected void addBlockage(ClassType type, String...args)
|
boolean tests = flags.contains("tests");
|
||||||
{
|
boolean forceTests = flags.contains("force-tests");
|
||||||
for(String s : args)
|
boolean load = flags.contains("load");
|
||||||
{
|
boolean save = flags.contains("save");
|
||||||
EnumSet<ClassType> set = blocked.get(s);
|
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||||
if(set == null)
|
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||||
{
|
if(tests) {
|
||||||
set = EnumSet.noneOf(ClassType.class);
|
createTests(silent, flag).process(force || forceTests);
|
||||||
blocked.put(s, set);
|
createTesters(silent, flag).process(force || forceTests);
|
||||||
}
|
}
|
||||||
set.add(type);
|
}
|
||||||
}
|
catch(InterruptedException | IOException e)
|
||||||
}
|
{
|
||||||
|
e.printStackTrace();
|
||||||
@Override
|
}
|
||||||
public void createProcesses(String name, Consumer<TemplateProcess> acceptor)
|
}
|
||||||
{
|
}
|
||||||
String splitter = biRequired.get(name);
|
|
||||||
boolean valueRequired = enumRequired.contains(name);
|
|
||||||
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
|
||||||
for(int i = 0,m=vars.size();i<m;i++)
|
|
||||||
{
|
|
||||||
GlobalVariables type = vars.get(i);
|
|
||||||
if(isAllowed(type.getType(), name))
|
|
||||||
{
|
|
||||||
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean isAllowed(ClassType type, String fileName)
|
|
||||||
{
|
|
||||||
EnumSet<ClassType> types = blocked.get(fileName);
|
|
||||||
if(types != null && types.contains(type)) return false;
|
|
||||||
List<Predicate<String>> list = blockedPredicate.get(type);
|
|
||||||
if(list != null) {
|
|
||||||
for(int i = 0,m=list.size();i<m;i++) {
|
|
||||||
if(list.get(i).test(fileName)) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
|
||||||
if(enumRequired.contains(name)) return enumVariables;
|
|
||||||
if(bi) return biVariables;
|
|
||||||
return variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getModuleInfo(Path basePath) {
|
|
||||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
|
||||||
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
|
||||||
{
|
|
||||||
stream.filter(Files::isDirectory)
|
|
||||||
.filter(this::containsFiles)
|
|
||||||
.map(basePath::relativize)
|
|
||||||
.map(Path::toString)
|
|
||||||
.map(this::sanitize)
|
|
||||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("/** @author Speiger */\n");
|
|
||||||
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
|
||||||
builder.append(joiner.toString()).append("}");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String sanitize(String input)
|
|
||||||
{
|
|
||||||
return input.replace("\\", ".").replace("/", ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean containsFiles(Path path)
|
|
||||||
{
|
|
||||||
try(Stream<Path> stream = Files.walk(path, 1))
|
|
||||||
{
|
|
||||||
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getVersion()
|
|
||||||
{
|
|
||||||
String version = System.getProperty("java.version");
|
|
||||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
|
||||||
int dot = version.indexOf(".");
|
|
||||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String...args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
|
||||||
boolean silent = flags.contains("silent");
|
|
||||||
boolean force = flags.contains("force");
|
|
||||||
boolean tests = flags.contains("tests");
|
|
||||||
boolean forceTests = flags.contains("force-tests");
|
|
||||||
|
|
||||||
new PrimitiveCollectionsBuilder(silent).process(force);
|
|
||||||
if(tests) {
|
|
||||||
createTests(silent).process(force || forceTests);
|
|
||||||
createTesters(silent).process(force || forceTests);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(InterruptedException | IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package speiger.src.builder;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public enum RequiredType
|
||||||
|
{
|
||||||
|
BI_CLASS,
|
||||||
|
ENUM
|
||||||
|
}
|
||||||
@@ -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<String> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
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<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||||
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||||
|
|
||||||
|
public ClassType keyType() { return keyType; }
|
||||||
|
public ClassType valueType() { return valueType; }
|
||||||
|
|
||||||
|
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 addValue(String name, int value) {
|
||||||
|
entry.addValue(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
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<String> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<String> 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");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
import speiger.src.builder.RequiredType;
|
||||||
|
|
||||||
|
@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", "");
|
||||||
|
if(valueType == ClassType.BOOLEAN) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate");
|
||||||
|
}
|
||||||
|
else if(keyType.isObject() && !valueType.isObject()) {
|
||||||
|
addRequirement("Function", "%2$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", "To%sFunction");
|
||||||
|
}
|
||||||
|
else if(keyType == valueType) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"UnaryOperator");
|
||||||
|
}
|
||||||
|
else if(valueType.isObject()) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", "%sFunction");
|
||||||
|
}
|
||||||
|
else addBiRequirement("Function");
|
||||||
|
addRemapper("BiConsumer", "%sConsumer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||||
|
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
|
||||||
|
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Interfaces
|
||||||
|
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
||||||
|
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
||||||
|
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
||||||
|
addAbstractMapper("BI_FROM_INT_CONSUMER", "Int%sConsumer");
|
||||||
|
if(keyType.isObject()) {
|
||||||
|
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
|
||||||
|
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"Function");
|
||||||
|
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
||||||
|
}
|
||||||
|
if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate");
|
||||||
|
else if(keyType.isObject() && !valueType.isObject()) addFunctionValueMappers("FUNCTION", "To%sFunction");
|
||||||
|
else if(keyType == valueType) addFunctionMappers("FUNCTION", "%sUnaryOperator");
|
||||||
|
else if(valueType.isObject()) addFunctionMappers("FUNCTION", "%sFunction");
|
||||||
|
else addBiClassMapper("FUNCTION", "Function", "2");
|
||||||
|
|
||||||
|
addFunctionMappers("PREDICATE", "%sPredicate");
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
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());
|
||||||
|
addValue("JAVA_VERSION", getVersion());
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getVersion() {
|
||||||
|
String version = System.getProperty("java.version");
|
||||||
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
|
int dot = version.indexOf(".");
|
||||||
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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()
|
||||||
|
{
|
||||||
|
if(getVersion() >= 17) addSimpleMapper("RANDOM", "RandomGenerator");
|
||||||
|
else addSimpleMapper("RANDOM", "Random");
|
||||||
|
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() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_SAME_GENERIC_TYPE", keyType.isObject() ? "<T, T>" : "");
|
||||||
|
addSimpleMapper(" VALUE_SAME_GENERIC_TYPE", keyType.isObject() ? "<V, V>" : "");
|
||||||
|
|
||||||
|
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<T>>" : "");
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "<? super "+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? super "+keyType.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? "<? extends "+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? extends "+keyType.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
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(" SK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" KS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %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("<>");
|
||||||
|
addInjectMapper(" SV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" VS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %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<T>>" : "");
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
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<String> 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("GET_FIRST_KEY", "getFirst");
|
||||||
|
addFunctionMapper("GET_LAST_KEY", "getLast");
|
||||||
|
addFunctionMapper("REMOVE_FIRST_KEY", "removeFirst");
|
||||||
|
addFunctionMapper("REMOVE_LAST_KEY", "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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,288 @@
|
|||||||
|
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<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
Set<String> 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("MAP_FEATURE");
|
||||||
|
if(customHashMap) addFlag("CUSTOM_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", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||||
|
addBlockedFiles("TestOrderedMapGenerator");
|
||||||
|
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||||
|
}
|
||||||
|
if(valueType == ClassType.OBJECT) {
|
||||||
|
addBlockedFiles("MapComputeIfAbsentNonDefaultTester", "MapComputeIfPresentNonDefaultTester", "MapComputeNonDefaultTester", "MapSupplyIfAbsentNonDefaultTester");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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("MapComputeIfAbsentNonDefaultTester");
|
||||||
|
addBiRequirement("MapComputeIfPresentNonDefaultTester");
|
||||||
|
addBiRequirement("MapComputeNonDefaultTester");
|
||||||
|
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("MapSupplyIfAbsentNonDefaultTester");
|
||||||
|
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");
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<String> 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", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<String> 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
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<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
Set<String> 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", "TestSetGenerator");
|
||||||
|
addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedSetIterationTester");
|
||||||
|
addBlockedFiles("SortedSetTestSuiteBuilder", "TestSortedSetGenerator", "SortedSetNaviationTester", "SortedSetSubsetTestSetGenerator", "SortedSetIterationTester", "SortedSetNaviationTester");
|
||||||
|
addBlockedFiles("NavigableSetTestSuiteBuilder", "TestNavigableSetGenerator", "NavigableSetNavigationTester");
|
||||||
|
addBlockedFiles("MinimalSet", "AbstractSetTester", "SetAddAllTester", "SetAddTester", "SetCreationTester", "SetEqualsTester", "SetRemoveTester");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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");
|
||||||
|
}
|
||||||
|
}
|
||||||
+265
-263
@@ -1,264 +1,266 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.AbstractCollection;
|
import java.util.AbstractCollection;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
#endif
|
||||||
/**
|
|
||||||
* Abstract Type Specific Collection that reduces boxing/unboxing
|
/**
|
||||||
* @Type(T)
|
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||||
*/
|
* @Type(T)
|
||||||
public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractCollection<CLASS_TYPE> implements COLLECTION KEY_GENERIC_TYPE
|
*/
|
||||||
{
|
public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractCollection<CLASS_TYPE> implements COLLECTION KEY_GENERIC_TYPE
|
||||||
@Override
|
{
|
||||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
@Override
|
||||||
|
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
#if !TYPE_OBJECT
|
|
||||||
/** {@inheritDoc}
|
#if !TYPE_OBJECT
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
/** {@inheritDoc}
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
*/
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
@Override
|
*/
|
||||||
@Deprecated
|
@Override
|
||||||
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
@Deprecated
|
||||||
|
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
||||||
#endif
|
|
||||||
@Override
|
#endif
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
@Override
|
||||||
boolean modified = false;
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
boolean modified = false;
|
||||||
return modified;
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
||||||
}
|
return modified;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
@Override
|
||||||
|
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
#if !TYPE_OBJECT
|
|
||||||
/** {@inheritDoc}
|
#if !TYPE_OBJECT
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
/** {@inheritDoc}
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
*/
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
@Override
|
*/
|
||||||
@Deprecated
|
@Override
|
||||||
public boolean contains(Object e) { return COLLECTION.super.contains(e); }
|
@Deprecated
|
||||||
|
public boolean contains(Object e) { return COLLECTION.super.contains(e); }
|
||||||
/**
|
|
||||||
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
/**
|
||||||
* @param e the element that should be searched for.
|
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
||||||
* @return true if the value was found.
|
* @param e the element that should be searched for.
|
||||||
*/
|
* @return true if the value was found.
|
||||||
@Override
|
*/
|
||||||
public boolean contains(KEY_TYPE e) {
|
@Override
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
public boolean contains(KEY_TYPE e) {
|
||||||
return false;
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
/** {@inheritDoc}
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
*/
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
@Override
|
*/
|
||||||
@Deprecated
|
@Override
|
||||||
public boolean addAll(Collection<? extends CLASS_TYPE> c)
|
@Deprecated
|
||||||
{
|
public boolean addAll(Collection<? extends CLASS_TYPE> c)
|
||||||
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
{
|
||||||
}
|
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
||||||
#endif
|
}
|
||||||
|
#endif
|
||||||
/**
|
|
||||||
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
/**
|
||||||
* @param c the collection that should be checked if it contains all elements.
|
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||||
* @return true if all elements were found in the collection
|
* @param c the collection that should be checked if it contains all elements.
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @return true if all elements were found in the collection
|
||||||
*/
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
@Override
|
*/
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
if(c.isEmpty()) return true;
|
Objects.requireNonNull(c);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
if(c.isEmpty()) return true;
|
||||||
if(!contains(iter.NEXT()))
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
return false;
|
if(!contains(iter.NEXT()))
|
||||||
return true;
|
return false;
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean containsAll(Collection<?> c) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean containsAll(Collection<?> c) {
|
||||||
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(c);
|
Objects.requireNonNull(c);
|
||||||
}
|
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(c);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection
|
/**
|
||||||
* @param c the elements that should be checked for
|
* This implementation iterates over the elements of the collection and checks if they are stored in this collection
|
||||||
* @return true if any element is in this collection
|
* @param c the elements that should be checked for
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @return true if any element is in this collection
|
||||||
*/
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
@Override
|
*/
|
||||||
@Primitive
|
@Override
|
||||||
public boolean containsAny(Collection<?> c) {
|
@Primitive
|
||||||
Objects.requireNonNull(c);
|
public boolean containsAny(Collection<?> c) {
|
||||||
if(c.isEmpty()) return false;
|
Objects.requireNonNull(c);
|
||||||
for(Object e : c)
|
if(c.isEmpty()) return false;
|
||||||
if(contains(e))
|
for(Object e : c)
|
||||||
return true;
|
if(contains(e))
|
||||||
return false;
|
return true;
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
/**
|
||||||
* @param c the elements that should be checked for
|
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
||||||
* @return true if any element is in this collection
|
* @param c the elements that should be checked for
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @return true if any element is in this collection
|
||||||
*/
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
@Override
|
*/
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
if(c.isEmpty()) return false;
|
Objects.requireNonNull(c);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
if(c.isEmpty()) return false;
|
||||||
if(contains(iter.NEXT()))
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
return true;
|
if(contains(iter.NEXT()))
|
||||||
return false;
|
return true;
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
#if !TYPE_OBJECT
|
|
||||||
/** {@inheritDoc}
|
#if !TYPE_OBJECT
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
/** {@inheritDoc}
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
*/
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
@Override
|
*/
|
||||||
@Deprecated
|
@Override
|
||||||
public boolean remove(Object e) { return COLLECTION.super.remove(e); }
|
@Deprecated
|
||||||
|
public boolean remove(Object e) { return COLLECTION.super.remove(e); }
|
||||||
/**
|
|
||||||
* A Type-Specific implementation of remove. This implementation iterates over the elements until it finds the element that is searched for or it runs out of elements.
|
/**
|
||||||
* It stops after finding the first element
|
* A Type-Specific implementation of remove. This implementation iterates over the elements until it finds the element that is searched for or it runs out of elements.
|
||||||
* @param e the element that is searched for
|
* It stops after finding the first element
|
||||||
* @return true if the element was found and removed.
|
* @param e the element that is searched for
|
||||||
*/
|
* @return true if the element was found and removed.
|
||||||
@Override
|
*/
|
||||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
@Override
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||||
if(KEY_EQUALS(iter.NEXT(), e)) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
iter.remove();
|
if(KEY_EQUALS(iter.NEXT(), e)) {
|
||||||
return true;
|
iter.remove();
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
#endif
|
|
||||||
/**
|
#endif
|
||||||
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
/**
|
||||||
* @param c the elements that should be deleted
|
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
||||||
* @return true if the collection was modified.
|
* @param c the elements that should be deleted
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @return true if the collection was modified.
|
||||||
*/
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
@Override
|
*/
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
if(c.isEmpty()) return false;
|
Objects.requireNonNull(c);
|
||||||
boolean modified = false;
|
if(c.isEmpty()) return false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
boolean modified = false;
|
||||||
if(c.contains(iter.NEXT())) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
iter.remove();
|
if(c.contains(iter.NEXT())) {
|
||||||
modified = true;
|
iter.remove();
|
||||||
}
|
modified = true;
|
||||||
}
|
}
|
||||||
return modified;
|
}
|
||||||
}
|
return modified;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
if(c.isEmpty()) return false;
|
Objects.requireNonNull(c);
|
||||||
Objects.requireNonNull(r);
|
if(c.isEmpty()) return false;
|
||||||
boolean modified = false;
|
Objects.requireNonNull(r);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
boolean modified = false;
|
||||||
KEY_TYPE e = iter.NEXT();
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(c.contains(e)) {
|
KEY_TYPE e = iter.NEXT();
|
||||||
r.accept(e);
|
if(c.contains(e)) {
|
||||||
iter.remove();
|
r.accept(e);
|
||||||
modified = true;
|
iter.remove();
|
||||||
}
|
modified = true;
|
||||||
}
|
}
|
||||||
return modified;
|
}
|
||||||
}
|
return modified;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
/**
|
||||||
* @param c the elements that should be kept
|
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
||||||
* @return true if the collection was modified.
|
* @param c the elements that should be kept
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @return true if the collection was modified.
|
||||||
*/
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
@Override
|
*/
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
if(c.isEmpty()) {
|
Objects.requireNonNull(c);
|
||||||
boolean modified = !isEmpty();
|
if(c.isEmpty()) {
|
||||||
clear();
|
boolean modified = !isEmpty();
|
||||||
return modified;
|
clear();
|
||||||
}
|
return modified;
|
||||||
boolean modified = false;
|
}
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
boolean modified = false;
|
||||||
if(!c.contains(iter.NEXT())) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
iter.remove();
|
if(!c.contains(iter.NEXT())) {
|
||||||
modified = true;
|
iter.remove();
|
||||||
}
|
modified = true;
|
||||||
}
|
}
|
||||||
return modified;
|
}
|
||||||
}
|
return modified;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
@Override
|
||||||
Objects.requireNonNull(c);
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
Objects.requireNonNull(r);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) {
|
Objects.requireNonNull(r);
|
||||||
boolean modified = !isEmpty();
|
if(c.isEmpty()) {
|
||||||
forEach(r);
|
boolean modified = !isEmpty();
|
||||||
clear();
|
forEach(r);
|
||||||
return modified;
|
clear();
|
||||||
}
|
return modified;
|
||||||
boolean modified = false;
|
}
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
boolean modified = false;
|
||||||
KEY_TYPE e = iter.NEXT();
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(!c.contains(e)) {
|
KEY_TYPE e = iter.NEXT();
|
||||||
r.accept(e);
|
if(!c.contains(e)) {
|
||||||
iter.remove();
|
r.accept(e);
|
||||||
modified = true;
|
iter.remove();
|
||||||
}
|
modified = true;
|
||||||
}
|
}
|
||||||
return modified;
|
}
|
||||||
}
|
return modified;
|
||||||
|
}
|
||||||
#if !TYPE_OBJECT
|
|
||||||
/**
|
#if !TYPE_OBJECT
|
||||||
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
/**
|
||||||
* @return an array containing all of the elements in this collection
|
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
*/
|
* @return an array containing all of the elements in this collection
|
||||||
@Override
|
*/
|
||||||
public KEY_TYPE[] TO_ARRAY() {
|
@Override
|
||||||
return TO_ARRAY(new KEY_TYPE[size()]);
|
public KEY_TYPE[] TO_ARRAY() {
|
||||||
}
|
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
||||||
|
return TO_ARRAY(new KEY_TYPE[size()]);
|
||||||
/**
|
}
|
||||||
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
|
||||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
/**
|
||||||
* @return an array containing all of the elements in this collection
|
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
||||||
*/
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
@Override
|
* @return an array containing all of the elements in this collection
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
*/
|
||||||
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
@Override
|
||||||
ITERATORS.unwrap(a, iterator());
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
||||||
return a;
|
ITERATORS.unwrap(a, iterator());
|
||||||
}
|
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||||
#endif
|
return a;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+322
-312
@@ -1,313 +1,323 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.JAVA_STREAM;
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.JAVA_STREAM;
|
||||||
#endif
|
import java.util.stream.StreamSupport;
|
||||||
#if TYPE_OBJECT
|
#endif
|
||||||
import java.util.function.Consumer;
|
#endif
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
#if TYPE_OBJECT
|
||||||
#else
|
import java.util.function.Consumer;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import java.util.function.IntFunction;
|
||||||
#endif
|
#else
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
#endif
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
/**
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
* @Type(T)
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
*/
|
|
||||||
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
/**
|
||||||
{
|
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||||
#if !TYPE_OBJECT
|
* @Type(T)
|
||||||
/**
|
*/
|
||||||
* A Type-Specific add function to reduce (un)boxing
|
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
* @param o the element that should be added
|
{
|
||||||
* @return true if the element was added to the collection
|
#if !TYPE_OBJECT
|
||||||
*/
|
/**
|
||||||
public boolean add(KEY_TYPE o);
|
* A Type-Specific add function to reduce (un)boxing
|
||||||
|
* @param o the element that should be added
|
||||||
#endif
|
* @return true if the element was added to the collection
|
||||||
/**
|
*/
|
||||||
* A Type-Specific addAll function to reduce (un)boxing
|
public boolean add(KEY_TYPE o);
|
||||||
* @param c the collection of elements that should be added
|
|
||||||
* @return true if elements were added into the collection
|
#endif
|
||||||
*/
|
/**
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
* A Type-Specific addAll function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be added
|
||||||
/**
|
* @return true if elements were added into the collection
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
*/
|
||||||
* @param e the elements that should be added
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
* @return if the collection was modified
|
|
||||||
*/
|
/**
|
||||||
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
|
* @param e the elements that should be added
|
||||||
/**
|
* @return if the collection was modified
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
*/
|
||||||
* @param e the elements that should be added
|
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
||||||
* @param length how many elements of the array should be added
|
|
||||||
* @return if the collection was modified
|
/**
|
||||||
*/
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
* @param e the elements that should be added
|
||||||
|
* @param length how many elements of the array should be added
|
||||||
/**
|
* @return if the collection was modified
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
*/
|
||||||
* @param e the elements that should be added
|
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
||||||
* @param offset where to start within the array
|
|
||||||
* @param length how many elements of the array should be added
|
/**
|
||||||
* @return if the collection was modified
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
*/
|
* @param e the elements that should be added
|
||||||
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
* @param offset where to start within the array
|
||||||
if(length <= 0) return false;
|
* @param length how many elements of the array should be added
|
||||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
* @return if the collection was modified
|
||||||
boolean added = false;
|
*/
|
||||||
for(int i = 0;i<length;i++) {
|
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
||||||
if(add(e[offset+i])) added = true;
|
if(length <= 0) return false;
|
||||||
}
|
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
||||||
return added;
|
boolean added = false;
|
||||||
}
|
for(int i = 0;i<length;i++) {
|
||||||
|
if(add(e[offset+i])) added = true;
|
||||||
#if !TYPE_OBJECT
|
}
|
||||||
/**
|
return added;
|
||||||
* A Type-Specific contains function to reduce (un)boxing
|
}
|
||||||
* @param o the element that is checked for
|
|
||||||
* @return true if the element is found in the collection
|
#if !TYPE_OBJECT
|
||||||
*/
|
/**
|
||||||
public boolean contains(KEY_TYPE o);
|
* A Type-Specific contains function to reduce (un)boxing
|
||||||
|
* @param o the element that is checked for
|
||||||
#endif
|
* @return true if the element is found in the collection
|
||||||
/**
|
*/
|
||||||
* A Type-Specific containsAll function to reduce (un)boxing
|
public boolean contains(KEY_TYPE o);
|
||||||
* @param c the collection of elements that should be tested for
|
|
||||||
* @return true if all the element is found in the collection
|
#endif
|
||||||
*/
|
/**
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
* A Type-Specific containsAll function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be tested for
|
||||||
/**
|
* @return true if all the element is found in the collection
|
||||||
* A Type-Specific containsAny function to reduce (un)boxing
|
*/
|
||||||
* @param c the collection of elements that should be tested for
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
* @return true if any element was found
|
|
||||||
*/
|
/**
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
* A Type-Specific containsAny function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be tested for
|
||||||
/**
|
* @return true if any element was found
|
||||||
* Returns true if any element of the Collection is found in the provided collection.
|
*/
|
||||||
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
* @param c the collection of elements that should be tested for
|
|
||||||
* @return true if any element was found.
|
/**
|
||||||
*/
|
* Returns true if any element of the Collection is found in the provided collection.
|
||||||
@Primitive
|
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||||
public boolean containsAny(Collection<?> c);
|
* @param c the collection of elements that should be tested for
|
||||||
|
* @return true if any element was found.
|
||||||
#if !TYPE_OBJECT
|
*/
|
||||||
/**
|
@Primitive
|
||||||
* A Type-Specific remove function that reduces (un)boxing.
|
public boolean containsAny(Collection<?> c);
|
||||||
* @param o the element that should be removed
|
|
||||||
* @return true if the element was removed
|
#if !TYPE_OBJECT
|
||||||
* @see Collection#remove(Object)
|
/**
|
||||||
*/
|
* A Type-Specific remove function that reduces (un)boxing.
|
||||||
public boolean REMOVE_KEY(KEY_TYPE o);
|
* @param o the element that should be removed
|
||||||
|
* @return true if the element was removed
|
||||||
#endif
|
* @see Collection#remove(Object)
|
||||||
/**
|
*/
|
||||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
public boolean REMOVE_KEY(KEY_TYPE o);
|
||||||
* @param c the collection of elements that should be removed
|
|
||||||
* @return true if any element was removed
|
#endif
|
||||||
* @see Collection#removeAll(Collection)
|
/**
|
||||||
*/
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
* @param c the collection of elements that should be removed
|
||||||
|
* @return true if any element was removed
|
||||||
/**
|
* @see Collection#removeAll(Collection)
|
||||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
*/
|
||||||
* It also notifies the remover of which exact element is going to be removed.
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
* @param c the collection of elements that should be removed
|
|
||||||
* @param r elements that got removed
|
/**
|
||||||
* @return true if any element was removed
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
* @see Collection#removeAll(Collection)
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
*/
|
* @param c the collection of elements that should be removed
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
* @param r elements that got removed
|
||||||
|
* @return true if any element was removed
|
||||||
/**
|
* @see Collection#removeAll(Collection)
|
||||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
*/
|
||||||
* @param c the collection of elements that should be kept
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||||
* @return true if any element was removed
|
|
||||||
* @see Collection#retainAll(Collection)
|
/**
|
||||||
*/
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
* @param c the collection of elements that should be kept
|
||||||
|
* @return true if any element was removed
|
||||||
/**
|
* @see Collection#retainAll(Collection)
|
||||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
*/
|
||||||
* It also notifies the remover of which exact element is going to be removed.
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
* @param c the collection of elements that should be kept
|
|
||||||
* @param r elements that got removed
|
/**
|
||||||
* @return true if any element was removed
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
* @see Collection#retainAll(Collection)
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
*/
|
* @param c the collection of elements that should be kept
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
* @param r elements that got removed
|
||||||
|
* @return true if any element was removed
|
||||||
/**
|
* @see Collection#retainAll(Collection)
|
||||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
*/
|
||||||
* @param collection that the elements should be inserted to
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||||
* @param <E> the collection type
|
|
||||||
* @return the input with the desired elements
|
/**
|
||||||
*/
|
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
* @param collection that the elements should be inserted to
|
||||||
collection.addAll(this);
|
* @param <E> the collection type
|
||||||
return collection;
|
* @return the input with the desired elements
|
||||||
}
|
*/
|
||||||
|
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||||
/**
|
collection.addAll(this);
|
||||||
* A Function that does a shallow clone of the Collection itself.
|
return collection;
|
||||||
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
}
|
||||||
* It can be compared to Cloneable but with less exception risk
|
|
||||||
* @return a Shallow Copy of the collection
|
/**
|
||||||
* @note Wrappers and view collections will not support this feature
|
* A Function that does a shallow clone of the Collection itself.
|
||||||
*/
|
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy();
|
* It can be compared to Cloneable but with less exception risk
|
||||||
|
* @return a Shallow Copy of the collection
|
||||||
#if TYPE_OBJECT
|
* @note Wrappers and view collections will not support this feature
|
||||||
/**
|
*/
|
||||||
* A Helper function that simplifies the process of creating a new Array.
|
public COLLECTION KEY_GENERIC_TYPE copy();
|
||||||
* @param action the array creation function
|
|
||||||
* @return an array containing all of the elements in this collection
|
#if TYPE_OBJECT
|
||||||
* @see Collection#toArray(Object[])
|
/**
|
||||||
*/
|
* A Helper function that simplifies the process of creating a new Array.
|
||||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
* @param action the array creation function
|
||||||
return TO_ARRAY(action.get(size()));
|
* @param <E> the returning arrayType
|
||||||
}
|
* @return an array containing all of the elements in this collection
|
||||||
|
* @see Collection#toArray(Object[])
|
||||||
#else
|
*/
|
||||||
/**
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
return TO_ARRAY(action.apply(size()));
|
||||||
* @return an array containing all of the elements in this collection
|
}
|
||||||
* @see Collection#toArray()
|
|
||||||
*/
|
#else
|
||||||
public KEY_TYPE[] TO_ARRAY();
|
/**
|
||||||
|
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
/**
|
* @return an array containing all of the elements in this collection
|
||||||
* A Type-Specific toArray function that reduces (un)boxing.
|
* @see Collection#toArray()
|
||||||
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
*/
|
||||||
* @return an array containing all of the elements in this collection
|
public KEY_TYPE[] TO_ARRAY();
|
||||||
* @see Collection#toArray(Object[])
|
|
||||||
*/
|
/**
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
* A Type-Specific toArray function that reduces (un)boxing.
|
||||||
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
#if PRIMITIVES
|
* @return an array containing all of the elements in this collection
|
||||||
/** {@inheritDoc}
|
* @see Collection#toArray(Object[])
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
*/
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
||||||
*/
|
|
||||||
@Override
|
#if PRIMITIVES
|
||||||
@Deprecated
|
/** {@inheritDoc}
|
||||||
public default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
Objects.requireNonNull(filter);
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
*/
|
||||||
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
@Override
|
||||||
#else
|
@Deprecated
|
||||||
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
public default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
||||||
#endif
|
Objects.requireNonNull(filter);
|
||||||
}
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
|
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
||||||
/**
|
#else
|
||||||
* A Type-Specific removeIf function to reduce (un)boxing.
|
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
||||||
* <p>Removes elements that were selected by the filter
|
#endif
|
||||||
* @see Collection#removeIf(Predicate)
|
}
|
||||||
* @param filter Filters the elements that should be removed
|
|
||||||
* @return true if the collection was modified
|
/**
|
||||||
* @throws java.lang.NullPointerException if filter is null
|
* A Type-Specific removeIf function to reduce (un)boxing.
|
||||||
*/
|
* <p>Removes elements that were selected by the filter
|
||||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
* @see Collection#removeIf(Predicate)
|
||||||
Objects.requireNonNull(filter);
|
* @param filter Filters the elements that should be removed
|
||||||
boolean removed = false;
|
* @return true if the collection was modified
|
||||||
final ITERATOR each = iterator();
|
* @throws java.lang.NullPointerException if filter is null
|
||||||
while (each.hasNext()) {
|
*/
|
||||||
if (filter.test(each.NEXT())) {
|
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||||
each.remove();
|
Objects.requireNonNull(filter);
|
||||||
removed = true;
|
boolean removed = false;
|
||||||
}
|
final ITERATOR each = iterator();
|
||||||
}
|
while (each.hasNext()) {
|
||||||
return removed;
|
if (filter.test(each.NEXT())) {
|
||||||
}
|
each.remove();
|
||||||
|
removed = true;
|
||||||
#endif
|
}
|
||||||
/** {@inheritDoc}
|
}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
return removed;
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
}
|
||||||
*/
|
|
||||||
@Override
|
#endif
|
||||||
@Deprecated
|
/** {@inheritDoc}
|
||||||
public default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
/** {@inheritDoc}
|
*/
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
@Override
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
@Deprecated
|
||||||
*/
|
public default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
||||||
@Override
|
|
||||||
@Deprecated
|
/** {@inheritDoc}
|
||||||
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
/** {@inheritDoc}
|
*/
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
@Override
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
@Deprecated
|
||||||
*/
|
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
||||||
@Override
|
|
||||||
@Deprecated
|
/** {@inheritDoc}
|
||||||
public default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
#endif
|
*/
|
||||||
/**
|
@Override
|
||||||
* Returns a Type-Specific Iterator to reduce (un)boxing
|
@Deprecated
|
||||||
* @return a iterator of the collection
|
public default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
||||||
* @see Collection#iterator()
|
|
||||||
*/
|
#endif
|
||||||
@Override
|
/**
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
* Returns a Type-Specific Iterator to reduce (un)boxing
|
||||||
|
* @return a iterator of the collection
|
||||||
/**
|
* @see Collection#iterator()
|
||||||
* Creates a Wrapped Collection that is Synchronized
|
*/
|
||||||
* @return a new Collection that is synchronized
|
@Override
|
||||||
* @see COLLECTIONS#synchronize
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
*/
|
|
||||||
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
/**
|
||||||
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
/**
|
* @return a new Collection that is synchronized
|
||||||
* Creates a Wrapped Collection that is Synchronized
|
* @see COLLECTIONS#synchronize
|
||||||
* @param mutex is the controller of the synchronization block
|
*/
|
||||||
* @return a new Collection Wrapper that is synchronized
|
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
||||||
* @see COLLECTIONS#synchronize
|
|
||||||
*/
|
/**
|
||||||
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
|
* @param mutex is the controller of the synchronization block
|
||||||
/**
|
* @return a new Collection Wrapper that is synchronized
|
||||||
* Creates a Wrapped Collection that is unmodifiable
|
* @see COLLECTIONS#synchronize
|
||||||
* @return a new Collection Wrapper that is unmodifiable
|
*/
|
||||||
* @see COLLECTIONS#unmodifiable
|
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
||||||
*/
|
|
||||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
/**
|
||||||
|
* Creates a Wrapped Collection that is unmodifiable
|
||||||
#if PRIMITIVES
|
* @return a new Collection Wrapper that is unmodifiable
|
||||||
/**
|
* @see COLLECTIONS#unmodifiable
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
*/
|
||||||
* @return a Stream of the closest java type
|
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||||
*/
|
|
||||||
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
|
#if PRIMITIVES
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
*/
|
*/
|
||||||
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
||||||
* @return type specific splititerator
|
* @return a Stream of the closest java type
|
||||||
*/
|
*/
|
||||||
@Override
|
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
|
||||||
|
#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
|
||||||
}
|
}
|
||||||
+489
-383
@@ -1,384 +1,490 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#if !TYPE_OBJECT
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
#if !TYPE_OBJECT
|
||||||
#else
|
|
||||||
import java.util.function.BiFunction;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import java.util.Comparator;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
#else
|
||||||
#endif
|
import java.util.function.BiFunction;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import java.util.function.IntFunction;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import java.util.Comparator;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.booleans.collections.BooleanIterable;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#iterate
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
#endif
|
#argument PACKAGE bytes shorts ints longs floats doubles
|
||||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
#if FILTER_TYPE
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
#endif
|
||||||
|
#enditerate
|
||||||
/**
|
#endif
|
||||||
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
* @Type(T)
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
*/
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
#if !JDK_FUNCTION
|
||||||
{
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
/**
|
#endif
|
||||||
* Returns an iterator over elements of type {@code T}.
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
*
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
* @return an Iterator.
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
*/
|
#if ARRAY_LIST_FEATURE
|
||||||
@Override
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
ITERATOR KEY_GENERIC_TYPE iterator();
|
#else
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
#if !TYPE_OBJECT
|
#endif
|
||||||
/**
|
#endif
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
#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
|
||||||
* @implSpec
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
* <p>The default implementation behaves as if:
|
#if LINKED_SET_FEATURE
|
||||||
* <pre>{@code
|
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||||
* iterator().forEachRemaining(action);
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
* }</pre>
|
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||||
*
|
#else if SET_FEATURE
|
||||||
* @param action The action to be performed for each element
|
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||||
* @throws NullPointerException if the specified action is null
|
#else if CUSTOM_SET_FEATURE
|
||||||
* @see Iterable#forEach(Consumer)
|
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||||
*/
|
#else if RB_TREE_SET_FEATURE
|
||||||
default void forEach(CONSUMER action) {
|
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||||
Objects.requireNonNull(action);
|
#else if AVL_TREE_SET_FEATURE
|
||||||
iterator().forEachRemaining(action);
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||||
}
|
#else if ARRAY_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||||
/** {@inheritDoc}
|
#endif
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
#endif
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
#endif
|
||||||
*/
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
@Deprecated
|
#if ASYNC_MODULE
|
||||||
@Override
|
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||||
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
#endif
|
||||||
Objects.requireNonNull(action);
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
iterator().forEachRemaining(action);
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
}
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
/**
|
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
* @param input the object that should be included
|
#endif
|
||||||
* @param action The action to be performed for each element
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
* @param <E> the generic type of the Object
|
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
/**
|
||||||
*/
|
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||||
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
* @Type(T)
|
||||||
Objects.requireNonNull(action);
|
*/
|
||||||
iterator().forEachRemaining(input, action);
|
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
||||||
}
|
{
|
||||||
|
/**
|
||||||
/**
|
* Returns an iterator over elements of type {@code T}.
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
*
|
||||||
* @return type specific splititerator
|
* @return an Iterator.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
|
|
||||||
/**
|
#if !TYPE_OBJECT
|
||||||
* 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.
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
* @see ASYNC_BUILDER
|
*
|
||||||
* @return a AsyncBuilder
|
* @implSpec
|
||||||
*/
|
* <p>The default implementation behaves as if:
|
||||||
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
* <pre>{@code
|
||||||
return new ASYNC_BUILDERBRACES(this);
|
* iterator().forEachRemaining(action);
|
||||||
}
|
* }</pre>
|
||||||
|
*
|
||||||
/**
|
* @param action The action to be performed for each element
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* @throws NullPointerException if the specified action is null
|
||||||
* @param mapper the mapping function
|
* @see Iterable#forEach(Consumer)
|
||||||
* @param <E> The return type.
|
*/
|
||||||
* @return a new Iterable that returns the desired result
|
default void forEach(CONSUMER action) {
|
||||||
*/
|
Objects.requireNonNull(action);
|
||||||
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
iterator().forEachRemaining(action);
|
||||||
return ITERABLES.map(this, mapper);
|
}
|
||||||
}
|
|
||||||
|
/** {@inheritDoc}
|
||||||
/**
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
* @param mapper the flatMapping function
|
*/
|
||||||
* @param <V> The return type supplier.
|
@Deprecated
|
||||||
* @param <E> The return type.
|
@Override
|
||||||
* @return a new Iterable that returns the desired result
|
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
* @note does not support TO_ARRAY optimizations.
|
Objects.requireNonNull(action);
|
||||||
*/
|
iterator().forEachRemaining(action);
|
||||||
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
}
|
||||||
return ITERABLES.flatMap(this, mapper);
|
|
||||||
}
|
#endif
|
||||||
|
/**
|
||||||
/**
|
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* @param action The action to be performed for each element
|
||||||
* @param mapper the flatMapping function
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
* @param <E> The return type.
|
*/
|
||||||
* @return a new Iterable that returns the desired result
|
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
* @note does not support TO_ARRAY optimizations.
|
Objects.requireNonNull(action);
|
||||||
*/
|
int index = 0;
|
||||||
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
||||||
return ITERABLES.arrayFlatMap(this, mapper);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||||
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
* @param input the object that should be included
|
||||||
* @param filter the elements that should be kept.
|
* @param action The action to be performed for each element
|
||||||
* @return a Iterable that filtered out all unwanted elements
|
* @param <E> the generic type of the Object
|
||||||
* @note does not support TO_ARRAY optimizations.
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
*/
|
*/
|
||||||
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
return ITERABLES.filter(this, filter);
|
Objects.requireNonNull(action);
|
||||||
}
|
iterator().forEachRemaining(input, action);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
* @return a Iterable that filtered out all duplicated elements
|
/**
|
||||||
* @note does not support TO_ARRAY optimizations.
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
*/
|
* @return type specific splititerator
|
||||||
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
*/
|
||||||
return ITERABLES.distinct(this);
|
@Override
|
||||||
}
|
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||||
|
|
||||||
/**
|
#endif
|
||||||
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
#if ASYNC_MODULE
|
||||||
* @param repeats how many times the elements should be repeated
|
/**
|
||||||
* @return a Iterable that is repeating multiple times
|
* 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.
|
||||||
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
* @see ASYNC_BUILDER
|
||||||
return ITERABLES.repeat(this, repeats);
|
* @return a AsyncBuilder
|
||||||
}
|
*/
|
||||||
|
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
||||||
/**
|
return new ASYNC_BUILDERBRACES(this);
|
||||||
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
}
|
||||||
* @param limit the amount of elements it should be limited to
|
|
||||||
* @return a Iterable that is limited in length
|
#endif
|
||||||
*/
|
/**
|
||||||
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
return ITERABLES.limit(this, limit);
|
* @param mapper the mapping function
|
||||||
}
|
* @param <E> The return type.
|
||||||
|
* @return a new Iterable that returns the desired result
|
||||||
/**
|
*/
|
||||||
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
||||||
* @param sorter that sorts the elements.
|
return ITERABLES.map(this, mapper);
|
||||||
* @return a Iterable that is sorted
|
}
|
||||||
*/
|
|
||||||
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
#if TYPE_OBJECT
|
||||||
return ITERABLES.sorted(this, sorter);
|
#iterate
|
||||||
}
|
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
/**
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
* @param action the action that should be applied
|
#if FILTER_TYPE
|
||||||
* @return a Peeked Iterable
|
/**
|
||||||
*/
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
* @param mapper the mapping function
|
||||||
return ITERABLES.peek(this, action);
|
* @return a new Iterable that returns the desired result
|
||||||
}
|
*/
|
||||||
|
default OUTPUT_ITERABLE mapToDATA_TYPE(MAPPER<T> mapper) {
|
||||||
/**
|
return ITERABLES.mapToDATA_TYPE(this, mapper);
|
||||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
}
|
||||||
* @param collection that the elements should be inserted to
|
|
||||||
* @param <E> the collection type
|
#endif
|
||||||
* @return the input with the desired elements
|
#enditerate
|
||||||
*/
|
#endif
|
||||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
/**
|
||||||
ITERATORS.pour(iterator(), collection);
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
return collection;
|
* @param mapper the flatMapping function
|
||||||
}
|
* @param <V> The return type supplier.
|
||||||
|
* @param <E> The return type.
|
||||||
/**
|
* @return a new Iterable that returns the desired result
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
* @note does not support TO_ARRAY optimizations.
|
||||||
* @return a new ArrayList of all elements
|
*/
|
||||||
*/
|
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
||||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
return ITERABLES.flatMap(this, mapper);
|
||||||
return pour(new ARRAY_LISTBRACES());
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
#if !TYPE_BOOLEAN
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
/**
|
* @param mapper the flatMapping function
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
* @param <E> The return type.
|
||||||
* @return a new LinkedHashSet of all elements
|
* @return a new Iterable that returns the desired result
|
||||||
*/
|
* @note does not support TO_ARRAY optimizations.
|
||||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
*/
|
||||||
return pour(new LINKED_HASH_SETBRACES());
|
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
||||||
}
|
return ITERABLES.arrayFlatMap(this, mapper);
|
||||||
|
}
|
||||||
#endif
|
|
||||||
|
/**
|
||||||
#if TYPE_OBJECT
|
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||||
/**
|
* @param filter the elements that should be kept.
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
* @return a Iterable that filtered out all unwanted elements
|
||||||
* @param action is the creator function of said Array to ensure type is kept.
|
* @note does not support TO_ARRAY optimizations.
|
||||||
* @return a new Array of all elements
|
*/
|
||||||
*/
|
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
return ITERABLES.filter(this, filter);
|
||||||
ISizeProvider prov = ISizeProvider.of(this);
|
}
|
||||||
if(prov != null) {
|
|
||||||
int size = prov.size();
|
/**
|
||||||
if(size >= 0) {
|
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||||
KEY_TYPE[] array = action.get(size);
|
* @return a Iterable that filtered out all duplicated elements
|
||||||
ITERATORS.unwrap(array, iterator());
|
* @note does not support TO_ARRAY optimizations.
|
||||||
return array;
|
*/
|
||||||
}
|
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
||||||
}
|
return ITERABLES.distinct(this);
|
||||||
return ITERATORS.pour(iterator()).TO_ARRAY(action);
|
}
|
||||||
}
|
|
||||||
#else
|
/**
|
||||||
/**
|
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
* @param repeats how many times the elements should be repeated
|
||||||
* @return a new Array of all elements
|
* @return a Iterable that is repeating multiple times
|
||||||
*/
|
*/
|
||||||
default KEY_TYPE[] TO_ARRAY() {
|
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
||||||
ISizeProvider prov = ISizeProvider.of(this);
|
return ITERABLES.repeat(this, repeats);
|
||||||
if(prov != null) {
|
}
|
||||||
int size = prov.size();
|
|
||||||
if(size >= 0) {
|
/**
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||||
ITERATORS.unwrap(array, iterator());
|
* @param limit the amount of elements it should be limited to
|
||||||
return array;
|
* @return a Iterable that is limited in length
|
||||||
}
|
*/
|
||||||
}
|
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
||||||
return ITERATORS.pour(iterator()).TO_ARRAY();
|
return ITERABLES.limit(this, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
/**
|
||||||
/**
|
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
||||||
* Helper function to reduce stream usage that allows to filter for any matches.
|
* @param sorter that sorts the elements.
|
||||||
* @param filter that should be applied
|
* @return a Iterable that is sorted
|
||||||
* @return true if any matches were found
|
*/
|
||||||
*/
|
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
return ITERABLES.sorted(this, sorter);
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) return true;
|
/**
|
||||||
}
|
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
||||||
return false;
|
* @param action the action that should be applied
|
||||||
}
|
* @return a Peeked Iterable
|
||||||
|
*/
|
||||||
/**
|
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
* Helper function to reduce stream usage that allows to filter for no matches.
|
return ITERABLES.peek(this, action);
|
||||||
* @param filter that should be applied
|
}
|
||||||
* @return true if no matches were found
|
|
||||||
*/
|
/**
|
||||||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||||
Objects.requireNonNull(filter);
|
* @param collection that the elements should be inserted to
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
* @param <E> the collection type
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) return false;
|
* @return the input with the desired elements
|
||||||
}
|
*/
|
||||||
return true;
|
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||||
}
|
ITERATORS.pour(iterator(), collection);
|
||||||
|
return collection;
|
||||||
/**
|
}
|
||||||
* Helper function to reduce stream usage that allows to filter for all matches.
|
|
||||||
* @param filter that should be applied
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
* @return true if all matches.
|
/**
|
||||||
*/
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
* @return a new ArrayList of all elements
|
||||||
Objects.requireNonNull(filter);
|
*/
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||||
if(!filter.TEST_VALUE(iter.NEXT())) return false;
|
#if ARRAY_LIST_FEATURE
|
||||||
}
|
return pour(new ARRAY_LISTBRACES());
|
||||||
return true;
|
#else
|
||||||
}
|
return pour(new LINKED_LISTBRACES());
|
||||||
|
#endif
|
||||||
/**
|
}
|
||||||
* Helper function to reduce stream usage that allows to filter for the first match.
|
|
||||||
* @param filter that should be applied
|
#endif
|
||||||
* @return the found value or the null equivalent variant.
|
#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
|
||||||
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
/**
|
||||||
Objects.requireNonNull(filter);
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
* @return a new LinkedHashSet of all elements
|
||||||
KEY_TYPE entry = iter.NEXT();
|
*/
|
||||||
if(filter.TEST_VALUE(entry)) return entry;
|
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||||
}
|
#if LINKED_SET_FEATURE
|
||||||
return EMPTY_VALUE;
|
return pour(new LINKED_HASH_SETBRACES());
|
||||||
}
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
|
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
#if !TYPE_OBJECT
|
#else if SET_FEATURE
|
||||||
/**
|
return pour(new HASH_SETBRACES());
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
#else if CUSTOM_SET_FEATURE
|
||||||
* elements of this Iterable
|
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
* @param operator the operation that should be applied
|
#else if RB_TREE_SET_FEATURE
|
||||||
* @param identity the start value
|
return pour(new RB_Tree_SETBRACES());
|
||||||
* @return the reduction result, returns identity if nothing was found
|
#else if AVL_TREE_SET_FEATURE
|
||||||
*/
|
return pour(new AVL_Tree_SETBRACES());
|
||||||
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
#else if ARRAY_SET_FEATURE
|
||||||
Objects.requireNonNull(operator);
|
return pour(new ARRAY_SETBRACES());
|
||||||
KEY_TYPE state = identity;
|
#endif
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
|
||||||
}
|
#endif
|
||||||
return state;
|
#endif
|
||||||
}
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
#else
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
/**
|
* @param action is the creator function of said Array to ensure type is kept.
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
* @param <E> the returning arrayType
|
||||||
* elements of this Iterable
|
* @return a new Array of all elements
|
||||||
* @param operator the operation that should be applied
|
*/
|
||||||
* @param identity the start value
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
* @Type(E)
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
* @return the reduction result, returns identity if nothing was found
|
if(prov != null) {
|
||||||
*/
|
int size = prov.size();
|
||||||
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
if(size >= 0) {
|
||||||
Objects.requireNonNull(operator);
|
E[] array = action.apply(size);
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
ITERATORS.unwrap(array, iterator());
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
return array;
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
}
|
||||||
}
|
}
|
||||||
return state;
|
return ARRAYS.pour(iterator(), action);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
#endif
|
/**
|
||||||
/**
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
* @return a new Array of all elements
|
||||||
* elements of this Iterable
|
*/
|
||||||
* @param operator the operation that should be applied
|
default KEY_TYPE[] TO_ARRAY() {
|
||||||
* @return the reduction result, returns null value if nothing was found
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
*/
|
if(prov != null) {
|
||||||
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
int size = prov.size();
|
||||||
Objects.requireNonNull(operator);
|
if(size >= 0) {
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
||||||
boolean empty = true;
|
ITERATORS.unwrap(array, iterator());
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
return array;
|
||||||
if(empty) {
|
}
|
||||||
empty = false;
|
}
|
||||||
state = iter.NEXT();
|
return ARRAYS.pour(iterator());
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
#endif
|
||||||
}
|
/**
|
||||||
return state;
|
* Helper function to reduce stream usage that allows to filter for any matches.
|
||||||
}
|
* @param filter that should be applied
|
||||||
|
* @return true if any matches were found
|
||||||
/**
|
*/
|
||||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
* @param filter that should be applied
|
Objects.requireNonNull(filter);
|
||||||
* @return the amount of Valid Elements
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
*/
|
if(filter.test(iter.NEXT())) return true;
|
||||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
return false;
|
||||||
int result = 0;
|
}
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) result++;
|
/**
|
||||||
}
|
* Helper function to reduce stream usage that allows to filter for no matches.
|
||||||
return result;
|
* @param filter that should be applied
|
||||||
}
|
* @return true if no matches were found
|
||||||
|
*/
|
||||||
|
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
if(filter.test(iter.NEXT())) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for all matches.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return true if all matches.
|
||||||
|
*/
|
||||||
|
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
if(!filter.test(iter.NEXT())) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for the first match.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return the found value or the null equivalent variant.
|
||||||
|
*/
|
||||||
|
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
KEY_TYPE entry = iter.NEXT();
|
||||||
|
if(filter.test(entry)) return entry;
|
||||||
|
}
|
||||||
|
return EMPTY_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
|
* elements of this Iterable
|
||||||
|
* @param operator the operation that should be applied
|
||||||
|
* @param identity the start value
|
||||||
|
* @return the reduction result, returns identity if nothing was found
|
||||||
|
*/
|
||||||
|
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
|
KEY_TYPE state = identity;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
|
* elements of this Iterable
|
||||||
|
* @param operator the operation that should be applied
|
||||||
|
* @param identity the start value
|
||||||
|
* @Type(E)
|
||||||
|
* @return the reduction result, returns identity if nothing was found
|
||||||
|
*/
|
||||||
|
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
|
* elements of this Iterable
|
||||||
|
* @param operator the operation that should be applied
|
||||||
|
* @return the reduction result, returns null value if nothing was found
|
||||||
|
*/
|
||||||
|
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
|
boolean empty = true;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
if(empty) {
|
||||||
|
empty = false;
|
||||||
|
state = iter.NEXT();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to count the valid elements.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return the amount of Valid Elements
|
||||||
|
*/
|
||||||
|
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
int result = 0;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
|
if(filter.test(iter.NEXT())) result++;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import speiger.src.collections.utils.Stack;
|
import speiger.src.collections.utils.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,6 +16,14 @@ public interface STACK
|
|||||||
*/
|
*/
|
||||||
public void push(KEY_TYPE e);
|
public void push(KEY_TYPE e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that pushes the top element on top of the stack again.
|
||||||
|
* @throws NoSuchElementException if the stack is empty
|
||||||
|
*/
|
||||||
|
public default void pushTop() {
|
||||||
|
push(top());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the Object on top of the stack.
|
* Removes the Object on top of the stack.
|
||||||
* @return the element that is on top of the stack
|
* @return the element that is on top of the stack
|
||||||
@@ -59,4 +69,19 @@ public interface STACK
|
|||||||
public default boolean isEmpty() {
|
public default boolean isEmpty() {
|
||||||
return size() == 0;
|
return size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A method to drop the contents of the Stack without clearing the stack
|
||||||
|
* @Type(E)
|
||||||
|
* @return the contents of the stack into a seperate array.
|
||||||
|
*/
|
||||||
|
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
||||||
|
/**
|
||||||
|
* A method to drop the contents of the Stack without clearing the stack
|
||||||
|
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||||
|
* @Type(E)
|
||||||
|
* @return the contents of the stack into a seperate array.
|
||||||
|
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||||
|
*/
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
||||||
}
|
}
|
||||||
+69
-69
@@ -1,70 +1,70 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
package speiger.src.collections.PACKAGE.functions;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-Specific Class for Comparator to reduce (un)boxing
|
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||||
*/
|
*/
|
||||||
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
public interface COMPARATOR extends Comparator<CLASS_TYPE>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Type-Specific compare function to reduce (un)boxing
|
* Type-Specific compare function to reduce (un)boxing
|
||||||
* @param o1 the first object to be compared.
|
* @param o1 the first object to be compared.
|
||||||
* @param o2 the second object to be compared.
|
* @param o2 the second object to be compared.
|
||||||
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||||
* @see Comparator#compare(Object, Object)
|
* @see Comparator#compare(Object, Object)
|
||||||
*/
|
*/
|
||||||
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
int compare(KEY_TYPE o1, KEY_TYPE o2);
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
default int compare(CLASS_TYPE o1, CLASS_TYPE o2) {
|
||||||
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
return compare(OBJ_TO_KEY(o1), OBJ_TO_KEY(o2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||||
* @param c comparator to convert
|
* @param c comparator to convert
|
||||||
* @return the wrapper of the comparator
|
* @return the wrapper of the comparator
|
||||||
* @throws NullPointerException if the comparator is null
|
* @throws NullPointerException if the comparator is null
|
||||||
*/
|
*/
|
||||||
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
public static COMPARATOR of(Comparator<CLASS_TYPE> c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
return (K, V) -> c.compare(KEY_TO_OBJ(K), KEY_TO_OBJ(V));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public default COMPARATOR reversed() {
|
public default COMPARATOR reversed() {
|
||||||
return new Reversed(this);
|
return new Reversed(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||||
*/
|
*/
|
||||||
static class Reversed implements COMPARATOR
|
static class Reversed implements COMPARATOR
|
||||||
{
|
{
|
||||||
COMPARATOR original;
|
COMPARATOR original;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default constructor
|
* default constructor
|
||||||
* @param original that is going to be reversed
|
* @param original that is going to be reversed
|
||||||
*/
|
*/
|
||||||
public Reversed(COMPARATOR original) {
|
public Reversed(COMPARATOR original) {
|
||||||
this.original = original;
|
this.original = original;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
public int compare(KEY_TYPE o1, KEY_TYPE o2) {
|
||||||
return original.compare(o2, o1);
|
return original.compare(o2, o1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR reversed() {
|
public COMPARATOR reversed() {
|
||||||
return original;
|
return original;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+18
-25
@@ -1,26 +1,19 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
package speiger.src.collections.PACKAGE.functions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
||||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
#else if JDK_TYPE && !TYPE_BOOLEAN
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
||||||
#else
|
#else
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
public interface SUPPLIER KEY_GENERIC_TYPE
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return the supplied value
|
* @return the supplied value
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_KEY();
|
public KEY_TYPE SUPPLY_GET();
|
||||||
#if JDK_TYPE && PRIMITIVES
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public default KEY_TYPE GET_JAVA() {
|
|
||||||
return GET_KEY();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
+91
-91
@@ -1,92 +1,92 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
package speiger.src.collections.PACKAGE.functions;
|
||||||
|
|
||||||
import java.util.concurrent.RunnableFuture;
|
import java.util.concurrent.RunnableFuture;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||||
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||||
*
|
*
|
||||||
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||||
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
public interface TASK KEY_GENERIC_TYPE extends RunnableFuture<CLASS_TYPE> {
|
||||||
/**
|
/**
|
||||||
* Helper function to detect if the task is currently paused.
|
* Helper function to detect if the task is currently paused.
|
||||||
* @return true if paused
|
* @return true if paused
|
||||||
*/
|
*/
|
||||||
public boolean isPaused();
|
public boolean isPaused();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses the task, which lets the thread finish without completing the task.
|
* Pauses the task, which lets the thread finish without completing the task.
|
||||||
* Tasks are written in the way where they can pause without any issues.
|
* Tasks are written in the way where they can pause without any issues.
|
||||||
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||||
* So make sure it had the time to pause.
|
* So make sure it had the time to pause.
|
||||||
*/
|
*/
|
||||||
public void pause();
|
public void pause();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pauses the task, which lets the thread finish without completing the task.
|
* Pauses the task, which lets the thread finish without completing the task.
|
||||||
* Tasks are written in the way where they can pause without any issues.
|
* Tasks are written in the way where they can pause without any issues.
|
||||||
* This won't be instant, as this function is applied asynchronous.
|
* This won't be instant, as this function is applied asynchronous.
|
||||||
* It will await the pausing of the task.
|
* It will await the pausing of the task.
|
||||||
*/
|
*/
|
||||||
public void awaitPausing();
|
public void awaitPausing();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Continues the task if it wasn't already completed.
|
* Continues the task if it wasn't already completed.
|
||||||
* This is done by resubmitting the task to the executor provided.
|
* This is done by resubmitting the task to the executor provided.
|
||||||
*/
|
*/
|
||||||
public void resume();
|
public void resume();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||||
* @return true if it was properly completed
|
* @return true if it was properly completed
|
||||||
*/
|
*/
|
||||||
public boolean isSuccessful();
|
public boolean isSuccessful();
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||||
*
|
*
|
||||||
* Waits if necessary for the computation to complete, and then
|
* Waits if necessary for the computation to complete, and then
|
||||||
* retrieves its result.
|
* retrieves its result.
|
||||||
*
|
*
|
||||||
* @return the computed result as primitive
|
* @return the computed result as primitive
|
||||||
* @throws CancellationException if the computation was cancelled
|
* @throws CancellationException if the computation was cancelled
|
||||||
* @throws ExecutionException if the computation threw an exception
|
* @throws ExecutionException if the computation threw an exception
|
||||||
* @throws InterruptedException if the current thread was interrupted
|
* @throws InterruptedException if the current thread was interrupted
|
||||||
* while waiting
|
* while waiting
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
public KEY_TYPE GET_KEY() throws InterruptedException, ExecutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits if necessary for at most the given time for the computation
|
* Waits if necessary for at most the given time for the computation
|
||||||
* to complete, and then retrieves its result, if available.
|
* to complete, and then retrieves its result, if available.
|
||||||
*
|
*
|
||||||
* @param timeout the maximum time to wait
|
* @param timeout the maximum time to wait
|
||||||
* @param unit the time unit of the timeout argument
|
* @param unit the time unit of the timeout argument
|
||||||
* @return the computed result as primitive
|
* @return the computed result as primitive
|
||||||
* @throws CancellationException if the computation was cancelled
|
* @throws CancellationException if the computation was cancelled
|
||||||
* @throws ExecutionException if the computation threw an exception
|
* @throws ExecutionException if the computation threw an exception
|
||||||
* @throws InterruptedException if the current thread was interrupted while waiting
|
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||||
* @throws TimeoutException if the wait timed out
|
* @throws TimeoutException if the wait timed out
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
public KEY_TYPE GET_KEY(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
public default CLASS_TYPE get() throws InterruptedException, ExecutionException { return KEY_TO_OBJ(GET_KEY()); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
public default CLASS_TYPE get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return KEY_TO_OBJ(GET_KEY(timeout, unit)); }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+133
-78
@@ -1,79 +1,134 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions.function;
|
package speiger.src.collections.PACKAGE.functions.function;
|
||||||
|
|
||||||
#if JDK_FUNCTION && VALUE_BOOLEAN
|
#if VALUE_BOOLEAN || SAME_TYPE
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
*/
|
*/
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
public interface FUNCTION KEY_VALUE_GENERIC_TYPE extends JAVA_FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||||
#else
|
#else
|
||||||
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Type Specific get function to reduce boxing/unboxing
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
* @param k the value that should be processed
|
* @param k the value that should be processed
|
||||||
* @return the result of the function
|
* @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 SAME_TYPE
|
||||||
#if VALUE_BOOLEAN
|
/**
|
||||||
@Override
|
* Creates a Default function that returns the input provided.
|
||||||
public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); }
|
* @Type(T)
|
||||||
|
* @return a input returning function
|
||||||
/**
|
*/
|
||||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||||
* @param other the other function that should be merged with.
|
return T -> T;
|
||||||
* @return a function that compares values in a and comparason
|
}
|
||||||
*/
|
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
/**
|
||||||
Objects.requireNonNull(other);
|
* Returns a composed function that first applies the {@code before}
|
||||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
* function to its input, and then applies this function to the result.
|
||||||
}
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
|
* the caller of the composed function.
|
||||||
@Override
|
*
|
||||||
@Deprecated
|
* @Type(I)
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
* @param before the function that should be used first
|
||||||
Objects.requireNonNull(other);
|
* @return a composed function with a different starting function.
|
||||||
return T -> GET_VALUE(T) && other.test(T);
|
*/
|
||||||
}
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||||
|
Objects.requireNonNull(before);
|
||||||
@Override
|
return T -> APPLY(before.APPLY(T));
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
}
|
||||||
return T -> !GET_VALUE(T);
|
|
||||||
}
|
/**
|
||||||
|
* Returns a composed function that first applies this function to
|
||||||
/**
|
* its input, and then applies the {@code after} function to the result.
|
||||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
* @param other the other function that should be merged with.
|
* the caller of the composed function.
|
||||||
* @return a function that compares values in a or comparason
|
*
|
||||||
*/
|
* @Type(I)
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
* @param after the function that should be used last
|
||||||
Objects.requireNonNull(other);
|
* @return a composed function with a different starting function.
|
||||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
*/
|
||||||
}
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
@Override
|
return T -> after.APPLY(APPLY(T));
|
||||||
@Deprecated
|
}
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
|
||||||
Objects.requireNonNull(other);
|
#endif
|
||||||
return T -> GET_VALUE(T) || other.test(T);
|
#if VALUE_BOOLEAN
|
||||||
}
|
/**
|
||||||
#else if VALUE_OBJECT
|
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||||
|
* @Type(T)
|
||||||
@Override
|
* @return a default returning function
|
||||||
public default VALUE_TYPE apply(KEY_TYPE k) { return GET_VALUE(k); }
|
*/
|
||||||
#else
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||||
|
return T -> true;
|
||||||
@Override
|
}
|
||||||
public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k) { return GET_VALUE(k); }
|
|
||||||
#endif
|
/**
|
||||||
#endif
|
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a default returning function
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||||
|
return T -> false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||||
|
* @param other the other function that should be merged with.
|
||||||
|
* @return a function that compares values in a and comparason
|
||||||
|
*/
|
||||||
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
|
Objects.requireNonNull(other);
|
||||||
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
|
Objects.requireNonNull(other);
|
||||||
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* A type specific inverter function
|
||||||
|
* @return the same function but inverts the result
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||||
|
return T -> !APPLY(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||||
|
* @param other the other function that should be merged with.
|
||||||
|
* @return a function that compares values in a or comparason
|
||||||
|
*/
|
||||||
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
|
Objects.requireNonNull(other);
|
||||||
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
|
Objects.requireNonNull(other);
|
||||||
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+305
-4
@@ -1,15 +1,20 @@
|
|||||||
package speiger.src.collections.PACKAGE.lists;
|
package speiger.src.collections.PACKAGE.lists;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.RandomAccess;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if INT_LIST_MODULE && !TYPE_INT
|
||||||
|
import speiger.src.collections.ints.lists.IntList;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@@ -66,8 +71,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean addAll(Collection<? extends CLASS_TYPE> c)
|
public boolean addAll(Collection<? extends CLASS_TYPE> c) {
|
||||||
{
|
|
||||||
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : addAll(size(), c);
|
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : addAll(size(), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +225,11 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
return new SubList(this, 0, fromIndex, toIndex);
|
return new SubList(this, 0, fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST KEY_GENERIC_TYPE reversed() {
|
||||||
|
return new ReversedList(this);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return listIterator(0);
|
return listIterator(0);
|
||||||
@@ -230,13 +239,25 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
||||||
return listIterator(0);
|
return listIterator(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
||||||
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
||||||
return new LIST_ITER(index);
|
return new LIST_ITER(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
||||||
|
return new IndexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
@Override
|
||||||
|
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
||||||
|
return new ListIndexedIterator(indecies);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) {
|
public void size(int size) {
|
||||||
while(size > size()) add(EMPTY_KEY_VALUE);
|
while(size > size()) add(EMPTY_KEY_VALUE);
|
||||||
@@ -245,6 +266,138 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
|
|
||||||
public ABSTRACT_LIST KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public ABSTRACT_LIST KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
private class ReversedList extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
final ABSTRACT_LIST KEY_GENERIC_TYPE list;
|
||||||
|
|
||||||
|
public ReversedList(ABSTRACT_LIST KEY_GENERIC_TYPE list) {
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(int index, KEY_TYPE e) {
|
||||||
|
list.add(list.size() - index - 1, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
|
return addCollection(index, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) {
|
||||||
|
if(c instanceof RandomAccess) {
|
||||||
|
for(int i = 0,m=c.size();i<m;i++) {
|
||||||
|
list.add(list.size() - index - i - 1, c.GET_KEY(i));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return addCollection(index, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean addCollection(int index, COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
|
int i = 0;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();i++) {
|
||||||
|
list.add(list.size() - index - i - 1, iter.NEXT());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(int index, Collection<? extends CLASS_TYPE> c) {
|
||||||
|
int i = 0;
|
||||||
|
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();i++) {
|
||||||
|
list.add(list.size() - index - i - 1, iter.next());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE GET_KEY(int index) {
|
||||||
|
return list.GET_KEY(list.size() - index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE set(int index, KEY_TYPE e) {
|
||||||
|
return list.set(list.size() - index - 1, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE REMOVE(int index) {
|
||||||
|
return list.REMOVE(list.size() - index - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
|
for(int i = 0,m=length;i<m;i++) {
|
||||||
|
list.add(list.size() - from - i - 1, a[i+offset]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
|
return reverse(list.getElements(list.size() - from - 1, a, offset, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeElements(int from, int to) {
|
||||||
|
list.removeElements(list.size() - to - 1, list.size() - from - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE swapRemove(int index) {
|
||||||
|
return list.swapRemove(list.size() - index - 1);
|
||||||
|
}
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
||||||
|
return reverse(list.extractElements(list.size() - to - 1, list.size() - from - 1, type));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE[] extractElements(int from, int to) {
|
||||||
|
return reverse(list.extractElements(list.size() - to - 1, list.size() - from - 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return list.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
list.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST KEY_GENERIC_TYPE reversed() {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
private <K> K[] reverse(K[] data) {
|
||||||
|
for (int i = 0, mid = data.length >> 1, j = data.length - 1; i < mid; i++, j--) {
|
||||||
|
K t = data[i];
|
||||||
|
data[i] = data[j];
|
||||||
|
data[j] = t;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private KEY_TYPE[] reverse(KEY_TYPE[] data) {
|
||||||
|
for (int i = 0, mid = data.length >> 1, j = data.length - 1; i < mid; i++, j--) {
|
||||||
|
KEY_TYPE t = data[i];
|
||||||
|
data[i] = data[j];
|
||||||
|
data[j] = t;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private class SubList extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
private class SubList extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
final ABSTRACT_LIST KEY_GENERIC_TYPE list;
|
final ABSTRACT_LIST KEY_GENERIC_TYPE list;
|
||||||
@@ -490,7 +643,155 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_LIST_MODULE
|
||||||
|
private class ListIndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
IntList indecies;
|
||||||
|
int index;
|
||||||
|
int lastReturned = -1;
|
||||||
|
|
||||||
|
ListIndexedIterator(IntList indecies) {
|
||||||
|
this.indecies = indecies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return index < indecies.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
int i = index++;
|
||||||
|
return GET_KEY((lastReturned = indecies.getInt(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return index > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE PREVIOUS() {
|
||||||
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
|
index--;
|
||||||
|
return GET_KEY((lastReturned = indecies.getInt(index)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int nextIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int previousIndex() {
|
||||||
|
return index-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(KEY_TYPE e) {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
ABSTRACT_LIST.this.set(lastReturned, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, indecies.size() - index);
|
||||||
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, index);
|
||||||
|
index -= steps;
|
||||||
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private class IndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
int[] indecies;
|
||||||
|
int index;
|
||||||
|
int lastReturned = -1;
|
||||||
|
|
||||||
|
IndexedIterator(int[] indecies) {
|
||||||
|
this.indecies = indecies;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return index < indecies.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
int i = index++;
|
||||||
|
return GET_KEY((lastReturned = indecies[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return index > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE PREVIOUS() {
|
||||||
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
|
index--;
|
||||||
|
return GET_KEY((lastReturned = indecies[index]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int nextIndex() {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int previousIndex() {
|
||||||
|
return index-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void set(KEY_TYPE e) {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
ABSTRACT_LIST.this.set(lastReturned, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, indecies.length - index);
|
||||||
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int steps = Math.min(amount, index);
|
||||||
|
index -= steps;
|
||||||
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
@@ -568,7 +869,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
int steps = Math.min(amount, index);
|
int steps = Math.min(amount, index);
|
||||||
index -= steps;
|
index -= steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
if(steps > 0) lastReturned = Math.max(index, 0);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1206
-1179
File diff suppressed because it is too large
Load Diff
+2196
-2175
File diff suppressed because it is too large
Load Diff
+21
-8
@@ -13,8 +13,13 @@ import java.util.function.Consumer;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
#if !TYPE_OBJECT && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -25,16 +30,20 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
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.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -129,7 +138,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
SanityChecks.checkArrayCapacity(data.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
|
SanityChecks.checkArrayCapacity(data.length, from, length);
|
||||||
System.arraycopy(data, from, a, offset, length);
|
System.arraycopy(data, from, a, offset, length);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -301,7 +311,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -310,7 +320,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -319,7 +329,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -328,7 +338,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -377,7 +387,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -436,6 +446,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(data.length == 0) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[data.length];
|
Object[] obj = new Object[data.length];
|
||||||
for(int i = 0,m=data.length;i<m;i++)
|
for(int i = 0,m=data.length;i<m;i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
@@ -487,7 +498,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + 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.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
@@ -505,6 +517,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
||||||
|
|
||||||
|
#endif
|
||||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|||||||
+1399
-1340
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+131
-16
@@ -3,15 +3,22 @@ package speiger.src.collections.PACKAGE.maps.abstracts;
|
|||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if VALUE_BOOLEAN && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
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_COLLECTION;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
@@ -19,6 +26,7 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -47,6 +55,22 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterable(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
|
return MAPS.fastIterable(map);
|
||||||
|
#else
|
||||||
|
return map.ENTRY_SET();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterator(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
|
return MAPS.fastIterator(map);
|
||||||
|
#else
|
||||||
|
return map.ENTRY_SET().iterator();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
@@ -63,14 +87,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#if VALUE_PRIMITIVES
|
#if VALUE_PRIMITIVES
|
||||||
@Override
|
@Override
|
||||||
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(m);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(m);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
@@ -101,7 +125,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +185,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
|
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
|
||||||
}
|
}
|
||||||
@@ -177,6 +201,96 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, GET_VALUE(key));
|
||||||
|
#else
|
||||||
|
VALUE_TYPE value = GET_VALUE(key);
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||||
|
remove(key);
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
#else
|
||||||
|
if(!containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
return get(key);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
#else
|
||||||
|
if(!containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
return get(key);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
remove(key);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, GET_VALUE(key));
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value = GET_VALUE(key);
|
VALUE_TYPE value = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
@@ -191,11 +305,11 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
@@ -205,11 +319,11 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
@@ -219,7 +333,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
if(VALUE_EQUALS_NOT((value = GET_VALUE(key)), getDefaultReturnValue()) || containsKey(key)) {
|
||||||
@@ -232,7 +346,8 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
}
|
}
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -246,7 +361,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||||
@@ -298,7 +413,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
@@ -332,7 +447,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
@@ -383,7 +498,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
|
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
@@ -423,7 +538,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);
|
||||||
while(iter.hasNext()) hash += iter.next().hashCode();
|
while(iter.hasNext()) hash += iter.next().hashCode();
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|||||||
+2689
-2452
File diff suppressed because it is too large
Load Diff
+1513
-1464
File diff suppressed because it is too large
Load Diff
+1676
-1504
File diff suppressed because it is too large
Load Diff
+1512
-1463
File diff suppressed because it is too large
Load Diff
+1631
-1460
File diff suppressed because it is too large
Load Diff
+1413
-1357
File diff suppressed because it is too large
Load Diff
+1578
-1424
File diff suppressed because it is too large
Load Diff
+860
-733
File diff suppressed because it is too large
Load Diff
+994
-963
File diff suppressed because it is too large
Load Diff
+3024
-2863
File diff suppressed because it is too large
Load Diff
+3096
-2936
File diff suppressed because it is too large
Load Diff
+94
-94
@@ -1,95 +1,95 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type specific ConcurrentMap interface that reduces boxing/unboxing.
|
* A type specific ConcurrentMap interface that reduces boxing/unboxing.
|
||||||
* Since the interface adds nothing new. It is there just for completion sake.
|
* Since the interface adds nothing new. It is there just for completion sake.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
*/
|
*/
|
||||||
public interface CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE extends ConcurrentMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
public interface CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE extends ConcurrentMap<CLASS_TYPE, CLASS_VALUE_TYPE>, MAP KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default CLASS_VALUE_TYPE compute(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
public default CLASS_VALUE_TYPE compute(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||||
return MAP.super.compute(key, mappingFunction);
|
return MAP.super.compute(key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default CLASS_VALUE_TYPE computeIfAbsent(CLASS_TYPE key, Function<? super CLASS_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
public default CLASS_VALUE_TYPE computeIfAbsent(CLASS_TYPE key, Function<? super CLASS_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||||
return MAP.super.computeIfAbsent(key, mappingFunction);
|
return MAP.super.computeIfAbsent(key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default CLASS_VALUE_TYPE computeIfPresent(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
public default CLASS_VALUE_TYPE computeIfPresent(CLASS_TYPE key, BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||||
return MAP.super.computeIfPresent(key, mappingFunction);
|
return MAP.super.computeIfPresent(key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) {
|
public default void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) {
|
||||||
MAP.super.forEach(action);
|
MAP.super.forEach(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default CLASS_VALUE_TYPE merge(CLASS_TYPE key, CLASS_VALUE_TYPE value, BiFunction<? super CLASS_VALUE_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
public default CLASS_VALUE_TYPE merge(CLASS_TYPE key, CLASS_VALUE_TYPE value, BiFunction<? super CLASS_VALUE_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||||
return MAP.super.merge(key, value, mappingFunction);
|
return MAP.super.merge(key, value, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT && VALUE_OBJECT
|
#if TYPE_OBJECT && VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue);
|
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue);
|
||||||
@Override
|
@Override
|
||||||
public CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
public CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value);
|
public boolean remove(Object key, Object value);
|
||||||
@Override
|
@Override
|
||||||
public boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue);
|
public boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue);
|
||||||
@Override
|
@Override
|
||||||
public CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
public CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Primitive
|
@Primitive
|
||||||
@Override
|
@Override
|
||||||
public default CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
public default CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||||
return MAP.super.getOrDefault(key, defaultValue);
|
return MAP.super.getOrDefault(key, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public default CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
public default CLASS_VALUE_TYPE putIfAbsent(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||||
return MAP.super.putIfAbsent(key, value);
|
return MAP.super.putIfAbsent(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean remove(Object key, Object value) {
|
public default boolean remove(Object key, Object value) {
|
||||||
return MAP.super.remove(key, value);
|
return MAP.super.remove(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue) {
|
public default boolean replace(CLASS_TYPE key, CLASS_VALUE_TYPE oldValue, CLASS_VALUE_TYPE newValue) {
|
||||||
return MAP.super.replace(key, oldValue, newValue);
|
return MAP.super.replace(key, oldValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
public default CLASS_VALUE_TYPE replace(CLASS_TYPE key, CLASS_VALUE_TYPE value) {
|
||||||
return MAP.super.replace(key, value);
|
return MAP.super.replace(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default void replaceAll(BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
public default void replaceAll(BiFunction<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE, ? extends CLASS_VALUE_TYPE> mappingFunction) {
|
||||||
MAP.super.replaceAll(mappingFunction);
|
MAP.super.replaceAll(mappingFunction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+142
-6
@@ -10,36 +10,72 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
#if VALUE_BOOLEAN && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN && SORTED_MAP_FEATURE
|
||||||
|
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||||
|
#endif
|
||||||
|
#if CONCURRENT_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
||||||
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if ENUM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||||
|
#endif
|
||||||
|
#if LINKED_ENUM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
#if CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
#endif
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
@@ -346,21 +382,26 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param key the key that should be computed
|
* @param key the key that should be computed
|
||||||
* @param mappingFunction the operator that should generate the value
|
* @param mappingFunction the operator that should generate the value
|
||||||
* @return the result of the computation
|
* @return the result of the computation
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param key the key that should be computed
|
* @param key the key that should be computed
|
||||||
* @param mappingFunction the operator that should generate the value if not present
|
* @param mappingFunction the operator that should generate the value if not present
|
||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param key the key that should be computed
|
* @param key the key that should be computed
|
||||||
* @param valueProvider the value if not present
|
* @param valueProvider the value if not present
|
||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
@@ -368,14 +409,57 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param key the key that should be computed
|
* @param key the key that should be computed
|
||||||
* @param mappingFunction the operator that should generate the value if present
|
* @param mappingFunction the operator that should generate the value if present
|
||||||
* @return the result of the default return value or present value
|
* @return the result of the default return value or present value
|
||||||
* @note if not present then compute is not executed
|
* @note if not present then compute is not executed
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value
|
||||||
|
* @return the result of the computation
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param valueProvider the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
|
/**
|
||||||
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if present
|
||||||
|
* @return the result of the default return value or present value
|
||||||
|
* @note if not present then compute is not executed
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type Specific merge method to reduce boxing/unboxing
|
* A Type Specific merge method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param key the key that should be be searched for
|
* @param key the key that should be be searched for
|
||||||
* @param value the value that should be merged with
|
* @param value the value that should be merged with
|
||||||
* @param mappingFunction the operator that should generate the new Value
|
* @param mappingFunction the operator that should generate the new Value
|
||||||
@@ -385,6 +469,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
/**
|
||||||
* A Bulk method for merging Maps.
|
* A Bulk method for merging Maps.
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
* @param m the entries that should be bulk added
|
* @param m the entries that should be bulk added
|
||||||
* @param mappingFunction the operator that should generate the new Value
|
* @param mappingFunction the operator that should generate the new Value
|
||||||
* @note if the result matches the default return value then the key is removed from the map
|
* @note if the result matches the default return value then the key is removed from the map
|
||||||
@@ -404,13 +490,19 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return VALUE_TO_OBJ(replace(OBJ_TO_KEY(key), OBJ_TO_VALUE(value)));
|
return VALUE_TO_OBJ(replace(OBJ_TO_KEY(key), OBJ_TO_VALUE(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public default VALUE_TYPE APPLY(KEY_TYPE key) {
|
||||||
|
return GET_VALUE(key);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A Type Specific get method to reduce boxing/unboxing
|
* A Type Specific get method to reduce boxing/unboxing
|
||||||
* @param key the key that is searched for
|
* @param key the key that is searched for
|
||||||
* @return the searched value or default return value
|
* @return the searched value or default return value
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key);
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key);
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific getOrDefault method to reduce boxing/unboxing
|
* A Type Specific getOrDefault method to reduce boxing/unboxing
|
||||||
* @param key the key that is searched for
|
* @param key the key that is searched for
|
||||||
@@ -505,7 +597,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
*/
|
*/
|
||||||
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped Map that is Synchronized
|
* Creates a Wrapped Map that is Synchronized
|
||||||
* @return a new Map that is synchronized
|
* @return a new Map that is synchronized
|
||||||
@@ -658,6 +750,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -731,6 +824,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new HASH_MAPKV_BRACES(map);
|
return new HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -804,6 +899,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keys the keys that should be inserted
|
* @param keys the keys that should be inserted
|
||||||
@@ -856,7 +953,9 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if ENUM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keyType the EnumClass that should be used
|
* @param keyType the EnumClass that should be used
|
||||||
@@ -924,6 +1023,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ENUM_MAPKV_BRACES(map);
|
return new ENUM_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_ENUM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keyType the EnumClass that should be used
|
* @param keyType the EnumClass that should be used
|
||||||
@@ -990,7 +1091,10 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
|
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
return new LINKED_ENUM_MAPKV_BRACES(map);
|
return new LINKED_ENUM_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param strategy the Hash Controller
|
* @param strategy the Hash Controller
|
||||||
@@ -1070,6 +1174,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param strategy the Hash Controller
|
* @param strategy the Hash Controller
|
||||||
@@ -1149,6 +1255,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1222,7 +1330,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ARRAY_MAPKV_BRACES(map);
|
return new ARRAY_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1300,6 +1409,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new RB_TREE_MAPKV_BRACES(map, comp);
|
return new RB_TREE_MAPKV_BRACES(map, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1376,6 +1487,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
return new AVL_TREE_MAPKV_BRACES(map, comp);
|
return new AVL_TREE_MAPKV_BRACES(map, comp);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1454,7 +1566,11 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
|
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
return putAll(MAPS.fastIterable(map));
|
return putAll(MAPS.fastIterable(map));
|
||||||
|
#else
|
||||||
|
return putAll(map.ENTRY_SET());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1483,11 +1599,14 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAP_FEATURE || LINKED_MAP_FEATURE || CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE || AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE || CONCURRENT_MAP_FEATURE
|
||||||
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
|
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
|
||||||
e.putAll(keys, values, 0, size);
|
e.putAll(keys, values, 0, size);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Hash Map
|
* Builds the Keys and Values into a Hash Map
|
||||||
* @return a HASH_MAP
|
* @return a HASH_MAP
|
||||||
@@ -1496,6 +1615,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new HASH_MAPKV_BRACES(size));
|
return putElements(new HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Linked Hash Map
|
* Builds the Keys and Values into a Linked Hash Map
|
||||||
* @return a LINKED_HASH_MAP
|
* @return a LINKED_HASH_MAP
|
||||||
@@ -1504,6 +1625,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
|
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Immutable Hash Map
|
* Builds the Keys and Values into a Immutable Hash Map
|
||||||
* @return a IMMUTABLE_HASH_MAP
|
* @return a IMMUTABLE_HASH_MAP
|
||||||
@@ -1512,6 +1635,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
|
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Custom Hash Map
|
* Builds the Keys and Values into a Custom Hash Map
|
||||||
* @param strategy the that controls the keys and values
|
* @param strategy the that controls the keys and values
|
||||||
@@ -1521,6 +1646,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Linked Custom Hash Map
|
* Builds the Keys and Values into a Linked Custom Hash Map
|
||||||
* @param strategy the that controls the keys and values
|
* @param strategy the that controls the keys and values
|
||||||
@@ -1530,6 +1657,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if CONCURRENT_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Concurrent Hash Map
|
* Builds the Keys and Values into a Concurrent Hash Map
|
||||||
* @return a CONCURRENT_HASH_MAP
|
* @return a CONCURRENT_HASH_MAP
|
||||||
@@ -1538,6 +1667,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Array Map
|
* Builds the Keys and Values into a Array Map
|
||||||
* @return a ARRAY_MAP
|
* @return a ARRAY_MAP
|
||||||
@@ -1546,6 +1677,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ARRAY_MAPKV_BRACES(keys, values, size);
|
return new ARRAY_MAPKV_BRACES(keys, values, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a RedBlack TreeMap
|
* Builds the Keys and Values into a RedBlack TreeMap
|
||||||
* @return a RB_TREE_MAP
|
* @return a RB_TREE_MAP
|
||||||
@@ -1563,6 +1696,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new RB_TREE_MAPKV_BRACES(comp));
|
return putElements(new RB_TREE_MAPKV_BRACES(comp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a AVL TreeMap
|
* Builds the Keys and Values into a AVL TreeMap
|
||||||
* @return a AVL_TREE_MAP
|
* @return a AVL_TREE_MAP
|
||||||
@@ -1579,6 +1714,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
|
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
|
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+5
@@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.maps.interfaces;
|
|||||||
|
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Navigable Map interface with a couple helper methods
|
* A Type Specific Navigable Map interface with a couple helper methods
|
||||||
@@ -37,6 +39,8 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||||||
/** @return a Type Specific Navigable Key Set */
|
/** @return a Type Specific Navigable Key Set */
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped NavigableMap that is Synchronized
|
* Creates a Wrapped NavigableMap that is Synchronized
|
||||||
* @return a new NavigableMap that is synchronized
|
* @return a new NavigableMap that is synchronized
|
||||||
@@ -59,6 +63,7 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||||||
*/
|
*/
|
||||||
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||||
|
|||||||
+4
@@ -1,6 +1,8 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
#endif
|
#endif
|
||||||
@@ -102,6 +104,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
* @return a new 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
|
@Override
|
||||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
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
|
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
|
|||||||
+4
@@ -10,7 +10,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
||||||
#endif
|
#endif
|
||||||
@@ -37,6 +39,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
* @return a new SortedMap that is synchronized
|
* @return a new SortedMap that is synchronized
|
||||||
@@ -59,6 +62,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
*/
|
*/
|
||||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package speiger.src.collections.PACKAGE.misc.pairs;
|
package speiger.src.collections.PACKAGE.misc.pairs;
|
||||||
|
|
||||||
|
#if IMMUTABLE_PAIR
|
||||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.IMMUTABLE_PAIR;
|
import speiger.src.collections.PACKAGE.misc.pairs.impl.IMMUTABLE_PAIR;
|
||||||
|
#endif
|
||||||
|
#if MUTABLE_PAIR
|
||||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key Value Pair Interface that allows to reduce boxing/unboxing.
|
* Key Value Pair Interface that allows to reduce boxing/unboxing.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -9,6 +14,7 @@ import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
|||||||
*/
|
*/
|
||||||
public interface PAIR KEY_VALUE_GENERIC_TYPE
|
public interface PAIR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
|
#if IMMUTABLE_PAIR
|
||||||
/**
|
/**
|
||||||
* Empty Reference for Immutable Pairs
|
* Empty Reference for Immutable Pairs
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +74,8 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||||||
return new IMMUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
return new IMMUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if MUTABLE_PAIR
|
||||||
/**
|
/**
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
@@ -118,6 +126,7 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||||||
return new MUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
return new MUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Sets the Key of the Pair.
|
* Sets the Key of the Pair.
|
||||||
* @param key the key that should be set.
|
* @param key the key that should be set.
|
||||||
|
|||||||
+46
-46
@@ -1,46 +1,46 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class that implements all the essential methods for the PriorityQueues
|
* Helper class that implements all the essential methods for the PriorityQueues
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj instanceof PRIORITY_QUEUE) {
|
if(obj instanceof PRIORITY_QUEUE) {
|
||||||
PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj;
|
PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj;
|
||||||
if(queue.size() != size()) return false;
|
if(queue.size() != size()) return false;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(KEY_EQUALS_NOT(queue.peek(i), peek(i))) return false;
|
if(KEY_EQUALS_NOT(queue.peek(i), peek(i))) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = 1;
|
int result = 1;
|
||||||
for (int i = 0,m=size();i<m;i++) {
|
for (int i = 0,m=size();i<m;i++) {
|
||||||
result = 31 * result + KEY_TO_HASH(peek(i));
|
result = 31 * result + KEY_TO_HASH(peek(i));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
if(isEmpty()) return "[]";
|
if(isEmpty()) return "[]";
|
||||||
StringJoiner joiner = new StringJoiner(", ", "[", "]");
|
StringJoiner joiner = new StringJoiner(", ", "[", "]");
|
||||||
for (int i = 0,m=size();i<m;i++) {
|
for (int i = 0,m=size();i<m;i++) {
|
||||||
joiner.add(KEY_TO_STRING(peek(i)));
|
joiner.add(KEY_TO_STRING(peek(i)));
|
||||||
}
|
}
|
||||||
return joiner.toString();
|
return joiner.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+467
-443
@@ -1,444 +1,468 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
#if JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import java.util.function.PREDICATE;
|
||||||
#if !TYPE_OBJECT
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#endif
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
#endif
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
/**
|
#if !JDK_FUNCTION
|
||||||
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
#endif
|
||||||
* @Type(T)
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
*/
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
|
||||||
{
|
/**
|
||||||
/** Max Possible ArraySize without the JVM Crashing */
|
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
||||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
||||||
/** The Minimum Capacity that is allowed */
|
* @Type(T)
|
||||||
public static final int MIN_CAPACITY = 4;
|
*/
|
||||||
/** The Backing array */
|
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
||||||
protected transient KEY_TYPE[] array;
|
{
|
||||||
/** The First Index pointer */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
protected int first;
|
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
/** The Last Index pointer */
|
/** The Minimum Capacity that is allowed */
|
||||||
protected int last;
|
public static final int MIN_CAPACITY = 4;
|
||||||
/** The Minimum Capacity of the Queue **/
|
/** The Backing array */
|
||||||
protected int minCapacity;
|
protected transient KEY_TYPE[] array;
|
||||||
|
/** The First Index pointer */
|
||||||
/**
|
protected int first;
|
||||||
* Constructor using a initial array
|
/** The Last Index pointer */
|
||||||
* @param values the Array that should be used
|
protected int last;
|
||||||
*/
|
/** The Minimum Capacity of the Queue **/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
protected int minCapacity;
|
||||||
this(values, 0, values.length);
|
|
||||||
}
|
/**
|
||||||
|
* Constructor using a initial array
|
||||||
/**
|
* @param values the Array that should be used
|
||||||
* Constructor using a initial array
|
*/
|
||||||
* @param values the Array that should be used
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
||||||
* @param size the amount of elements that are in the initial array
|
this(values, 0, values.length);
|
||||||
* @throws IllegalStateException if values is smaller then size
|
}
|
||||||
*/
|
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
/**
|
||||||
this(values, 0, size);
|
* Constructor using a initial array
|
||||||
}
|
* @param values the Array that should be used
|
||||||
|
* @param size the amount of elements that are in the initial array
|
||||||
/**
|
* @throws IllegalStateException if values is smaller then size
|
||||||
* Constructor using a initial array
|
*/
|
||||||
* @param values the Array that should be used
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
||||||
* @param offset where to begin in the initial array
|
this(values, 0, size);
|
||||||
* @param size the amount of elements that are in the initial array
|
}
|
||||||
* @throws IllegalStateException if values is smaller then size
|
|
||||||
*/
|
/**
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
* Constructor using a initial array
|
||||||
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
* @param values the Array that should be used
|
||||||
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
* @param offset where to begin in the initial array
|
||||||
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
* @param size the amount of elements that are in the initial array
|
||||||
minCapacity = MIN_CAPACITY;
|
* @throws IllegalStateException if values is smaller then size
|
||||||
array = values;
|
*/
|
||||||
first = offset;
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
||||||
last = (offset + size) % array.length;
|
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
||||||
if(array.length == size) expand();
|
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
||||||
}
|
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
||||||
|
minCapacity = MIN_CAPACITY;
|
||||||
/**
|
array = values;
|
||||||
* Constructor with a Min Capacity
|
first = offset;
|
||||||
* @param capacity the initial capacity of the backing array
|
last = (offset + size) % array.length;
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
if(array.length == size) expand();
|
||||||
*/
|
}
|
||||||
public ARRAY_FIFO_QUEUE(int capacity) {
|
|
||||||
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
/**
|
||||||
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
* Constructor with a Min Capacity
|
||||||
minCapacity = array.length;
|
* @param capacity the initial capacity of the backing array
|
||||||
}
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
|
*/
|
||||||
/**
|
public ARRAY_FIFO_QUEUE(int capacity) {
|
||||||
* Default Construtor
|
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
||||||
*/
|
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
||||||
public ARRAY_FIFO_QUEUE() {
|
minCapacity = array.length;
|
||||||
this(MIN_CAPACITY);
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
@Override
|
* Default Construtor
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
*/
|
||||||
return new Iter();
|
public ARRAY_FIFO_QUEUE() {
|
||||||
}
|
this(MIN_CAPACITY);
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int size() {
|
@Override
|
||||||
final int apparentLength = last - first;
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public int size() {
|
||||||
if(first != last) {
|
final int apparentLength = last - first;
|
||||||
#if TYPE_OBJECT
|
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
||||||
Arrays.fill(array, null);
|
}
|
||||||
#endif
|
|
||||||
first = last = 0;
|
@Override
|
||||||
}
|
public void clear() {
|
||||||
else if(first != 0) {
|
if(first != last) {
|
||||||
first = last = 0;
|
#if TYPE_OBJECT
|
||||||
}
|
Arrays.fill(array, null);
|
||||||
}
|
#endif
|
||||||
|
first = last = 0;
|
||||||
@Override
|
}
|
||||||
public void enqueue(KEY_TYPE e) {
|
else if(first != 0) {
|
||||||
array[last++] = e;
|
first = last = 0;
|
||||||
if(last == array.length) last = 0;
|
}
|
||||||
if(last == first) expand();
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void enqueue(KEY_TYPE e) {
|
||||||
public void enqueueFirst(KEY_TYPE e) {
|
array[last++] = e;
|
||||||
if(first == 0) first = array.length;
|
if(last == array.length) last = 0;
|
||||||
array[--first] = e;
|
if(last == first) expand();
|
||||||
if(first == last) expand();
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void enqueueFirst(KEY_TYPE e) {
|
||||||
public KEY_TYPE dequeue() {
|
if(first == 0) first = array.length;
|
||||||
if(first == last) throw new NoSuchElementException();
|
array[--first] = e;
|
||||||
KEY_TYPE data = array[first];
|
if(first == last) expand();
|
||||||
#if TYPE_OBJECT
|
}
|
||||||
array[first] = null;
|
|
||||||
#endif
|
@Override
|
||||||
if(++first == array.length) first = 0;
|
public KEY_TYPE dequeue() {
|
||||||
reduce();
|
if(first == last) throw new NoSuchElementException();
|
||||||
return data;
|
KEY_TYPE data = array[first];
|
||||||
}
|
#if TYPE_OBJECT
|
||||||
|
array[first] = null;
|
||||||
@Override
|
#endif
|
||||||
public KEY_TYPE dequeueLast() {
|
if(++first == array.length) first = 0;
|
||||||
if(first == last) throw new NoSuchElementException();
|
reduce();
|
||||||
if(last == 0) last = array.length;
|
return data;
|
||||||
KEY_TYPE data = array[--last];
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
array[last] = null;
|
@Override
|
||||||
#endif
|
public KEY_TYPE dequeueLast() {
|
||||||
reduce();
|
if(first == last) throw new NoSuchElementException();
|
||||||
return data;
|
if(last == 0) last = array.length;
|
||||||
}
|
KEY_TYPE data = array[--last];
|
||||||
|
#if TYPE_OBJECT
|
||||||
@Override
|
array[last] = null;
|
||||||
public KEY_TYPE peek(int index) {
|
#endif
|
||||||
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
reduce();
|
||||||
index += first;
|
return data;
|
||||||
return index >= array.length ? array[index-array.length] : array[index];
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public KEY_TYPE peek(int index) {
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
||||||
if(first == last) return false;
|
index += first;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
return index >= array.length ? array[index-array.length] : array[index];
|
||||||
int index = (first + i) % array.length;
|
}
|
||||||
if(e == array[index])
|
|
||||||
return removeIndex(index);
|
@Override
|
||||||
}
|
public boolean contains(KEY_TYPE e) {
|
||||||
return false;
|
if(first == last) return false;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
|
if(e == array[(first + i) % array.length]) return true;
|
||||||
@Override
|
}
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
return false;
|
||||||
if(first == last) return false;
|
}
|
||||||
for(int i = size()-1;i>=0;i--) {
|
|
||||||
int index = (first + i) % array.length;
|
@Override
|
||||||
if(e == array[index])
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
return removeIndex(index);
|
if(first == last) return false;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
return false;
|
int index = (first + i) % array.length;
|
||||||
}
|
if(e == array[index])
|
||||||
|
return removeIndex(index);
|
||||||
protected boolean removeIndex(int index) {
|
}
|
||||||
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
return false;
|
||||||
if(index == first) {
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
array[first] = null;
|
@Override
|
||||||
#endif
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
first++;
|
if(first == last) return false;
|
||||||
}
|
for(int i = size()-1;i>=0;i--) {
|
||||||
else if(index == last) {
|
int index = (first + i) % array.length;
|
||||||
last--;
|
if(e == array[index])
|
||||||
#if TYPE_OBJECT
|
return removeIndex(index);
|
||||||
array[last] = null;
|
}
|
||||||
#endif
|
return false;
|
||||||
}
|
}
|
||||||
else if(index > last) {
|
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
protected boolean removeIndex(int index) {
|
||||||
#if TYPE_OBJECT
|
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
||||||
array[first] = null;
|
if(index == first) {
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
first = ++first % array.length;
|
array[first] = null;
|
||||||
}
|
#endif
|
||||||
else if(index < first) {
|
first++;
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
}
|
||||||
#if TYPE_OBJECT
|
else if(index == last) {
|
||||||
array[last] = null;
|
last--;
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
if(--last < 0) last += array.length;
|
array[last] = null;
|
||||||
}
|
#endif
|
||||||
else {
|
}
|
||||||
if(index - first < last - index) {
|
else if(index > last) {
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[first] = null;
|
array[first] = null;
|
||||||
#endif
|
#endif
|
||||||
first = ++first % array.length;
|
first = ++first % array.length;
|
||||||
}
|
}
|
||||||
else {
|
else if(index < first) {
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[last] = null;
|
array[last] = null;
|
||||||
#endif
|
#endif
|
||||||
if(--last < 0) last += array.length;
|
if(--last < 0) last += array.length;
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
reduce();
|
if(index - first < last - index) {
|
||||||
return true;
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
}
|
#if TYPE_OBJECT
|
||||||
|
array[first] = null;
|
||||||
@Override
|
#endif
|
||||||
public void onChanged() {}
|
first = ++first % array.length;
|
||||||
|
}
|
||||||
@Override
|
else {
|
||||||
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
#if TYPE_OBJECT
|
||||||
queue.first = first;
|
array[last] = null;
|
||||||
queue.last = last;
|
#endif
|
||||||
queue.minCapacity = minCapacity;
|
if(--last < 0) last += array.length;
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
}
|
||||||
return queue;
|
}
|
||||||
}
|
reduce();
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onChanged() {}
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
|
||||||
Objects.requireNonNull(action);
|
@Override
|
||||||
if(first == last) return;
|
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
for(int i = 0,m=size();i<m;i++)
|
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
||||||
action.accept(array[(first + i) % array.length]);
|
queue.first = first;
|
||||||
clearAndTrim(0);
|
queue.last = last;
|
||||||
}
|
queue.minCapacity = minCapacity;
|
||||||
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
@Override
|
return queue;
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
}
|
||||||
Objects.requireNonNull(action);
|
|
||||||
if(first == last) return;
|
@Override
|
||||||
for(int i = 0,m=size();i<m;i++)
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
||||||
action.accept(input, array[(first + i) % array.length]);
|
|
||||||
clearAndTrim(0);
|
@Override
|
||||||
}
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
@Override
|
if(first == last) return;
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0,m=size();i<m;i++)
|
||||||
Objects.requireNonNull(filter);
|
action.accept(array[(first + i) % array.length]);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
clearAndTrim(0);
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return true;
|
}
|
||||||
}
|
|
||||||
return false;
|
@Override
|
||||||
}
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
@Override
|
if(first == last) return;
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0,m=size();i<m;i++)
|
||||||
Objects.requireNonNull(filter);
|
action.accept(i, array[(first + i) % array.length]);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
clearAndTrim(0);
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
}
|
||||||
}
|
|
||||||
return true;
|
@Override
|
||||||
}
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
@Override
|
if(first == last) return;
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0,m=size();i<m;i++)
|
||||||
Objects.requireNonNull(filter);
|
action.accept(input, array[(first + i) % array.length]);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
clearAndTrim(0);
|
||||||
if(!filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
}
|
||||||
}
|
|
||||||
return true;
|
@Override
|
||||||
}
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
@Override
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
if(filter.test(array[(first + i) % array.length])) return true;
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
return false;
|
||||||
int index = (first + i) % array.length;
|
}
|
||||||
if(filter.TEST_VALUE(array[index])) {
|
|
||||||
KEY_TYPE data = array[index];
|
@Override
|
||||||
removeIndex(index);
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
return data;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
}
|
if(filter.test(array[(first + i) % array.length])) return false;
|
||||||
return EMPTY_VALUE;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
#if !TYPE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE state = identity;
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
if(!filter.test(array[(first + i) % array.length])) return false;
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
}
|
||||||
}
|
return true;
|
||||||
return state;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
#else
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
Objects.requireNonNull(operator);
|
int index = (first + i) % array.length;
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
if(filter.test(array[index])) {
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
KEY_TYPE data = array[index];
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
removeIndex(index);
|
||||||
}
|
return data;
|
||||||
return state;
|
}
|
||||||
}
|
}
|
||||||
|
return EMPTY_VALUE;
|
||||||
#endif
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
#if !TYPE_OBJECT
|
||||||
Objects.requireNonNull(operator);
|
@Override
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
boolean empty = true;
|
Objects.requireNonNull(operator);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
KEY_TYPE state = identity;
|
||||||
if(empty) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
empty = false;
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
state = array[(first + i) % array.length];
|
}
|
||||||
continue;
|
return state;
|
||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
|
||||||
}
|
#else
|
||||||
return state;
|
@Override
|
||||||
}
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
@Override
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
Objects.requireNonNull(filter);
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
int result = 0;
|
}
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
return state;
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) result++;
|
}
|
||||||
}
|
|
||||||
return result;
|
#endif
|
||||||
}
|
@Override
|
||||||
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
@Override
|
Objects.requireNonNull(operator);
|
||||||
public boolean trim(int size) {
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
boolean empty = true;
|
||||||
if(newSize >= array.length) return false;
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
if(empty) {
|
||||||
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
empty = false;
|
||||||
else {
|
state = array[(first + i) % array.length];
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
continue;
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
}
|
||||||
}
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
first = 0;
|
}
|
||||||
last = size();
|
return state;
|
||||||
array = newArray;
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
/**
|
Objects.requireNonNull(filter);
|
||||||
* Trims the collection down to the requested size and clears all elements while doing so
|
int result = 0;
|
||||||
* @param size the amount of elements that should be allowed
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
* @note this will enforce minimum size of the collection itself
|
if(filter.test(array[(first + i) % array.length])) result++;
|
||||||
*/
|
}
|
||||||
@Override
|
return result;
|
||||||
public void clearAndTrim(int size) {
|
}
|
||||||
int newSize = Math.max(minCapacity, size);
|
|
||||||
if(array.length <= newSize) {
|
@Override
|
||||||
clear();
|
public boolean trim(int size) {
|
||||||
return;
|
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
||||||
}
|
if(newSize >= array.length) return false;
|
||||||
first = last = 0;
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
array = NEW_KEY_ARRAY(newSize);
|
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
||||||
}
|
else {
|
||||||
|
System.arraycopy(array, first, newArray, 0, array.length - first);
|
||||||
@Override
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
}
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
first = 0;
|
||||||
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
last = size();
|
||||||
else {
|
array = newArray;
|
||||||
System.arraycopy(array, first, input, 0, array.length - first);
|
return true;
|
||||||
System.arraycopy(array, 0, input, array.length - first, last);
|
}
|
||||||
}
|
|
||||||
return input;
|
/**
|
||||||
}
|
* Trims the collection down to the requested size and clears all elements while doing so
|
||||||
|
* @param size the amount of elements that should be allowed
|
||||||
protected void reduce() {
|
* @note this will enforce minimum size of the collection itself
|
||||||
final int size = size();
|
*/
|
||||||
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
@Override
|
||||||
}
|
public void clearAndTrim(int size) {
|
||||||
|
int newSize = Math.max(minCapacity, size);
|
||||||
protected void expand() {
|
if(array.length <= newSize) {
|
||||||
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
clear();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
protected final void resize(int oldSize, int newSize) {
|
first = last = 0;
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
array = NEW_KEY_ARRAY(newSize);
|
||||||
if(first >= last) {
|
}
|
||||||
if(oldSize != 0)
|
|
||||||
{
|
@Override
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
}
|
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
||||||
}
|
else {
|
||||||
else System.arraycopy(array, first, newArray, 0, last-first);
|
System.arraycopy(array, first, input, 0, array.length - first);
|
||||||
first = 0;
|
System.arraycopy(array, 0, input, array.length - first, last);
|
||||||
last = oldSize;
|
}
|
||||||
array = newArray;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
protected void reduce() {
|
||||||
{
|
final int size = size();
|
||||||
int index = first;
|
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
||||||
@Override
|
}
|
||||||
public boolean hasNext()
|
|
||||||
{
|
protected void expand() {
|
||||||
return index != last;
|
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected final void resize(int oldSize, int newSize) {
|
||||||
public KEY_TYPE NEXT() {
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(first >= last) {
|
||||||
KEY_TYPE value = array[index];
|
if(oldSize != 0)
|
||||||
removeIndex(index);
|
{
|
||||||
index = ++index % array.length;
|
System.arraycopy(array, first, newArray, 0, array.length - first);
|
||||||
return value;
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else System.arraycopy(array, first, newArray, 0, last-first);
|
||||||
|
first = 0;
|
||||||
|
last = oldSize;
|
||||||
|
array = newArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
int index = first;
|
||||||
|
@Override
|
||||||
|
public boolean hasNext()
|
||||||
|
{
|
||||||
|
return index != last;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
KEY_TYPE value = array[index];
|
||||||
|
removeIndex(index);
|
||||||
|
index = ++index % array.length;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+446
-420
@@ -1,421 +1,447 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import java.util.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
#endif
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#endif
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
/**
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
#endif
|
||||||
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
* @Type(T)
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
*/
|
|
||||||
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
/**
|
||||||
{
|
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
||||||
/** The Backing Array */
|
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
||||||
/** The Amount of elements stored within the array */
|
* @Type(T)
|
||||||
protected int size;
|
*/
|
||||||
/** The Last known first index pointer */
|
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
protected int firstIndex = -1;
|
{
|
||||||
/** The Sorter of the Array */
|
/** The Backing Array */
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
|
/** The Amount of elements stored within the array */
|
||||||
/**
|
protected int size;
|
||||||
* Default Constructor
|
/** The Last known first index pointer */
|
||||||
*/
|
protected int firstIndex = -1;
|
||||||
public ARRAY_PRIORITY_QUEUE() {
|
/** The Sorter of the Array */
|
||||||
this(0, null);
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Default Constructor
|
||||||
* Constructor using custom sorter
|
*/
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
public ARRAY_PRIORITY_QUEUE() {
|
||||||
*/
|
this(0, null);
|
||||||
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
}
|
||||||
this(0, comp);
|
|
||||||
}
|
/**
|
||||||
|
* Constructor using custom sorter
|
||||||
/**
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* Constructor with a Min Capacity
|
*/
|
||||||
* @param size the initial capacity of the backing array
|
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
this(0, comp);
|
||||||
*/
|
}
|
||||||
public ARRAY_PRIORITY_QUEUE(int size) {
|
|
||||||
this(size, null);
|
/**
|
||||||
}
|
* Constructor with a Min Capacity
|
||||||
|
* @param size the initial capacity of the backing array
|
||||||
/**
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
*/
|
||||||
* @param size the initial capacity of the backing array
|
public ARRAY_PRIORITY_QUEUE(int size) {
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
this(size, null);
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
}
|
||||||
*/
|
|
||||||
public ARRAY_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
/**
|
||||||
if(size < 0) throw new IllegalAccessError("Size has to be 0 or positive");
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
* @param size the initial capacity of the backing array
|
||||||
comparator = comp;
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
}
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
|
*/
|
||||||
/**
|
public ARRAY_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* Constructor using a initial array
|
if(size < 0) throw new IllegalAccessError("Size has to be 0 or positive");
|
||||||
* @param array the Array that should be used
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
*/
|
comparator = comp;
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
}
|
||||||
this(array, array.length);
|
|
||||||
}
|
/**
|
||||||
|
* Constructor using a initial array
|
||||||
/**
|
* @param array the Array that should be used
|
||||||
* Constructor using a initial array
|
*/
|
||||||
* @param array the Array that should be used
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
* @param size the amount of elements found within the array
|
this(array, array.length);
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
}
|
||||||
*/
|
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
/**
|
||||||
this.array = Arrays.copyOf(array, size);
|
* Constructor using a initial array
|
||||||
this.size = size;
|
* @param array the Array that should be used
|
||||||
}
|
* @param size the amount of elements found within the array
|
||||||
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
/**
|
*/
|
||||||
* Constructor using a initial array and a custom sorter
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
* @param array the Array that should be used
|
this.array = Arrays.copyOf(array, size);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
this.size = size;
|
||||||
*/
|
}
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
|
||||||
this(array, array.length, comp);
|
/**
|
||||||
}
|
* Constructor using a initial array and a custom sorter
|
||||||
|
* @param array the Array that should be used
|
||||||
/**
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* Constructor using a initial array and a custom sorter
|
*/
|
||||||
* @param array the Array that should be used
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @param size the amount of elements found within the array
|
this(array, array.length, comp);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
}
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
|
||||||
*/
|
/**
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* Constructor using a initial array and a custom sorter
|
||||||
this.array = Arrays.copyOf(array, size);
|
* @param array the Array that should be used
|
||||||
this.size = size;
|
* @param size the amount of elements found within the array
|
||||||
this.comparator = comp;
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
}
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
|
*/
|
||||||
/**
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* Constructor using a Collection
|
this.array = Arrays.copyOf(array, size);
|
||||||
* @param c the Collection that should be used
|
this.size = size;
|
||||||
*/
|
this.comparator = comp;
|
||||||
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
}
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
|
||||||
size = c.size();
|
/**
|
||||||
}
|
* Constructor using a Collection
|
||||||
|
* @param c the Collection that should be used
|
||||||
/**
|
*/
|
||||||
* Constructor using a Collection and a custom sorter
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
* @param c the Collection that should be used
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
size = c.size();
|
||||||
*/
|
}
|
||||||
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
/**
|
||||||
size = c.size();
|
* Constructor using a Collection and a custom sorter
|
||||||
comparator = comp;
|
* @param c the Collection that should be used
|
||||||
}
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
|
*/
|
||||||
/**
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* Wrapping method to help serialization
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
* @param array the array that should be used
|
size = c.size();
|
||||||
* @Type(T)
|
comparator = comp;
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
}
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
/**
|
||||||
return wrap(array, array.length);
|
* Wrapping method to help serialization
|
||||||
}
|
* @param array the array that should be used
|
||||||
|
* @Type(T)
|
||||||
/**
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
* Wrapping method to help serialization
|
*/
|
||||||
* @param array the array that should be used
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
* @param size the amount of elements within the array
|
return wrap(array, array.length);
|
||||||
* @Type(T)
|
}
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
|
||||||
*/
|
/**
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
* Wrapping method to help serialization
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
* @param array the array that should be used
|
||||||
queue.array = array;
|
* @param size the amount of elements within the array
|
||||||
queue.size = size;
|
* @Type(T)
|
||||||
return queue;
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
}
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
/**
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
queue.array = array;
|
||||||
* @param array the array that should be used
|
queue.size = size;
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
return queue;
|
||||||
* @Type(T)
|
}
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
|
||||||
*/
|
/**
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
return wrap(array, array.length, comp);
|
* @param array the array that should be used
|
||||||
}
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
|
* @Type(T)
|
||||||
/**
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
*/
|
||||||
* @param array the array that should be used
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @param size the amount of elements within the array
|
return wrap(array, array.length, comp);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
}
|
||||||
* @Type(T)
|
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
/**
|
||||||
*/
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* @param array the array that should be used
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
* @param size the amount of elements within the array
|
||||||
queue.array = array;
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
queue.size = size;
|
* @Type(T)
|
||||||
return queue;
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
}
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
@Override
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
||||||
public void enqueue(KEY_TYPE e) {
|
queue.array = array;
|
||||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
queue.size = size;
|
||||||
if(firstIndex != -1){
|
return queue;
|
||||||
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
}
|
||||||
if(compare < 0) firstIndex = size;
|
|
||||||
else if(compare > 0) firstIndex = -1;
|
@Override
|
||||||
}
|
public void enqueue(KEY_TYPE e) {
|
||||||
array[size++] = e;
|
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||||
}
|
if(firstIndex != -1){
|
||||||
|
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
||||||
@Override
|
if(compare < 0) firstIndex = size;
|
||||||
public KEY_TYPE dequeue() {
|
else if(compare > 0) firstIndex = -1;
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
}
|
||||||
int index = findFirstIndex();
|
array[size++] = e;
|
||||||
KEY_TYPE value = array[index];
|
}
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
|
||||||
#if TYPE_OBJECT
|
@Override
|
||||||
array[size] = null;
|
public KEY_TYPE dequeue() {
|
||||||
#endif
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
firstIndex = -1;
|
int index = findFirstIndex();
|
||||||
return value;
|
KEY_TYPE value = array[index];
|
||||||
}
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
|
#if TYPE_OBJECT
|
||||||
@Override
|
array[size] = null;
|
||||||
public KEY_TYPE peek(int index) {
|
#endif
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
firstIndex = -1;
|
||||||
return array[index];
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public KEY_TYPE first() {
|
||||||
for(int i = 0;i<size;i++)
|
if(isEmpty()) throw new NoSuchElementException();
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(firstIndex == -1) findFirstIndex();
|
||||||
return false;
|
return array[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
public KEY_TYPE peek(int index) {
|
||||||
for(int i = size-1;i>=0;i--)
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
return array[index];
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
protected boolean removeIndex(int index) {
|
public boolean contains(KEY_TYPE e) {
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
for(int i = 0;i<size;i++)
|
||||||
#if TYPE_OBJECT
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
array[size] = null;
|
return false;
|
||||||
#endif
|
}
|
||||||
if(index == firstIndex) firstIndex = -1;
|
|
||||||
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
@Override
|
||||||
return true;
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
}
|
for(int i = 0;i<size;i++)
|
||||||
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
@Override
|
return false;
|
||||||
public void onChanged() {
|
}
|
||||||
firstIndex = -1;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
@Override
|
for(int i = size-1;i>=0;i--)
|
||||||
public int size() {
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return size;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean removeIndex(int index) {
|
||||||
public void clear() {
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
Arrays.fill(array, null);
|
array[size] = null;
|
||||||
#endif
|
#endif
|
||||||
size = 0;
|
if(index == firstIndex) firstIndex = -1;
|
||||||
}
|
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
|
||||||
Objects.requireNonNull(action);
|
@Override
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
public void onChanged() {
|
||||||
}
|
firstIndex = -1;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
@Override
|
||||||
Objects.requireNonNull(action);
|
public int size() {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public void clear() {
|
||||||
Objects.requireNonNull(filter);
|
#if TYPE_OBJECT
|
||||||
for(int i = 0;i<size;i++) {
|
Arrays.fill(array, null);
|
||||||
if(filter.TEST_VALUE(array[i])) return true;
|
#endif
|
||||||
}
|
size = 0;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
Objects.requireNonNull(action);
|
||||||
Objects.requireNonNull(filter);
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.TEST_VALUE(array[i])) return false;
|
|
||||||
}
|
@Override
|
||||||
return true;
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
}
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
@Override
|
}
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
if(!filter.TEST_VALUE(array[i])) return false;
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
#if !TYPE_OBJECT
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(operator);
|
if(filter.test(array[i])) return true;
|
||||||
KEY_TYPE state = identity;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return false;
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
}
|
||||||
}
|
|
||||||
return state;
|
@Override
|
||||||
}
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
#else
|
for(int i = 0;i<size;i++) {
|
||||||
@Override
|
if(filter.test(array[i])) return false;
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
return true;
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
@Override
|
||||||
}
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
return state;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
if(!filter.test(array[i])) return false;
|
||||||
#endif
|
}
|
||||||
@Override
|
return true;
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
#if !TYPE_OBJECT
|
||||||
boolean empty = true;
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
if(empty) {
|
Objects.requireNonNull(operator);
|
||||||
empty = false;
|
KEY_TYPE state = identity;
|
||||||
state = array[i];
|
for(int i = 0;i<size;i++) {
|
||||||
continue;
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
return state;
|
||||||
}
|
}
|
||||||
return state;
|
|
||||||
}
|
#else
|
||||||
|
@Override
|
||||||
@Override
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
Objects.requireNonNull(operator);
|
||||||
Objects.requireNonNull(filter);
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
KEY_TYPE data = array[i];
|
}
|
||||||
removeIndex(i);
|
return state;
|
||||||
return data;
|
}
|
||||||
}
|
|
||||||
}
|
#endif
|
||||||
return EMPTY_VALUE;
|
@Override
|
||||||
}
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
@Override
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
boolean empty = true;
|
||||||
Objects.requireNonNull(filter);
|
for(int i = 0;i<size;i++) {
|
||||||
int result = 0;
|
if(empty) {
|
||||||
for(int i = 0;i<size;i++) {
|
empty = false;
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
state = array[i];
|
||||||
}
|
continue;
|
||||||
return result;
|
}
|
||||||
}
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
|
}
|
||||||
@Override
|
return state;
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
}
|
||||||
return new Iter();
|
|
||||||
}
|
@Override
|
||||||
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
for(int i = 0;i<size;i++) {
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
if(filter.test(array[i])) {
|
||||||
queue.firstIndex = firstIndex;
|
KEY_TYPE data = array[i];
|
||||||
queue.size = size;
|
removeIndex(i);
|
||||||
queue.comparator = comparator;
|
return data;
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
}
|
||||||
return queue;
|
}
|
||||||
}
|
return EMPTY_VALUE;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
@Override
|
||||||
return comparator;
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
|
int result = 0;
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
if(filter.test(array[i])) result++;
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
}
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
return result;
|
||||||
return input;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
protected int findFirstIndex() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
if(firstIndex == -1) {
|
return new Iter();
|
||||||
int index = size-1;
|
}
|
||||||
KEY_TYPE value = array[index];
|
|
||||||
if(comparator == null) {
|
@Override
|
||||||
for(int i = index;i>=0;i--) {
|
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
value = array[index = i];
|
queue.firstIndex = firstIndex;
|
||||||
}
|
queue.size = size;
|
||||||
}
|
queue.comparator = comparator;
|
||||||
else {
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
for(int i = index;i>=0;i--) {
|
return queue;
|
||||||
if(comparator.compare(array[i], value) < 0)
|
}
|
||||||
value = array[index = i];
|
|
||||||
}
|
@Override
|
||||||
}
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
firstIndex = index;
|
return comparator;
|
||||||
}
|
}
|
||||||
return firstIndex;
|
|
||||||
}
|
@Override
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
@Override
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
public boolean hasNext() {
|
return input;
|
||||||
return !isEmpty();
|
}
|
||||||
}
|
|
||||||
|
protected int findFirstIndex() {
|
||||||
@Override
|
if(firstIndex == -1) {
|
||||||
public KEY_TYPE NEXT() {
|
int index = size-1;
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
KEY_TYPE value = array[index];
|
||||||
return dequeue();
|
if(comparator == null) {
|
||||||
}
|
for(int i = index;i>=0;i--) {
|
||||||
}
|
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
||||||
|
value = array[index = i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(int i = index;i>=0;i--) {
|
||||||
|
if(comparator.compare(array[i], value) < 0)
|
||||||
|
value = array[index = i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firstIndex = index;
|
||||||
|
}
|
||||||
|
return firstIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return !isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
return dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+414
-395
@@ -1,396 +1,415 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import java.util.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
#endif
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#endif
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
/**
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
* A Simple Heap base Priority Queue implementation
|
#endif
|
||||||
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
* @Type(T)
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
*/
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
|
||||||
{
|
/**
|
||||||
/** The Backing Array */
|
* A Simple Heap base Priority Queue implementation
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
||||||
/** The Amount of elements stored within the array */
|
* @Type(T)
|
||||||
protected int size;
|
*/
|
||||||
/** The Sorter of the Array */
|
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
{
|
||||||
|
/** The Backing Array */
|
||||||
/**
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
* Default Constructor
|
/** The Amount of elements stored within the array */
|
||||||
*/
|
protected int size;
|
||||||
public HEAP_PRIORITY_QUEUE() {
|
/** The Sorter of the Array */
|
||||||
this(0, null);
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Default Constructor
|
||||||
* Constructor using custom sorter
|
*/
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
public HEAP_PRIORITY_QUEUE() {
|
||||||
*/
|
this(0, null);
|
||||||
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
}
|
||||||
this(0, comp);
|
|
||||||
}
|
/**
|
||||||
|
* Constructor using custom sorter
|
||||||
/**
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* Constructor with a Min Capacity
|
*/
|
||||||
* @param size the initial capacity of the backing array
|
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
this(0, comp);
|
||||||
*/
|
}
|
||||||
public HEAP_PRIORITY_QUEUE(int size) {
|
|
||||||
this(size, null);
|
/**
|
||||||
}
|
* Constructor with a Min Capacity
|
||||||
|
* @param size the initial capacity of the backing array
|
||||||
/**
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
*/
|
||||||
* @param size the initial capacity of the backing array
|
public HEAP_PRIORITY_QUEUE(int size) {
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
this(size, null);
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
}
|
||||||
*/
|
|
||||||
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
/**
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
comparator = comp;
|
* @param size the initial capacity of the backing array
|
||||||
}
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
/**
|
*/
|
||||||
* Constructor using a initial array
|
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @param array the Array that should be used
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
*/
|
comparator = comp;
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
}
|
||||||
this(array, array.length);
|
|
||||||
}
|
/**
|
||||||
|
* Constructor using a initial array
|
||||||
/**
|
* @param array the Array that should be used
|
||||||
* Constructor using a initial array
|
*/
|
||||||
* @param array the Array that should be used
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
* @param size the amount of elements found within the array
|
this(array, array.length);
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
}
|
||||||
*/
|
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
/**
|
||||||
this.array = Arrays.copyOf(array, size);
|
* Constructor using a initial array
|
||||||
this.size = size;
|
* @param array the Array that should be used
|
||||||
ARRAYS.heapify(array, size, null);
|
* @param size the amount of elements found within the array
|
||||||
}
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
|
*/
|
||||||
/**
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
* Constructor using a initial array and a custom sorter
|
this.array = Arrays.copyOf(array, size);
|
||||||
* @param array the Array that should be used
|
this.size = size;
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
ARRAYS.heapify(array, size, null);
|
||||||
*/
|
}
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
|
||||||
this(array, array.length, comp);
|
/**
|
||||||
}
|
* Constructor using a initial array and a custom sorter
|
||||||
|
* @param array the Array that should be used
|
||||||
/**
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* Constructor using a initial array and a custom sorter
|
*/
|
||||||
* @param array the Array that should be used
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @param size the amount of elements found within the array
|
this(array, array.length, comp);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
}
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
|
||||||
*/
|
/**
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* Constructor using a initial array and a custom sorter
|
||||||
this.array = Arrays.copyOf(array, size);
|
* @param array the Array that should be used
|
||||||
this.size = size;
|
* @param size the amount of elements found within the array
|
||||||
comparator = comp;
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
ARRAYS.heapify(array, size, comp);
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
}
|
*/
|
||||||
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
/**
|
this.array = Arrays.copyOf(array, size);
|
||||||
* Constructor using a Collection
|
this.size = size;
|
||||||
* @param c the Collection that should be used
|
comparator = comp;
|
||||||
*/
|
ARRAYS.heapify(array, size, comp);
|
||||||
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
}
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
|
||||||
size = c.size();
|
/**
|
||||||
ARRAYS.heapify(array, size, null);
|
* Constructor using a Collection
|
||||||
}
|
* @param c the Collection that should be used
|
||||||
|
*/
|
||||||
/**
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
* Constructor using a Collection and a custom sorter
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
* @param c the Collection that should be used
|
size = c.size();
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
ARRAYS.heapify(array, size, null);
|
||||||
*/
|
}
|
||||||
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
/**
|
||||||
size = c.size();
|
* Constructor using a Collection and a custom sorter
|
||||||
comparator = comp;
|
* @param c the Collection that should be used
|
||||||
ARRAYS.heapify(array, size, comp);
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
}
|
*/
|
||||||
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
/**
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
* Wrapping method to help serialization
|
size = c.size();
|
||||||
* @param array the array that should be used
|
comparator = comp;
|
||||||
* @Type(T)
|
ARRAYS.heapify(array, size, comp);
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
}
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
/**
|
||||||
return wrap(array, array.length);
|
* Wrapping method to help serialization
|
||||||
}
|
* @param array the array that should be used
|
||||||
|
* @Type(T)
|
||||||
/**
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
* Wrapping method to help serialization
|
*/
|
||||||
* @param array the array that should be used
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
* @param size the amount of elements within the array
|
return wrap(array, array.length);
|
||||||
* @Type(T)
|
}
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
|
||||||
*/
|
/**
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
* Wrapping method to help serialization
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
* @param array the array that should be used
|
||||||
queue.array = array;
|
* @param size the amount of elements within the array
|
||||||
queue.size = size;
|
* @Type(T)
|
||||||
ARRAYS.heapify(array, size, null);
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
return queue;
|
*/
|
||||||
}
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
/**
|
queue.array = array;
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
queue.size = size;
|
||||||
* @param array the array that should be used
|
ARRAYS.heapify(array, size, null);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
return queue;
|
||||||
* @Type(T)
|
}
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
|
||||||
*/
|
/**
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
return wrap(array, array.length, comp);
|
* @param array the array that should be used
|
||||||
}
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
|
* @Type(T)
|
||||||
/**
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
*/
|
||||||
* @param array the array that should be used
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
* @param size the amount of elements within the array
|
return wrap(array, array.length, comp);
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
}
|
||||||
* @Type(T)
|
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
/**
|
||||||
*/
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
* @param array the array that should be used
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
* @param size the amount of elements within the array
|
||||||
queue.array = array;
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
queue.size = size;
|
* @Type(T)
|
||||||
ARRAYS.heapify(array, size, comp);
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
return queue;
|
*/
|
||||||
}
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
||||||
@Override
|
queue.array = array;
|
||||||
public int size() {
|
queue.size = size;
|
||||||
return size;
|
ARRAYS.heapify(array, size, comp);
|
||||||
}
|
return queue;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void clear() {
|
@Override
|
||||||
#if TYPE_OBJECT
|
public int size() {
|
||||||
Arrays.fill(array, null);
|
return size;
|
||||||
#endif
|
}
|
||||||
size = 0;
|
|
||||||
}
|
@Override
|
||||||
|
public void clear() {
|
||||||
@Override
|
#if TYPE_OBJECT
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
Arrays.fill(array, null);
|
||||||
return new Iter();
|
#endif
|
||||||
}
|
size = 0;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void enqueue(KEY_TYPE e) {
|
@Override
|
||||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
array[size++] = e;
|
return new Iter();
|
||||||
ARRAYS.shiftUp(array, size-1, comparator);
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void enqueue(KEY_TYPE e) {
|
||||||
public KEY_TYPE dequeue() {
|
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
array[size++] = e;
|
||||||
KEY_TYPE value = array[0];
|
ARRAYS.shiftUp(array, size-1, comparator);
|
||||||
array[0] = array[--size];
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
array[size] = null;
|
@Override
|
||||||
#endif
|
public KEY_TYPE dequeue() {
|
||||||
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
return value;
|
KEY_TYPE value = array[0];
|
||||||
}
|
array[0] = array[--size];
|
||||||
|
#if TYPE_OBJECT
|
||||||
@Override
|
array[size] = null;
|
||||||
public KEY_TYPE peek(int index) {
|
#endif
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
return array[index];
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public KEY_TYPE peek(int index) {
|
||||||
for(int i = 0;i<size;i++)
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
return array[index];
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean contains(KEY_TYPE e) {
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
for(int i = 0;i<size;i++)
|
||||||
for(int i = size-1;i>=0;i--)
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
for(int i = 0;i<size;i++)
|
||||||
Objects.requireNonNull(action);
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
Objects.requireNonNull(action);
|
for(int i = size-1;i>=0;i--)
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
@Override
|
||||||
Objects.requireNonNull(filter);
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
for(int i = 0;i<size;i++) {
|
Objects.requireNonNull(action);
|
||||||
if(filter.TEST_VALUE(array[i])) return true;
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
@Override
|
Objects.requireNonNull(action);
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(array[i])) return false;
|
@Override
|
||||||
}
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
return true;
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
@Override
|
||||||
Objects.requireNonNull(filter);
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
for(int i = 0;i<size;i++) {
|
Objects.requireNonNull(filter);
|
||||||
if(!filter.TEST_VALUE(array[i])) return false;
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(filter.test(array[i])) return true;
|
||||||
return true;
|
}
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
#if !TYPE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE state = identity;
|
for(int i = 0;i<size;i++) {
|
||||||
for(int i = 0;i<size;i++) {
|
if(filter.test(array[i])) return false;
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
}
|
||||||
}
|
return true;
|
||||||
return state;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
#else
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(operator);
|
if(!filter.test(array[i])) return false;
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return true;
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
}
|
||||||
}
|
|
||||||
return state;
|
#if !TYPE_OBJECT
|
||||||
}
|
@Override
|
||||||
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
#endif
|
Objects.requireNonNull(operator);
|
||||||
@Override
|
KEY_TYPE state = identity;
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(operator);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
}
|
||||||
boolean empty = true;
|
return state;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(empty) {
|
|
||||||
empty = false;
|
#else
|
||||||
state = array[i];
|
@Override
|
||||||
continue;
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return state;
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
@Override
|
}
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
#endif
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
if(filter.TEST_VALUE(array[i])) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
KEY_TYPE data = array[i];
|
Objects.requireNonNull(operator);
|
||||||
removeIndex(i);
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
return data;
|
boolean empty = true;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(empty) {
|
||||||
return EMPTY_VALUE;
|
empty = false;
|
||||||
}
|
state = array[i];
|
||||||
|
continue;
|
||||||
@Override
|
}
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
int result = 0;
|
return state;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
|
||||||
}
|
@Override
|
||||||
return result;
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
protected boolean removeIndex(int index) {
|
if(filter.test(array[i])) {
|
||||||
array[index] = array[--size];
|
KEY_TYPE data = array[i];
|
||||||
#if TYPE_OBJECT
|
removeIndex(i);
|
||||||
array[size] = null;
|
return data;
|
||||||
#endif
|
}
|
||||||
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
}
|
||||||
return true;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
if(size <= 0) return;
|
Objects.requireNonNull(filter);
|
||||||
ARRAYS.shiftDown(array, size, 0, comparator);
|
int result = 0;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
if(filter.test(array[i])) result++;
|
||||||
@Override
|
}
|
||||||
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
return result;
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
}
|
||||||
queue.size = size;
|
|
||||||
queue.comparator = comparator;
|
protected boolean removeIndex(int index) {
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
array[index] = array[--size];
|
||||||
return queue;
|
#if TYPE_OBJECT
|
||||||
}
|
array[size] = null;
|
||||||
|
#endif
|
||||||
@Override
|
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
return true;
|
||||||
return comparator;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void onChanged() {
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
if(size <= 0) return;
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
}
|
||||||
return input;
|
|
||||||
}
|
@Override
|
||||||
|
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
@Override
|
queue.size = size;
|
||||||
public boolean hasNext() {
|
queue.comparator = comparator;
|
||||||
return !isEmpty();
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
}
|
return queue;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
@Override
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
return dequeue();
|
return comparator;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return !isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
return dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -6,7 +6,9 @@ import java.util.Iterator;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if QUEUES_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
||||||
@@ -81,6 +83,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
*/
|
*/
|
||||||
public default KEY_TYPE last() { return peek(size()-1); }
|
public default KEY_TYPE last() { return peek(size()-1); }
|
||||||
|
|
||||||
|
#if QUEUES_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped PriorityDequeue that is Synchronized
|
* Creates a Wrapped PriorityDequeue that is Synchronized
|
||||||
* @return a new PriorityDequeue that is synchronized
|
* @return a new PriorityDequeue that is synchronized
|
||||||
@@ -96,6 +99,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
*/
|
*/
|
||||||
public default PRIORITY_DEQUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
public default PRIORITY_DEQUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
||||||
}
|
}
|
||||||
+202
-191
@@ -1,192 +1,203 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
#else
|
||||||
#else
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
#endif
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
#if QUEUES_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
/**
|
||||||
* @Type(T)
|
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
||||||
*/
|
* @Type(T)
|
||||||
public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TYPE
|
*/
|
||||||
{
|
public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TYPE
|
||||||
/**
|
{
|
||||||
* @return true if the PriorityQueue is empty
|
/**
|
||||||
*/
|
* @return true if the PriorityQueue is empty
|
||||||
public default boolean isEmpty() { return size() <= 0; }
|
*/
|
||||||
/**
|
public default boolean isEmpty() { return size() <= 0; }
|
||||||
* @return the amount of elements that are stored in the PriorityQueue
|
/**
|
||||||
*/
|
* @return the amount of elements that are stored in the PriorityQueue
|
||||||
public int size();
|
*/
|
||||||
/**
|
public int size();
|
||||||
* clears all elements within the PriorityQueue,
|
/**
|
||||||
* this does not resize the backing arrays
|
* clears all elements within the PriorityQueue,
|
||||||
*/
|
* this does not resize the backing arrays
|
||||||
public void clear();
|
*/
|
||||||
|
public void clear();
|
||||||
/**
|
|
||||||
* Method to insert a element into the PriorityQueue
|
/**
|
||||||
* @param e the element that should be inserted
|
* Method to insert a element into the PriorityQueue
|
||||||
*/
|
* @param e the element that should be inserted
|
||||||
public void enqueue(KEY_TYPE e);
|
*/
|
||||||
|
public void enqueue(KEY_TYPE e);
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
/**
|
||||||
* @param e the elements that should be inserted
|
* Method to mass insert elements into the PriorityQueue
|
||||||
*/
|
* @param e the elements that should be inserted
|
||||||
public default void enqueueAll(KEY_TYPE... e) {
|
*/
|
||||||
enqueueAll(e, 0, e.length);
|
public default void enqueueAll(KEY_TYPE... e) {
|
||||||
}
|
enqueueAll(e, 0, e.length);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
/**
|
||||||
* @param e the elements that should be inserted
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param length the amount of elements that should be inserted
|
* @param e the elements that should be inserted
|
||||||
*/
|
* @param length the amount of elements that should be inserted
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
*/
|
||||||
enqueueAll(e, 0, length);
|
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
||||||
}
|
enqueueAll(e, 0, length);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
/**
|
||||||
* @param e the elements that should be inserted
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param offset the offset where in the array should be started
|
* @param e the elements that should be inserted
|
||||||
* @param length the amount of elements that should be inserted
|
* @param offset the offset where in the array should be started
|
||||||
*/
|
* @param length the amount of elements that should be inserted
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
*/
|
||||||
for(int i = 0;i<length;i++)
|
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
||||||
enqueue(e[i+offset]);
|
for(int i = 0;i<length;i++)
|
||||||
}
|
enqueue(e[i+offset]);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
/**
|
||||||
* @param c the elements that should be inserted from the Collection
|
* Method to mass insert elements into the PriorityQueue
|
||||||
*/
|
* @param c the elements that should be inserted from the Collection
|
||||||
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
*/
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
enqueue(iter.NEXT());
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
}
|
enqueue(iter.NEXT());
|
||||||
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
#if TYPE_OBJECT
|
||||||
* Method to mass insert elements into the PriorityQueue
|
/**
|
||||||
* This method exists to add support for Java Collections to make it more useable
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param c the elements that should be inserted from the Collection
|
* This method exists to add support for Java Collections to make it more useable
|
||||||
*/
|
* @param c the elements that should be inserted from the Collection
|
||||||
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
*/
|
||||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
||||||
enqueue(iter.next());
|
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
||||||
}
|
enqueue(iter.next());
|
||||||
|
}
|
||||||
#endif
|
|
||||||
|
#endif
|
||||||
/**
|
|
||||||
* Method to extract a element from the PriorityQueue
|
/**
|
||||||
* @return a element from the Queue
|
* Method to extract a element from the PriorityQueue
|
||||||
* @throws java.util.NoSuchElementException if no element is present
|
* @return a element from the Queue
|
||||||
*/
|
* @throws java.util.NoSuchElementException if no element is present
|
||||||
public KEY_TYPE dequeue();
|
*/
|
||||||
|
public KEY_TYPE dequeue();
|
||||||
/**
|
|
||||||
* Peeking function to see whats inside the queue.
|
/**
|
||||||
* @param index of the element that is requested to be viewed.
|
* Peeking function to see whats inside the queue.
|
||||||
* @return the element that is requested
|
* @param index of the element that is requested to be viewed.
|
||||||
*/
|
* @return the element that is requested
|
||||||
public KEY_TYPE peek(int index);
|
*/
|
||||||
/**
|
public KEY_TYPE peek(int index);
|
||||||
* Shows the element that is to be returned next
|
/**
|
||||||
* @return the first element in the Queue
|
* Shows the element that is to be returned next
|
||||||
*/
|
* @return the first element in the Queue
|
||||||
public default KEY_TYPE first() { return peek(0); }
|
*/
|
||||||
|
public default KEY_TYPE first() { return peek(0); }
|
||||||
/**
|
|
||||||
* Removes the first found element in the queue
|
/**
|
||||||
* @param e the element that should be removed
|
* Method to find out if a element is part of the queue
|
||||||
* @return if a searched element was removed
|
* @param e the element that is searched for
|
||||||
*/
|
* @return true if the element is in the queue
|
||||||
public boolean removeFirst(KEY_TYPE e);
|
*/
|
||||||
/**
|
public boolean contains(KEY_TYPE e);
|
||||||
* Removes the last found element in the queue
|
|
||||||
* @param e the element that should be removed
|
/**
|
||||||
* @return if a searched element was removed
|
* Removes the first found element in the queue
|
||||||
*/
|
* @param e the element that should be removed
|
||||||
public boolean removeLast(KEY_TYPE e);
|
* @return if a searched element was removed
|
||||||
|
*/
|
||||||
/**
|
public boolean removeFirst(KEY_TYPE e);
|
||||||
* Allows to notify the Queue to be revalidate its data
|
/**
|
||||||
*/
|
* Removes the last found element in the queue
|
||||||
public void onChanged();
|
* @param e the element that should be removed
|
||||||
|
* @return if a searched element was removed
|
||||||
/**
|
*/
|
||||||
* A Function that does a shallow clone of the PriorityQueue itself.
|
public boolean removeLast(KEY_TYPE e);
|
||||||
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
|
||||||
* It can be compared to Cloneable but with less exception risk
|
/**
|
||||||
* @return a Shallow Copy of the PriorityQueue
|
* Allows to notify the Queue to be revalidate its data
|
||||||
* @note Wrappers and view PriorityQueues will not support this feature
|
*/
|
||||||
*/
|
public void onChanged();
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy();
|
|
||||||
|
/**
|
||||||
/**
|
* A Function that does a shallow clone of the PriorityQueue itself.
|
||||||
* @return the sorter of the Queue, can be null
|
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
||||||
*/
|
* It can be compared to Cloneable but with less exception risk
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
* @return a Shallow Copy of the PriorityQueue
|
||||||
|
* @note Wrappers and view PriorityQueues will not support this feature
|
||||||
#if TYPE_OBJECT
|
*/
|
||||||
/**
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy();
|
||||||
* @return draining iterator of the PriorityQueue
|
|
||||||
*/
|
/**
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
* @return the sorter of the Queue, can be null
|
||||||
#endif
|
*/
|
||||||
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
||||||
/**
|
|
||||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
#if TYPE_OBJECT
|
||||||
* @return a new PriorityQueue that is synchronized
|
/**
|
||||||
* @see PRIORITY_QUEUES#synchronize
|
* @return draining iterator of the PriorityQueue
|
||||||
*/
|
*/
|
||||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
|
|
||||||
/**
|
#endif
|
||||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
#if QUEUES_FEATURE
|
||||||
* @param mutex is the controller of the synchronization block
|
/**
|
||||||
* @return a new PriorityQueue Wrapper that is synchronized
|
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||||
* @see PRIORITY_QUEUES#synchronize
|
* @return a new PriorityQueue that is synchronized
|
||||||
*/
|
* @see PRIORITY_QUEUES#synchronize
|
||||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
*/
|
||||||
|
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
||||||
/**
|
|
||||||
* A method to drop the contents of the Queue without clearing the queue
|
/**
|
||||||
* @Type(E)
|
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||||
* @return the contents of the queue into a seperate array.
|
* @param mutex is the controller of the synchronization block
|
||||||
*/
|
* @return a new PriorityQueue Wrapper that is synchronized
|
||||||
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
* @see PRIORITY_QUEUES#synchronize
|
||||||
/**
|
*/
|
||||||
* A method to drop the contents of the Queue without clearing the queue
|
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||||
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
|
||||||
* @Type(E)
|
#endif
|
||||||
* @return the contents of the queue into a seperate array.
|
/**
|
||||||
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
* A method to drop the contents of the Queue without clearing the queue
|
||||||
*/
|
* @Type(E)
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
* @return the contents of the queue into a seperate array.
|
||||||
#if TYPE_OBJECT
|
*/
|
||||||
/**
|
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
||||||
* A Helper function that simplifies the process of creating a new Array.
|
/**
|
||||||
* @param action the array creation function
|
* A method to drop the contents of the Queue without clearing the queue
|
||||||
* @return an array containing all of the elements in this collection
|
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||||
* @see Collection#toArray(Object[])
|
* @Type(E)
|
||||||
*/
|
* @return the contents of the queue into a seperate array.
|
||||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||||
return TO_ARRAY(action.get(size()));
|
*/
|
||||||
}
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Helper function that simplifies the process of creating a new Array.
|
||||||
|
* @param action the array creation function
|
||||||
|
* @param <E> the returning arrayType
|
||||||
|
* @return an array containing all of the elements in this collection
|
||||||
|
* @see Collection#toArray(Object[])
|
||||||
|
*/
|
||||||
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
|
return TO_ARRAY(action.apply(size()));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+1668
-1604
File diff suppressed because it is too large
Load Diff
+50
-50
@@ -1,50 +1,50 @@
|
|||||||
package speiger.src.collections.PACKAGE.sets;
|
package speiger.src.collections.PACKAGE.sets;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract Type Specific Set that reduces boxing/unboxing
|
* Abstract Type Specific Set that reduces boxing/unboxing
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
@Override
|
@Override
|
||||||
public ABSTRACT_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public ABSTRACT_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hashCode = 0;
|
int hashCode = 0;
|
||||||
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
ITERATOR KEY_GENERIC_TYPE i = iterator();
|
||||||
while(i.hasNext())
|
while(i.hasNext())
|
||||||
hashCode += KEY_TO_HASH(i.NEXT());
|
hashCode += KEY_TO_HASH(i.NEXT());
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == this)
|
if (o == this)
|
||||||
return true;
|
return true;
|
||||||
if (!(o instanceof Set))
|
if (!(o instanceof Set))
|
||||||
return false;
|
return false;
|
||||||
Set<?> l = (Set<?>)o;
|
Set<?> l = (Set<?>)o;
|
||||||
if(l.size() != size()) return false;
|
if(l.size() != size()) return false;
|
||||||
try {
|
try {
|
||||||
return containsAll(l);
|
return containsAll(l);
|
||||||
} catch (ClassCastException | NullPointerException unused) {
|
} catch (ClassCastException | NullPointerException unused) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,21 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if PRIMITIVES
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if PRIMITIVES && !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -391,6 +397,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
for(int i = 0;i<size;action.accept(data[i++]));
|
for(int i = 0;i<size;action.accept(data[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;action.accept(i, data[i++]));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -402,7 +414,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -411,7 +423,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -420,7 +432,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -429,7 +441,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -478,7 +490,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -539,6 +551,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(isEmpty()) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[size()];
|
Object[] obj = new Object[size()];
|
||||||
for(int i = 0;i<size();i++)
|
for(int i = 0;i<size();i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
|
|||||||
+655
-600
File diff suppressed because it is too large
Load Diff
+897
-844
File diff suppressed because it is too large
Load Diff
+868
-815
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -4,7 +4,9 @@ import java.util.NavigableSet;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +121,7 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped NavigableSet that is Synchronized
|
* Creates a Wrapped NavigableSet that is Synchronized
|
||||||
* @return a new NavigableSet that is synchronized
|
* @return a new NavigableSet that is synchronized
|
||||||
|
|||||||
+774
-712
File diff suppressed because it is too large
Load Diff
+742
-680
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
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();
|
public KEY_TYPE POLL_LAST_KEY();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped OrderedSet that is Synchronized
|
* Creates a Wrapped OrderedSet that is Synchronized
|
||||||
* @return a new OrderedSet that is synchronized
|
* @return a new OrderedSet that is synchronized
|
||||||
|
|||||||
+1733
-1670
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ import java.util.Set;
|
|||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
@@ -64,7 +64,7 @@ public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GE
|
|||||||
public KEY_TYPE addOrGet(KEY_TYPE o);
|
public KEY_TYPE addOrGet(KEY_TYPE o);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped Set that is Synchronized
|
* Creates a Wrapped Set that is Synchronized
|
||||||
* @return a new Set that is synchronized
|
* @return a new Set that is synchronized
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import java.util.Comparator;
|
|||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
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);
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedSet that is Synchronized
|
* Creates a Wrapped SortedSet that is Synchronized
|
||||||
* @return a new SortedSet that is synchronized
|
* @return a new SortedSet that is synchronized
|
||||||
|
|||||||
+1655
-1621
File diff suppressed because it is too large
Load Diff
+187
-32
@@ -12,35 +12,81 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#else
|
#else
|
||||||
|
import java.util.function.IntFunction;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
#iterate
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
||||||
|
#argument PACKAGE booleans bytes shorts ints longs floats doubles
|
||||||
|
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
||||||
|
#if CHECK
|
||||||
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.BUILDER;
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.TASK;
|
import speiger.src.collections.PACKAGE.functions.TASK;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
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
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#if OBJECT_ASYNC_MODULE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
|
#endif
|
||||||
|
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
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT
|
#if !TYPE_INT && INT_ASYNC_MODULE
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,6 +159,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
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.
|
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
||||||
* @param values that should be wrapped
|
* @param values that should be wrapped
|
||||||
@@ -123,6 +170,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Maps the elements to something else
|
* Maps the elements to something else
|
||||||
* @param mapper the mapping function
|
* @param mapper the mapping function
|
||||||
@@ -154,6 +203,26 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#iterate
|
||||||
|
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
||||||
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
|
#argument TYPE Boolean Byte Short Int Long Float Double
|
||||||
|
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
||||||
|
#if CHECK
|
||||||
|
/**
|
||||||
|
* Maps the elements to something else
|
||||||
|
* @param mapper the mapping function
|
||||||
|
* @return a new Builder Object with the mapped Iterable
|
||||||
|
*/
|
||||||
|
public BUILDER mapToTYPE(MAPPER<T> mapper) {
|
||||||
|
return new BUILDER(ITERABLES.mapToTYPE(iterable, mapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#enditerate
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Filters out the unwanted elements out of the Iterable
|
* Filters out the unwanted elements out of the Iterable
|
||||||
* @param filter the elements that should be kept
|
* @param filter the elements that should be kept
|
||||||
@@ -214,6 +283,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Iterates over the Iterable with a desired action
|
* Iterates over the Iterable with a desired action
|
||||||
* @param action that should be applied
|
* @param action that should be applied
|
||||||
@@ -223,6 +293,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action));
|
return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Reduces the elements inside of the Iterable down to one element
|
* Reduces the elements inside of the Iterable down to one element
|
||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
@@ -257,23 +328,66 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Pours all elements of the Iterable down into a Array.
|
||||||
|
* @param action creates the final array that should be copied into.
|
||||||
|
* @return a new Builder with the ToArray function applied
|
||||||
|
*/
|
||||||
|
public ObjectAsyncBuilder<KEY_TYPE[]> TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
|
||||||
|
return new ObjectAsyncBuilder<>(new ArrayTaskBRACES(iterable, action));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Pours all elements of the Iterable down into a Array.
|
||||||
|
* @return a new Builder with the ToArray function applied
|
||||||
|
*/
|
||||||
|
public ObjectAsyncBuilder<KEY_TYPE[]> TO_ARRAY() {
|
||||||
|
return new ObjectAsyncBuilder<>(new ArrayTaskBRACES(iterable));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
/**
|
/**
|
||||||
* Pours all elements into a List that can be later
|
* Pours all elements into a List that can be later
|
||||||
* @return a new Builder with the pour function applied
|
* @return a new Builder with the pour function applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<LIST KEY_GENERIC_TYPE> pourAsList() {
|
public ObjectAsyncBuilder<LIST KEY_GENERIC_TYPE> pourAsList() {
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
return pour(new ARRAY_LISTBRACES());
|
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
|
* Pours all elements into a Set that can be later
|
||||||
* @return a new Builder with the pour function applied
|
* @return a new Builder with the pour function applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
|
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
|
||||||
|
#if LINKED_SET_FEATURE
|
||||||
return pour(new LINKED_HASH_SETBRACES());
|
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
|
#endif
|
||||||
/**
|
/**
|
||||||
* Pours all elements into a collection that can be later
|
* Pours all elements into a collection that can be later
|
||||||
@@ -285,6 +399,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection));
|
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.
|
* Searches through the elements of the Iterable to find if the desired element is present.
|
||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
@@ -312,6 +428,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2));
|
return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Searches through the elements of the Iterable to find if the desired element.
|
* 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
|
* If not present it will return the default value of the type
|
||||||
@@ -323,6 +440,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Counts all desired elements inside the Iterable
|
* Counts all desired elements inside the Iterable
|
||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
@@ -332,6 +450,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter));
|
return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Optional way to add a custom executor that runs this offthread task.
|
* Optional way to add a custom executor that runs this offthread task.
|
||||||
* Can only be set after the action was decided on.
|
* Can only be set after the action was decided on.
|
||||||
@@ -512,6 +631,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOLEAN_ASYNC_MODULE
|
||||||
private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask
|
private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -530,11 +650,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case 0:
|
case 0:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(true);
|
setResult(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -542,11 +658,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(false);
|
setResult(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -554,11 +666,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(!filter.test(iter.NEXT())) {
|
||||||
if(!filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(!filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(false);
|
setResult(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -580,6 +688,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -594,11 +703,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
protected boolean execute() throws Exception {
|
protected boolean execute() throws Exception {
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(entry);
|
setResult(entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -614,6 +719,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_ASYNC_MODULE
|
||||||
private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask
|
private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -628,7 +734,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
protected boolean execute() throws Exception {
|
protected boolean execute() throws Exception {
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) {
|
if(filter.test(iter.NEXT())) {
|
||||||
counted++;
|
counted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -648,6 +754,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
private static class CollectTask KSS_GENERIC_TYPE<V, T extends COLLECTION KEY_SPECIAL_GENERIC_TYPE<V>> extends BaseObjectTask<T>
|
private static class CollectTask KSS_GENERIC_TYPE<V, T extends COLLECTION KEY_SPECIAL_GENERIC_TYPE<V>> extends BaseObjectTask<T>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_SPECIAL_GENERIC_TYPE<V> iter;
|
ITERATOR KEY_SPECIAL_GENERIC_TYPE<V> iter;
|
||||||
@@ -678,6 +786,52 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ArrayTask KEY_GENERIC_TYPE extends BaseObjectTask<KEY_TYPE[]>
|
||||||
|
{
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
IntFunction<KEY_TYPE[]> builder;
|
||||||
|
|
||||||
|
public ArrayTask(ITERABLE KEY_GENERIC_TYPE iterable, IntFunction<KEY_TYPE[]> builder) {
|
||||||
|
this.builder = builder;
|
||||||
|
#else
|
||||||
|
|
||||||
|
public ArrayTask(ITERABLE KEY_GENERIC_TYPE iterable) {
|
||||||
|
#endif
|
||||||
|
iter = iterable.iterator();
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
int size = prov == null ? -1 : prov.size();
|
||||||
|
wrapper = size < 0 ? COLLECTIONS.wrapper() : COLLECTIONS.wrapper(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute() throws Exception {
|
||||||
|
while(shouldRun() && iter.hasNext()) {
|
||||||
|
wrapper.add(iter.NEXT());
|
||||||
|
}
|
||||||
|
if(!iter.hasNext()) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setResult(wrapper.TO_ARRAY(builder));
|
||||||
|
#else
|
||||||
|
setResult(wrapper.TO_ARRAY());
|
||||||
|
#endif
|
||||||
|
wrapper = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCompletion() {
|
||||||
|
super.onCompletion();
|
||||||
|
iter = null;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
builder = null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ForEachTask<T> extends BaseObjectTask<Void>
|
private static class ForEachTask<T> extends BaseObjectTask<Void>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -704,6 +858,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Base Task of the Actions that can be performed.
|
* Base Task of the Actions that can be performed.
|
||||||
* Allows to simplify the actions that get executed.
|
* Allows to simplify the actions that get executed.
|
||||||
|
|||||||
+1036
-438
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,9 @@ import speiger.src.collections.utils.IArray;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-Specific Helper class to get the underlying array of array implementations.
|
* Type-Specific Helper class to get the underlying array of array implementations.
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
||||||
|
#endif
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
||||||
|
|||||||
+678
-587
File diff suppressed because it is too large
Load Diff
+1262
-1117
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+13
@@ -5,18 +5,25 @@ import java.util.Collection;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +53,7 @@ public class PRIORITY_QUEUES
|
|||||||
return queue instanceof SynchronizedPriorityQueue ? (SynchronizedPriorityQueue KEY_GENERIC_TYPE)queue : new SynchronizedPriorityQueueBRACES(queue, mutex);
|
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.
|
* Returns a synchronized PriorityDequeue instance based on the instance given.
|
||||||
* @param dequeue that should be synchronized
|
* @param dequeue that should be synchronized
|
||||||
@@ -67,6 +75,7 @@ public class PRIORITY_QUEUES
|
|||||||
return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex);
|
return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Wrapper class for synchronization
|
* Wrapper class for synchronization
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -107,6 +116,8 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
||||||
@Override
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) { synchronized(mutex) { return queue.contains(e); } }
|
||||||
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
||||||
@@ -134,6 +145,7 @@ public class PRIORITY_QUEUES
|
|||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
/**
|
/**
|
||||||
* Wrapper class for synchronization
|
* Wrapper class for synchronization
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -166,4 +178,5 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } }
|
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } }
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,31 +2,30 @@ package speiger.src.collections.PACKAGE.utils;
|
|||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_OBJECT && SORTED_SET_FEATURE
|
||||||
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
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT && SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for sets
|
* A Helper class for sets
|
||||||
@@ -51,7 +50,6 @@ public class SETS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
/**
|
/**
|
||||||
* Creates a Synchronized set while preserving the ITrimmable interface
|
* Creates a Synchronized set while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @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));
|
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
|
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @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));
|
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
|
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @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));
|
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
|
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @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));
|
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable Set wrapper
|
* Creates Unmodifyable Set wrapper
|
||||||
* @param s set that should be made unmodifiable
|
* @param s set that should be made unmodifiable
|
||||||
@@ -154,6 +158,7 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
|
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable SortedSet wrapper
|
* Creates Unmodifyable SortedSet wrapper
|
||||||
* @param s sortedSet that should be made unmodifiable
|
* @param s sortedSet that should be made unmodifiable
|
||||||
@@ -164,6 +169,8 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable OrderedSet wrapper
|
* Creates Unmodifyable OrderedSet wrapper
|
||||||
* @param s OrderedSet that should be made unmodifiable
|
* @param s OrderedSet that should be made unmodifiable
|
||||||
@@ -174,6 +181,8 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable NavigableSet wrapper
|
* Creates Unmodifyable NavigableSet wrapper
|
||||||
* @param s navigableSet that should be made unmodifiable
|
* @param s navigableSet that should be made unmodifiable
|
||||||
@@ -254,7 +263,7 @@ public class SETS
|
|||||||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
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
|
private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE n;
|
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)); }
|
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
|
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ORDERED_SET KEY_GENERIC_TYPE s;
|
ORDERED_SET KEY_GENERIC_TYPE s;
|
||||||
@@ -373,6 +384,8 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
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
|
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
SORTED_SET KEY_GENERIC_TYPE s;
|
SORTED_SET KEY_GENERIC_TYPE s;
|
||||||
@@ -406,6 +419,7 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
|
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -434,6 +448,7 @@ public class SETS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
|
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -597,6 +612,8 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
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
|
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -656,6 +673,7 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
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
|
private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -704,5 +722,4 @@ public class SETS
|
|||||||
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
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
|
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -19,6 +21,17 @@ public interface STRATEGY KEY_GENERIC_TYPE
|
|||||||
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
|
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
|
||||||
|
|
||||||
#endif
|
#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
|
* Type Specific HashCode function
|
||||||
* @param o the element that the hashcode is requested for (if object may be null)
|
* @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
|
@Override
|
||||||
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
|
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1219
-1151
File diff suppressed because it is too large
Load Diff
+28
-28
@@ -1,28 +1,28 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueDequeueTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueDequeueTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueEnqueueTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueEnqueueTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueLastTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueLastTester;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends QUEUE_TEST_BUILDER KEY_GENERIC_TYPE
|
public class DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends QUEUE_TEST_BUILDER KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public static GENERIC_KEY_BRACES DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
public static GENERIC_KEY_BRACES DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||||
return (DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE)new DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
return (DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE)new DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> tester = super.getTesters();
|
List<Class<? extends AbstractTester>> tester = super.getTesters();
|
||||||
tester.add(FILE_KEY_TYPEDequeueDequeueTester.class);
|
tester.add(FILE_KEY_TYPEDequeueDequeueTester.class);
|
||||||
tester.add(FILE_KEY_TYPEDequeueEnqueueTester.class);
|
tester.add(FILE_KEY_TYPEDequeueEnqueueTester.class);
|
||||||
tester.add(FILE_KEY_TYPEDequeueLastTester.class);
|
tester.add(FILE_KEY_TYPEDequeueLastTester.class);
|
||||||
return tester;
|
return tester;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+384
-384
@@ -1,384 +1,384 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.ListTestSuiteBuilder;
|
import com.google.common.collect.testing.ListTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.SampleElements;
|
import com.google.common.collect.testing.SampleElements;
|
||||||
import com.google.common.collect.testing.TestListGenerator;
|
import com.google.common.collect.testing.TestListGenerator;
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||||
import com.google.common.collect.testing.testers.ListAddAllAtIndexTester;
|
import com.google.common.collect.testing.testers.ListAddAllAtIndexTester;
|
||||||
import com.google.common.collect.testing.testers.ListAddAllTester;
|
import com.google.common.collect.testing.testers.ListAddAllTester;
|
||||||
import com.google.common.collect.testing.testers.ListAddAtIndexTester;
|
import com.google.common.collect.testing.testers.ListAddAtIndexTester;
|
||||||
import com.google.common.collect.testing.testers.ListAddTester;
|
import com.google.common.collect.testing.testers.ListAddTester;
|
||||||
import com.google.common.collect.testing.testers.ListCreationTester;
|
import com.google.common.collect.testing.testers.ListCreationTester;
|
||||||
import com.google.common.collect.testing.testers.ListEqualsTester;
|
import com.google.common.collect.testing.testers.ListEqualsTester;
|
||||||
import com.google.common.collect.testing.testers.ListGetTester;
|
import com.google.common.collect.testing.testers.ListGetTester;
|
||||||
import com.google.common.collect.testing.testers.ListHashCodeTester;
|
import com.google.common.collect.testing.testers.ListHashCodeTester;
|
||||||
import com.google.common.collect.testing.testers.ListIndexOfTester;
|
import com.google.common.collect.testing.testers.ListIndexOfTester;
|
||||||
import com.google.common.collect.testing.testers.ListLastIndexOfTester;
|
import com.google.common.collect.testing.testers.ListLastIndexOfTester;
|
||||||
import com.google.common.collect.testing.testers.ListRemoveAllTester;
|
import com.google.common.collect.testing.testers.ListRemoveAllTester;
|
||||||
import com.google.common.collect.testing.testers.ListRemoveAtIndexTester;
|
import com.google.common.collect.testing.testers.ListRemoveAtIndexTester;
|
||||||
import com.google.common.collect.testing.testers.ListRemoveTester;
|
import com.google.common.collect.testing.testers.ListRemoveTester;
|
||||||
import com.google.common.collect.testing.testers.ListReplaceAllTester;
|
import com.google.common.collect.testing.testers.ListReplaceAllTester;
|
||||||
import com.google.common.collect.testing.testers.ListRetainAllTester;
|
import com.google.common.collect.testing.testers.ListRetainAllTester;
|
||||||
import com.google.common.collect.testing.testers.ListSetTester;
|
import com.google.common.collect.testing.testers.ListSetTester;
|
||||||
import com.google.common.collect.testing.testers.ListSubListTester;
|
import com.google.common.collect.testing.testers.ListSubListTester;
|
||||||
import com.google.common.collect.testing.testers.ListToArrayTester;
|
import com.google.common.collect.testing.testers.ListToArrayTester;
|
||||||
import com.google.common.testing.SerializableTester;
|
import com.google.common.testing.SerializableTester;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
import speiger.src.testers.base.tests.list.JavaListListIteratorTester;
|
import speiger.src.testers.base.tests.list.JavaListListIteratorTester;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAbsentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllArrayAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllArrayAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllListAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllListAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAllTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListAddTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListCreationTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListCreationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListEqualsTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListEqualsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListExtractElementsTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListExtractElementsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetElementsTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetElementsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListGetTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListIndexOfTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListIndexOfTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListLastIndexOfTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListLastIndexOfTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListListIteratorTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListListIteratorTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListPresentTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListPresentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAllTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAllTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveElementsTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveElementsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRemoveTester;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSortTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSortTester;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListFillBufferTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListFillBufferTester;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListReplaceAllTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListReplaceAllTester;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRetainAllTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListRetainAllTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSetTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSetTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSubListTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSubListTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveAtIndexTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveAtIndexTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSwapRemoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListToArrayTester;
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListToArrayTester;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class LIST_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class LIST_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
KEY_TYPE[] prefixes;
|
KEY_TYPE[] prefixes;
|
||||||
KEY_TYPE[] suffixes;
|
KEY_TYPE[] suffixes;
|
||||||
#else
|
#else
|
||||||
KEY_TYPE[] prefixes = createPrefixes();
|
KEY_TYPE[] prefixes = createPrefixes();
|
||||||
KEY_TYPE[] suffixes = createSuffixes();
|
KEY_TYPE[] suffixes = createSuffixes();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public static GENERIC_KEY_BRACES LIST_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_BRACES LIST_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return (LIST_TEST_BUILDER KEY_GENERIC_TYPE) new LIST_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
return (LIST_TEST_BUILDER KEY_GENERIC_TYPE) new LIST_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setPrefixes(KEY_TYPE[] prefixes) {
|
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setPrefixes(KEY_TYPE[] prefixes) {
|
||||||
this.prefixes = prefixes;
|
this.prefixes = prefixes;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setSuffixes(KEY_TYPE[] suffixes) {
|
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setSuffixes(KEY_TYPE[] suffixes) {
|
||||||
this.suffixes = suffixes;
|
this.suffixes = suffixes;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
public KEY_TYPE[] createPrefixes() {
|
public KEY_TYPE[] createPrefixes() {
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
return new KEY_TYPE[]{false, false, false};
|
return new KEY_TYPE[]{false, false, false};
|
||||||
#else if TYPE_BYTE
|
#else if TYPE_BYTE
|
||||||
return new KEY_TYPE[]{(byte)-3, (byte)-2, (byte)-1};
|
return new KEY_TYPE[]{(byte)-3, (byte)-2, (byte)-1};
|
||||||
#else if TYPE_SHORT
|
#else if TYPE_SHORT
|
||||||
return new KEY_TYPE[]{(short)-3, (short)-2, (short)-1};
|
return new KEY_TYPE[]{(short)-3, (short)-2, (short)-1};
|
||||||
#else if TYPE_CHAR
|
#else if TYPE_CHAR
|
||||||
return new KEY_TYPE[]{'^', '_', '`'};
|
return new KEY_TYPE[]{'^', '_', '`'};
|
||||||
#else
|
#else
|
||||||
return new KEY_TYPE[]{-3, -2, -1};
|
return new KEY_TYPE[]{-3, -2, -1};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public KEY_TYPE[] createSuffixes() {
|
public KEY_TYPE[] createSuffixes() {
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
return new KEY_TYPE[]{true, true, true};
|
return new KEY_TYPE[]{true, true, true};
|
||||||
#else if TYPE_BYTE
|
#else if TYPE_BYTE
|
||||||
return new KEY_TYPE[]{(byte)5, (byte)6, (byte)7};
|
return new KEY_TYPE[]{(byte)5, (byte)6, (byte)7};
|
||||||
#else if TYPE_SHORT
|
#else if TYPE_SHORT
|
||||||
return new KEY_TYPE[]{(short)5, (short)6, (short)7};
|
return new KEY_TYPE[]{(short)5, (short)6, (short)7};
|
||||||
#else if TYPE_CHAR
|
#else if TYPE_CHAR
|
||||||
return new KEY_TYPE[]{'f', 'g', 'h'};
|
return new KEY_TYPE[]{'f', 'g', 'h'};
|
||||||
#else
|
#else
|
||||||
return new KEY_TYPE[]{5, 6, 7};
|
return new KEY_TYPE[]{5, 6, 7};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
|
||||||
testers.add(CollectionSerializationEqualTester.class);
|
testers.add(CollectionSerializationEqualTester.class);
|
||||||
testers.add(ListAddAllAtIndexTester.class);
|
testers.add(ListAddAllAtIndexTester.class);
|
||||||
testers.add(ListAddAllTester.class);
|
testers.add(ListAddAllTester.class);
|
||||||
testers.add(ListAddAtIndexTester.class);
|
testers.add(ListAddAtIndexTester.class);
|
||||||
testers.add(ListAddTester.class);
|
testers.add(ListAddTester.class);
|
||||||
testers.add(ListCreationTester.class);
|
testers.add(ListCreationTester.class);
|
||||||
testers.add(ListEqualsTester.class);
|
testers.add(ListEqualsTester.class);
|
||||||
testers.add(ListGetTester.class);
|
testers.add(ListGetTester.class);
|
||||||
testers.add(ListHashCodeTester.class);
|
testers.add(ListHashCodeTester.class);
|
||||||
testers.add(ListIndexOfTester.class);
|
testers.add(ListIndexOfTester.class);
|
||||||
testers.add(ListLastIndexOfTester.class);
|
testers.add(ListLastIndexOfTester.class);
|
||||||
testers.add(JavaListListIteratorTester.class);
|
testers.add(JavaListListIteratorTester.class);
|
||||||
testers.add(ListRemoveAllTester.class);
|
testers.add(ListRemoveAllTester.class);
|
||||||
testers.add(ListRemoveAtIndexTester.class);
|
testers.add(ListRemoveAtIndexTester.class);
|
||||||
testers.add(ListRemoveTester.class);
|
testers.add(ListRemoveTester.class);
|
||||||
testers.add(ListReplaceAllTester.class);
|
testers.add(ListReplaceAllTester.class);
|
||||||
testers.add(ListRetainAllTester.class);
|
testers.add(ListRetainAllTester.class);
|
||||||
testers.add(ListSetTester.class);
|
testers.add(ListSetTester.class);
|
||||||
testers.add(ListSubListTester.class);
|
testers.add(ListSubListTester.class);
|
||||||
testers.add(ListToArrayTester.class);
|
testers.add(ListToArrayTester.class);
|
||||||
|
|
||||||
testers.add(FILE_KEY_TYPEListAddAllAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListAddAllAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAddAllListAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListAddAllListAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAddAllArrayAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListAddAllArrayAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAddAllTester.class);
|
testers.add(FILE_KEY_TYPEListAddAllTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAddAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListAddAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAddTester.class);
|
testers.add(FILE_KEY_TYPEListAddTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListAbsentTester.class);
|
testers.add(FILE_KEY_TYPEListAbsentTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListPresentTester.class);
|
testers.add(FILE_KEY_TYPEListPresentTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListCreationTester.class);
|
testers.add(FILE_KEY_TYPEListCreationTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListEqualsTester.class);
|
testers.add(FILE_KEY_TYPEListEqualsTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListGetTester.class);
|
testers.add(FILE_KEY_TYPEListGetTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListGetElementsTester.class);
|
testers.add(FILE_KEY_TYPEListGetElementsTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListExtractElementsTester.class);
|
testers.add(FILE_KEY_TYPEListExtractElementsTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListIndexOfTester.class);
|
testers.add(FILE_KEY_TYPEListIndexOfTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListLastIndexOfTester.class);
|
testers.add(FILE_KEY_TYPEListLastIndexOfTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListListIteratorTester.class);
|
testers.add(FILE_KEY_TYPEListListIteratorTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListRemoveAllTester.class);
|
testers.add(FILE_KEY_TYPEListRemoveAllTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListRemoveAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListRemoveAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListRemoveTester.class);
|
testers.add(FILE_KEY_TYPEListRemoveTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListRemoveElementsTester.class);
|
testers.add(FILE_KEY_TYPEListRemoveElementsTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListSwapRemoveAtIndexTester.class);
|
testers.add(FILE_KEY_TYPEListSwapRemoveAtIndexTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListSwapRemoveTester.class);
|
testers.add(FILE_KEY_TYPEListSwapRemoveTester.class);
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
testers.add(FILE_KEY_TYPEListSortTester.class);
|
testers.add(FILE_KEY_TYPEListSortTester.class);
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
testers.add(FILE_KEY_TYPEListFillBufferTester.class);
|
testers.add(FILE_KEY_TYPEListFillBufferTester.class);
|
||||||
#endif
|
#endif
|
||||||
testers.add(FILE_KEY_TYPEListReplaceAllTester.class);
|
testers.add(FILE_KEY_TYPEListReplaceAllTester.class);
|
||||||
#endif
|
#endif
|
||||||
testers.add(FILE_KEY_TYPEListRetainAllTester.class);
|
testers.add(FILE_KEY_TYPEListRetainAllTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListSetTester.class);
|
testers.add(FILE_KEY_TYPEListSetTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListSubListTester.class);
|
testers.add(FILE_KEY_TYPEListSubListTester.class);
|
||||||
testers.add(FILE_KEY_TYPEListToArrayTester.class);
|
testers.add(FILE_KEY_TYPEListToArrayTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestSuite createTestSuite() {
|
public TestSuite createTestSuite() {
|
||||||
#ignore
|
#ignore
|
||||||
withFeatures(KNOWN_ORDER);
|
withFeatures(KNOWN_ORDER);
|
||||||
#endignore
|
#endignore
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
#ignore
|
#ignore
|
||||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||||
#endignore
|
#endignore
|
||||||
derivedSuites.add(ListTestSuiteBuilder.using(new ReserializedListGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
derivedSuites.add(ListTestSuiteBuilder.using(new ReserializedListGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||||
.named(getName() + " reserialized")
|
.named(getName() + " reserialized")
|
||||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
}
|
||||||
#ignore
|
#ignore
|
||||||
if(!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
if(!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||||
#endignore
|
#endignore
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
if(prefixes != null) {
|
if(prefixes != null) {
|
||||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, null))
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, null))
|
||||||
.named(getName() + " subSet_prefix")
|
.named(getName() + " subSet_prefix")
|
||||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
}
|
||||||
if(suffixes != null) {
|
if(suffixes != null) {
|
||||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), null, suffixes))
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), null, suffixes))
|
||||||
.named(getName() + " subSet_suffixes")
|
.named(getName() + " subSet_suffixes")
|
||||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
}
|
||||||
if(prefixes != null && suffixes != null) {
|
if(prefixes != null && suffixes != null) {
|
||||||
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, suffixes))
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, suffixes))
|
||||||
.named(getName() + " subSet")
|
.named(getName() + " subSet")
|
||||||
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class SubListListGenerator KEY_GENERIC_TYPE implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE {
|
static class SubListListGenerator KEY_GENERIC_TYPE implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE {
|
||||||
TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator;
|
TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator;
|
||||||
KEY_TYPE[] prefix;
|
KEY_TYPE[] prefix;
|
||||||
KEY_TYPE[] suffix;
|
KEY_TYPE[] suffix;
|
||||||
|
|
||||||
public SubListListGenerator(OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE> gen, KEY_TYPE[] prefix, KEY_TYPE[] suffix) {
|
public SubListListGenerator(OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE> gen, KEY_TYPE[] prefix, KEY_TYPE[] suffix) {
|
||||||
generator = (TEST_LIST_GENERATOR KEY_GENERIC_TYPE)gen.getInnerGenerator();
|
generator = (TEST_LIST_GENERATOR KEY_GENERIC_TYPE)gen.getInnerGenerator();
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.suffix = suffix;
|
this.suffix = suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SampleElements<CLASS_TYPE> samples() {
|
public SampleElements<CLASS_TYPE> samples() {
|
||||||
return generator.samples();
|
return generator.samples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CLASS_TYPE[] createArray(int length) {
|
public CLASS_TYPE[] createArray(int length) {
|
||||||
return generator.createArray(length);
|
return generator.createArray(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
return generator.order(insertionOrder);
|
return generator.order(insertionOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
return generator.getSamples();
|
return generator.getSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
return generator.order(insertionOrder);
|
return generator.order(insertionOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Object e : elements) {
|
for (Object e : elements) {
|
||||||
array[i++] = CLASS_TO_KEY(e);
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
}
|
}
|
||||||
return create(array);
|
return create(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
public LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
int length = getLength(prefix);
|
int length = getLength(prefix);
|
||||||
return generator.create(merge(elements)).subList(length, length+elements.length);
|
return generator.create(merge(elements)).subList(length, length+elements.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Object e : elements) {
|
for (Object e : elements) {
|
||||||
array[i++] = CLASS_TO_KEY(e);
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
}
|
}
|
||||||
int length = getLength(prefix);
|
int length = getLength(prefix);
|
||||||
return generator.create(merge(array)).subList(length, length+elements.length);
|
return generator.create(merge(array)).subList(length, length+elements.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private int getLength(KEY_TYPE[] keys) {
|
private int getLength(KEY_TYPE[] keys) {
|
||||||
return keys == null ? 0 : keys.length;
|
return keys == null ? 0 : keys.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private KEY_TYPE[] merge(KEY_TYPE[] input) {
|
private KEY_TYPE[] merge(KEY_TYPE[] input) {
|
||||||
int prefixLength = getLength(prefix);
|
int prefixLength = getLength(prefix);
|
||||||
int suffixLength = getLength(suffix);
|
int suffixLength = getLength(suffix);
|
||||||
KEY_TYPE[] result = NEW_KEY_ARRAY(input.length+prefixLength+suffixLength);
|
KEY_TYPE[] result = NEW_KEY_ARRAY(input.length+prefixLength+suffixLength);
|
||||||
if(prefixLength != 0) System.arraycopy(prefix, 0, result, 0, prefixLength);
|
if(prefixLength != 0) System.arraycopy(prefix, 0, result, 0, prefixLength);
|
||||||
System.arraycopy(input, 0, result, prefixLength, input.length);
|
System.arraycopy(input, 0, result, prefixLength, input.length);
|
||||||
if(suffixLength != 0) System.arraycopy(suffix, 0, result, prefixLength+input.length, suffixLength);
|
if(suffixLength != 0) System.arraycopy(suffix, 0, result, prefixLength+input.length, suffixLength);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ReserializedListGenerator<E> implements TestListGenerator<E> {
|
static class ReserializedListGenerator<E> implements TestListGenerator<E> {
|
||||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||||
|
|
||||||
private ReserializedListGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
private ReserializedListGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SampleElements<E> samples() {
|
public SampleElements<E> samples() {
|
||||||
return gen.samples();
|
return gen.samples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<E> create(Object... elements) {
|
public List<E> create(Object... elements) {
|
||||||
return (List<E>) SerializableTester.reserialize(gen.create(elements));
|
return (List<E>) SerializableTester.reserialize(gen.create(elements));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E[] createArray(int length) {
|
public E[] createArray(int length) {
|
||||||
return gen.createArray(length);
|
return gen.createArray(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<E> order(List<E> insertionOrder) {
|
public Iterable<E> order(List<E> insertionOrder) {
|
||||||
return gen.order(insertionOrder);
|
return gen.order(insertionOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
private static Set<Feature<?>> computeSubListFeatures(Set<Feature<?>> features) {
|
private static Set<Feature<?>> computeSubListFeatures(Set<Feature<?>> features) {
|
||||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
#ignore
|
#ignore
|
||||||
derivedFeatures.add(CollectionFeature.SUBSET_VIEW);
|
derivedFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||||
derivedFeatures.remove(SpecialFeature.COPYING);
|
derivedFeatures.remove(SpecialFeature.COPYING);
|
||||||
derivedFeatures.remove(SpecialFeature.CHILDREN_COPY);
|
derivedFeatures.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
#endignore
|
#endignore
|
||||||
return derivedFeatures;
|
return derivedFeatures;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
#ignore
|
#ignore
|
||||||
derivedFeatures.remove(SERIALIZABLE);
|
derivedFeatures.remove(SERIALIZABLE);
|
||||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||||
#endignore
|
#endignore
|
||||||
return derivedFeatures;
|
return derivedFeatures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+140
-140
@@ -1,140 +1,140 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.DESCENDING_VIEW;
|
import static com.google.common.collect.testing.features.CollectionFeature.DESCENDING_VIEW;
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.SUBSET_VIEW;
|
import static com.google.common.collect.testing.features.CollectionFeature.SUBSET_VIEW;
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.SampleElements;
|
import com.google.common.collect.testing.SampleElements;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
import com.google.common.collect.testing.testers.NavigableSetNavigationTester;
|
import com.google.common.collect.testing.testers.NavigableSetNavigationTester;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR.SUB_NAVIGABLE_SET_CLASS_GENERATOR;
|
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR.SUB_NAVIGABLE_SET_CLASS_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPENavigableSetNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPENavigableSetNavigationTester;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
public static GENERIC_KEY_BRACES NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_BRACES NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return (NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE) new NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
return (NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE) new NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
testers.add(NavigableSetNavigationTester.class);
|
testers.add(NavigableSetNavigationTester.class);
|
||||||
testers.add(FILE_KEY_TYPENavigableSetNavigationTester.class);
|
testers.add(FILE_KEY_TYPENavigableSetNavigationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
|
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
|
||||||
#endignore
|
#endignore
|
||||||
// Other combinations are inherited from SortedSetTestSuiteBuilder.
|
// Other combinations are inherited from SortedSetTestSuiteBuilder.
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||||
}
|
}
|
||||||
#ignore
|
#ignore
|
||||||
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
|
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
|
||||||
#endignore
|
#endignore
|
||||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||||
}
|
}
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
return NAVIGABLE_SET_TEST_BUILDER.using(new SUB_NAVIGABLE_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
return NAVIGABLE_SET_TEST_BUILDER.using(new SUB_NAVIGABLE_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||||
|
|
||||||
List<Feature<?>> features = new ArrayList<>();
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
#ignore
|
#ignore
|
||||||
features.add(DESCENDING_VIEW);
|
features.add(DESCENDING_VIEW);
|
||||||
features.addAll(parentBuilder.getFeatures());
|
features.addAll(parentBuilder.getFeatures());
|
||||||
features.remove(SpecialFeature.COPYING);
|
features.remove(SpecialFeature.COPYING);
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
return NAVIGABLE_SET_TEST_BUILDER.using(new TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE() {
|
return NAVIGABLE_SET_TEST_BUILDER.using(new TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SampleElements<CLASS_TYPE> samples() {
|
public SampleElements<CLASS_TYPE> samples() {
|
||||||
return delegate.samples();
|
return delegate.samples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
return delegate.getSamples();
|
return delegate.getSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
delegate.order(insertionOrder).forEach(list::add);
|
delegate.order(insertionOrder).forEach(list::add);
|
||||||
LISTS.reverse(list);
|
LISTS.reverse(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
for(CLASS_TYPE entry : delegate.order(insertionOrder))
|
for(CLASS_TYPE entry : delegate.order(insertionOrder))
|
||||||
{
|
{
|
||||||
list.add(OBJ_TO_KEY(entry));
|
list.add(OBJ_TO_KEY(entry));
|
||||||
}
|
}
|
||||||
LISTS.reverse(list);
|
LISTS.reverse(list);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return delegate.aboveSamplesGreater(); }
|
public KEY_TYPE belowSamplesLesser() { return delegate.aboveSamplesGreater(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return delegate.aboveSamplesLesser(); }
|
public KEY_TYPE belowSamplesGreater() { return delegate.aboveSamplesLesser(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return delegate.belowSamplesGreater(); }
|
public KEY_TYPE aboveSamplesLesser() { return delegate.belowSamplesGreater(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return delegate.belowSamplesLesser(); }
|
public KEY_TYPE aboveSamplesGreater() { return delegate.belowSamplesLesser(); }
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
return delegate.create(elements).descendingSet();
|
return delegate.create(elements).descendingSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
return delegate.create(elements).descendingSet();
|
return delegate.create(elements).descendingSet();
|
||||||
}
|
}
|
||||||
}).named(parentBuilder.getName() + " descending").withFeatures(features)
|
}).named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-38
@@ -1,38 +1,38 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
public static GENERIC_KEY_BRACES ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_BRACES ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return (ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
return (ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
testers.add(FILE_KEY_TYPEOrderedSetNavigationTester.class);
|
testers.add(FILE_KEY_TYPEOrderedSetNavigationTester.class);
|
||||||
testers.add(FILE_KEY_TYPEOrderedSetMoveTester.class);
|
testers.add(FILE_KEY_TYPEOrderedSetMoveTester.class);
|
||||||
testers.add(FILE_KEY_TYPEOrderedSetIterationTester.class);
|
testers.add(FILE_KEY_TYPEOrderedSetIterationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestSuite createTestSuite() {
|
public TestSuite createTestSuite() {
|
||||||
#ignore
|
#ignore
|
||||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||||
#endignore
|
#endignore
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-60
@@ -1,60 +1,60 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
|
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueDequeueTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueDequeueTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueEnqueueTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueEnqueueTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueFirstTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueFirstTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueRemoveTester;
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEQueueRemoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueCountTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueCountTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueDistinctTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueDistinctTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFilterTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFilterTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFindFirstTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueFindFirstTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueLimitTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueLimitTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMapTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMapTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMatchesTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueMatchesTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueuePeekTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueuePeekTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueForEachTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueForEachTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueReduceTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueReduceTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueSortedTester;
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueSortedTester;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class QUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends PerCollectionSizeTestSuiteBuilder<QUEUE_TEST_BUILDER KEY_GENERIC_TYPE, TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE, PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
public class QUEUE_TEST_BUILDER KEY_GENERIC_TYPE extends PerCollectionSizeTestSuiteBuilder<QUEUE_TEST_BUILDER KEY_GENERIC_TYPE, TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE, PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||||
{
|
{
|
||||||
public static GENERIC_KEY_BRACES QUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
public static GENERIC_KEY_BRACES QUEUE_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE builder) {
|
||||||
return new QUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
return new QUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters()
|
protected List<Class<? extends AbstractTester>> getTesters()
|
||||||
{
|
{
|
||||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
testers.add(FILE_KEY_TYPEQueueEnqueueTester.class);
|
testers.add(FILE_KEY_TYPEQueueEnqueueTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueRemoveTester.class);
|
testers.add(FILE_KEY_TYPEQueueRemoveTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueDistinctTester.class);
|
testers.add(FILE_KEY_TYPEQueueDistinctTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueFilterTester.class);
|
testers.add(FILE_KEY_TYPEQueueFilterTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueFindFirstTester.class);
|
testers.add(FILE_KEY_TYPEQueueFindFirstTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueLimitTester.class);
|
testers.add(FILE_KEY_TYPEQueueLimitTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueMapTester.class);
|
testers.add(FILE_KEY_TYPEQueueMapTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueMatchesTester.class);
|
testers.add(FILE_KEY_TYPEQueueMatchesTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueuePeekTester.class);
|
testers.add(FILE_KEY_TYPEQueuePeekTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueForEachTester.class);
|
testers.add(FILE_KEY_TYPEQueueForEachTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueReduceTester.class);
|
testers.add(FILE_KEY_TYPEQueueReduceTester.class);
|
||||||
testers.add(FILE_KEY_TYPEQueueSortedTester.class);
|
testers.add(FILE_KEY_TYPEQueueSortedTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+116
-116
@@ -1,116 +1,116 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.SampleElements;
|
import com.google.common.collect.testing.SampleElements;
|
||||||
import com.google.common.collect.testing.SetTestSuiteBuilder;
|
import com.google.common.collect.testing.SetTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.TestSetGenerator;
|
import com.google.common.collect.testing.TestSetGenerator;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||||
import com.google.common.collect.testing.testers.SetAddAllTester;
|
import com.google.common.collect.testing.testers.SetAddAllTester;
|
||||||
import com.google.common.collect.testing.testers.SetAddTester;
|
import com.google.common.collect.testing.testers.SetAddTester;
|
||||||
import com.google.common.collect.testing.testers.SetCreationTester;
|
import com.google.common.collect.testing.testers.SetCreationTester;
|
||||||
import com.google.common.collect.testing.testers.SetEqualsTester;
|
import com.google.common.collect.testing.testers.SetEqualsTester;
|
||||||
import com.google.common.collect.testing.testers.SetHashCodeTester;
|
import com.google.common.collect.testing.testers.SetHashCodeTester;
|
||||||
import com.google.common.collect.testing.testers.SetRemoveTester;
|
import com.google.common.collect.testing.testers.SetRemoveTester;
|
||||||
import com.google.common.testing.SerializableTester;
|
import com.google.common.testing.SerializableTester;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddAllTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddAllTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetAddTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetCreationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetCreationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetEqualsTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetEqualsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetRemoveTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESetRemoveTester;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SET_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class SET_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
public static GENERIC_KEY_BRACES SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_BRACES SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return (SET_TEST_BUILDER KEY_GENERIC_TYPE) new SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
return (SET_TEST_BUILDER KEY_GENERIC_TYPE) new SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
testers.add(CollectionSerializationEqualTester.class);
|
testers.add(CollectionSerializationEqualTester.class);
|
||||||
testers.add(SetAddAllTester.class);
|
testers.add(SetAddAllTester.class);
|
||||||
testers.add(SetAddTester.class);
|
testers.add(SetAddTester.class);
|
||||||
testers.add(SetCreationTester.class);
|
testers.add(SetCreationTester.class);
|
||||||
testers.add(SetHashCodeTester.class);
|
testers.add(SetHashCodeTester.class);
|
||||||
testers.add(SetEqualsTester.class);
|
testers.add(SetEqualsTester.class);
|
||||||
testers.add(SetRemoveTester.class);
|
testers.add(SetRemoveTester.class);
|
||||||
|
|
||||||
testers.add(FILE_KEY_TYPESetAddAllTester.class);
|
testers.add(FILE_KEY_TYPESetAddAllTester.class);
|
||||||
testers.add(FILE_KEY_TYPESetAddTester.class);
|
testers.add(FILE_KEY_TYPESetAddTester.class);
|
||||||
testers.add(FILE_KEY_TYPESetCreationTester.class);
|
testers.add(FILE_KEY_TYPESetCreationTester.class);
|
||||||
testers.add(FILE_KEY_TYPESetEqualsTester.class);
|
testers.add(FILE_KEY_TYPESetEqualsTester.class);
|
||||||
testers.add(FILE_KEY_TYPESetRemoveTester.class);
|
testers.add(FILE_KEY_TYPESetRemoveTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(
|
protected List<TestSuite> createDerivedSuites(
|
||||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
|
|
||||||
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||||
derivedSuites.add(SetTestSuiteBuilder.using(new ReserializedSetGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
derivedSuites.add(SetTestSuiteBuilder.using(new ReserializedSetGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||||
.named(getName() + " reserialized")
|
.named(getName() + " reserialized")
|
||||||
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
}
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
|
static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
|
||||||
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||||
|
|
||||||
private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SampleElements<E> samples() {
|
public SampleElements<E> samples() {
|
||||||
return gen.samples();
|
return gen.samples();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<E> create(Object... elements) {
|
public Set<E> create(Object... elements) {
|
||||||
return (Set<E>) SerializableTester.reserialize(gen.create(elements));
|
return (Set<E>) SerializableTester.reserialize(gen.create(elements));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E[] createArray(int length) {
|
public E[] createArray(int length) {
|
||||||
return gen.createArray(length);
|
return gen.createArray(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<E> order(List<E> insertionOrder) {
|
public Iterable<E> order(List<E> insertionOrder) {
|
||||||
return gen.order(insertionOrder);
|
return gen.order(insertionOrder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||||
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
#ignore
|
#ignore
|
||||||
derivedFeatures.remove(SERIALIZABLE);
|
derivedFeatures.remove(SERIALIZABLE);
|
||||||
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||||
#endignore
|
#endignore
|
||||||
return derivedFeatures;
|
return derivedFeatures;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+88
-88
@@ -1,88 +1,88 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
import com.google.common.collect.testing.testers.SortedSetNavigationTester;
|
import com.google.common.collect.testing.testers.SortedSetNavigationTester;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR;
|
import speiger.src.testers.PACKAGE.impl.SUB_SORTED_SET_CLASS_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetIterationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetIterationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetNaviationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetNaviationTester;
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
public static GENERIC_KEY_BRACES SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_BRACES SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return (SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
return (SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
testers.add(SortedSetNavigationTester.class);
|
testers.add(SortedSetNavigationTester.class);
|
||||||
testers.add(FILE_KEY_TYPESortedSetIterationTester.class);
|
testers.add(FILE_KEY_TYPESortedSetIterationTester.class);
|
||||||
testers.add(FILE_KEY_TYPESortedSetNaviationTester.class);
|
testers.add(FILE_KEY_TYPESortedSetNaviationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestSuite createTestSuite() {
|
public TestSuite createTestSuite() {
|
||||||
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
|
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
|
||||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||||
#ignore
|
#ignore
|
||||||
features.add(CollectionFeature.KNOWN_ORDER);
|
features.add(CollectionFeature.KNOWN_ORDER);
|
||||||
#endignore
|
#endignore
|
||||||
withFeatures(features);
|
withFeatures(features);
|
||||||
}
|
}
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(
|
protected List<TestSuite> createDerivedSuites(
|
||||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||||
#endignore
|
#endignore
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||||
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||||
}
|
}
|
||||||
|
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
final TestSuite createSubsetSuite(
|
final TestSuite createSubsetSuite(
|
||||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder,
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder,
|
||||||
Bound from, Bound to) {
|
Bound from, Bound to) {
|
||||||
TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||||
|
|
||||||
List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
|
List<Feature<?>> features = new ArrayList<>(parentBuilder.getFeatures());
|
||||||
#ignore
|
#ignore
|
||||||
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
|
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
features.add(CollectionFeature.SUBSET_VIEW);
|
features.add(CollectionFeature.SUBSET_VIEW);
|
||||||
features.remove(SpecialFeature.COPYING);
|
features.remove(SpecialFeature.COPYING);
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subSet " + from + "-" + to)
|
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subSet " + from + "-" + to)
|
||||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE newBuilderUsing(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
return using(new SUB_SORTED_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
return using(new SUB_SORTED_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+317
-303
@@ -1,304 +1,318 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder.maps;
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.MapTestSuiteBuilder;
|
import com.google.common.collect.testing.MapTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
import com.google.common.collect.testing.testers.CollectionIteratorTester;
|
import com.google.common.collect.testing.testers.CollectionIteratorTester;
|
||||||
#if VALUE_BOOLEAN
|
#if VALUE_BOOLEAN
|
||||||
import com.google.common.collect.testing.testers.CollectionRemoveTester;
|
import com.google.common.collect.testing.testers.CollectionRemoveTester;
|
||||||
import com.google.common.collect.testing.testers.CollectionRetainAllTester;
|
import com.google.common.collect.testing.testers.CollectionRetainAllTester;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.testers.VALUE_PACKAGE.builder.VALUE_COLLECTION_TEST_BUILDER;
|
import speiger.src.testers.VALUE_PACKAGE.builder.VALUE_COLLECTION_TEST_BUILDER;
|
||||||
import speiger.src.testers.VALUE_PACKAGE.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
import speiger.src.testers.VALUE_PACKAGE.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||||
#if TYPE_CHAR || TYPE_FLOAT || TYPE_DOUBLE
|
#if TYPE_CHAR || TYPE_FLOAT || TYPE_DOUBLE
|
||||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||||
#if !SAME_TYPE && !VALUE_OBJECT
|
#if !SAME_TYPE && !VALUE_OBJECT
|
||||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
#endif
|
#endif
|
||||||
#else if TYPE_OBJECT && !VALUE_OBJECT
|
#else if TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_PRIMITIVES
|
#if VALUE_PRIMITIVES
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester;
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_BOOLEAN
|
#if VALUE_BOOLEAN
|
||||||
#if !TYPE_CHAR && !TYPE_FLOAT && !TYPE_DOUBLE && !TYPE_OBJECT
|
#if !TYPE_CHAR && !TYPE_FLOAT && !TYPE_DOUBLE && !TYPE_OBJECT
|
||||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRemoveAllTester;
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRemoveAllTester;
|
||||||
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRetainAllTester;
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRetainAllTester;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester;
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester;
|
||||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester;
|
||||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionIteratorTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRemoveAllTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||||
import speiger.src.testers.objects.tests.collection.ObjectCollectionRetainAllTester;
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester;
|
||||||
import speiger.src.testers.utils.TestUtils;
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||||
@SuppressWarnings("javadoc")
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
boolean shouldBlockKeys;
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionIteratorTester;
|
||||||
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionRemoveAllTester;
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionRetainAllTester;
|
||||||
return (MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
}
|
import speiger.src.testers.utils.TestUtils;
|
||||||
|
|
||||||
public MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE shouldBlockKeys(boolean value) {
|
@SuppressWarnings("javadoc")
|
||||||
shouldBlockKeys = value;
|
public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||||
return this;
|
boolean shouldBlockKeys;
|
||||||
}
|
|
||||||
|
public static GENERIC_KEY_VALUE_BRACES MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||||
@Override
|
return (MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
@SuppressWarnings("rawtypes")
|
}
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
|
||||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
public MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE shouldBlockKeys(boolean value) {
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
shouldBlockKeys = value;
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
return this;
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
}
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester.class);
|
@Override
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester.class);
|
@SuppressWarnings("rawtypes")
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester.class);
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester.class);
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester.class);
|
#if !VALUE_OBJECT
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester.class);
|
#endif
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester.class);
|
||||||
#if VALUE_PRIMITIVES
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester.class);
|
||||||
#endif
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester.class);
|
#if VALUE_PRIMITIVES
|
||||||
return testers;
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester.class);
|
||||||
}
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester.class);
|
||||||
|
#endif
|
||||||
@Override
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester.class);
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester.class);
|
||||||
List<TestSuite> derivedSuites = new ArrayList<>();
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester.class);
|
||||||
derivedSuites.add(createDerivedEntrySetSuite(
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester.class);
|
||||||
DERIVED_MAP_GENERATORS.entrySetGenerator(parentBuilder.getSubjectGenerator()))
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester.class);
|
||||||
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester.class);
|
||||||
.named(parentBuilder.getName() + " entrySet")
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester.class);
|
||||||
.suppressing(getEntrySetSuppressing(parentBuilder.getSuppressedTests())).suppressing(getSuppressing(1))
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester.class);
|
||||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester.class);
|
||||||
.createTestSuite());
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester.class);
|
||||||
derivedSuites.add(createDerivedKeySetSuite(
|
return testers;
|
||||||
DERIVED_MAP_GENERATORS.keySetGenerator(parentBuilder.getSubjectGenerator()))
|
}
|
||||||
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
|
|
||||||
.named(parentBuilder.getName() + " keys").suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(0))
|
@Override
|
||||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||||
.createTestSuite());
|
List<TestSuite> derivedSuites = new ArrayList<>();
|
||||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
derivedSuites.add(createDerivedEntrySetSuite(
|
||||||
derivedSuites.add(createDerivedValueCollectionSuite(
|
DERIVED_MAP_GENERATORS.entrySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||||
new DERIVED_MAP_GENERATORS.MapValueCollectionGeneratorKV_BRACES(parentBuilder.getSubjectGenerator()))
|
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
|
||||||
.named(parentBuilder.getName() + " values")
|
.named(parentBuilder.getName() + " entrySet")
|
||||||
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
|
.suppressing(getEntrySetSuppressing(parentBuilder.getSuppressedTests())).suppressing(getSuppressing(1))
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(2)).withSetUp(parentBuilder.getSetUp())
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||||
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
.createTestSuite());
|
||||||
#endif
|
|
||||||
return derivedSuites;
|
derivedSuites.add(createDerivedKeySetSuite(
|
||||||
}
|
DERIVED_MAP_GENERATORS.keySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||||
|
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
|
||||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
.named(parentBuilder.getName() + " keys").suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(0))
|
||||||
return ObjectSetTestSuiteBuilder.using(entrySetGenerator);
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||||
}
|
.createTestSuite());
|
||||||
|
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
derivedSuites.add(createDerivedValueCollectionSuite(
|
||||||
return SET_TEST_BUILDER.using(generator);
|
new DERIVED_MAP_GENERATORS.MapValueCollectionGeneratorKV_BRACES(parentBuilder.getSubjectGenerator()))
|
||||||
}
|
.named(parentBuilder.getName() + " values")
|
||||||
|
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
protected VALUE_COLLECTION_TEST_BUILDER VALUE_GENERIC_TYPE createDerivedValueCollectionSuite(VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE generator) {
|
.suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(2)).withSetUp(parentBuilder.getSetUp())
|
||||||
return VALUE_COLLECTION_TEST_BUILDER.using(generator);
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
}
|
#endif
|
||||||
|
return derivedSuites;
|
||||||
private Method[] getSuppressing(int type) {
|
}
|
||||||
#if TYPE_CHAR || TYPE_OBJECT || TYPE_FLOAT || TYPE_DOUBLE
|
|
||||||
if(shouldBlockKeys) {
|
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||||
switch(type) {
|
return ObjectSetTestSuiteBuilder.using(entrySetGenerator);
|
||||||
case 0: return TestUtils.getSurpession(FILE_KEY_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
}
|
||||||
case 1: return TestUtils.getSurpession(ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
|
||||||
case 2: {
|
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
List<Method> result = new ArrayList<>();
|
return SET_TEST_BUILDER.using(generator);
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
}
|
||||||
#if VALUE_BOOLEAN
|
|
||||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
protected VALUE_COLLECTION_TEST_BUILDER VALUE_GENERIC_TYPE createDerivedValueCollectionSuite(VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE generator) {
|
||||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
return VALUE_COLLECTION_TEST_BUILDER.using(generator);
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
}
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
private Method[] getSuppressing(int type) {
|
||||||
#endif
|
#if TYPE_CHAR || TYPE_OBJECT || TYPE_FLOAT || TYPE_DOUBLE
|
||||||
return result.toArray(new Method[result.size()]);
|
if(shouldBlockKeys) {
|
||||||
}
|
switch(type) {
|
||||||
}
|
case 0: return TestUtils.getSurpession(FILE_KEY_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
}
|
case 1: return TestUtils.getSurpession(ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
return new Method[0];
|
case 2: {
|
||||||
#else if VALUE_BOOLEAN
|
List<Method> result = new ArrayList<>();
|
||||||
if(type == 2) {
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
List<Method> result = new ArrayList<>();
|
#if VALUE_BOOLEAN
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||||
#if VALUE_BOOLEAN
|
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||||
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||||
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
#endif
|
||||||
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
return result.toArray(new Method[result.size()]);
|
||||||
#endif
|
}
|
||||||
return result.toArray(new Method[result.size()]);
|
}
|
||||||
}
|
}
|
||||||
return new Method[0];
|
return new Method[0];
|
||||||
#else
|
#else if VALUE_BOOLEAN
|
||||||
return new Method[0];
|
if(type == 2) {
|
||||||
#endif
|
List<Method> result = new ArrayList<>();
|
||||||
}
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||||
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||||
#ignore
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||||
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionRetainAllTester.class);
|
||||||
}
|
#endif
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
return result.toArray(new Method[result.size()]);
|
||||||
entrySetFeatures.add(SpecialFeature.COPYING);
|
}
|
||||||
}
|
return new Method[0];
|
||||||
else {
|
#else
|
||||||
entrySetFeatures.remove(SpecialFeature.COPYING);
|
return new Method[0];
|
||||||
}
|
#endif
|
||||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
}
|
||||||
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
|
||||||
}
|
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
else {
|
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
#ignore
|
||||||
}
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
||||||
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
#endignore
|
}
|
||||||
return entrySetFeatures;
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
}
|
entrySetFeatures.add(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
private static Set<Feature<?>> computeKeySetFeatures(Set<Feature<?>> mapFeatures) {
|
else {
|
||||||
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
entrySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
#ignore
|
}
|
||||||
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
}
|
||||||
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
else {
|
||||||
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
}
|
}
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
||||||
keySetFeatures.add(SpecialFeature.COPYING);
|
#endignore
|
||||||
}
|
return entrySetFeatures;
|
||||||
else {
|
}
|
||||||
keySetFeatures.remove(SpecialFeature.COPYING);
|
|
||||||
}
|
private static Set<Feature<?>> computeKeySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
#ignore
|
||||||
}
|
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||||
else {
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
||||||
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
}
|
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
||||||
#endignore
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
return keySetFeatures;
|
}
|
||||||
}
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
|
keySetFeatures.add(SpecialFeature.COPYING);
|
||||||
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
}
|
||||||
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
else {
|
||||||
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
keySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
#ignore
|
}
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
}
|
}
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
else {
|
||||||
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
}
|
}
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
#endignore
|
||||||
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
return keySetFeatures;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||||
}
|
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
#endignore
|
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
return valuesCollectionFeatures;
|
#ignore
|
||||||
}
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
||||||
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
#endif
|
}
|
||||||
private static Set<Method> getEntrySetSuppressing(Set<Method> suppressing) {
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
||||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
}
|
||||||
TestUtils.getSurpession(suppressing, ObjectCollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
TestUtils.getSurpession(suppressing, ObjectCollectionRetainAllTester.class, "testRetainAllExtra_disjointPreviouslyNonEmpty", "testRetainAllExtra_containsDuplicatesSizeSeveral", "testRetainAllExtra_subset", "testRetainAllExtra_partialOverlap");
|
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
||||||
#if TYPE_DOUBLE || TYPE_FLOAT
|
}
|
||||||
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
else {
|
||||||
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
||||||
#endif
|
}
|
||||||
return suppressing;
|
#endignore
|
||||||
}
|
return valuesCollectionFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private static Set<Method> getEntrySetSuppressing(Set<Method> suppressing) {
|
||||||
|
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||||
|
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_removeAffectsBackingCollection");
|
||||||
|
TestUtils.getSurpession(suppressing, ObjectCollectionRemoveAllTester.class, "testRemoveAll_someFetchRemovedElements");
|
||||||
|
TestUtils.getSurpession(suppressing, ObjectCollectionRetainAllTester.class, "testRetainAllExtra_disjointPreviouslyNonEmpty", "testRetainAllExtra_containsDuplicatesSizeSeveral", "testRetainAllExtra_subset", "testRetainAllExtra_partialOverlap");
|
||||||
|
#if TYPE_DOUBLE || TYPE_FLOAT
|
||||||
|
TestUtils.getSurpession(suppressing, CollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
TestUtils.getSurpession(suppressing, ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
#endif
|
||||||
|
return suppressing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+79
-79
@@ -1,79 +1,79 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder.maps;
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.testers.PACKAGE.builder.NAVIGABLE_SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.NAVIGABLE_SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester;
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
public class NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||||
return (NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE)new NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
return (NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE)new NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||||
#ignore
|
#ignore
|
||||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.DESCENDING)) {
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.DESCENDING)) {
|
||||||
derivedSuites.add(createDescendingSuite(parentBuilder));
|
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||||
}
|
}
|
||||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.INCLUSIVE));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.NO_BOUND));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.EXCLUSIVE));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||||
}
|
}
|
||||||
#endignore
|
#endignore
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.NavigableMapGeneratorKV_BRACES(delegate, to, from));
|
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.NavigableMapGeneratorKV_BRACES(delegate, to, from));
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
private TestSuite createDescendingSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||||
|
|
||||||
List<Feature<?>> features = new ArrayList<>();
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
#ignore
|
#ignore
|
||||||
features.add(SpecialFeature.DESCENDING);
|
features.add(SpecialFeature.DESCENDING);
|
||||||
features.addAll(parentBuilder.getFeatures());
|
features.addAll(parentBuilder.getFeatures());
|
||||||
features.remove(SpecialFeature.COPYING);
|
features.remove(SpecialFeature.COPYING);
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
#endignore
|
#endignore
|
||||||
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.DescendingTestMapGeneratorKV_BRACES(delegate))
|
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.DescendingTestMapGeneratorKV_BRACES(delegate))
|
||||||
.named(parentBuilder.getName() + " descending").withFeatures(features)
|
.named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
protected NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||||
return NAVIGABLE_SET_TEST_BUILDER.using((TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator);
|
return NAVIGABLE_SET_TEST_BUILDER.using((TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-55
@@ -1,55 +1,55 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder.maps;
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.testers.PACKAGE.builder.ORDERED_SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.ORDERED_SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||||
return (ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
return (ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestSuite createTestSuite() {
|
public TestSuite createTestSuite() {
|
||||||
#ignore
|
#ignore
|
||||||
withFeatures(CollectionFeature.KNOWN_ORDER);
|
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||||
#endignore
|
#endignore
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||||
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+90
-90
@@ -1,90 +1,90 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder.maps;
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester;
|
||||||
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.builder.SORTED_SET_TEST_BUILDER;
|
import speiger.src.testers.PACKAGE.builder.SORTED_SET_TEST_BUILDER;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE {
|
public class SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE {
|
||||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||||
return (SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
return (SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester.class);
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TestSuite createTestSuite() {
|
public TestSuite createTestSuite() {
|
||||||
#ignore
|
#ignore
|
||||||
if (!getFeatures().contains(KNOWN_ORDER)) {
|
if (!getFeatures().contains(KNOWN_ORDER)) {
|
||||||
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||||
features.add(KNOWN_ORDER);
|
features.add(KNOWN_ORDER);
|
||||||
withFeatures(features);
|
withFeatures(features);
|
||||||
}
|
}
|
||||||
#endignore
|
#endignore
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||||
#ignore
|
#ignore
|
||||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.NO_BOUND, Bound.EXCLUSIVE));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.NO_BOUND));
|
||||||
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.EXCLUSIVE));
|
||||||
}
|
}
|
||||||
#endignore
|
#endignore
|
||||||
return derivedSuites;
|
return derivedSuites;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator) {
|
||||||
return keySetGenerator instanceof TEST_SORTED_SET_GENERATOR ? SORTED_SET_TEST_BUILDER.using((TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator) : SET_TEST_BUILDER.using(keySetGenerator);
|
return keySetGenerator instanceof TEST_SORTED_SET_GENERATOR ? SORTED_SET_TEST_BUILDER.using((TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE) keySetGenerator) : SET_TEST_BUILDER.using(keySetGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestSuite createSubmapSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder, Bound from, Bound to) {
|
TestSuite createSubmapSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder, Bound from, Bound to) {
|
||||||
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
||||||
List<Feature<?>> features = new ArrayList<>();
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
#ignore
|
#ignore
|
||||||
features.add(SpecialFeature.SUBMAP);
|
features.add(SpecialFeature.SUBMAP);
|
||||||
features.addAll(parentBuilder.getFeatures());
|
features.addAll(parentBuilder.getFeatures());
|
||||||
features.remove(SpecialFeature.COPYING);
|
features.remove(SpecialFeature.COPYING);
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subMap " + from + "-" + to)
|
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subMap " + from + "-" + to)
|
||||||
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||||
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown()).createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE newBuilderUsing(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
return using(new DERIVED_MAP_GENERATORS.SortedMapGeneratorKV_BRACES(delegate, to, from));
|
return using(new DERIVED_MAP_GENERATORS.SortedMapGeneratorKV_BRACES(delegate, to, from));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-30
@@ -1,30 +1,30 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.SampleElements;
|
import com.google.common.collect.testing.SampleElements;
|
||||||
import com.google.common.collect.testing.TestCollectionGenerator;
|
import com.google.common.collect.testing.TestCollectionGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE extends TestCollectionGenerator<CLASS_TYPE>
|
public interface TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE extends TestCollectionGenerator<CLASS_TYPE>
|
||||||
{
|
{
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
public COLLECTION KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
public COLLECTION KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||||
#endif
|
#endif
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||||
@Override
|
@Override
|
||||||
public COLLECTION KEY_GENERIC_TYPE create(Object... elements);
|
public COLLECTION KEY_GENERIC_TYPE create(Object... elements);
|
||||||
@Override
|
@Override
|
||||||
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user