Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6afed5e174 | ||
|
|
640a1a8161 | ||
|
|
274d37c4d6 | ||
|
|
a89c812c06 | ||
|
|
6af0656216 | ||
|
|
e76db94136 | ||
|
|
7011101b05 | ||
|
|
d0599b99ec | ||
|
|
d7c5b9ad7d | ||
|
|
d2c81e7779 | ||
|
|
ef5fdbd377 | ||
|
|
5e67e45910 | ||
|
|
63ef68fb95 | ||
|
|
0f9751bf70 | ||
|
|
bcc2ffdc13 | ||
|
|
2da4588430 | ||
|
|
ed9ce60af4 |
@@ -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
-259
@@ -1,260 +1,280 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
### Version 0.8.0
|
### 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.
|
||||||
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
- 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: Functions of a BooleanValue have now alwaysTrue/False function.
|
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
||||||
- Added: ForEachIndexed for all Iterable implementations
|
- Added: Iterators.infinite as an option that will create a Infinite Iterator based on the inputed one.
|
||||||
- Added: RandomGenerator support (Java17), though requires self compilation
|
- Added: List.indexedIterator which allows you to create a iterator with a customized iteration indecies. Useful if you want to transform lists output.
|
||||||
- Added: Optimizations for HashUtils next power of function.
|
- Added: PriorityQueue.contains is now a function
|
||||||
- Added: toArray() now returns a cached empty array if the collection is empty.
|
- 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: toArray function for AsyncBuilder
|
- Fixed: SetValue wasn't working on forEach implementations.
|
||||||
- Added: Modularization to the library where feature can be disabled as needed. (Requires Self-Compilation)
|
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
||||||
- Fixed: putIfAbsent now replaces defaultValues
|
- Fixed: Supplier was using the wrong dataType in their function name.
|
||||||
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
||||||
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
|
||||||
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
|
### Version 0.8.0
|
||||||
- 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
|
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
||||||
- Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat.
|
- Added: Dedicated implementations for toArray into TreeSets
|
||||||
- Breaking Change: Some function classes now get closer to javas terms. (Predicate/UnaryOperator etc)
|
- Fixed: forEach methods in Maps now can use "setValue" functions.
|
||||||
|
|
||||||
### Version 0.7.0
|
### Version 0.8.0
|
||||||
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
- Added: ISizeProvider interface (Optimization Helper)
|
||||||
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
|
||||||
- Added: EnumMap specialized forEach implementation.
|
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
||||||
- Added: AbstractMap.remove now delegates to its primitive counterpart.
|
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
||||||
- Added: ConcurrentHashMap now implements ITrimmable
|
- Added: Functions of a BooleanValue have now alwaysTrue/False function.
|
||||||
- Refactor: Removed a lot of disabled code from ArraySet.
|
- Added: ForEachIndexed for all Iterable implementations
|
||||||
- Removed: LinkedList.addAll(index, List) now delegates to LinkedList.addAll(index, Collection) due to no special optimization required.
|
- Added: RandomGenerator support (Java17), though requires self compilation
|
||||||
- Fixed: AbstractList.SubList.get/set/swapRemove didn't calculate their List index Properly
|
- Added: Optimizations for HashUtils next power of function.
|
||||||
- Fixed: AbstractList.SubList chains now properly if you create SubLists within SubLists.
|
- Added: toArray() now returns a cached empty array if the collection is empty.
|
||||||
- Fixed: AbstractList.Iterator.add now respects Immutable/UnmodifiableLists.
|
- Added: toArray function for AsyncBuilder
|
||||||
- Fixed: AbstractList.Iterator.skip/back now keep track of the last returned value for remove function to work properly.
|
- Added: Modularization to the library where feature can be disabled as needed. (Requires Self-Compilation)
|
||||||
- Fixed: CopyOnWriteArrayList.extract/removeElements(int, int) does now proper range checks and remove elements properly.
|
- Fixed: putIfAbsent now replaces defaultValues
|
||||||
- Fixed: CopyOnWriteArrayList.SubList now works properly. (Reimplemented entirely)
|
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
||||||
- Fixed: CopyOnWriteArrayList.Iterator.previous() was returning the wrong values.
|
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
||||||
- Fixed: CopyOnWriteArrayList.Iterator.skip now skips the right amount of elements and stops where it should.
|
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
|
||||||
- Fixed: LinkedList.first/last/dequeue/dequeueLast now throws NoSuchElementException when empty instead of IllegalStateException.
|
- 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: LinkedList had an edge case where the entire reverse iterator would break if the wrong element was removed.
|
- Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat.
|
||||||
- Fixed: LinkedList.extractElement now returns the correct values.
|
- Breaking Change: Some function classes now get closer to javas terms. (Predicate/UnaryOperator etc)
|
||||||
- Fixed: AbstractMap.entrySet().remove(Object) now returns true if defaultReturnValue elements were removed.
|
|
||||||
- Fixed: ConcurrentHashMap.remove(Object, Object) checks if the type matches before comparing against null Values.
|
### Version 0.7.0
|
||||||
- Fixed: LinkedHashMap.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: HashMap.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
|
||||||
- Fixed: HashMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
- Added: EnumMap specialized forEach implementation.
|
||||||
- Fixed: ImmutableMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
- Added: AbstractMap.remove now delegates to its primitive counterpart.
|
||||||
- Fixed: ArrayMap.iterator(key) now throws NoSuchElementException when the element wasn't found.
|
- Added: ConcurrentHashMap now implements ITrimmable
|
||||||
- Fixed: Linked/EnumMap array constructor was creating the wrong size values array.
|
- Refactor: Removed a lot of disabled code from ArraySet.
|
||||||
- Fixed: LinkedEnumMap.getAndMoveToFirst/Last was moving elements even if the element wasn't present.
|
- Removed: LinkedList.addAll(index, List) now delegates to LinkedList.addAll(index, Collection) due to no special optimization required.
|
||||||
- Fixed: AVL/RBTreeMap.getFirst/LastKey was not throwing a NoSuchElementException if the map was empty.
|
- Fixed: AbstractList.SubList.get/set/swapRemove didn't calculate their List index Properly
|
||||||
- Fixed: Map.Builder wasn't throwing a IllegalStateException when creating a negative size builder.
|
- Fixed: AbstractList.SubList chains now properly if you create SubLists within SubLists.
|
||||||
- Fixed: AVL/RBTreeSet.DecendingSet.subSet(from, fromInclusive, to, toInclusive) was creating a corrupt asending subset.
|
- Fixed: AbstractList.Iterator.add now respects Immutable/UnmodifiableLists.
|
||||||
- Fixed: ArraySet throws now a IllegalStateException when trying to create it with a negative size.
|
- Fixed: AbstractList.Iterator.skip/back now keep track of the last returned value for remove function to work properly.
|
||||||
- Fixed: ArraySet.addMoveToLast(key) was crashing when a key was already present.
|
- Fixed: CopyOnWriteArrayList.extract/removeElements(int, int) does now proper range checks and remove elements properly.
|
||||||
- Fixed: Immutable/LinkedHashSet now keep track of their iteration index properly.
|
- Fixed: CopyOnWriteArrayList.SubList now works properly. (Reimplemented entirely)
|
||||||
- Fixed: LinkedHashSet.moveToFirst/Last(key) would crash if the Set was empty.
|
- Fixed: CopyOnWriteArrayList.Iterator.previous() was returning the wrong values.
|
||||||
- Fixed: LinkedHashSet.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
- Fixed: CopyOnWriteArrayList.Iterator.skip now skips the right amount of elements and stops where it should.
|
||||||
- Fixed: HashSet.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
- Fixed: LinkedList.first/last/dequeue/dequeueLast now throws NoSuchElementException when empty instead of IllegalStateException.
|
||||||
|
- Fixed: LinkedList had an edge case where the entire reverse iterator would break if the wrong element was removed.
|
||||||
|
- Fixed: LinkedList.extractElement now returns the correct values.
|
||||||
### Version 0.6.2
|
- Fixed: AbstractMap.entrySet().remove(Object) now returns true if defaultReturnValue elements were removed.
|
||||||
- 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.
|
- Fixed: ConcurrentHashMap.remove(Object, Object) checks if the type matches before comparing against null Values.
|
||||||
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
- Fixed: LinkedHashMap.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
||||||
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
- Fixed: HashMap.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
||||||
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
- Fixed: HashMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
- Fixed: ImmutableMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
- Fixed: ArrayMap.iterator(key) now throws NoSuchElementException when the element wasn't found.
|
||||||
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
- Fixed: Linked/EnumMap array constructor was creating the wrong size values array.
|
||||||
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
- Fixed: LinkedEnumMap.getAndMoveToFirst/Last was moving elements even if the element wasn't present.
|
||||||
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
- Fixed: AVL/RBTreeMap.getFirst/LastKey was not throwing a NoSuchElementException if the map was empty.
|
||||||
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
- Fixed: Map.Builder wasn't throwing a IllegalStateException when creating a negative size builder.
|
||||||
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
- Fixed: AVL/RBTreeSet.DecendingSet.subSet(from, fromInclusive, to, toInclusive) was creating a corrupt asending subset.
|
||||||
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
- Fixed: ArraySet throws now a IllegalStateException when trying to create it with a negative size.
|
||||||
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
- Fixed: ArraySet.addMoveToLast(key) was crashing when a key was already present.
|
||||||
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
- Fixed: Immutable/LinkedHashSet now keep track of their iteration index properly.
|
||||||
- Fixed: ArrayList/LinkedList extractElements crashing when 0 or less elements are desired.
|
- Fixed: LinkedHashSet.moveToFirst/Last(key) would crash if the Set was empty.
|
||||||
- Fixed: TreeMap pollFirst/LastKey should return the defaultMin/max value instead of a Empty value.
|
- Fixed: LinkedHashSet.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: HashSet.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.
|
|
||||||
|
|
||||||
|
### Version 0.6.2
|
||||||
### Version 0.6.1
|
- 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.
|
||||||
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
||||||
- Fixed: FIFO queue only clears the array if it was in use.
|
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
||||||
- Added: Sorted Method for the stream replacing functions.
|
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
||||||
|
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
||||||
### Version 0.6.0
|
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
||||||
- Added: addOrGet for sets.
|
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
||||||
- Added: Async API which allows to easily execute Iterables/Collections offthread without the complexity.
|
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
||||||
- Added: CopyOnWriteArrayList and tests for it
|
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
||||||
- Added: Support up to Java17.
|
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
||||||
- Added: Build System now adds module-info if the Running JVM is 9 or higher
|
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
||||||
- 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.
|
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
||||||
- Added: A ConcurrentHashMap implementation.
|
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
||||||
- Fixed: containsValue in the HashMap wouldn't check the nullKey
|
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
||||||
- Removed: Deprecated functions from SortedMaps/Sets
|
- Fixed: ArrayList/LinkedList extractElements crashing when 0 or less elements are desired.
|
||||||
|
- Fixed: TreeMap pollFirst/LastKey should return the defaultMin/max value instead of a Empty value.
|
||||||
### Version 0.5.3
|
- Fixed: TreeMap keySet implementation was missing the class type implementations to pass keySet tests.
|
||||||
- Added: OrderedMap/Set
|
- Fixed: TreeMap.SubMap Iterator (primitive Keys) was crashing because a Null was set on to a primitive.
|
||||||
- Added: Deprecation to Functions that are specific to Ordered interfaces in the SortedMap/Set
|
|
||||||
- Added: subFrom to Maps which is the counterpart of the addTo method
|
|
||||||
- Added: pourAsList and pourAsSet (booleans excluded for sets) to Iterable
|
### Version 0.6.1
|
||||||
- Fixed: ArrayList.grow had a small bug where it would trigger to early causing performance problems with exact sized collections.
|
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
||||||
- Fixed: FIFOQueue size constructor had a small bug where it would trigger a array enlargement when all elements were inserted.
|
- Fixed: FIFO queue only clears the array if it was in use.
|
||||||
|
- Added: Sorted Method for the stream replacing functions.
|
||||||
### Version 0.5.2
|
|
||||||
- Fixed: Bugs with Queues starting with the wrong size
|
### Version 0.6.0
|
||||||
- Fixed: ArrayGrowth for Queues was +1 instead of +50%
|
- Added: addOrGet for sets.
|
||||||
- Added: Benchmarks with java and FastUtil
|
- Added: Async API which allows to easily execute Iterables/Collections offthread without the complexity.
|
||||||
|
- Added: CopyOnWriteArrayList and tests for it
|
||||||
### Version 0.5.1
|
- Added: Support up to Java17.
|
||||||
- Fixed: Reworked the NavigableSet/Map implementations of RBTree/AVLTree/Array Sets/Maps so they are now deemed stable.
|
- Added: Build System now adds module-info if the Running JVM is 9 or higher
|
||||||
- Added: Another 150k Unit tests.
|
- 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: List and Set Unit tests for Integer (or Primitives in this case) to ensure basic stability there. (Now covering all sets and lists)
|
- Added: A ConcurrentHashMap implementation.
|
||||||
- Fixed: Bugs with null values for primitive collections.
|
- Fixed: containsValue in the HashMap wouldn't check the nullKey
|
||||||
- Removed: ArraySet/Map subSet/subMap implementation was removed.
|
- Removed: Deprecated functions from SortedMaps/Sets
|
||||||
|
|
||||||
### Version 0.5.0
|
### Version 0.5.3
|
||||||
- Added: 2 Helper functions to find out how many bits are required to store a Number.
|
- Added: OrderedMap/Set
|
||||||
- Added: pour function directly into Iterable which allows to collect all elements in the Iterable directly.
|
- Added: Deprecation to Functions that are specific to Ordered interfaces in the SortedMap/Set
|
||||||
- Added: The new ToArray method from Java9 and newer into the library. Using a functional interface. (Just a backport)
|
- Added: subFrom to Maps which is the counterpart of the addTo method
|
||||||
- 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: pourAsList and pourAsSet (booleans excluded for sets) to Iterable
|
||||||
- Added: Map Builder that allows now to Build Maps like Guava ImmutableMaps can be build. Note: This has a slight performance overhead.
|
- Fixed: ArrayList.grow had a small bug where it would trigger to early causing performance problems with exact sized collections.
|
||||||
- Added: Unmodifiable and Synchronize wrapper functions direclty into Collection Interfaces. This is mostly a quality of life thing.
|
- Fixed: FIFOQueue size constructor had a small bug where it would trigger a array enlargement when all elements were inserted.
|
||||||
- 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: A boxed putAll array variant.
|
### Version 0.5.2
|
||||||
- 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.
|
- Fixed: Bugs with Queues starting with the wrong size
|
||||||
- Added: Tests for the new Stream replace functions to ensure no bugs are left.
|
- Fixed: ArrayGrowth for Queues was +1 instead of +50%
|
||||||
- Fixed: Custom HashSet reduce function with a default value was checking incorrectly for present keys.
|
- Added: Benchmarks with java and FastUtil
|
||||||
- Added: Guava TestSuit
|
|
||||||
- Fixed: HashCode and toString method would crash if the Object Key/Value was null
|
### Version 0.5.1
|
||||||
- Added: AbstractTypeCollection now delegates the contains check to type-specific Collections if it detects it.
|
- Fixed: Reworked the NavigableSet/Map implementations of RBTree/AVLTree/Array Sets/Maps so they are now deemed stable.
|
||||||
- Fixed: Map.Entry toString wasn't writing values not like it should do.
|
- Added: Another 150k Unit tests.
|
||||||
- Fixed: Set.hashCode now is the sum of the elements instead of a Unique HashCode based on the elements.
|
- 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: Added missing NonNull Checks.
|
- Fixed: Bugs with null values for primitive collections.
|
||||||
- Fixed: Custom/OpenHashMap.containsValue implementation was wrong.
|
- Removed: ArraySet/Map subSet/subMap implementation was removed.
|
||||||
- Fixed: Custom/OpenHashMap.compute/present/absent now works how it is specified in the Java Documentation
|
|
||||||
- Fixed: Custom/OpenHashMap.merge/BulkMerge now works how it is specified in the Java Documentation
|
### Version 0.5.0
|
||||||
- Fixed: Custom/Linked/OpenHashMap.keySet.remove was causing a infinite loop.
|
- Added: 2 Helper functions to find out how many bits are required to store a Number.
|
||||||
- Fixed: Custom/Linked/OpenHashMap.entrySet.contains was not correctly comparing the entry.
|
- Added: pour function directly into Iterable which allows to collect all elements in the Iterable directly.
|
||||||
- Fixed: Custom/OpenHashMap.mapIterator now no longer crashes in certain cases.
|
- Added: The new ToArray method from Java9 and newer into the library. Using a functional interface. (Just a backport)
|
||||||
- Added: Custom/LinkedOpenHashMap now takes use of the improved Iterator it has for containsValue
|
- 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)
|
||||||
- Fixed: CustomOpenHashMap.keySet.forEach was basically putting out keys even if they were present
|
- Added: Map Builder that allows now to Build Maps like Guava ImmutableMaps can be build. Note: This has a slight performance overhead.
|
||||||
- Fixed: ImmutableMaps issues thanks to the tests. Roughly the same as the rest of the maps
|
- Added: Unmodifiable and Synchronize wrapper functions direclty into Collection Interfaces. This is mostly a quality of life thing.
|
||||||
- Fixed: RB/AVLTreeMaps issues. Roughly the same as the rest of the maps
|
- 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)
|
||||||
- Fixed: SubLists are now properly implemented.
|
- Added: A boxed putAll array variant.
|
||||||
- Fixed: HashSet Iterator bugs now fixed... That was Painful.
|
- 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: Tests for Lists and Sets
|
- Added: Tests for the new Stream replace functions to ensure no bugs are left.
|
||||||
|
- Fixed: Custom HashSet reduce function with a default value was checking incorrectly for present keys.
|
||||||
### Version 0.4.5
|
- Added: Guava TestSuit
|
||||||
- Added: removeAll/retainAll(Collection c, Consumer r) which receives all the elements that got deleted from the collection
|
- Fixed: HashCode and toString method would crash if the Object Key/Value was null
|
||||||
- Fixed: Supplier get function wasn't referencing original function.
|
- Added: AbstractTypeCollection now delegates the contains check to type-specific Collections if it detects it.
|
||||||
- Added: addIfPresent/Absent to lists
|
- Fixed: Map.Entry toString wasn't writing values not like it should do.
|
||||||
- Added: distinct, limit and peek iterators
|
- Fixed: Set.hashCode now is the sum of the elements instead of a Unique HashCode based on the elements.
|
||||||
- Added: Iterable's can now reduce its contents
|
- Fixed: Added missing NonNull Checks.
|
||||||
- Added: Better ForEach support for IterableWrappers so a Iterator chain is not created
|
- Fixed: Custom/OpenHashMap.containsValue implementation was wrong.
|
||||||
- Added: SwapRemove to Lists which moves the last element into the desired space to be deleted
|
- Fixed: Custom/OpenHashMap.compute/present/absent now works how it is specified in the Java Documentation
|
||||||
- Added: More Test cases
|
- Fixed: Custom/OpenHashMap.merge/BulkMerge now works how it is specified in the Java Documentation
|
||||||
|
- Fixed: Custom/Linked/OpenHashMap.keySet.remove was causing a infinite loop.
|
||||||
### Version 0.4.4
|
- Fixed: Custom/Linked/OpenHashMap.entrySet.contains was not correctly comparing the entry.
|
||||||
- Fixed: ObjectArrayList.of was causing crashes because of a Poor implementation.
|
- Fixed: Custom/OpenHashMap.mapIterator now no longer crashes in certain cases.
|
||||||
- Added: Unsorted HashMaps/Sets now throw Concurrent exceptions if they were modified during a rehash.
|
- Added: Custom/LinkedOpenHashMap now takes use of the improved Iterator it has for containsValue
|
||||||
- Added: Array/Collection version of enqueue and enqueueFirst to PriorityQueues.
|
- Fixed: CustomOpenHashMap.keySet.forEach was basically putting out keys even if they were present
|
||||||
- Added: fillBuffer function into PrimitiveLists which allow to optimize JavaNio buffers if needed.
|
- 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.4.3
|
- Fixed: SubLists are now properly implemented.
|
||||||
- Added: Wrapper now support the Optimized Lambda replacer functions to improve performance.
|
- Fixed: HashSet Iterator bugs now fixed... That was Painful.
|
||||||
- Added: FIFO Queue has now a minimum capacity and that is now checked more consistently.
|
- Added: Tests for Lists and Sets
|
||||||
|
|
||||||
### Version 0.4.2
|
### Version 0.4.5
|
||||||
- Added: Lists/Sets/Maps/PriorityQueues are now copy-able. with the new copy() function.
|
- Added: removeAll/retainAll(Collection c, Consumer r) which receives all the elements that got deleted from the collection
|
||||||
Note: subLists/subMaps/subSets or synchronize/unmodifyable wrappers do not support that function.
|
- Fixed: Supplier get function wasn't referencing original function.
|
||||||
- Fixed: PriorityQueues didn't implement: hashCode/equals/toString
|
- Added: addIfPresent/Absent to lists
|
||||||
|
- Added: distinct, limit and peek iterators
|
||||||
### Version 0.4.1
|
- Added: Iterable's can now reduce its contents
|
||||||
- Changed: ForEach with input now provides input, value instead of value, input, this improves the usage of method references greatly
|
- Added: Better ForEach support for IterableWrappers so a Iterator chain is not created
|
||||||
- Added: addAll with Array-types in collections.
|
- Added: SwapRemove to Lists which moves the last element into the desired space to be deleted
|
||||||
- Added: Java Iterator/Iterable support for Stream replacing methods
|
- Added: More Test cases
|
||||||
- Added: Suppliers.
|
|
||||||
- Added: SupplyIfAbsent. It is ComputeIfAbsent but using suppliers
|
### Version 0.4.4
|
||||||
- Added: Count feature into Iterable
|
- Fixed: ObjectArrayList.of was causing crashes because of a Poor implementation.
|
||||||
- Fixed: A couple bugs with the new StreamReplacing functions in LinkedCollections Iterating to Infinity
|
- Added: Unsorted HashMaps/Sets now throw Concurrent exceptions if they were modified during a rehash.
|
||||||
|
- Added: Array/Collection version of enqueue and enqueueFirst to PriorityQueues.
|
||||||
### Version 0.4.0
|
- Added: fillBuffer function into PrimitiveLists which allow to optimize JavaNio buffers if needed.
|
||||||
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
|
||||||
- Added: New Stream replacing functions: findFirst, matchesAny/All/None
|
### Version 0.4.3
|
||||||
- Fixed: Compute/ComputeIfAbsent/ComputeIfPresent/Merge/BulkMerge in maps now behave like they should.
|
- Added: Wrapper now support the Optimized Lambda replacer functions to improve performance.
|
||||||
- Added: Implementations for New Stream replacing functions.
|
- Added: FIFO Queue has now a minimum capacity and that is now checked more consistently.
|
||||||
- Changed: Removed a lot of duplicated forEach implementations
|
|
||||||
- Added: Flat/Mapping functions (to object) are now accessible to primitive maps.
|
### Version 0.4.2
|
||||||
- Added: Filter function to Iterators/Iterables (Iterable implements it by default)
|
- Added: Lists/Sets/Maps/PriorityQueues are now copy-able. with the new copy() function.
|
||||||
- Changed: Cleanup of some variables/mappers
|
Note: subLists/subMaps/subSets or synchronize/unmodifyable wrappers do not support that function.
|
||||||
- Added/Fixed: AVL/RBTreeMap got reworked and SubMaps work more properly now. Also forEach support got improved a lot
|
- Fixed: PriorityQueues didn't implement: hashCode/equals/toString
|
||||||
- Added/Fixed: TreeSubSets (RB/AVL) got their functional implementations improved too.
|
|
||||||
- Added: Pairs are now a thing. In Mutable/Immutable Form
|
### Version 0.4.1
|
||||||
|
- Changed: ForEach with input now provides input, value instead of value, input, this improves the usage of method references greatly
|
||||||
### Version 0.3.6
|
- Added: addAll with Array-types in collections.
|
||||||
- Fixed: addAll non Type Specific Lists was causing crashes.
|
- Added: Java Iterator/Iterable support for Stream replacing methods
|
||||||
- Fixed/Changed: clearAndTrim's implementation was all over the place. In some cases causing crash scenarios.
|
- Added: Suppliers.
|
||||||
- Fixed: Wrappers didn't implement toString/equals/hashCode
|
- Added: SupplyIfAbsent. It is ComputeIfAbsent but using suppliers
|
||||||
- Added: Tests for addAll Bug
|
- Added: Count feature into Iterable
|
||||||
- Changed: Cleaned up CodeStyle as bugs were fixed.
|
- Fixed: A couple bugs with the new StreamReplacing functions in LinkedCollections Iterating to Infinity
|
||||||
|
|
||||||
### Version 0.3.5
|
### Version 0.4.0
|
||||||
- Fixed: Simple Code Generator dependency was declared wrong. Its only needed for runtime. Not for Compilation.
|
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
||||||
- Fixed: ObjectLists Crashed when a null was provided as a Comparator. (Unless the List was Initialized with the ClassType)
|
- Added: New Stream replacing functions: findFirst, matchesAny/All/None
|
||||||
- Fixed: LinkedLists didn't implement add(Object)
|
- Fixed: Compute/ComputeIfAbsent/ComputeIfPresent/Merge/BulkMerge in maps now behave like they should.
|
||||||
- Fixed: Object Collections did have the JavaCollections deprecated as the Constructor. This should only be deprecated for Primitives
|
- Added: Implementations for New Stream replacing functions.
|
||||||
- Added: Tests with 5k Random names for Object sorting.
|
- Changed: Removed a lot of duplicated forEach implementations
|
||||||
- Changed: Object Arrays no longer require a Comparable[] it just assumes now that the elements in the Array are Comparable
|
- Added: Flat/Mapping functions (to object) are now accessible to primitive maps.
|
||||||
- Fixed: Dependency to SimpleCodeGenerator should be no longer a thing. Because the resulting library doesn't need it only the builder does.
|
- Added: Filter function to Iterators/Iterables (Iterable implements it by default)
|
||||||
|
- Changed: Cleanup of some variables/mappers
|
||||||
### Version 0.3.4
|
- Added/Fixed: AVL/RBTreeMap got reworked and SubMaps work more properly now. Also forEach support got improved a lot
|
||||||
- Fixed: ArrayLists didn't resize properly if they were empty.
|
- Added/Fixed: TreeSubSets (RB/AVL) got their functional implementations improved too.
|
||||||
|
- Added: Pairs are now a thing. In Mutable/Immutable Form
|
||||||
|
|
||||||
### Version 0.3.3
|
### Version 0.3.6
|
||||||
- Added: Flat/Mapping function for Iterables/Iterators to help avoid streams for cleaner looking code
|
- Fixed: addAll non Type Specific Lists was causing crashes.
|
||||||
- Fixed: AVLTrees pollFirst/Last is now keeping orders and is fixed
|
- Fixed/Changed: clearAndTrim's implementation was all over the place. In some cases causing crash scenarios.
|
||||||
- Fixed: AbstractCollection bulk adding methods now link to the specialized implementations.
|
- Fixed: Wrappers didn't implement toString/equals/hashCode
|
||||||
- Fixed: A bug with getElements in ArrayList.
|
- Added: Tests for addAll Bug
|
||||||
- Fixed: PriorityQueue remove/toArray function were renamed so they fit better with other interfaces. (remove => removeFirst and toArray uses a different genericType)
|
- Changed: Cleaned up CodeStyle as bugs were fixed.
|
||||||
- Added: LinkedList which is a List/PriorityDequeue/Stack which allows for more optimized use-cases and reduced boxing/unboxing.
|
|
||||||
- Added: Tests for LinkedList
|
### Version 0.3.5
|
||||||
|
- Fixed: Simple Code Generator dependency was declared wrong. Its only needed for runtime. Not for Compilation.
|
||||||
### Version 0.3.2
|
- Fixed: ObjectLists Crashed when a null was provided as a Comparator. (Unless the List was Initialized with the ClassType)
|
||||||
- Fixed: Map.put wasn't referring to primitive variants.
|
- Fixed: LinkedLists didn't implement add(Object)
|
||||||
- Added: ImmutableList.
|
- Fixed: Object Collections did have the JavaCollections deprecated as the Constructor. This should only be deprecated for Primitives
|
||||||
- Added: Iterator pour function into a List or Array
|
- Added: Tests with 5k Random names for Object sorting.
|
||||||
- Changed: Arrays Wrap is now accessible to Objects and now is ? extends TYPE instead of TYPE.
|
- Changed: Object Arrays no longer require a Comparable[] it just assumes now that the elements in the Array are Comparable
|
||||||
- Added: OpenHashSets now implement foreach and have less overhead.
|
- Fixed: Dependency to SimpleCodeGenerator should be no longer a thing. Because the resulting library doesn't need it only the builder does.
|
||||||
- Added: ImmutableOpenHashSet that is not editable (is linked by default for fast iteration)
|
|
||||||
- Added: CustomOpenHashSets now implement foreach and have less overhead.
|
### Version 0.3.4
|
||||||
- Added: ImmutableOpenHashMap that is not editable (is linked by default for fast iteration)
|
- Fixed: ArrayLists didn't resize properly if they were empty.
|
||||||
- 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.3
|
||||||
|
- Added: Flat/Mapping function for Iterables/Iterators to help avoid streams for cleaner looking code
|
||||||
### Version 0.3.1
|
- Fixed: AVLTrees pollFirst/Last is now keeping orders and is fixed
|
||||||
- Fixed: containsKey & containsValue in HashMaps were deprecated for Object Variants.
|
- Fixed: AbstractCollection bulk adding methods now link to the specialized implementations.
|
||||||
- Fixed: HashMap wasn't deleting Keys & Values references when removing a Object
|
- Fixed: A bug with getElements in ArrayList.
|
||||||
- Fixed: AVLTreeMap didn't balance properly.
|
- Fixed: PriorityQueue remove/toArray function were renamed so they fit better with other interfaces. (remove => removeFirst and toArray uses a different genericType)
|
||||||
- Changed: EnumMap no longer tries to access SharedSecrets since its gone in java11
|
- Added: LinkedList which is a List/PriorityDequeue/Stack which allows for more optimized use-cases and reduced boxing/unboxing.
|
||||||
- Added: HashMaps now implement ITrimmable
|
- Added: Tests for LinkedList
|
||||||
- Added: AVLTreeSet didn't balance properly
|
|
||||||
- Fixed: HashMaps & LinkedMaps weren't clearing references properly.
|
### Version 0.3.2
|
||||||
|
- Fixed: Map.put wasn't referring to primitive variants.
|
||||||
### Version 0.3.0 (Breaking 0.2.0)
|
- Added: ImmutableList.
|
||||||
- Added: Stack.isEmpty was missing
|
- Added: Iterator pour function into a List or Array
|
||||||
- Changed: remove/removeLast/enqueue/enqueueFirst no longer use Type Suffixes
|
- Changed: Arrays Wrap is now accessible to Objects and now is ? extends TYPE instead of TYPE.
|
||||||
- Removed: Suffixes for unmodifiable & synchronize functions.
|
- Added: OpenHashSets now implement foreach and have less overhead.
|
||||||
- Changed: Primitive Stacks no longer depend on the base Stack class. Because seriously not needed.
|
- Added: ImmutableOpenHashSet that is not editable (is linked by default for fast iteration)
|
||||||
- Changed: PriorityQueues no longer extends Object Variant.
|
- Added: CustomOpenHashSets now implement foreach and have less overhead.
|
||||||
- Changed: Maps.get function is no longer using Suffixes unless its absolutely necessary.
|
- Added: ImmutableOpenHashMap that is not editable (is linked by default for fast iteration)
|
||||||
- Changed: Maps.remove function is no longer using Suffixes unless its absolutely necessary.
|
- Added: Maps can now be created through the interface.
|
||||||
- Changed: ObjectList methods are no longer marked Deprecated even so it was for primitive ones.
|
- Fixed: Lists.addElements(T...elements) was adding elements at the beginning of a list instead of the end.
|
||||||
- Added: Shuffle & Reverse Methods.
|
- Fixed: Bugs with the AVLTreeSet. And marked bugs with AVLTreeX that are still present.
|
||||||
- Added: Concat Iterators.
|
|
||||||
|
### 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
|
||||||
@@ -50,7 +50,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.Speiger:Primitive-Collections:0.7.0'
|
implementation 'com.github.Speiger:Primitive-Collections:0.9.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
+33
-25
@@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.8.0';
|
version = '0.9.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'com.google.code.gson:gson:2.10'
|
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.2.2'
|
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'
|
||||||
|
|
||||||
@@ -83,6 +83,14 @@ 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) {
|
task generateLimitSource(type: JavaExec) {
|
||||||
group = 'internal'
|
group = 'internal'
|
||||||
description = 'Builds the Sourcecode with the ModuleSettings.json applied'
|
description = 'Builds the Sourcecode with the ModuleSettings.json applied'
|
||||||
@@ -93,12 +101,12 @@ task generateLimitSource(type: JavaExec) {
|
|||||||
|
|
||||||
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
|
||||||
@@ -121,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) {
|
||||||
@@ -133,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) {
|
||||||
@@ -146,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) {
|
||||||
@@ -159,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) {
|
||||||
@@ -172,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) {
|
||||||
@@ -185,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) {
|
||||||
@@ -198,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) {
|
||||||
@@ -211,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) {
|
||||||
@@ -224,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()) {
|
||||||
@@ -248,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
|
||||||
|
|||||||
@@ -1,155 +1,155 @@
|
|||||||
package speiger.src.builder;
|
package speiger.src.builder;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
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.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
import speiger.src.builder.mappers.IMapper;
|
import speiger.src.builder.mappers.IMapper;
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ModulePackage
|
public class ModulePackage
|
||||||
{
|
{
|
||||||
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
||||||
public static final ClassType[] TYPE = ClassType.values();
|
public static final ClassType[] TYPE = ClassType.values();
|
||||||
final ClassType keyType;
|
final ClassType keyType;
|
||||||
final ClassType valueType;
|
final ClassType valueType;
|
||||||
Set<String> blocked = new HashSet<>();
|
Set<String> blocked = new HashSet<>();
|
||||||
Map<String, String> nameRemapper = new HashMap<>();
|
Map<String, String> nameRemapper = new HashMap<>();
|
||||||
Map<String, String> splitters = new HashMap<>();
|
Map<String, String> splitters = new HashMap<>();
|
||||||
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||||
List<IMapper> mappers = new ArrayList<>();
|
List<IMapper> mappers = new ArrayList<>();
|
||||||
Set<String> flags = new LinkedHashSet<>();
|
Set<String> flags = new LinkedHashSet<>();
|
||||||
Set<String> globalFlags;
|
Set<String> globalFlags;
|
||||||
Map<String, Integer> flaggedValues = new HashMap<>();
|
Map<String, Integer> flaggedValues = new HashMap<>();
|
||||||
BiConsumer<String, RequiredType> requirements = VOID;
|
BiConsumer<String, RequiredType> requirements = VOID;
|
||||||
|
|
||||||
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
||||||
this.globalFlags = globalFlags;
|
this.globalFlags = globalFlags;
|
||||||
this.keyType = keyType;
|
this.keyType = keyType;
|
||||||
this.valueType = valueType;
|
this.valueType = valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
requirements = VOID;
|
requirements = VOID;
|
||||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
||||||
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
||||||
this.requirements = requirements;
|
this.requirements = requirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSame() {
|
public boolean isSame() {
|
||||||
return keyType == valueType;
|
return keyType == valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnumValid() {
|
public boolean isEnumValid() {
|
||||||
return keyType == ClassType.OBJECT;
|
return keyType == ClassType.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassType getKeyType() {
|
public ClassType getKeyType() {
|
||||||
return keyType;
|
return keyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassType getValueType() {
|
public ClassType getValueType() {
|
||||||
return valueType;
|
return valueType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFlag(String flag) {
|
public void addFlag(String flag) {
|
||||||
flags.add(flag);
|
flags.add(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addGlobalFlag(String flag) {
|
public void addGlobalFlag(String flag) {
|
||||||
globalFlags.add(flag);
|
globalFlags.add(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addValue(String key, int value) {
|
public void addValue(String key, int value) {
|
||||||
flaggedValues.put(key, value);
|
flaggedValues.put(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRequirement(String fileName, RequiredType type) {
|
public void addRequirement(String fileName, RequiredType type) {
|
||||||
requirements.accept(fileName, type);
|
requirements.accept(fileName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMapper(IMapper mapper) {
|
public void addMapper(IMapper mapper) {
|
||||||
mappers.add(mapper);
|
mappers.add(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockedFilter(Predicate<String> filter) {
|
public void addBlockedFilter(Predicate<String> filter) {
|
||||||
blockedFilters.add(filter);
|
blockedFilters.add(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBlockedFiles(String... names) {
|
public void addBlockedFiles(String... names) {
|
||||||
blocked.addAll(Arrays.asList(names));
|
blocked.addAll(Arrays.asList(names));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addSplitter(String fileName, String splitter) {
|
public void addSplitter(String fileName, String splitter) {
|
||||||
splitters.put(fileName, splitter);
|
splitters.put(fileName, splitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRemapper(String fileName, String actualName) {
|
public void addRemapper(String fileName, String actualName) {
|
||||||
nameRemapper.put(fileName, actualName);
|
nameRemapper.put(fileName, actualName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void process(String fileName, Consumer<TemplateProcess> result) {
|
public void process(String fileName, Consumer<TemplateProcess> result) {
|
||||||
if(isBlocked(fileName)) return;
|
if(isBlocked(fileName)) return;
|
||||||
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
||||||
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
||||||
TemplateProcess process = new TemplateProcess(newName+".java");
|
TemplateProcess process = new TemplateProcess(newName+".java");
|
||||||
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
||||||
process.addFlags(flags);
|
process.addFlags(flags);
|
||||||
process.addFlags(globalFlags);
|
process.addFlags(globalFlags);
|
||||||
process.addMappers(mappers);
|
process.addMappers(mappers);
|
||||||
process.addValues(flaggedValues);
|
process.addValues(flaggedValues);
|
||||||
result.accept(process);
|
result.accept(process);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isBlocked(String fileName) {
|
private boolean isBlocked(String fileName) {
|
||||||
if(blocked.contains(fileName)) return true;
|
if(blocked.contains(fileName)) return true;
|
||||||
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||||
if(blockedFilters.get(i).test(fileName)) return true;
|
if(blockedFilters.get(i).test(fileName)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||||
List<ModulePackage> list = new ArrayList<>();
|
List<ModulePackage> list = new ArrayList<>();
|
||||||
for(ClassType key : TYPE) {
|
for(ClassType key : TYPE) {
|
||||||
for(ClassType value : TYPE) {
|
for(ClassType value : TYPE) {
|
||||||
list.add(new ModulePackage(globalFlags, key, value));
|
list.add(new ModulePackage(globalFlags, key, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int sort(String key, String value) {
|
private int sort(String key, String value) {
|
||||||
if(value.contains(key)) return 1;
|
if(value.contains(key)) return 1;
|
||||||
else if(key.contains(value)) return -1;
|
else if(key.contains(value)) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PathBuilder implements UnaryOperator<Path> {
|
class PathBuilder implements UnaryOperator<Path> {
|
||||||
String before;
|
String before;
|
||||||
|
|
||||||
public PathBuilder(String before) {
|
public PathBuilder(String before) {
|
||||||
this.before = before;
|
this.before = before;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Path apply(Path t) {
|
public Path apply(Path t) {
|
||||||
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,270 +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.Collections;
|
import java.util.Collections;
|
||||||
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.stream.Stream;
|
||||||
|
|
||||||
import speiger.src.builder.modules.AsyncModule;
|
import speiger.src.builder.modules.AsyncModule;
|
||||||
import speiger.src.builder.modules.BaseModule;
|
import speiger.src.builder.modules.BaseModule;
|
||||||
import speiger.src.builder.modules.CollectionModule;
|
import speiger.src.builder.modules.CollectionModule;
|
||||||
import speiger.src.builder.modules.FunctionModule;
|
import speiger.src.builder.modules.FunctionModule;
|
||||||
import speiger.src.builder.modules.JavaModule;
|
import speiger.src.builder.modules.JavaModule;
|
||||||
import speiger.src.builder.modules.ListModule;
|
import speiger.src.builder.modules.ListModule;
|
||||||
import speiger.src.builder.modules.MapModule;
|
import speiger.src.builder.modules.MapModule;
|
||||||
import speiger.src.builder.modules.PairModule;
|
import speiger.src.builder.modules.PairModule;
|
||||||
import speiger.src.builder.modules.PrioQueueModule;
|
import speiger.src.builder.modules.PrioQueueModule;
|
||||||
import speiger.src.builder.modules.SetModule;
|
import speiger.src.builder.modules.SetModule;
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
import speiger.src.builder.processor.TemplateProcessor;
|
import speiger.src.builder.processor.TemplateProcessor;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||||
{
|
{
|
||||||
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||||
private static final int LOAD = 0x2; //If Configs should be loaded
|
private static final int LOAD = 0x2; //If Configs should be loaded
|
||||||
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
||||||
private static final int SAVE = 0x4; //if the configuration should be created
|
private static final int SAVE = 0x4; //if the configuration should be created
|
||||||
Set<String> globalFlags = new HashSet<>();
|
Set<String> globalFlags = new HashSet<>();
|
||||||
List<ModulePackage> simplePackages = new ArrayList<>();
|
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||||
List<ModulePackage> biPackages = new ArrayList<>();
|
List<ModulePackage> biPackages = new ArrayList<>();
|
||||||
List<ModulePackage> enumPackages = new ArrayList<>();
|
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||||
Map<String, RequiredType> requirements = new HashMap<>();
|
Map<String, RequiredType> requirements = new HashMap<>();
|
||||||
SettingsManager manager = new SettingsManager();
|
SettingsManager manager = new SettingsManager();
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder()
|
public PrimitiveCollectionsBuilder() {
|
||||||
{
|
this(false);
|
||||||
this(false);
|
}
|
||||||
}
|
|
||||||
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess) {
|
||||||
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/"));
|
||||||
{
|
}
|
||||||
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(Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
|
this(false, sourceFolder, outputFolder, dataFolder);
|
||||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
}
|
||||||
{
|
|
||||||
this(false, sourceFolder, outputFolder, dataFolder);
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder) {
|
||||||
}
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
|
}
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
|
||||||
{
|
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
this.flags = flags;
|
||||||
}
|
if((flags & ANTI_SAVE) != 0) {
|
||||||
|
this.flags &= ~SAVE;
|
||||||
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
}
|
||||||
this.flags = flags;
|
return this;
|
||||||
if((flags & ANTI_SAVE) != 0) {
|
}
|
||||||
this.flags &= ~SAVE;
|
|
||||||
}
|
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||||
return this;
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
}
|
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||||
|
Paths.get("src/test/java/speiger/src/tests/"),
|
||||||
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||||
return new PrimitiveCollectionsBuilder(silent,
|
}
|
||||||
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
|
||||||
Paths.get("src/test/java/speiger/src/tests/"),
|
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||||
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
}
|
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
||||||
|
Paths.get("src/test/java/speiger/src/testers/"),
|
||||||
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
||||||
return new PrimitiveCollectionsBuilder(silent,
|
}
|
||||||
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
|
||||||
Paths.get("src/test/java/speiger/src/testers/"),
|
@Override
|
||||||
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
protected boolean isFileValid(Path fileName) { return true; }
|
||||||
}
|
@Override
|
||||||
|
protected boolean relativePackages() { return true; }
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFileValid(Path fileName)
|
protected boolean debugUnusedMappers() { return false; }
|
||||||
{
|
|
||||||
return true;
|
@Override
|
||||||
}
|
protected void afterFinish() {
|
||||||
|
if((flags & SPECIAL) == 0 && getVersion() > 8) {
|
||||||
@Override
|
Path basePath = Paths.get("src/main/java");
|
||||||
protected boolean relativePackages()
|
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java"))) {
|
||||||
{
|
writer.write(getModuleInfo(basePath));
|
||||||
return true;
|
}
|
||||||
}
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
@Override
|
}
|
||||||
protected boolean debugUnusedMappers()
|
|
||||||
{
|
public List<BaseModule> createModules() {
|
||||||
return false;
|
List<BaseModule> modules = new ArrayList<>();
|
||||||
}
|
modules.add(JavaModule.INSTANCE);
|
||||||
|
modules.add(FunctionModule.INSTANCE);
|
||||||
@Override
|
modules.add(CollectionModule.INSTANCE);
|
||||||
protected void afterFinish()
|
modules.add(PrioQueueModule.INSTANCE);
|
||||||
{
|
modules.add(ListModule.INSTANCE);
|
||||||
if((flags & SPECIAL) == 0 && getVersion() > 8)
|
modules.add(SetModule.INSTANCE);
|
||||||
{
|
modules.add(MapModule.INSTANCE);
|
||||||
Path basePath = Paths.get("src/main/java");
|
modules.add(PairModule.INSTANCE);
|
||||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
modules.add(AsyncModule.INSTANCE);
|
||||||
{
|
return modules;
|
||||||
writer.write(getModuleInfo(basePath));
|
}
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
@Override
|
||||||
e.printStackTrace();
|
protected void init() {
|
||||||
}
|
prepPackages();
|
||||||
}
|
//Init Modules here
|
||||||
}
|
addModules(createModules());
|
||||||
|
finishPackages();
|
||||||
public List<BaseModule> createModules()
|
}
|
||||||
{
|
|
||||||
List<BaseModule> modules = new ArrayList<>();
|
public void addModules(List<BaseModule> modules) {
|
||||||
modules.add(JavaModule.INSTANCE);
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
modules.add(FunctionModule.INSTANCE);
|
modules.get(i).setManager(manager);
|
||||||
modules.add(CollectionModule.INSTANCE);
|
}
|
||||||
modules.add(PrioQueueModule.INSTANCE);
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
modules.add(ListModule.INSTANCE);
|
biPackages.forEach(modules.get(i)::init);
|
||||||
modules.add(SetModule.INSTANCE);
|
}
|
||||||
modules.add(MapModule.INSTANCE);
|
modules.forEach(BaseModule::cleanup);
|
||||||
modules.add(PairModule.INSTANCE);
|
}
|
||||||
modules.add(AsyncModule.INSTANCE);
|
|
||||||
return modules;
|
private void finishPackages() {
|
||||||
}
|
biPackages.forEach(ModulePackage::finish);
|
||||||
|
if((flags & SAVE) != 0) manager.save();
|
||||||
|
}
|
||||||
@Override
|
|
||||||
protected void init()
|
private void prepPackages() {
|
||||||
{
|
if((flags & LOAD) != 0) manager.load();
|
||||||
prepPackages();
|
for(ModulePackage entry : ModulePackage.createPackages(globalFlags)) {
|
||||||
//Init Modules here
|
entry.setRequirements(requirements::put);
|
||||||
addModules(createModules());
|
biPackages.add(entry);
|
||||||
finishPackages();
|
if(entry.isSame()) simplePackages.add(entry);
|
||||||
}
|
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||||
|
}
|
||||||
public void addModules(List<BaseModule> modules)
|
}
|
||||||
{
|
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
@Override
|
||||||
modules.get(i).setManager(manager);
|
public void createProcesses(String fileName, Consumer<TemplateProcess> process) {
|
||||||
}
|
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
for(int i = 0,m=packages.size();i<m;i++) {
|
||||||
biPackages.forEach(modules.get(i)::init);
|
packages.get(i).process(fileName, process);
|
||||||
}
|
}
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
}
|
||||||
modules.get(i).cleanup();
|
|
||||||
}
|
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||||
}
|
if(type == null) return simplePackages;
|
||||||
|
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||||
private void finishPackages()
|
if(type == RequiredType.ENUM) return enumPackages;
|
||||||
{
|
return Collections.emptyList();
|
||||||
biPackages.forEach(ModulePackage::finish);
|
}
|
||||||
if((flags & SAVE) != 0) manager.save();
|
|
||||||
}
|
private String getModuleInfo(Path basePath) {
|
||||||
|
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||||
private void prepPackages()
|
try(Stream<Path> stream = Files.walk(getOutputFolder())) {
|
||||||
{
|
stream.filter(Files::isDirectory)
|
||||||
if((flags & LOAD) != 0) manager.load();
|
.filter(this::containsFiles)
|
||||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
.map(basePath::relativize)
|
||||||
{
|
.map(Path::toString)
|
||||||
entry.setRequirements(requirements::put);
|
.map(this::sanitize)
|
||||||
biPackages.add(entry);
|
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||||
if(entry.isSame()) simplePackages.add(entry);
|
}
|
||||||
if(entry.isEnumValid()) enumPackages.add(entry);
|
catch(Exception e) {
|
||||||
}
|
e.printStackTrace();
|
||||||
}
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
@Override
|
StringBuilder builder = new StringBuilder();
|
||||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
builder.append("/** @author Speiger */\n");
|
||||||
{
|
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
||||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
builder.append(joiner.toString()).append("}");
|
||||||
for(int i = 0,m=packages.size();i<m;i++)
|
return builder.toString();
|
||||||
{
|
}
|
||||||
packages.get(i).process(fileName, process);
|
|
||||||
}
|
private String sanitize(String input) {
|
||||||
}
|
return input.replace("\\", ".").replace("/", ".");
|
||||||
|
}
|
||||||
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
|
||||||
if(type == null) return simplePackages;
|
private boolean containsFiles(Path path) {
|
||||||
if(type == RequiredType.BI_CLASS) return biPackages;
|
try(Stream<Path> stream = Files.walk(path, 1)) {
|
||||||
if(type == RequiredType.ENUM) return enumPackages;
|
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||||
return Collections.emptyList();
|
}
|
||||||
}
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
|
return false;
|
||||||
private String getModuleInfo(Path basePath) {
|
}
|
||||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
|
||||||
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
private int getVersion() {
|
||||||
{
|
String version = System.getProperty("java.version");
|
||||||
stream.filter(Files::isDirectory)
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
.filter(this::containsFiles)
|
int dot = version.indexOf(".");
|
||||||
.map(basePath::relativize)
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
.map(Path::toString)
|
}
|
||||||
.map(this::sanitize)
|
|
||||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
public static void main(String...args) {
|
||||||
}
|
try
|
||||||
catch(Exception e)
|
{
|
||||||
{
|
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||||
e.printStackTrace();
|
boolean silent = flags.contains("silent");
|
||||||
throw new RuntimeException(e);
|
boolean force = flags.contains("force");
|
||||||
}
|
boolean tests = flags.contains("tests");
|
||||||
StringBuilder builder = new StringBuilder();
|
boolean forceTests = flags.contains("force-tests");
|
||||||
builder.append("/** @author Speiger */\n");
|
boolean load = flags.contains("load");
|
||||||
builder.append("module ").append(sanitize(basePath.relativize(getOutputFolder()).toString())).append(" {\n");
|
boolean save = flags.contains("save");
|
||||||
builder.append(joiner.toString()).append("}");
|
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||||
return builder.toString();
|
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||||
}
|
if(tests) {
|
||||||
|
createTests(silent, flag).process(force || forceTests);
|
||||||
private String sanitize(String input)
|
createTesters(silent, flag).process(force || forceTests);
|
||||||
{
|
}
|
||||||
return input.replace("\\", ".").replace("/", ".");
|
}
|
||||||
}
|
catch(InterruptedException | IOException e)
|
||||||
|
{
|
||||||
private boolean containsFiles(Path path)
|
e.printStackTrace();
|
||||||
{
|
}
|
||||||
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");
|
|
||||||
boolean load = flags.contains("load");
|
|
||||||
boolean save = flags.contains("save");
|
|
||||||
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
|
||||||
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
|
||||||
if(tests) {
|
|
||||||
createTests(silent, flag).process(force || forceTests);
|
|
||||||
createTesters(silent, flag).process(force || forceTests);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(InterruptedException | IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public abstract class BaseModule
|
|||||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||||
|
|
||||||
|
public ClassType keyType() { return keyType; }
|
||||||
|
public ClassType valueType() { return valueType; }
|
||||||
|
|
||||||
protected boolean isModuleEnabled() {
|
protected boolean isModuleEnabled() {
|
||||||
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public class FunctionModule extends BaseModule
|
|||||||
protected void loadFunctions()
|
protected void loadFunctions()
|
||||||
{
|
{
|
||||||
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||||
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
|
||||||
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,221 +1,221 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class JavaModule extends BaseModule
|
public class JavaModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new JavaModule();
|
public static final BaseModule INSTANCE = new JavaModule();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Base"; }
|
public String getModuleName() { return "Base"; }
|
||||||
@Override
|
@Override
|
||||||
protected void loadVariables()
|
protected void loadVariables()
|
||||||
{
|
{
|
||||||
createHelperVars(keyType, false, "KEY");
|
createHelperVars(keyType, false, "KEY");
|
||||||
createHelperVars(valueType, true, "VALUE");
|
createHelperVars(valueType, true, "VALUE");
|
||||||
loadBaseVariables();
|
loadBaseVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags()
|
protected void loadFlags()
|
||||||
{
|
{
|
||||||
addFlag("TYPE_"+keyType.getCapType());
|
addFlag("TYPE_"+keyType.getCapType());
|
||||||
addFlag("VALUE_"+valueType.getCapType());
|
addFlag("VALUE_"+valueType.getCapType());
|
||||||
addValue("JAVA_VERSION", getVersion());
|
addValue("JAVA_VERSION", getVersion());
|
||||||
if(keyType == valueType) addFlag("SAME_TYPE");
|
if(keyType == valueType) addFlag("SAME_TYPE");
|
||||||
if(keyType.hasFunction(valueType)) addFlag("JDK_FUNCTION");
|
if(keyType.hasFunction(valueType)) addFlag("JDK_FUNCTION");
|
||||||
if(!keyType.needsCustomJDKType()) addFlag("JDK_TYPE");
|
if(!keyType.needsCustomJDKType()) addFlag("JDK_TYPE");
|
||||||
if(!keyType.isPrimitiveBlocking()) addFlag("PRIMITIVES");
|
if(!keyType.isPrimitiveBlocking()) addFlag("PRIMITIVES");
|
||||||
if(!valueType.isPrimitiveBlocking()) addFlag("VALUE_PRIMITIVES");
|
if(!valueType.isPrimitiveBlocking()) addFlag("VALUE_PRIMITIVES");
|
||||||
if(!valueType.needsCustomJDKType()) addFlag("JDK_VALUE");
|
if(!valueType.needsCustomJDKType()) addFlag("JDK_VALUE");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVersion() {
|
private int getVersion() {
|
||||||
String version = System.getProperty("java.version");
|
String version = System.getProperty("java.version");
|
||||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
int dot = version.indexOf(".");
|
int dot = version.indexOf(".");
|
||||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadRemappers() {}
|
protected void loadRemappers() {}
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades() {}
|
protected void loadBlockades() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFunctions()
|
protected void loadFunctions()
|
||||||
{
|
{
|
||||||
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
|
|
||||||
//Shared by Maps and Pairs so moved to java.
|
//Shared by Maps and Pairs so moved to java.
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||||
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
||||||
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
||||||
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadClasses()
|
protected void loadClasses()
|
||||||
{
|
{
|
||||||
if(getVersion() >= 17) addSimpleMapper("RANDOM", "RandomGenerator");
|
if(getVersion() >= 17) addSimpleMapper("RANDOM", "RandomGenerator");
|
||||||
else addSimpleMapper("RANDOM", "Random");
|
else addSimpleMapper("RANDOM", "Random");
|
||||||
addSimpleMapper("JAVA_PREDICATE", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Predicate");
|
addSimpleMapper("JAVA_PREDICATE", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Predicate");
|
||||||
addSimpleMapper("JAVA_CONSUMER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Consumer");
|
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_SUPPLIER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Supplier");
|
||||||
addSimpleMapper("JAVA_FUNCTION", keyType.getFunctionClass(valueType));
|
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_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_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_SPLIT_ITERATOR", keyType.isPrimitiveBlocking() ? "Spliterator" : "Of"+keyType.getCustomJDKType().getFileType());
|
||||||
addSimpleMapper("JAVA_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Stream");
|
addSimpleMapper("JAVA_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Stream");
|
||||||
addSimpleMapper("JAVA_BUFFER", keyType.getFileType()+"Buffer");
|
addSimpleMapper("JAVA_BUFFER", keyType.getFileType()+"Buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadTestClasses()
|
protected void loadTestClasses()
|
||||||
{
|
{
|
||||||
addClassMapper("HELPERS", "Helpers");
|
addClassMapper("HELPERS", "Helpers");
|
||||||
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadBaseVariables()
|
private void loadBaseVariables()
|
||||||
{
|
{
|
||||||
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
||||||
addSimpleMapper("PACKAGE", keyType.getPathType());
|
addSimpleMapper("PACKAGE", keyType.getPathType());
|
||||||
addSimpleMapper("CLASS_TYPE", keyType.getClassType());
|
addSimpleMapper("CLASS_TYPE", keyType.getClassType());
|
||||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
||||||
addSimpleMapper("KEY_TYPE", keyType.getKeyType());
|
addSimpleMapper("KEY_TYPE", keyType.getKeyType());
|
||||||
addSimpleMapper("KEY_OBJECT_TYPE", keyType.isObject() ? "Object" : keyType.getKeyType());
|
addSimpleMapper("KEY_OBJECT_TYPE", keyType.isObject() ? "Object" : keyType.getKeyType());
|
||||||
addSimpleMapper("KEY_STRING_TYPE", keyType.isObject() ? "String" : keyType.getKeyType());
|
addSimpleMapper("KEY_STRING_TYPE", keyType.isObject() ? "String" : keyType.getKeyType());
|
||||||
addSimpleMapper("KEY_SPECIAL_TYPE", keyType.isObject() ? "E" : keyType.getKeyType());
|
addSimpleMapper("KEY_SPECIAL_TYPE", keyType.isObject() ? "E" : keyType.getKeyType());
|
||||||
addSimpleMapper("CLASS_OBJECT_TYPE", keyType.getClassType());
|
addSimpleMapper("CLASS_OBJECT_TYPE", keyType.getClassType());
|
||||||
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
||||||
addSimpleMapper("CLASS_STRING_TYPE", keyType.isObject() ? "String" : keyType.getClassType());
|
addSimpleMapper("CLASS_STRING_TYPE", keyType.isObject() ? "String" : keyType.getClassType());
|
||||||
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
||||||
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
||||||
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
||||||
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
||||||
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
||||||
addSimpleMapper("KEY_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
addSimpleMapper("KEY_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
addSimpleMapper("VALUE_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
addSimpleMapper("VALUE_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
|
|
||||||
addSimpleMapper("EMPTY_KEY_VALUE", keyType.getEmptyValue());
|
addSimpleMapper("EMPTY_KEY_VALUE", keyType.getEmptyValue());
|
||||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
||||||
|
|
||||||
addSimpleMapper("INVALID_KEY_VALUE", keyType.getInvalidValue());
|
addSimpleMapper("INVALID_KEY_VALUE", keyType.getInvalidValue());
|
||||||
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
||||||
|
|
||||||
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", keyType.isObject() ? "<String>" : "");
|
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", keyType.isObject() ? "<String>" : "");
|
||||||
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.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_VALUE_STRING_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||||
|
|
||||||
addSimpleMapper(" KEY_SAME_GENERIC_TYPE", keyType.isObject() ? "<T, T>" : "");
|
addSimpleMapper(" KEY_SAME_GENERIC_TYPE", keyType.isObject() ? "<T, T>" : "");
|
||||||
addSimpleMapper(" VALUE_SAME_GENERIC_TYPE", keyType.isObject() ? "<V, V>" : "");
|
addSimpleMapper(" VALUE_SAME_GENERIC_TYPE", keyType.isObject() ? "<V, V>" : "");
|
||||||
|
|
||||||
addSimpleMapper(" KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+">" : "");
|
addSimpleMapper(" KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", "+keyType.getKeyType()+">" : "");
|
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", "+keyType.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getClassType()+">" : "");
|
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getClassType()+">" : "");
|
||||||
|
|
||||||
|
|
||||||
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
||||||
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "");
|
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "");
|
||||||
addSimpleMapper(" VALUE_CLASS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getClassValueType()+">" : "");
|
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_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()+">" : ""));
|
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();
|
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_GENERIC_TYPE", keyType.isObject() ? "<?>" : "");
|
||||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.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_COMPAREABLE_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||||
|
|
||||||
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "<? super "+keyType.getKeyType()+">" : "");
|
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "<? super "+keyType.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
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_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(" KEY_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? "<? extends "+keyType.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
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_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_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()+">>" : ""));
|
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(" KEY_SPECIAL_GENERIC_TYPE", keyType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.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(" KSK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" KKS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "<%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("<>");
|
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(" SK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" KS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "").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(" VSV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" VVS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%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("<>");
|
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(" SV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" VS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "").removeBraces().setBraceType("<>");
|
addInjectMapper(" VS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
|
||||||
|
|
||||||
addSimpleMapper(" GENERIC_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+">" : "");
|
addSimpleMapper(" GENERIC_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
||||||
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", keyType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", keyType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.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()+">" : ""));
|
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_KEY_SPECIAL_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
||||||
addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.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(" 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(" COMPAREABLE_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||||
addSimpleMapper("KV_BRACES", keyType.isObject() || valueType.isObject() ? "<>" : "");
|
addSimpleMapper("KV_BRACES", keyType.isObject() || valueType.isObject() ? "<>" : "");
|
||||||
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
||||||
addSimpleMapper("BRACES", keyType.isObject() ? "<>" : "");
|
addSimpleMapper("BRACES", keyType.isObject() ? "<>" : "");
|
||||||
if(keyType.needsCustomJDKType())
|
if(keyType.needsCustomJDKType())
|
||||||
{
|
{
|
||||||
addSimpleMapper("JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
addSimpleMapper("JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
addSimpleMapper("SANITY_CAST", "castTo"+keyType.getFileType());
|
addSimpleMapper("SANITY_CAST", "castTo"+keyType.getFileType());
|
||||||
}
|
}
|
||||||
addSimpleMapper("JAVA_CLASS", keyType.getCustomJDKType().getClassType());
|
addSimpleMapper("JAVA_CLASS", keyType.getCustomJDKType().getClassType());
|
||||||
if(valueType.needsCustomJDKType())
|
if(valueType.needsCustomJDKType())
|
||||||
{
|
{
|
||||||
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
||||||
}
|
}
|
||||||
addSimpleMapper("[SPACE]", " ");
|
addSimpleMapper("[SPACE]", " ");
|
||||||
addComment("@ArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
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");
|
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("@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");
|
addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection");
|
||||||
addAnnontion("@PrimitiveOverride", "@Override");
|
addAnnontion("@PrimitiveOverride", "@Override");
|
||||||
addSimpleMapper("@PrimitiveDoc", "");
|
addSimpleMapper("@PrimitiveDoc", "");
|
||||||
addAnnontion("@Primitive", "@Deprecated");
|
addAnnontion("@Primitive", "@Deprecated");
|
||||||
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
||||||
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createHelperVars(ClassType type, boolean value, String fix)
|
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();
|
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_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();
|
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_NOT", type.getEquals(true)).removeBraces();
|
||||||
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
||||||
addSimpleMapper("FILE_"+fix+"_TYPE", type.getFileType());
|
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("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();
|
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(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("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("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_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();
|
addInjectMapper(fix+"_TO_STRING", type.isObject() ? "Objects.toString(%s)" : type.getClassType(value)+".toString(%s)").removeBraces();
|
||||||
|
|
||||||
addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : "");
|
addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : "");
|
||||||
addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY");
|
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_"+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();
|
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();
|
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();
|
else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ public class ListModule extends BaseModule
|
|||||||
protected void loadFunctions()
|
protected void loadFunctions()
|
||||||
{
|
{
|
||||||
addFunctionMapper("GET_KEY", "get");
|
addFunctionMapper("GET_KEY", "get");
|
||||||
addFunctionMapper("REMOVE_LAST", "removeLast");
|
addFunctionMapper("GET_FIRST_KEY", "getFirst");
|
||||||
|
addFunctionMapper("GET_LAST_KEY", "getLast");
|
||||||
|
addFunctionMapper("REMOVE_FIRST_KEY", "removeFirst");
|
||||||
|
addFunctionMapper("REMOVE_LAST_KEY", "removeLast");
|
||||||
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
||||||
addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss");
|
addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
addFunctionMappers("SORT", "sort%ss");
|
addFunctionMappers("SORT", "sort%ss");
|
||||||
|
|||||||
@@ -1,281 +1,288 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class MapModule extends BaseModule
|
public class MapModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new MapModule();
|
public static final BaseModule INSTANCE = new MapModule();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Map"; }
|
public String getModuleName() { return "Map"; }
|
||||||
@Override
|
@Override
|
||||||
public boolean isBiModule() { return true; }
|
public boolean isBiModule() { return true; }
|
||||||
@Override
|
@Override
|
||||||
protected void loadVariables() {}
|
protected void loadVariables() {}
|
||||||
@Override
|
@Override
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||||
@Override
|
@Override
|
||||||
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
Set<String> sets = new TreeSet<>();
|
Set<String> sets = new TreeSet<>();
|
||||||
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||||
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
||||||
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
||||||
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
||||||
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
||||||
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
||||||
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
||||||
return sets;
|
return sets;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags()
|
protected void loadFlags()
|
||||||
{
|
{
|
||||||
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||||
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||||
boolean implementations = isModuleEnabled("Implementations");
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||||
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||||
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||||
|
|
||||||
if(isModuleEnabled("OrderedMap")) {
|
if(isModuleEnabled("OrderedMap")) {
|
||||||
addFlag("ORDERED_MAP_FEATURE");
|
addFlag("ORDERED_MAP_FEATURE");
|
||||||
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||||
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||||
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||||
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||||
}
|
}
|
||||||
if(isModuleEnabled("SortedMap")) {
|
if(isModuleEnabled("SortedMap")) {
|
||||||
addFlag("SORTED_MAP_FEATURE");
|
addFlag("SORTED_MAP_FEATURE");
|
||||||
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
||||||
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
||||||
}
|
}
|
||||||
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
||||||
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||||
if(hashMap) addFlag("MAP_FEATURE");
|
if(hashMap) addFlag("MAP_FEATURE");
|
||||||
if(customHashMap) addFlag("CUSTOM_MAP_FEATURE");
|
if(customHashMap) addFlag("CUSTOM_MAP_FEATURE");
|
||||||
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||||
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||||
boolean implementations = !isModuleEnabled("Implementations");
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||||
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
|
|
||||||
boolean ordered = !isModuleEnabled("OrderedMap");
|
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||||
if(ordered) addBlockedFiles("OrderedMap");
|
if(ordered) addBlockedFiles("OrderedMap");
|
||||||
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||||
if(hashMap) addBlockedFiles("OpenHashMap");
|
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||||
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||||
|
|
||||||
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||||
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||||
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
||||||
|
|
||||||
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
||||||
if(enumMap) addBlockedFiles("EnumMap");
|
if(enumMap) addBlockedFiles("EnumMap");
|
||||||
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
||||||
|
|
||||||
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
||||||
|
|
||||||
boolean sorted = !isModuleEnabled("SortedMap");
|
boolean sorted = !isModuleEnabled("SortedMap");
|
||||||
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
||||||
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
||||||
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
||||||
|
|
||||||
if(keyType == ClassType.BOOLEAN)
|
if(keyType == ClassType.BOOLEAN)
|
||||||
{
|
{
|
||||||
//Main Classes
|
//Main Classes
|
||||||
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
||||||
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
||||||
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
||||||
|
|
||||||
//Test Classes
|
//Test Classes
|
||||||
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
||||||
addBlockedFiles("TestSortedMapGenerator", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
addBlockedFiles("TestSortedMapGenerator", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||||
addBlockedFiles("TestOrderedMapGenerator");
|
addBlockedFiles("TestOrderedMapGenerator");
|
||||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
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
|
@Override
|
||||||
addBiRequirement("Map");
|
protected void loadRemappers()
|
||||||
addBiRequirement("SortedMap");
|
{
|
||||||
addBiRequirement("OrderedMap");
|
//Main Classes
|
||||||
addBiRequirement("NavigableMap");
|
addBiRequirement("Map");
|
||||||
addBiRequirement("ConcurrentMap");
|
addBiRequirement("SortedMap");
|
||||||
addBiRequirement("AbstractMap");
|
addBiRequirement("OrderedMap");
|
||||||
addEnumRequirement("EnumMap");
|
addBiRequirement("NavigableMap");
|
||||||
addEnumRequirement("LinkedEnumMap");
|
addBiRequirement("ConcurrentMap");
|
||||||
addBiRequirement("ConcurrentOpenHashMap");
|
addBiRequirement("AbstractMap");
|
||||||
addBiRequirement("ImmutableOpenHashMap");
|
addEnumRequirement("EnumMap");
|
||||||
addBiRequirement("OpenHashMap");
|
addEnumRequirement("LinkedEnumMap");
|
||||||
addBiRequirement("LinkedOpenHashMap");
|
addBiRequirement("ConcurrentOpenHashMap");
|
||||||
addBiRequirement("OpenCustomHashMap");
|
addBiRequirement("ImmutableOpenHashMap");
|
||||||
addBiRequirement("LinkedOpenCustomHashMap");
|
addBiRequirement("OpenHashMap");
|
||||||
addBiRequirement("ArrayMap");
|
addBiRequirement("LinkedOpenHashMap");
|
||||||
addBiRequirement("RBTreeMap");
|
addBiRequirement("OpenCustomHashMap");
|
||||||
addBiRequirement("AVLTreeMap");
|
addBiRequirement("LinkedOpenCustomHashMap");
|
||||||
addBiRequirement("Maps");
|
addBiRequirement("ArrayMap");
|
||||||
|
addBiRequirement("RBTreeMap");
|
||||||
addRemapper("AbstractMap", "Abstract%sMap");
|
addBiRequirement("AVLTreeMap");
|
||||||
addRemapper("EnumMap", "Enum2%sMap");
|
addBiRequirement("Maps");
|
||||||
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
|
||||||
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
addRemapper("AbstractMap", "Abstract%sMap");
|
||||||
|
addRemapper("EnumMap", "Enum2%sMap");
|
||||||
//Test Classes
|
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||||
addBiRequirement("TestMapGenerator");
|
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||||
addBiRequirement("TestSortedMapGenerator");
|
|
||||||
addBiRequirement("TestOrderedMapGenerator");
|
//Test Classes
|
||||||
addBiRequirement("SimpleMapTestGenerator");
|
addBiRequirement("TestMapGenerator");
|
||||||
addBiRequirement("DerivedMapGenerators");
|
addBiRequirement("TestSortedMapGenerator");
|
||||||
addBiRequirement("AbstractMapTester");
|
addBiRequirement("TestOrderedMapGenerator");
|
||||||
addBiRequirement("MapTestSuiteBuilder");
|
addBiRequirement("SimpleMapTestGenerator");
|
||||||
addBiRequirement("SortedMapTestSuiteBuilder");
|
addBiRequirement("DerivedMapGenerators");
|
||||||
addBiRequirement("NavigableMapTestSuiteBuilder");
|
addBiRequirement("AbstractMapTester");
|
||||||
addBiRequirement("OrderedMapTestSuiteBuilder");
|
addBiRequirement("MapTestSuiteBuilder");
|
||||||
addBiRequirement("MapTests");
|
addBiRequirement("SortedMapTestSuiteBuilder");
|
||||||
addBiRequirement("MapConstructorTests");
|
addBiRequirement("NavigableMapTestSuiteBuilder");
|
||||||
addBiRequirement("TestMap");
|
addBiRequirement("OrderedMapTestSuiteBuilder");
|
||||||
addBiRequirement("MapAddToTester");
|
addBiRequirement("MapTests");
|
||||||
addBiRequirement("MapSubFromTester");
|
addBiRequirement("MapConstructorTests");
|
||||||
addBiRequirement("MapClearTester");
|
addBiRequirement("TestMap");
|
||||||
addBiRequirement("MapComputeIfAbsentTester");
|
addBiRequirement("MapAddToTester");
|
||||||
addBiRequirement("MapComputeIfPresentTester");
|
addBiRequirement("MapSubFromTester");
|
||||||
addBiRequirement("MapComputeTester");
|
addBiRequirement("MapClearTester");
|
||||||
addBiRequirement("MapCopyTester");
|
addBiRequirement("MapComputeIfAbsentTester");
|
||||||
addBiRequirement("MapContainsTester");
|
addBiRequirement("MapComputeIfPresentTester");
|
||||||
addBiRequirement("MapContainsKeyTester");
|
addBiRequirement("MapComputeTester");
|
||||||
addBiRequirement("MapContainsValueTester");
|
addBiRequirement("MapComputeIfAbsentNonDefaultTester");
|
||||||
addBiRequirement("MapCreatorTester");
|
addBiRequirement("MapComputeIfPresentNonDefaultTester");
|
||||||
addBiRequirement("MapEntrySetTester");
|
addBiRequirement("MapComputeNonDefaultTester");
|
||||||
addBiRequirement("MapEqualsTester");
|
addBiRequirement("MapCopyTester");
|
||||||
addBiRequirement("MapForEachTester");
|
addBiRequirement("MapContainsTester");
|
||||||
addBiRequirement("MapGetOrDefaultTester");
|
addBiRequirement("MapContainsKeyTester");
|
||||||
addBiRequirement("MapGetTester");
|
addBiRequirement("MapContainsValueTester");
|
||||||
addBiRequirement("MapHashCodeTester");
|
addBiRequirement("MapCreatorTester");
|
||||||
addBiRequirement("MapIsEmptyTester");
|
addBiRequirement("MapEntrySetTester");
|
||||||
addBiRequirement("MapMergeTester");
|
addBiRequirement("MapEqualsTester");
|
||||||
addBiRequirement("MapMergeBulkTester");
|
addBiRequirement("MapForEachTester");
|
||||||
addBiRequirement("MapPutAllArrayTester");
|
addBiRequirement("MapGetOrDefaultTester");
|
||||||
addBiRequirement("MapPutAllTester");
|
addBiRequirement("MapGetTester");
|
||||||
addBiRequirement("MapPutIfAbsentTester");
|
addBiRequirement("MapHashCodeTester");
|
||||||
addBiRequirement("MapPutTester");
|
addBiRequirement("MapIsEmptyTester");
|
||||||
addBiRequirement("MapRemoveEntryTester");
|
addBiRequirement("MapMergeTester");
|
||||||
addBiRequirement("MapRemoveOrDefaultTester");
|
addBiRequirement("MapMergeBulkTester");
|
||||||
addBiRequirement("MapRemoveTester");
|
addBiRequirement("MapPutAllArrayTester");
|
||||||
addBiRequirement("MapReplaceAllTester");
|
addBiRequirement("MapPutAllTester");
|
||||||
addBiRequirement("MapReplaceEntryTester");
|
addBiRequirement("MapPutIfAbsentTester");
|
||||||
addBiRequirement("MapReplaceTester");
|
addBiRequirement("MapPutTester");
|
||||||
addBiRequirement("MapSizeTester");
|
addBiRequirement("MapRemoveEntryTester");
|
||||||
addBiRequirement("MapSupplyIfAbsentTester");
|
addBiRequirement("MapRemoveOrDefaultTester");
|
||||||
addBiRequirement("MapToStringTester");
|
addBiRequirement("MapRemoveTester");
|
||||||
addBiRequirement("NavigableMapNavigationTester");
|
addBiRequirement("MapReplaceAllTester");
|
||||||
addBiRequirement("SortedMapNavigationTester");
|
addBiRequirement("MapReplaceEntryTester");
|
||||||
addBiRequirement("OrderedMapNavigationTester");
|
addBiRequirement("MapReplaceTester");
|
||||||
addBiRequirement("OrderedMapMoveTester");
|
addBiRequirement("MapSizeTester");
|
||||||
addBiRequirement("MapConstructorTester");
|
addBiRequirement("MapSupplyIfAbsentTester");
|
||||||
|
addBiRequirement("MapSupplyIfAbsentNonDefaultTester");
|
||||||
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
addBiRequirement("MapToStringTester");
|
||||||
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
addBiRequirement("NavigableMapNavigationTester");
|
||||||
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
addBiRequirement("SortedMapNavigationTester");
|
||||||
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
addBiRequirement("OrderedMapNavigationTester");
|
||||||
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
addBiRequirement("OrderedMapMoveTester");
|
||||||
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
addBiRequirement("MapConstructorTester");
|
||||||
addRemapper("TestMap", "Test%sMap");
|
|
||||||
}
|
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||||
|
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||||
@Override
|
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||||
protected void loadFunctions()
|
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||||
{
|
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||||
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
||||||
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
addRemapper("TestMap", "Test%sMap");
|
||||||
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
}
|
||||||
addFunctionValueMapper("COMPUTE", "compute");
|
|
||||||
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
@Override
|
||||||
addFunctionMapper("DEQUEUE", "dequeue");
|
protected void loadFunctions()
|
||||||
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
{
|
||||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
||||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
||||||
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
||||||
else addSimpleMapper("GET_VALUE", "get");
|
addFunctionValueMapper("COMPUTE", "compute");
|
||||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
||||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
addFunctionMapper("DEQUEUE", "dequeue");
|
||||||
addFunctionValueMapper("MERGE", "merge");
|
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
||||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
||||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
||||||
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
else addSimpleMapper("GET_VALUE", "get");
|
||||||
addFunctionMapper("REMOVE", "remove");
|
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
||||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
||||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
addFunctionValueMapper("MERGE", "merge");
|
||||||
}
|
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
||||||
|
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
||||||
@Override
|
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
||||||
protected void loadClasses()
|
else addSimpleMapper("REMOVE_VALUE", "remove");
|
||||||
{
|
addFunctionMapper("REMOVE", "remove");
|
||||||
//Implementation Classes
|
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
||||||
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
}
|
||||||
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
|
||||||
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
@Override
|
||||||
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
protected void loadClasses()
|
||||||
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
{
|
||||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
//Implementation Classes
|
||||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
||||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
||||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
||||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
||||||
|
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
||||||
//Abstract Classes
|
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
||||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||||
|
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||||
//Helper Classes
|
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||||
addBiClassMapper("MAPS", "Maps", "2");
|
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||||
|
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||||
//Interfaces
|
|
||||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
//Abstract Classes
|
||||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
|
||||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
//Helper Classes
|
||||||
addBiClassMapper("MAP", "Map", "2");
|
addBiClassMapper("MAPS", "Maps", "2");
|
||||||
}
|
|
||||||
|
//Interfaces
|
||||||
@Override
|
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||||
protected void loadTestClasses()
|
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||||
{
|
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||||
//Implementation Classes
|
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
||||||
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
addBiClassMapper("MAP", "Map", "2");
|
||||||
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
}
|
||||||
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
|
||||||
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
@Override
|
||||||
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
protected void loadTestClasses()
|
||||||
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
{
|
||||||
|
//Implementation Classes
|
||||||
//Abstract Classes
|
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||||
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||||
|
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||||
//Helper Classes
|
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||||
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||||
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||||
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
|
||||||
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
//Abstract Classes
|
||||||
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||||
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@ public class SetModule extends BaseModule
|
|||||||
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
||||||
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
||||||
addFunctionMapper("FIRST_KEY", "first");
|
addFunctionMapper("FIRST_KEY", "first");
|
||||||
addFunctionMapper("LAST_KEY", "last");
|
addFunctionMapper("LAST_KEY", "last");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+265
-265
@@ -1,266 +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;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract Type Specific Collection that reduces boxing/unboxing
|
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||||
* @Type(T)
|
* @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
|
@Override
|
||||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/** {@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
|
||||||
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
public boolean add(CLASS_TYPE e) { return COLLECTION.super.add(e); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();modified |= add(iter.NEXT()));
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/** {@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
|
||||||
public boolean contains(Object e) { return COLLECTION.super.contains(e); }
|
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.
|
* 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.
|
* @param e the element that should be searched for.
|
||||||
* @return true if the value was found.
|
* @return true if the value was found.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE e) {
|
public boolean contains(KEY_TYPE e) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) { if(KEY_EQUALS(iter.NEXT(), e)) return true; }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@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
|
||||||
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) : 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.
|
* 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.
|
* @param c the collection that should be checked if it contains all elements.
|
||||||
* @return true if all elements were found in the collection
|
* @return true if all elements were found in the collection
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) return true;
|
if(c.isEmpty()) return true;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
if(!contains(iter.NEXT()))
|
if(!contains(iter.NEXT()))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(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
|
* 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
|
* @param c the elements that should be checked for
|
||||||
* @return true if any element is in this collection
|
* @return true if any element is in this collection
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAny(Collection<?> c) {
|
public boolean containsAny(Collection<?> c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) return false;
|
if(c.isEmpty()) return false;
|
||||||
for(Object e : c)
|
for(Object e : c)
|
||||||
if(contains(e))
|
if(contains(e))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
* 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
|
* @param c the elements that should be checked for
|
||||||
* @return true if any element is in this collection
|
* @return true if any element is in this collection
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) return false;
|
if(c.isEmpty()) return false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
if(contains(iter.NEXT()))
|
if(contains(iter.NEXT()))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/** {@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
|
||||||
public boolean remove(Object e) { return COLLECTION.super.remove(e); }
|
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.
|
* 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
|
* It stops after finding the first element
|
||||||
* @param e the element that is searched for
|
* @param e the element that is searched for
|
||||||
* @return true if the element was found and removed.
|
* @return true if the element was found and removed.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(KEY_EQUALS(iter.NEXT(), e)) {
|
if(KEY_EQUALS(iter.NEXT(), e)) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
return true;
|
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.
|
* 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
|
* @param c the elements that should be deleted
|
||||||
* @return true if the collection was modified.
|
* @return true if the collection was modified.
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) return false;
|
if(c.isEmpty()) return false;
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(c.contains(iter.NEXT())) {
|
if(c.contains(iter.NEXT())) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) return false;
|
if(c.isEmpty()) return false;
|
||||||
Objects.requireNonNull(r);
|
Objects.requireNonNull(r);
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
KEY_TYPE e = iter.NEXT();
|
KEY_TYPE e = iter.NEXT();
|
||||||
if(c.contains(e)) {
|
if(c.contains(e)) {
|
||||||
r.accept(e);
|
r.accept(e);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
modified = true;
|
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.
|
* 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
|
* @param c the elements that should be kept
|
||||||
* @return true if the collection was modified.
|
* @return true if the collection was modified.
|
||||||
* @throws java.lang.NullPointerException if the collection is null
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
if(c.isEmpty()) {
|
if(c.isEmpty()) {
|
||||||
boolean modified = !isEmpty();
|
boolean modified = !isEmpty();
|
||||||
clear();
|
clear();
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(!c.contains(iter.NEXT())) {
|
if(!c.contains(iter.NEXT())) {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
Objects.requireNonNull(r);
|
Objects.requireNonNull(r);
|
||||||
if(c.isEmpty()) {
|
if(c.isEmpty()) {
|
||||||
boolean modified = !isEmpty();
|
boolean modified = !isEmpty();
|
||||||
forEach(r);
|
forEach(r);
|
||||||
clear();
|
clear();
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
KEY_TYPE e = iter.NEXT();
|
KEY_TYPE e = iter.NEXT();
|
||||||
if(!c.contains(e)) {
|
if(!c.contains(e)) {
|
||||||
r.accept(e);
|
r.accept(e);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
modified = true;
|
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.
|
* A Type-Specific implementation of toArray that links to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY() {
|
public KEY_TYPE[] TO_ARRAY() {
|
||||||
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
||||||
return TO_ARRAY(new KEY_TYPE[size()]);
|
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.
|
* 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
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||||
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
if(a == null || a.length < size()) a = new KEY_TYPE[size()];
|
||||||
ITERATORS.unwrap(a, iterator());
|
ITERATORS.unwrap(a, iterator());
|
||||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+322
-321
@@ -1,322 +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;
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
#if 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
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific add function to reduce (un)boxing
|
* A Type-Specific add function to reduce (un)boxing
|
||||||
* @param o the element that should be added
|
* @param o the element that should be added
|
||||||
* @return true if the element was added to the collection
|
* @return true if the element was added to the collection
|
||||||
*/
|
*/
|
||||||
public boolean add(KEY_TYPE o);
|
public boolean add(KEY_TYPE o);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type-Specific addAll function to reduce (un)boxing
|
* A Type-Specific addAll function to reduce (un)boxing
|
||||||
* @param c the collection of elements that should be added
|
* @param c the collection of elements that should be added
|
||||||
* @return true if elements were added into the collection
|
* @return true if elements were added into the collection
|
||||||
*/
|
*/
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
* @param e the elements that should be added
|
* @param e the elements that should be added
|
||||||
* @return if the collection was modified
|
* @return if the collection was modified
|
||||||
*/
|
*/
|
||||||
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
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
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
* @param e the elements that should be added
|
* @param e the elements that should be added
|
||||||
* @param length how many elements of the array should be added
|
* @param length how many elements of the array should be added
|
||||||
* @return if the collection was modified
|
* @return if the collection was modified
|
||||||
*/
|
*/
|
||||||
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
public default boolean addAll(KEY_TYPE[] e, int length) { return addAll(e, 0, length); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
* @param e the elements that should be added
|
* @param e the elements that should be added
|
||||||
* @param offset where to start within the array
|
* @param offset where to start within the array
|
||||||
* @param length how many elements of the array should be added
|
* @param length how many elements of the array should be added
|
||||||
* @return if the collection was modified
|
* @return if the collection was modified
|
||||||
*/
|
*/
|
||||||
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
public default boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
||||||
if(length <= 0) return false;
|
if(length <= 0) return false;
|
||||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
||||||
boolean added = false;
|
boolean added = false;
|
||||||
for(int i = 0;i<length;i++) {
|
for(int i = 0;i<length;i++) {
|
||||||
if(add(e[offset+i])) added = true;
|
if(add(e[offset+i])) added = true;
|
||||||
}
|
}
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific contains function to reduce (un)boxing
|
* A Type-Specific contains function to reduce (un)boxing
|
||||||
* @param o the element that is checked for
|
* @param o the element that is checked for
|
||||||
* @return true if the element is found in the collection
|
* @return true if the element is found in the collection
|
||||||
*/
|
*/
|
||||||
public boolean contains(KEY_TYPE o);
|
public boolean contains(KEY_TYPE o);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type-Specific containsAll function to reduce (un)boxing
|
* A Type-Specific containsAll function to reduce (un)boxing
|
||||||
* @param c the collection of elements that should be tested for
|
* @param c the collection of elements that should be tested for
|
||||||
* @return true if all the element is found in the collection
|
* @return true if all the element is found in the collection
|
||||||
*/
|
*/
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific containsAny function to reduce (un)boxing
|
* A Type-Specific containsAny function to reduce (un)boxing
|
||||||
* @param c the collection of elements that should be tested for
|
* @param c the collection of elements that should be tested for
|
||||||
* @return true if any element was found
|
* @return true if any element was found
|
||||||
*/
|
*/
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if any element of the Collection is found in the provided collection.
|
* 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.
|
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||||
* @param c the collection of elements that should be tested for
|
* @param c the collection of elements that should be tested for
|
||||||
* @return true if any element was found.
|
* @return true if any element was found.
|
||||||
*/
|
*/
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAny(Collection<?> c);
|
public boolean containsAny(Collection<?> c);
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific remove function that reduces (un)boxing.
|
* A Type-Specific remove function that reduces (un)boxing.
|
||||||
* @param o the element that should be removed
|
* @param o the element that should be removed
|
||||||
* @return true if the element was removed
|
* @return true if the element was removed
|
||||||
* @see Collection#remove(Object)
|
* @see Collection#remove(Object)
|
||||||
*/
|
*/
|
||||||
public boolean REMOVE_KEY(KEY_TYPE o);
|
public boolean REMOVE_KEY(KEY_TYPE o);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
* @param c the collection of elements that should be removed
|
* @param c the collection of elements that should be removed
|
||||||
* @return true if any element was removed
|
* @return true if any element was removed
|
||||||
* @see Collection#removeAll(Collection)
|
* @see Collection#removeAll(Collection)
|
||||||
*/
|
*/
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific removeAll function that reduces (un)boxing.
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
* It also notifies the remover of which exact element is going to be removed.
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
* @param c the collection of elements that should be removed
|
* @param c the collection of elements that should be removed
|
||||||
* @param r elements that got removed
|
* @param r elements that got removed
|
||||||
* @return true if any element was removed
|
* @return true if any element was removed
|
||||||
* @see Collection#removeAll(Collection)
|
* @see Collection#removeAll(Collection)
|
||||||
*/
|
*/
|
||||||
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
* @param c the collection of elements that should be kept
|
* @param c the collection of elements that should be kept
|
||||||
* @return true if any element was removed
|
* @return true if any element was removed
|
||||||
* @see Collection#retainAll(Collection)
|
* @see Collection#retainAll(Collection)
|
||||||
*/
|
*/
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific retainAll function that reduces (un)boxing.
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
* It also notifies the remover of which exact element is going to be removed.
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
* @param c the collection of elements that should be kept
|
* @param c the collection of elements that should be kept
|
||||||
* @param r elements that got removed
|
* @param r elements that got removed
|
||||||
* @return true if any element was removed
|
* @return true if any element was removed
|
||||||
* @see Collection#retainAll(Collection)
|
* @see Collection#retainAll(Collection)
|
||||||
*/
|
*/
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
* 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 collection that the elements should be inserted to
|
||||||
* @param <E> the collection type
|
* @param <E> the collection type
|
||||||
* @return the input with the desired elements
|
* @return the input with the desired elements
|
||||||
*/
|
*/
|
||||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||||
collection.addAll(this);
|
collection.addAll(this);
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Function that does a shallow clone of the Collection itself.
|
* 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.
|
* 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
|
* It can be compared to Cloneable but with less exception risk
|
||||||
* @return a Shallow Copy of the collection
|
* @return a Shallow Copy of the collection
|
||||||
* @note Wrappers and view collections will not support this feature
|
* @note Wrappers and view collections will not support this feature
|
||||||
*/
|
*/
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy();
|
public COLLECTION KEY_GENERIC_TYPE copy();
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Helper function that simplifies the process of creating a new Array.
|
* A Helper function that simplifies the process of creating a new Array.
|
||||||
* @param action the array creation function
|
* @param action the array creation function
|
||||||
* @return an array containing all of the elements in this collection
|
* @param <E> the returning arrayType
|
||||||
* @see Collection#toArray(Object[])
|
* @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()));
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
}
|
return TO_ARRAY(action.apply(size()));
|
||||||
|
}
|
||||||
#else
|
|
||||||
/**
|
#else
|
||||||
* 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 delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
* @see Collection#toArray()
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
* @see Collection#toArray()
|
||||||
public KEY_TYPE[] TO_ARRAY();
|
*/
|
||||||
|
public KEY_TYPE[] TO_ARRAY();
|
||||||
/**
|
|
||||||
* 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
|
* A Type-Specific toArray function that reduces (un)boxing.
|
||||||
* @return an array containing all of the elements in this collection
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
* @see Collection#toArray(Object[])
|
* @return an array containing all of the elements in this collection
|
||||||
*/
|
* @see Collection#toArray(Object[])
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
*/
|
||||||
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a);
|
||||||
#if PRIMITIVES
|
|
||||||
/** {@inheritDoc}
|
#if PRIMITIVES
|
||||||
* <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 default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
@Deprecated
|
||||||
Objects.requireNonNull(filter);
|
public default boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
||||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
Objects.requireNonNull(filter);
|
||||||
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
#else
|
return remIf(v -> filter.test(KEY_TO_OBJ(SanityChecks.SANITY_CAST(v))));
|
||||||
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
#else
|
||||||
#endif
|
return remIf(v -> filter.test(KEY_TO_OBJ(v)));
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
/**
|
|
||||||
* A Type-Specific removeIf function to reduce (un)boxing.
|
/**
|
||||||
* <p>Removes elements that were selected by the filter
|
* A Type-Specific removeIf function to reduce (un)boxing.
|
||||||
* @see Collection#removeIf(Predicate)
|
* <p>Removes elements that were selected by the filter
|
||||||
* @param filter Filters the elements that should be removed
|
* @see Collection#removeIf(Predicate)
|
||||||
* @return true if the collection was modified
|
* @param filter Filters the elements that should be removed
|
||||||
* @throws java.lang.NullPointerException if filter is null
|
* @return true if the collection was modified
|
||||||
*/
|
* @throws java.lang.NullPointerException if filter is null
|
||||||
public default boolean remIf(JAVA_PREDICATE filter) {
|
*/
|
||||||
Objects.requireNonNull(filter);
|
public default boolean remIf(JAVA_PREDICATE filter) {
|
||||||
boolean removed = false;
|
Objects.requireNonNull(filter);
|
||||||
final ITERATOR each = iterator();
|
boolean removed = false;
|
||||||
while (each.hasNext()) {
|
final ITERATOR each = iterator();
|
||||||
if (filter.test(each.NEXT())) {
|
while (each.hasNext()) {
|
||||||
each.remove();
|
if (filter.test(each.NEXT())) {
|
||||||
removed = true;
|
each.remove();
|
||||||
}
|
removed = true;
|
||||||
}
|
}
|
||||||
return removed;
|
}
|
||||||
}
|
return removed;
|
||||||
|
}
|
||||||
#endif
|
|
||||||
/** {@inheritDoc}
|
#endif
|
||||||
* <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 default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
@Deprecated
|
||||||
|
public default boolean add(CLASS_TYPE o) { return add(OBJ_TO_KEY(o)); }
|
||||||
/** {@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 default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
@Deprecated
|
||||||
|
public default boolean contains(Object o) { return o != null && contains(CLASS_TO_KEY(o)); }
|
||||||
/** {@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 default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
@Deprecated
|
||||||
|
public default boolean remove(Object o) { return o != null && REMOVE_KEY(CLASS_TO_KEY(o)); }
|
||||||
#endif
|
|
||||||
/**
|
#endif
|
||||||
* Returns a Type-Specific Iterator to reduce (un)boxing
|
/**
|
||||||
* @return a iterator of the collection
|
* Returns a Type-Specific Iterator to reduce (un)boxing
|
||||||
* @see Collection#iterator()
|
* @return a iterator of the collection
|
||||||
*/
|
* @see Collection#iterator()
|
||||||
@Override
|
*/
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
@Override
|
||||||
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
/**
|
|
||||||
* Creates a Wrapped Collection that is Synchronized
|
/**
|
||||||
* @return a new Collection that is synchronized
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
* @see COLLECTIONS#synchronize
|
* @return a new Collection that is synchronized
|
||||||
*/
|
* @see COLLECTIONS#synchronize
|
||||||
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
*/
|
||||||
|
public default COLLECTION KEY_GENERIC_TYPE synchronize() { return COLLECTIONS.synchronize(this); }
|
||||||
/**
|
|
||||||
* Creates a Wrapped Collection that is Synchronized
|
/**
|
||||||
* @param mutex is the controller of the synchronization block
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
* @return a new Collection Wrapper that is synchronized
|
* @param mutex is the controller of the synchronization block
|
||||||
* @see COLLECTIONS#synchronize
|
* @return a new Collection Wrapper that is synchronized
|
||||||
*/
|
* @see COLLECTIONS#synchronize
|
||||||
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
*/
|
||||||
|
public default COLLECTION KEY_GENERIC_TYPE synchronize(Object mutex) { return COLLECTIONS.synchronize(this, mutex); }
|
||||||
/**
|
|
||||||
* Creates a Wrapped Collection that is unmodifiable
|
/**
|
||||||
* @return a new Collection Wrapper that is unmodifiable
|
* Creates a Wrapped Collection that is unmodifiable
|
||||||
* @see COLLECTIONS#unmodifiable
|
* @return a new Collection Wrapper that is unmodifiable
|
||||||
*/
|
* @see COLLECTIONS#unmodifiable
|
||||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
*/
|
||||||
|
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
#if PRIMITIVES
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
/**
|
#if PRIMITIVES
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
/**
|
||||||
* @return a Stream of the closest java type
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
*/
|
* @return a Stream of the closest java type
|
||||||
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
*/
|
||||||
|
default JAVA_STREAM primitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), false); }
|
||||||
/**
|
|
||||||
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
/**
|
||||||
* @return a Stream of the closest java type
|
* Returns a Java-Type-Specific Parallel Stream to reduce boxing/unboxing.
|
||||||
*/
|
* @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 parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||||
#endif
|
|
||||||
#if STREAM_FEATURE
|
#endif
|
||||||
/**
|
#if STREAM_FEATURE
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
/**
|
||||||
* @return type specific splititerator
|
* 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); }
|
@Override
|
||||||
#endif
|
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+489
-456
@@ -1,457 +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 JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#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.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#else
|
#else
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#endif
|
#if BOOLEAN_COLLECTION_MODULE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.booleans.collections.BooleanIterable;
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#iterate
|
||||||
#if !JDK_FUNCTION
|
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
#endif
|
#argument PACKAGE bytes shorts ints longs floats doubles
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
#if FILTER_TYPE
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.objects.functions.function.MAPPER;
|
||||||
#if ARRAY_LIST_FEATURE
|
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
#endif
|
||||||
#else
|
#enditerate
|
||||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
#endif
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
#endif
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
#if SET_MODULE && !TYPE_BOOLEAN
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#if LINKED_SET_FEATURE
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#else if LINKED_CUSTOM_SET_FEATURE
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
#else if SET_FEATURE
|
#if ARRAY_LIST_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
#else if CUSTOM_SET_FEATURE
|
#else
|
||||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
#else if RB_TREE_SET_FEATURE
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
#endif
|
||||||
#else if AVL_TREE_SET_FEATURE
|
#if SET_MODULE && !TYPE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
#else if ARRAY_SET_FEATURE
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
#if LINKED_SET_FEATURE
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||||
#endif
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
#else if SET_FEATURE
|
||||||
#if ASYNC_MODULE
|
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
#else if CUSTOM_SET_FEATURE
|
||||||
#endif
|
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#else if RB_TREE_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||||
#endif
|
#else if AVL_TREE_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
#else if ARRAY_SET_FEATURE
|
||||||
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
/**
|
#if ASYNC_MODULE
|
||||||
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||||
* @Type(T)
|
#endif
|
||||||
*/
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
{
|
#endif
|
||||||
/**
|
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||||
* Returns an iterator over elements of type {@code T}.
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
*
|
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||||
* @return an Iterator.
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
*/
|
#endif
|
||||||
@Override
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
ITERATOR KEY_GENERIC_TYPE iterator();
|
|
||||||
|
/**
|
||||||
#if !TYPE_OBJECT
|
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||||
/**
|
* @Type(T)
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
*/
|
||||||
*
|
public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
||||||
* @implSpec
|
{
|
||||||
* <p>The default implementation behaves as if:
|
/**
|
||||||
* <pre>{@code
|
* Returns an iterator over elements of type {@code T}.
|
||||||
* iterator().forEachRemaining(action);
|
*
|
||||||
* }</pre>
|
* @return an Iterator.
|
||||||
*
|
*/
|
||||||
* @param action The action to be performed for each element
|
@Override
|
||||||
* @throws NullPointerException if the specified action is null
|
ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
* @see Iterable#forEach(Consumer)
|
|
||||||
*/
|
#if !TYPE_OBJECT
|
||||||
default void forEach(CONSUMER action) {
|
/**
|
||||||
Objects.requireNonNull(action);
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
iterator().forEachRemaining(action);
|
*
|
||||||
}
|
* @implSpec
|
||||||
|
* <p>The default implementation behaves as if:
|
||||||
/** {@inheritDoc}
|
* <pre>{@code
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* iterator().forEachRemaining(action);
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* }</pre>
|
||||||
*/
|
*
|
||||||
@Deprecated
|
* @param action The action to be performed for each element
|
||||||
@Override
|
* @throws NullPointerException if the specified action is null
|
||||||
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
* @see Iterable#forEach(Consumer)
|
||||||
Objects.requireNonNull(action);
|
*/
|
||||||
iterator().forEachRemaining(action);
|
default void forEach(CONSUMER action) {
|
||||||
}
|
Objects.requireNonNull(action);
|
||||||
|
iterator().forEachRemaining(action);
|
||||||
#endif
|
}
|
||||||
/**
|
|
||||||
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
/** {@inheritDoc}
|
||||||
* @param action The action to be performed for each element
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
*/
|
*/
|
||||||
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
@Deprecated
|
||||||
Objects.requireNonNull(action);
|
@Override
|
||||||
int index = 0;
|
default void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
Objects.requireNonNull(action);
|
||||||
}
|
iterator().forEachRemaining(action);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
#endif
|
||||||
* @param input the object that should be included
|
/**
|
||||||
* @param action The action to be performed for each element
|
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||||
* @param <E> the generic type of the Object
|
* @param action The action to be performed for each element
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
*/
|
*/
|
||||||
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterator().forEachRemaining(input, action);
|
int index = 0;
|
||||||
}
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
||||||
|
}
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||||
* @return type specific splititerator
|
* @param input the object that should be included
|
||||||
*/
|
* @param action The action to be performed for each element
|
||||||
@Override
|
* @param <E> the generic type of the Object
|
||||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
*/
|
||||||
#endif
|
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
#if ASYNC_MODULE
|
Objects.requireNonNull(action);
|
||||||
/**
|
iterator().forEachRemaining(input, action);
|
||||||
* 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.
|
|
||||||
* @see ASYNC_BUILDER
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
* @return a AsyncBuilder
|
/**
|
||||||
*/
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
* @return type specific splititerator
|
||||||
return new ASYNC_BUILDERBRACES(this);
|
*/
|
||||||
}
|
@Override
|
||||||
|
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||||
#endif
|
|
||||||
/**
|
#endif
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
#if ASYNC_MODULE
|
||||||
* @param mapper the mapping function
|
/**
|
||||||
* @param <E> The return type.
|
* Creates a Async Builder for moving work of the thread.
|
||||||
* @return a new Iterable that returns the desired result
|
* 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.
|
||||||
*/
|
* @see ASYNC_BUILDER
|
||||||
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
* @return a AsyncBuilder
|
||||||
return ITERABLES.map(this, mapper);
|
*/
|
||||||
}
|
default ASYNC_BUILDER KEY_GENERIC_TYPE asAsync() {
|
||||||
|
return new ASYNC_BUILDERBRACES(this);
|
||||||
/**
|
}
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
|
||||||
* @param mapper the flatMapping function
|
#endif
|
||||||
* @param <V> The return type supplier.
|
/**
|
||||||
* @param <E> The return type.
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
* @return a new Iterable that returns the desired result
|
* @param mapper the mapping function
|
||||||
* @note does not support TO_ARRAY optimizations.
|
* @param <E> The return type.
|
||||||
*/
|
* @return a new Iterable that returns the desired result
|
||||||
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
*/
|
||||||
return ITERABLES.flatMap(this, mapper);
|
default <E> ObjectIterable<E> map(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
||||||
}
|
return ITERABLES.map(this, mapper);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
#if TYPE_OBJECT
|
||||||
* @param mapper the flatMapping function
|
#iterate
|
||||||
* @param <E> The return type.
|
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
||||||
* @return a new Iterable that returns the desired result
|
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
||||||
* @note does not support TO_ARRAY optimizations.
|
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
||||||
*/
|
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
||||||
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
#if FILTER_TYPE
|
||||||
return ITERABLES.arrayFlatMap(this, mapper);
|
/**
|
||||||
}
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
|
* @param mapper the mapping function
|
||||||
/**
|
* @return a new Iterable that returns the desired result
|
||||||
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
*/
|
||||||
* @param filter the elements that should be kept.
|
default OUTPUT_ITERABLE mapToDATA_TYPE(MAPPER<T> mapper) {
|
||||||
* @return a Iterable that filtered out all unwanted elements
|
return ITERABLES.mapToDATA_TYPE(this, mapper);
|
||||||
* @note does not support TO_ARRAY optimizations.
|
}
|
||||||
*/
|
|
||||||
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
#endif
|
||||||
return ITERABLES.filter(this, filter);
|
#enditerate
|
||||||
}
|
#endif
|
||||||
|
/**
|
||||||
/**
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
* @param mapper the flatMapping function
|
||||||
* @return a Iterable that filtered out all duplicated elements
|
* @param <V> The return type supplier.
|
||||||
* @note does not support TO_ARRAY optimizations.
|
* @param <E> The return type.
|
||||||
*/
|
* @return a new Iterable that returns the desired result
|
||||||
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
* @note does not support TO_ARRAY optimizations.
|
||||||
return ITERABLES.distinct(this);
|
*/
|
||||||
}
|
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
||||||
|
return ITERABLES.flatMap(this, mapper);
|
||||||
/**
|
}
|
||||||
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
|
||||||
* @param repeats how many times the elements should be repeated
|
/**
|
||||||
* @return a Iterable that is repeating multiple times
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
*/
|
* @param mapper the flatMapping function
|
||||||
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
* @param <E> The return type.
|
||||||
return ITERABLES.repeat(this, repeats);
|
* @return a new Iterable that returns the desired result
|
||||||
}
|
* @note does not support TO_ARRAY optimizations.
|
||||||
|
*/
|
||||||
/**
|
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
||||||
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
return ITERABLES.arrayFlatMap(this, mapper);
|
||||||
* @param limit the amount of elements it should be limited to
|
}
|
||||||
* @return a Iterable that is limited in length
|
|
||||||
*/
|
/**
|
||||||
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||||
return ITERABLES.limit(this, limit);
|
* @param filter the elements that should be kept.
|
||||||
}
|
* @return a Iterable that filtered out all unwanted elements
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
/**
|
*/
|
||||||
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
* @param sorter that sorts the elements.
|
return ITERABLES.filter(this, filter);
|
||||||
* @return a Iterable that is sorted
|
}
|
||||||
*/
|
|
||||||
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
/**
|
||||||
return ITERABLES.sorted(this, sorter);
|
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||||
}
|
* @return a Iterable that filtered out all duplicated elements
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
/**
|
*/
|
||||||
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
||||||
* @param action the action that should be applied
|
return ITERABLES.distinct(this);
|
||||||
* @return a Peeked Iterable
|
}
|
||||||
*/
|
|
||||||
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
/**
|
||||||
return ITERABLES.peek(this, action);
|
* A Helper function to reduce the usage of Streams and allows to repeat elements a desired amount of times
|
||||||
}
|
* @param repeats how many times the elements should be repeated
|
||||||
|
* @return a Iterable that is repeating multiple times
|
||||||
/**
|
*/
|
||||||
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
||||||
* @param collection that the elements should be inserted to
|
return ITERABLES.repeat(this, repeats);
|
||||||
* @param <E> the collection type
|
}
|
||||||
* @return the input with the desired elements
|
|
||||||
*/
|
/**
|
||||||
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||||
ITERATORS.pour(iterator(), collection);
|
* @param limit the amount of elements it should be limited to
|
||||||
return collection;
|
* @return a Iterable that is limited in length
|
||||||
}
|
*/
|
||||||
|
default ITERABLE KEY_GENERIC_TYPE limit(long limit) {
|
||||||
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
return ITERABLES.limit(this, limit);
|
||||||
/**
|
}
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
|
||||||
* @return a new ArrayList of all elements
|
/**
|
||||||
*/
|
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
||||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
* @param sorter that sorts the elements.
|
||||||
#if ARRAY_LIST_FEATURE
|
* @return a Iterable that is sorted
|
||||||
return pour(new ARRAY_LISTBRACES());
|
*/
|
||||||
#else
|
default ITERABLE KEY_GENERIC_TYPE sorted(COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||||
return pour(new LINKED_LISTBRACES());
|
return ITERABLES.sorted(this, sorter);
|
||||||
#endif
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
#endif
|
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
||||||
#if !TYPE_BOOLEAN && SET_MODULE
|
* @param action the action that should be applied
|
||||||
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
* @return a Peeked Iterable
|
||||||
/**
|
*/
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
default ITERABLE KEY_GENERIC_TYPE peek(CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
* @return a new LinkedHashSet of all elements
|
return ITERABLES.peek(this, action);
|
||||||
*/
|
}
|
||||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
|
||||||
#if LINKED_SET_FEATURE
|
/**
|
||||||
return pour(new LINKED_HASH_SETBRACES());
|
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||||
#else if LINKED_CUSTOM_SET_FEATURE
|
* @param collection that the elements should be inserted to
|
||||||
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
* @param <E> the collection type
|
||||||
#else if SET_FEATURE
|
* @return the input with the desired elements
|
||||||
return pour(new HASH_SETBRACES());
|
*/
|
||||||
#else if CUSTOM_SET_FEATURE
|
default <E extends COLLECTION KEY_GENERIC_TYPE> E pour(E collection) {
|
||||||
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
ITERATORS.pour(iterator(), collection);
|
||||||
#else if RB_TREE_SET_FEATURE
|
return collection;
|
||||||
return pour(new RB_Tree_SETBRACES());
|
}
|
||||||
#else if AVL_TREE_SET_FEATURE
|
|
||||||
return pour(new AVL_Tree_SETBRACES());
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
#else if ARRAY_SET_FEATURE
|
/**
|
||||||
return pour(new ARRAY_SETBRACES());
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||||
#endif
|
* @return a new ArrayList of all elements
|
||||||
}
|
*/
|
||||||
|
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||||
#endif
|
#if ARRAY_LIST_FEATURE
|
||||||
#endif
|
return pour(new ARRAY_LISTBRACES());
|
||||||
#if TYPE_OBJECT
|
#else
|
||||||
/**
|
return pour(new LINKED_LISTBRACES());
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
#endif
|
||||||
* @param action is the creator function of said Array to ensure type is kept.
|
}
|
||||||
* @return a new Array of all elements
|
|
||||||
*/
|
#endif
|
||||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
#if !TYPE_BOOLEAN && SET_MODULE
|
||||||
ISizeProvider prov = ISizeProvider.of(this);
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
if(prov != null) {
|
/**
|
||||||
int size = prov.size();
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||||
if(size >= 0) {
|
* @return a new LinkedHashSet of all elements
|
||||||
E[] array = action.apply(size);
|
*/
|
||||||
ITERATORS.unwrap(array, iterator());
|
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||||
return array;
|
#if LINKED_SET_FEATURE
|
||||||
}
|
return pour(new LINKED_HASH_SETBRACES());
|
||||||
}
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
return ARRAYS.pour(iterator(), action);
|
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
}
|
#else if SET_FEATURE
|
||||||
#else
|
return pour(new HASH_SETBRACES());
|
||||||
/**
|
#else if CUSTOM_SET_FEATURE
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
* @return a new Array of all elements
|
#else if RB_TREE_SET_FEATURE
|
||||||
*/
|
return pour(new RB_Tree_SETBRACES());
|
||||||
default KEY_TYPE[] TO_ARRAY() {
|
#else if AVL_TREE_SET_FEATURE
|
||||||
ISizeProvider prov = ISizeProvider.of(this);
|
return pour(new AVL_Tree_SETBRACES());
|
||||||
if(prov != null) {
|
#else if ARRAY_SET_FEATURE
|
||||||
int size = prov.size();
|
return pour(new ARRAY_SETBRACES());
|
||||||
if(size >= 0) {
|
#endif
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
}
|
||||||
ITERATORS.unwrap(array, iterator());
|
|
||||||
return array;
|
#endif
|
||||||
}
|
#endif
|
||||||
}
|
#if TYPE_OBJECT
|
||||||
return ARRAYS.pour(iterator());
|
/**
|
||||||
}
|
* 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.
|
||||||
#endif
|
* @param <E> the returning arrayType
|
||||||
/**
|
* @return a new Array of all elements
|
||||||
* Helper function to reduce stream usage that allows to filter for any matches.
|
*/
|
||||||
* @param filter that should be applied
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
* @return true if any matches were found
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
*/
|
if(prov != null) {
|
||||||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
int size = prov.size();
|
||||||
Objects.requireNonNull(filter);
|
if(size >= 0) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
E[] array = action.apply(size);
|
||||||
if(filter.test(iter.NEXT())) return true;
|
ITERATORS.unwrap(array, iterator());
|
||||||
}
|
return array;
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
|
return ARRAYS.pour(iterator(), action);
|
||||||
/**
|
}
|
||||||
* Helper function to reduce stream usage that allows to filter for no matches.
|
#else
|
||||||
* @param filter that should be applied
|
/**
|
||||||
* @return true if no matches were found
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
*/
|
* @return a new Array of all elements
|
||||||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
*/
|
||||||
Objects.requireNonNull(filter);
|
default KEY_TYPE[] TO_ARRAY() {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
if(filter.test(iter.NEXT())) return false;
|
if(prov != null) {
|
||||||
}
|
int size = prov.size();
|
||||||
return true;
|
if(size >= 0) {
|
||||||
}
|
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
||||||
|
ITERATORS.unwrap(array, iterator());
|
||||||
/**
|
return array;
|
||||||
* Helper function to reduce stream usage that allows to filter for all matches.
|
}
|
||||||
* @param filter that should be applied
|
}
|
||||||
* @return true if all matches.
|
return ARRAYS.pour(iterator());
|
||||||
*/
|
}
|
||||||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
#endif
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
/**
|
||||||
if(!filter.test(iter.NEXT())) return false;
|
* Helper function to reduce stream usage that allows to filter for any matches.
|
||||||
}
|
* @param filter that should be applied
|
||||||
return true;
|
* @return true if any matches were found
|
||||||
}
|
*/
|
||||||
|
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
/**
|
Objects.requireNonNull(filter);
|
||||||
* Helper function to reduce stream usage that allows to filter for the first match.
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
* @param filter that should be applied
|
if(filter.test(iter.NEXT())) return true;
|
||||||
* @return the found value or the null equivalent variant.
|
}
|
||||||
*/
|
return false;
|
||||||
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();
|
* Helper function to reduce stream usage that allows to filter for no matches.
|
||||||
if(filter.test(entry)) return entry;
|
* @param filter that should be applied
|
||||||
}
|
* @return true if no matches were found
|
||||||
return EMPTY_VALUE;
|
*/
|
||||||
}
|
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
#if !TYPE_OBJECT
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
/**
|
if(filter.test(iter.NEXT())) return false;
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
}
|
||||||
* elements of this Iterable
|
return true;
|
||||||
* @param operator the operation that should be applied
|
}
|
||||||
* @param identity the start value
|
|
||||||
* @return the reduction result, returns identity if nothing was found
|
/**
|
||||||
*/
|
* Helper function to reduce stream usage that allows to filter for all matches.
|
||||||
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
* @param filter that should be applied
|
||||||
Objects.requireNonNull(operator);
|
* @return true if all matches.
|
||||||
KEY_TYPE state = identity;
|
*/
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
return state;
|
if(!filter.test(iter.NEXT())) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
#else
|
}
|
||||||
/**
|
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
/**
|
||||||
* elements of this Iterable
|
* Helper function to reduce stream usage that allows to filter for the first match.
|
||||||
* @param operator the operation that should be applied
|
* @param filter that should be applied
|
||||||
* @param identity the start value
|
* @return the found value or the null equivalent variant.
|
||||||
* @Type(E)
|
*/
|
||||||
* @return the reduction result, returns identity if nothing was found
|
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
*/
|
Objects.requireNonNull(filter);
|
||||||
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
Objects.requireNonNull(operator);
|
KEY_TYPE entry = iter.NEXT();
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
if(filter.test(entry)) return entry;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
return state;
|
|
||||||
}
|
#if !TYPE_OBJECT
|
||||||
|
/**
|
||||||
#endif
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
/**
|
* elements of this Iterable
|
||||||
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
* @param operator the operation that should be applied
|
||||||
* elements of this Iterable
|
* @param identity the start value
|
||||||
* @param operator the operation that should be applied
|
* @return the reduction result, returns identity if nothing was found
|
||||||
* @return the reduction result, returns null value if nothing was found
|
*/
|
||||||
*/
|
default KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
Objects.requireNonNull(operator);
|
||||||
Objects.requireNonNull(operator);
|
KEY_TYPE state = identity;
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
boolean empty = true;
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
}
|
||||||
if(empty) {
|
return state;
|
||||||
empty = false;
|
}
|
||||||
state = iter.NEXT();
|
|
||||||
continue;
|
#else
|
||||||
}
|
/**
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
}
|
* elements of this Iterable
|
||||||
return state;
|
* @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
|
||||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
*/
|
||||||
* @param filter that should be applied
|
default <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
* @return the amount of Valid Elements
|
Objects.requireNonNull(operator);
|
||||||
*/
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
Objects.requireNonNull(filter);
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
int result = 0;
|
}
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
return state;
|
||||||
if(filter.test(iter.NEXT())) result++;
|
}
|
||||||
}
|
|
||||||
return result;
|
#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
-18
@@ -1,19 +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 SUPPLY_GET();
|
public KEY_TYPE SUPPLY_GET();
|
||||||
}
|
}
|
||||||
+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
-133
@@ -1,134 +1,134 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions.function;
|
package speiger.src.collections.PACKAGE.functions.function;
|
||||||
|
|
||||||
#if VALUE_BOOLEAN || SAME_TYPE
|
#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 APPLY(KEY_TYPE k);
|
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||||
|
|
||||||
#if SAME_TYPE
|
#if SAME_TYPE
|
||||||
/**
|
/**
|
||||||
* Creates a Default function that returns the input provided.
|
* Creates a Default function that returns the input provided.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a input returning function
|
* @return a input returning function
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||||
return T -> T;
|
return T -> T;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a composed function that first applies the {@code before}
|
* Returns a composed function that first applies the {@code before}
|
||||||
* function to its input, and then applies this function to the result.
|
* function to its input, and then applies this function to the result.
|
||||||
* If evaluation of either function throws an exception, it is relayed to
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
* the caller of the composed function.
|
* the caller of the composed function.
|
||||||
*
|
*
|
||||||
* @Type(I)
|
* @Type(I)
|
||||||
* @param before the function that should be used first
|
* @param before the function that should be used first
|
||||||
* @return a composed function with a different starting function.
|
* @return a composed function with a different starting function.
|
||||||
*/
|
*/
|
||||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||||
Objects.requireNonNull(before);
|
Objects.requireNonNull(before);
|
||||||
return T -> APPLY(before.APPLY(T));
|
return T -> APPLY(before.APPLY(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a composed function that first applies this function to
|
* Returns a composed function that first applies this function to
|
||||||
* its input, and then applies the {@code after} function to the result.
|
* its input, and then applies the {@code after} function to the result.
|
||||||
* If evaluation of either function throws an exception, it is relayed to
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
* the caller of the composed function.
|
* the caller of the composed function.
|
||||||
*
|
*
|
||||||
* @Type(I)
|
* @Type(I)
|
||||||
* @param after the function that should be used last
|
* @param after the function that should be used last
|
||||||
* @return a composed function with a different starting function.
|
* @return a composed function with a different starting function.
|
||||||
*/
|
*/
|
||||||
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||||
Objects.requireNonNull(after);
|
Objects.requireNonNull(after);
|
||||||
return T -> after.APPLY(APPLY(T));
|
return T -> after.APPLY(APPLY(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_BOOLEAN
|
#if VALUE_BOOLEAN
|
||||||
/**
|
/**
|
||||||
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a default returning function
|
* @return a default returning function
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||||
return T -> true;
|
return T -> true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a default returning function
|
* @return a default returning function
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||||
return T -> false;
|
return T -> false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||||
* @param other the other function that should be merged with.
|
* @param other the other function that should be merged with.
|
||||||
* @return a function that compares values in a and comparason
|
* @return a function that compares values in a and comparason
|
||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> APPLY(T) && other.APPLY(T);
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> APPLY(T) && other.APPLY(T);
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
#else
|
#else
|
||||||
/**
|
/**
|
||||||
* A type specific inverter function
|
* A type specific inverter function
|
||||||
* @return the same function but inverts the result
|
* @return the same function but inverts the result
|
||||||
*/
|
*/
|
||||||
#endif
|
#endif
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||||
return T -> !APPLY(T);
|
return T -> !APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type specific or-function helper function that reduces boxing/unboxing
|
* A Type specific or-function helper function that reduces boxing/unboxing
|
||||||
* @param other the other function that should be merged with.
|
* @param other the other function that should be merged with.
|
||||||
* @return a function that compares values in a or comparason
|
* @return a function that compares values in a or comparason
|
||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> APPLY(T) || other.APPLY(T);
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> APPLY(T) || other.APPLY(T);
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#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
-1197
File diff suppressed because it is too large
Load Diff
+2196
-2188
File diff suppressed because it is too large
Load Diff
+1399
-1376
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+95
-4
@@ -201,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())) {
|
||||||
@@ -215,7 +305,7 @@ 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)) {
|
||||||
@@ -229,7 +319,7 @@ 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)) {
|
||||||
@@ -243,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)) {
|
||||||
@@ -256,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);
|
||||||
|
|||||||
+2689
-2524
File diff suppressed because it is too large
Load Diff
+1513
-1511
File diff suppressed because it is too large
Load Diff
+1676
-1553
File diff suppressed because it is too large
Load Diff
+1512
-1510
File diff suppressed because it is too large
Load Diff
+1631
-1508
File diff suppressed because it is too large
Load Diff
+1413
-1405
File diff suppressed because it is too large
Load Diff
+1578
-1455
File diff suppressed because it is too large
Load Diff
+860
-738
File diff suppressed because it is too large
Load Diff
+994
-963
File diff suppressed because it is too large
Load Diff
+3024
-2916
File diff suppressed because it is too large
Load Diff
+3096
-2988
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+52
-2
@@ -382,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
|
||||||
@@ -404,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
|
||||||
@@ -421,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
|
||||||
|
|||||||
+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
-458
@@ -1,459 +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
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
||||||
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, 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 */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
/** The Minimum Capacity that is allowed */
|
/** The Minimum Capacity that is allowed */
|
||||||
public static final int MIN_CAPACITY = 4;
|
public static final int MIN_CAPACITY = 4;
|
||||||
/** The Backing array */
|
/** The Backing array */
|
||||||
protected transient KEY_TYPE[] array;
|
protected transient KEY_TYPE[] array;
|
||||||
/** The First Index pointer */
|
/** The First Index pointer */
|
||||||
protected int first;
|
protected int first;
|
||||||
/** The Last Index pointer */
|
/** The Last Index pointer */
|
||||||
protected int last;
|
protected int last;
|
||||||
/** The Minimum Capacity of the Queue **/
|
/** The Minimum Capacity of the Queue **/
|
||||||
protected int minCapacity;
|
protected int minCapacity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
||||||
this(values, 0, values.length);
|
this(values, 0, values.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
* @param size the amount of elements that are in the initial array
|
* @param size the amount of elements that are in the initial array
|
||||||
* @throws IllegalStateException if values is smaller then size
|
* @throws IllegalStateException if values is smaller then size
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
||||||
this(values, 0, size);
|
this(values, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
* @param offset where to begin in the initial array
|
* @param offset where to begin in the initial array
|
||||||
* @param size the amount of elements that are in the initial array
|
* @param size the amount of elements that are in the initial array
|
||||||
* @throws IllegalStateException if values is smaller then size
|
* @throws IllegalStateException if values is smaller then size
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
||||||
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
||||||
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
||||||
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
||||||
minCapacity = MIN_CAPACITY;
|
minCapacity = MIN_CAPACITY;
|
||||||
array = values;
|
array = values;
|
||||||
first = offset;
|
first = offset;
|
||||||
last = (offset + size) % array.length;
|
last = (offset + size) % array.length;
|
||||||
if(array.length == size) expand();
|
if(array.length == size) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param capacity the initial capacity of the backing array
|
* @param capacity the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(int capacity) {
|
public ARRAY_FIFO_QUEUE(int capacity) {
|
||||||
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
||||||
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
||||||
minCapacity = array.length;
|
minCapacity = array.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Construtor
|
* Default Construtor
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE() {
|
public ARRAY_FIFO_QUEUE() {
|
||||||
this(MIN_CAPACITY);
|
this(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
final int apparentLength = last - first;
|
final int apparentLength = last - first;
|
||||||
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(first != last) {
|
if(first != last) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
Arrays.fill(array, null);
|
Arrays.fill(array, null);
|
||||||
#endif
|
#endif
|
||||||
first = last = 0;
|
first = last = 0;
|
||||||
}
|
}
|
||||||
else if(first != 0) {
|
else if(first != 0) {
|
||||||
first = last = 0;
|
first = last = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
array[last++] = e;
|
array[last++] = e;
|
||||||
if(last == array.length) last = 0;
|
if(last == array.length) last = 0;
|
||||||
if(last == first) expand();
|
if(last == first) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueueFirst(KEY_TYPE e) {
|
public void enqueueFirst(KEY_TYPE e) {
|
||||||
if(first == 0) first = array.length;
|
if(first == 0) first = array.length;
|
||||||
array[--first] = e;
|
array[--first] = e;
|
||||||
if(first == last) expand();
|
if(first == last) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(first == last) throw new NoSuchElementException();
|
if(first == last) throw new NoSuchElementException();
|
||||||
KEY_TYPE data = array[first];
|
KEY_TYPE data = array[first];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[first] = null;
|
array[first] = null;
|
||||||
#endif
|
#endif
|
||||||
if(++first == array.length) first = 0;
|
if(++first == array.length) first = 0;
|
||||||
reduce();
|
reduce();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeueLast() {
|
public KEY_TYPE dequeueLast() {
|
||||||
if(first == last) throw new NoSuchElementException();
|
if(first == last) throw new NoSuchElementException();
|
||||||
if(last == 0) last = array.length;
|
if(last == 0) last = array.length;
|
||||||
KEY_TYPE data = array[--last];
|
KEY_TYPE data = array[--last];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[last] = null;
|
array[last] = null;
|
||||||
#endif
|
#endif
|
||||||
reduce();
|
reduce();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
||||||
index += first;
|
index += first;
|
||||||
return index >= array.length ? array[index-array.length] : array[index];
|
return index >= array.length ? array[index-array.length] : array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean contains(KEY_TYPE e) {
|
||||||
if(first == last) return false;
|
if(first == last) return false;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
int index = (first + i) % array.length;
|
if(e == array[(first + i) % array.length]) return true;
|
||||||
if(e == array[index])
|
}
|
||||||
return removeIndex(index);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
@Override
|
if(first == last) return false;
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(first == last) return false;
|
int index = (first + i) % array.length;
|
||||||
for(int i = size()-1;i>=0;i--) {
|
if(e == array[index])
|
||||||
int index = (first + i) % array.length;
|
return removeIndex(index);
|
||||||
if(e == array[index])
|
}
|
||||||
return removeIndex(index);
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
protected boolean removeIndex(int index) {
|
if(first == last) return false;
|
||||||
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
for(int i = size()-1;i>=0;i--) {
|
||||||
if(index == first) {
|
int index = (first + i) % array.length;
|
||||||
#if TYPE_OBJECT
|
if(e == array[index])
|
||||||
array[first] = null;
|
return removeIndex(index);
|
||||||
#endif
|
}
|
||||||
first++;
|
return false;
|
||||||
}
|
}
|
||||||
else if(index == last) {
|
|
||||||
last--;
|
protected boolean removeIndex(int index) {
|
||||||
#if TYPE_OBJECT
|
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
||||||
array[last] = null;
|
if(index == first) {
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
}
|
array[first] = null;
|
||||||
else if(index > last) {
|
#endif
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
first++;
|
||||||
#if TYPE_OBJECT
|
}
|
||||||
array[first] = null;
|
else if(index == last) {
|
||||||
#endif
|
last--;
|
||||||
first = ++first % array.length;
|
#if TYPE_OBJECT
|
||||||
}
|
array[last] = null;
|
||||||
else if(index < first) {
|
#endif
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
}
|
||||||
#if TYPE_OBJECT
|
else if(index > last) {
|
||||||
array[last] = null;
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
if(--last < 0) last += array.length;
|
array[first] = null;
|
||||||
}
|
#endif
|
||||||
else {
|
first = ++first % array.length;
|
||||||
if(index - first < last - index) {
|
}
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
else if(index < first) {
|
||||||
#if TYPE_OBJECT
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
array[first] = null;
|
#if TYPE_OBJECT
|
||||||
#endif
|
array[last] = null;
|
||||||
first = ++first % array.length;
|
#endif
|
||||||
}
|
if(--last < 0) last += array.length;
|
||||||
else {
|
}
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
else {
|
||||||
#if TYPE_OBJECT
|
if(index - first < last - index) {
|
||||||
array[last] = null;
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
#endif
|
#if TYPE_OBJECT
|
||||||
if(--last < 0) last += array.length;
|
array[first] = null;
|
||||||
}
|
#endif
|
||||||
}
|
first = ++first % array.length;
|
||||||
reduce();
|
}
|
||||||
return true;
|
else {
|
||||||
}
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
|
#if TYPE_OBJECT
|
||||||
@Override
|
array[last] = null;
|
||||||
public void onChanged() {}
|
#endif
|
||||||
|
if(--last < 0) last += array.length;
|
||||||
@Override
|
}
|
||||||
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
}
|
||||||
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
reduce();
|
||||||
queue.first = first;
|
return true;
|
||||||
queue.last = last;
|
}
|
||||||
queue.minCapacity = minCapacity;
|
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
@Override
|
||||||
return queue;
|
public void onChanged() {}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
||||||
|
queue.first = first;
|
||||||
@Override
|
queue.last = last;
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
queue.minCapacity = minCapacity;
|
||||||
Objects.requireNonNull(action);
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
if(first == last) return;
|
return queue;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
}
|
||||||
action.accept(array[(first + i) % array.length]);
|
|
||||||
clearAndTrim(0);
|
@Override
|
||||||
}
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(first == last) return;
|
if(first == last) return;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
for(int i = 0,m=size();i<m;i++)
|
||||||
action.accept(i, array[(first + i) % array.length]);
|
action.accept(array[(first + i) % array.length]);
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(first == last) return;
|
if(first == last) return;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
for(int i = 0,m=size();i<m;i++)
|
||||||
action.accept(input, array[(first + i) % array.length]);
|
action.accept(i, array[(first + i) % array.length]);
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
if(first == last) return;
|
||||||
if(filter.test(array[(first + i) % array.length])) return true;
|
for(int i = 0,m=size();i<m;i++)
|
||||||
}
|
action.accept(input, array[(first + i) % array.length]);
|
||||||
return false;
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
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;
|
if(filter.test(array[(first + i) % array.length])) return true;
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
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;
|
if(filter.test(array[(first + i) % array.length])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
int index = (first + i) % array.length;
|
if(!filter.test(array[(first + i) % array.length])) return false;
|
||||||
if(filter.test(array[index])) {
|
}
|
||||||
KEY_TYPE data = array[index];
|
return true;
|
||||||
removeIndex(index);
|
}
|
||||||
return data;
|
|
||||||
}
|
@Override
|
||||||
}
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
return EMPTY_VALUE;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
|
int index = (first + i) % array.length;
|
||||||
#if !TYPE_OBJECT
|
if(filter.test(array[index])) {
|
||||||
@Override
|
KEY_TYPE data = array[index];
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
removeIndex(index);
|
||||||
Objects.requireNonNull(operator);
|
return data;
|
||||||
KEY_TYPE state = identity;
|
}
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
return state;
|
|
||||||
}
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
#else
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
@Override
|
Objects.requireNonNull(operator);
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
KEY_TYPE state = identity;
|
||||||
Objects.requireNonNull(operator);
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
return state;
|
||||||
}
|
}
|
||||||
return state;
|
|
||||||
}
|
#else
|
||||||
|
@Override
|
||||||
#endif
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
@Override
|
Objects.requireNonNull(operator);
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
Objects.requireNonNull(operator);
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
boolean empty = true;
|
}
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
return state;
|
||||||
if(empty) {
|
}
|
||||||
empty = false;
|
|
||||||
state = array[(first + i) % array.length];
|
#endif
|
||||||
continue;
|
@Override
|
||||||
}
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
Objects.requireNonNull(operator);
|
||||||
}
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
return state;
|
boolean empty = true;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
|
if(empty) {
|
||||||
@Override
|
empty = false;
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
state = array[(first + i) % array.length];
|
||||||
Objects.requireNonNull(filter);
|
continue;
|
||||||
int result = 0;
|
}
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
if(filter.test(array[(first + i) % array.length])) result++;
|
}
|
||||||
}
|
return state;
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
public boolean trim(int size) {
|
Objects.requireNonNull(filter);
|
||||||
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
int result = 0;
|
||||||
if(newSize >= array.length) return false;
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
if(filter.test(array[(first + i) % array.length])) result++;
|
||||||
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
}
|
||||||
else {
|
return result;
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
}
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
|
||||||
}
|
@Override
|
||||||
first = 0;
|
public boolean trim(int size) {
|
||||||
last = size();
|
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
||||||
array = newArray;
|
if(newSize >= array.length) return false;
|
||||||
return true;
|
KEY_TYPE[] newArray = 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);
|
||||||
* Trims the collection down to the requested size and clears all elements while doing so
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
* @param size the amount of elements that should be allowed
|
}
|
||||||
* @note this will enforce minimum size of the collection itself
|
first = 0;
|
||||||
*/
|
last = size();
|
||||||
@Override
|
array = newArray;
|
||||||
public void clearAndTrim(int size) {
|
return true;
|
||||||
int newSize = Math.max(minCapacity, size);
|
}
|
||||||
if(array.length <= newSize) {
|
|
||||||
clear();
|
/**
|
||||||
return;
|
* 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
|
||||||
first = last = 0;
|
* @note this will enforce minimum size of the collection itself
|
||||||
array = NEW_KEY_ARRAY(newSize);
|
*/
|
||||||
}
|
@Override
|
||||||
|
public void clearAndTrim(int size) {
|
||||||
@Override
|
int newSize = Math.max(minCapacity, size);
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
if(array.length <= newSize) {
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
clear();
|
||||||
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
return;
|
||||||
else {
|
}
|
||||||
System.arraycopy(array, first, input, 0, array.length - first);
|
first = last = 0;
|
||||||
System.arraycopy(array, 0, input, array.length - first, last);
|
array = NEW_KEY_ARRAY(newSize);
|
||||||
}
|
}
|
||||||
return input;
|
|
||||||
}
|
@Override
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
protected void reduce() {
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
final int size = size();
|
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
||||||
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
else {
|
||||||
}
|
System.arraycopy(array, first, input, 0, array.length - first);
|
||||||
|
System.arraycopy(array, 0, input, array.length - first, last);
|
||||||
protected void expand() {
|
}
|
||||||
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void resize(int oldSize, int newSize) {
|
protected void reduce() {
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
final int size = size();
|
||||||
if(first >= last) {
|
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
||||||
if(oldSize != 0)
|
}
|
||||||
{
|
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
protected void expand() {
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else System.arraycopy(array, first, newArray, 0, last-first);
|
protected final void resize(int oldSize, int newSize) {
|
||||||
first = 0;
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
last = oldSize;
|
if(first >= last) {
|
||||||
array = newArray;
|
if(oldSize != 0)
|
||||||
}
|
{
|
||||||
|
System.arraycopy(array, first, newArray, 0, array.length - first);
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
{
|
}
|
||||||
int index = first;
|
}
|
||||||
@Override
|
else System.arraycopy(array, first, newArray, 0, last-first);
|
||||||
public boolean hasNext()
|
first = 0;
|
||||||
{
|
last = oldSize;
|
||||||
return index != last;
|
array = newArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
||||||
public KEY_TYPE NEXT() {
|
{
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
int index = first;
|
||||||
KEY_TYPE value = array[index];
|
@Override
|
||||||
removeIndex(index);
|
public boolean hasNext()
|
||||||
index = ++index % array.length;
|
{
|
||||||
return value;
|
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
-439
@@ -1,440 +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
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#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 !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
||||||
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
||||||
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
/** The Amount of elements stored within the array */
|
/** The Amount of elements stored within the array */
|
||||||
protected int size;
|
protected int size;
|
||||||
/** The Last known first index pointer */
|
/** The Last known first index pointer */
|
||||||
protected int firstIndex = -1;
|
protected int firstIndex = -1;
|
||||||
/** The Sorter of the Array */
|
/** The Sorter of the Array */
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE() {
|
public ARRAY_PRIORITY_QUEUE() {
|
||||||
this(0, null);
|
this(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using custom sorter
|
* Constructor using custom sorter
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(0, comp);
|
this(0, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(int size) {
|
public ARRAY_PRIORITY_QUEUE(int size) {
|
||||||
this(size, null);
|
this(size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
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");
|
if(size < 0) throw new IllegalAccessError("Size has to be 0 or positive");
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
this(array, array.length);
|
this(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(array, array.length, comp);
|
this(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.comparator = comp;
|
this.comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection
|
* Constructor using a Collection
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection and a custom sorter
|
* Constructor using a Collection and a custom sorter
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @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) {
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
return wrap(array, array.length);
|
return wrap(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @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) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @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) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
return wrap(array, array.length, comp);
|
return wrap(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @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) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE 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(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){
|
if(firstIndex != -1){
|
||||||
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
||||||
if(compare < 0) firstIndex = size;
|
if(compare < 0) firstIndex = size;
|
||||||
else if(compare > 0) firstIndex = -1;
|
else if(compare > 0) firstIndex = -1;
|
||||||
}
|
}
|
||||||
array[size++] = e;
|
array[size++] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
int index = findFirstIndex();
|
int index = findFirstIndex();
|
||||||
KEY_TYPE value = array[index];
|
KEY_TYPE value = array[index];
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[size] = null;
|
array[size] = null;
|
||||||
#endif
|
#endif
|
||||||
firstIndex = -1;
|
firstIndex = -1;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE first() {
|
public KEY_TYPE first() {
|
||||||
if(isEmpty()) throw new NoSuchElementException();
|
if(isEmpty()) throw new NoSuchElementException();
|
||||||
if(firstIndex == -1) findFirstIndex();
|
if(firstIndex == -1) findFirstIndex();
|
||||||
return array[firstIndex];
|
return array[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean contains(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = size-1;i>=0;i--)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean removeIndex(int index) {
|
@Override
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
#if TYPE_OBJECT
|
for(int i = size-1;i>=0;i--)
|
||||||
array[size] = null;
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
#endif
|
return false;
|
||||||
if(index == firstIndex) firstIndex = -1;
|
}
|
||||||
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
|
||||||
return true;
|
protected boolean removeIndex(int index) {
|
||||||
}
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
|
#if TYPE_OBJECT
|
||||||
@Override
|
array[size] = null;
|
||||||
public void onChanged() {
|
#endif
|
||||||
firstIndex = -1;
|
if(index == firstIndex) firstIndex = -1;
|
||||||
}
|
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public int size() {
|
|
||||||
return size;
|
@Override
|
||||||
}
|
public void onChanged() {
|
||||||
|
firstIndex = -1;
|
||||||
@Override
|
}
|
||||||
public void clear() {
|
|
||||||
#if TYPE_OBJECT
|
@Override
|
||||||
Arrays.fill(array, null);
|
public int size() {
|
||||||
#endif
|
return size;
|
||||||
size = 0;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void clear() {
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
#if TYPE_OBJECT
|
||||||
Objects.requireNonNull(action);
|
Arrays.fill(array, null);
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
#endif
|
||||||
}
|
size = 0;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
@Override
|
||||||
Objects.requireNonNull(action);
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
@Override
|
||||||
Objects.requireNonNull(action);
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
@Override
|
||||||
Objects.requireNonNull(filter);
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
for(int i = 0;i<size;i++) {
|
Objects.requireNonNull(action);
|
||||||
if(filter.test(array[i])) return true;
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(filter);
|
if(filter.test(array[i])) return true;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.test(array[i])) return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(filter);
|
if(filter.test(array[i])) return false;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(!filter.test(array[i])) return false;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
#if !TYPE_OBJECT
|
Objects.requireNonNull(filter);
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
if(!filter.test(array[i])) return false;
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_TYPE state = identity;
|
return true;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
|
||||||
}
|
#if !TYPE_OBJECT
|
||||||
return state;
|
@Override
|
||||||
}
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
#else
|
KEY_TYPE state = identity;
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
return state;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
|
||||||
}
|
#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);
|
||||||
#endif
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
return state;
|
||||||
boolean empty = true;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(empty) {
|
#endif
|
||||||
empty = false;
|
@Override
|
||||||
state = array[i];
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
continue;
|
Objects.requireNonNull(operator);
|
||||||
}
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
boolean empty = true;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return state;
|
if(empty) {
|
||||||
}
|
empty = false;
|
||||||
|
state = array[i];
|
||||||
@Override
|
continue;
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.test(array[i])) {
|
return state;
|
||||||
KEY_TYPE data = array[i];
|
}
|
||||||
removeIndex(i);
|
|
||||||
return data;
|
@Override
|
||||||
}
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
return EMPTY_VALUE;
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(filter.test(array[i])) {
|
||||||
|
KEY_TYPE data = array[i];
|
||||||
@Override
|
removeIndex(i);
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
return data;
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
int result = 0;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return EMPTY_VALUE;
|
||||||
if(filter.test(array[i])) result++;
|
}
|
||||||
}
|
|
||||||
return result;
|
@Override
|
||||||
}
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
@Override
|
int result = 0;
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
for(int i = 0;i<size;i++) {
|
||||||
return new Iter();
|
if(filter.test(array[i])) result++;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
@Override
|
}
|
||||||
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
@Override
|
||||||
queue.firstIndex = firstIndex;
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
queue.size = size;
|
return new Iter();
|
||||||
queue.comparator = comparator;
|
}
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
|
||||||
return queue;
|
@Override
|
||||||
}
|
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
@Override
|
queue.firstIndex = firstIndex;
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
queue.size = size;
|
||||||
return comparator;
|
queue.comparator = comparator;
|
||||||
}
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
|
return queue;
|
||||||
@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());
|
@Override
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
return input;
|
return comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int findFirstIndex() {
|
@Override
|
||||||
if(firstIndex == -1) {
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
int index = size-1;
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
KEY_TYPE value = array[index];
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
if(comparator == null) {
|
return input;
|
||||||
for(int i = index;i>=0;i--) {
|
}
|
||||||
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
|
||||||
value = array[index = i];
|
protected int findFirstIndex() {
|
||||||
}
|
if(firstIndex == -1) {
|
||||||
}
|
int index = size-1;
|
||||||
else {
|
KEY_TYPE value = array[index];
|
||||||
for(int i = index;i>=0;i--) {
|
if(comparator == null) {
|
||||||
if(comparator.compare(array[i], value) < 0)
|
for(int i = index;i>=0;i--) {
|
||||||
value = array[index = i];
|
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
||||||
}
|
value = array[index = i];
|
||||||
}
|
}
|
||||||
firstIndex = index;
|
}
|
||||||
}
|
else {
|
||||||
return firstIndex;
|
for(int i = index;i>=0;i--) {
|
||||||
}
|
if(comparator.compare(array[i], value) < 0)
|
||||||
|
value = array[index = i];
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
}
|
||||||
@Override
|
}
|
||||||
public boolean hasNext() {
|
firstIndex = index;
|
||||||
return !isEmpty();
|
}
|
||||||
}
|
return firstIndex;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
@Override
|
||||||
return dequeue();
|
public boolean hasNext() {
|
||||||
}
|
return !isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
return dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+414
-407
@@ -1,408 +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
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#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 !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple Heap base Priority Queue implementation
|
* A Simple Heap base Priority Queue implementation
|
||||||
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
/** The Amount of elements stored within the array */
|
/** The Amount of elements stored within the array */
|
||||||
protected int size;
|
protected int size;
|
||||||
/** The Sorter of the Array */
|
/** The Sorter of the Array */
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE() {
|
public HEAP_PRIORITY_QUEUE() {
|
||||||
this(0, null);
|
this(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using custom sorter
|
* Constructor using custom sorter
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(0, comp);
|
this(0, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(int size) {
|
public HEAP_PRIORITY_QUEUE(int size) {
|
||||||
this(size, null);
|
this(size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
this(array, array.length);
|
this(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(array, array.length, comp);
|
this(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection
|
* Constructor using a Collection
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection and a custom sorter
|
* Constructor using a Collection and a custom sorter
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @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) {
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
return wrap(array, array.length);
|
return wrap(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @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) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @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) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
return wrap(array, array.length, comp);
|
return wrap(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @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, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
Arrays.fill(array, null);
|
Arrays.fill(array, null);
|
||||||
#endif
|
#endif
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE 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(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));
|
||||||
array[size++] = e;
|
array[size++] = e;
|
||||||
ARRAYS.shiftUp(array, size-1, comparator);
|
ARRAYS.shiftUp(array, size-1, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
KEY_TYPE value = array[0];
|
KEY_TYPE value = array[0];
|
||||||
array[0] = array[--size];
|
array[0] = array[--size];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[size] = null;
|
array[size] = null;
|
||||||
#endif
|
#endif
|
||||||
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean contains(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = size-1;i>=0;i--)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE 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(dequeue());
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
@Override
|
||||||
Objects.requireNonNull(action);
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
@Override
|
||||||
Objects.requireNonNull(action);
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
Objects.requireNonNull(action);
|
||||||
}
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
@Override
|
||||||
Objects.requireNonNull(filter);
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
for(int i = 0;i<size;i++) {
|
Objects.requireNonNull(action);
|
||||||
if(filter.test(array[i])) return true;
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(filter);
|
if(filter.test(array[i])) return true;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.test(array[i])) return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
@Override
|
Objects.requireNonNull(filter);
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
for(int i = 0;i<size;i++) {
|
||||||
Objects.requireNonNull(filter);
|
if(filter.test(array[i])) return false;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(!filter.test(array[i])) return false;
|
return true;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
#if !TYPE_OBJECT
|
Objects.requireNonNull(filter);
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
if(!filter.test(array[i])) return false;
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_TYPE state = identity;
|
return true;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
|
||||||
}
|
#if !TYPE_OBJECT
|
||||||
return state;
|
@Override
|
||||||
}
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
#else
|
KEY_TYPE state = identity;
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
return state;
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
|
||||||
}
|
#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);
|
||||||
#endif
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
@Override
|
for(int i = 0;i<size;i++) {
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
Objects.requireNonNull(operator);
|
}
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
return state;
|
||||||
boolean empty = true;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(empty) {
|
#endif
|
||||||
empty = false;
|
@Override
|
||||||
state = array[i];
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
continue;
|
Objects.requireNonNull(operator);
|
||||||
}
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
boolean empty = true;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return state;
|
if(empty) {
|
||||||
}
|
empty = false;
|
||||||
|
state = array[i];
|
||||||
@Override
|
continue;
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(filter.test(array[i])) {
|
return state;
|
||||||
KEY_TYPE data = array[i];
|
}
|
||||||
removeIndex(i);
|
|
||||||
return data;
|
@Override
|
||||||
}
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
return EMPTY_VALUE;
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(filter.test(array[i])) {
|
||||||
|
KEY_TYPE data = array[i];
|
||||||
@Override
|
removeIndex(i);
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
return data;
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
int result = 0;
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return EMPTY_VALUE;
|
||||||
if(filter.test(array[i])) result++;
|
}
|
||||||
}
|
|
||||||
return result;
|
@Override
|
||||||
}
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
protected boolean removeIndex(int index) {
|
int result = 0;
|
||||||
array[index] = array[--size];
|
for(int i = 0;i<size;i++) {
|
||||||
#if TYPE_OBJECT
|
if(filter.test(array[i])) result++;
|
||||||
array[size] = null;
|
}
|
||||||
#endif
|
return result;
|
||||||
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
}
|
||||||
return true;
|
|
||||||
}
|
protected boolean removeIndex(int index) {
|
||||||
|
array[index] = array[--size];
|
||||||
@Override
|
#if TYPE_OBJECT
|
||||||
public void onChanged() {
|
array[size] = null;
|
||||||
if(size <= 0) return;
|
#endif
|
||||||
ARRAYS.shiftDown(array, size, 0, comparator);
|
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
@Override
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
public void onChanged() {
|
||||||
queue.size = size;
|
if(size <= 0) return;
|
||||||
queue.comparator = comparator;
|
ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
}
|
||||||
return queue;
|
|
||||||
}
|
@Override
|
||||||
|
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
@Override
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
queue.size = size;
|
||||||
return comparator;
|
queue.comparator = comparator;
|
||||||
}
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
|
return queue;
|
||||||
@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());
|
@Override
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
return input;
|
return comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
@Override
|
||||||
@Override
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
public boolean hasNext() {
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
return !isEmpty();
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
}
|
return input;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
@Override
|
||||||
return dequeue();
|
public boolean hasNext() {
|
||||||
}
|
return !isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
return dequeue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+202
-194
@@ -1,195 +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 java.util.function.IntFunction;
|
||||||
#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
|
#if QUEUES_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
||||||
* @Type(T)
|
* @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,
|
* clears all elements within the PriorityQueue,
|
||||||
* this does not resize the backing arrays
|
* this does not resize the backing arrays
|
||||||
*/
|
*/
|
||||||
public void clear();
|
public void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to insert a element into the PriorityQueue
|
* Method to insert a element into the PriorityQueue
|
||||||
* @param e the element that should be inserted
|
* @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
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param e the elements that should be inserted
|
* @param e the elements that should be inserted
|
||||||
*/
|
*/
|
||||||
public default void enqueueAll(KEY_TYPE... e) {
|
public default void enqueueAll(KEY_TYPE... e) {
|
||||||
enqueueAll(e, 0, e.length);
|
enqueueAll(e, 0, e.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to mass insert elements into the PriorityQueue
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param e the elements that should be inserted
|
* @param e the elements that should be inserted
|
||||||
* @param length the amount of elements that should be inserted
|
* @param length the amount of elements that should be inserted
|
||||||
*/
|
*/
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
||||||
enqueueAll(e, 0, length);
|
enqueueAll(e, 0, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to mass insert elements into the PriorityQueue
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param e the elements that should be inserted
|
* @param e the elements that should be inserted
|
||||||
* @param offset the offset where in the array should be started
|
* @param offset the offset where in the array should be started
|
||||||
* @param length the amount of elements that should be inserted
|
* @param length the amount of elements that should be inserted
|
||||||
*/
|
*/
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
||||||
for(int i = 0;i<length;i++)
|
for(int i = 0;i<length;i++)
|
||||||
enqueue(e[i+offset]);
|
enqueue(e[i+offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to mass insert elements into the PriorityQueue
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* @param c the elements that should be inserted from the Collection
|
* @param c the elements that should be inserted from the Collection
|
||||||
*/
|
*/
|
||||||
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
||||||
enqueue(iter.NEXT());
|
enqueue(iter.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* Method to mass insert elements into the PriorityQueue
|
* Method to mass insert elements into the PriorityQueue
|
||||||
* This method exists to add support for Java Collections to make it more useable
|
* 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
|
* @param c the elements that should be inserted from the Collection
|
||||||
*/
|
*/
|
||||||
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
||||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
||||||
enqueue(iter.next());
|
enqueue(iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to extract a element from the PriorityQueue
|
* Method to extract a element from the PriorityQueue
|
||||||
* @return a element from the Queue
|
* @return a element from the Queue
|
||||||
* @throws java.util.NoSuchElementException if no element is present
|
* @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.
|
* Peeking function to see whats inside the queue.
|
||||||
* @param index of the element that is requested to be viewed.
|
* @param index of the element that is requested to be viewed.
|
||||||
* @return the element that is requested
|
* @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
|
* Shows the element that is to be returned next
|
||||||
* @return the first element in the Queue
|
* @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
|
* Method to find out if a element is part of the queue
|
||||||
* @param e the element that should be removed
|
* @param e the element that is searched for
|
||||||
* @return if a searched element was removed
|
* @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
|
* Removes the first found element in the queue
|
||||||
* @return if a searched element was removed
|
* @param e the element that should be removed
|
||||||
*/
|
* @return if a searched element was removed
|
||||||
public boolean removeLast(KEY_TYPE e);
|
*/
|
||||||
|
public boolean removeFirst(KEY_TYPE e);
|
||||||
/**
|
/**
|
||||||
* Allows to notify the Queue to be revalidate its data
|
* Removes the last found element in the queue
|
||||||
*/
|
* @param e the element that should be removed
|
||||||
public void onChanged();
|
* @return if a searched element was removed
|
||||||
|
*/
|
||||||
/**
|
public boolean removeLast(KEY_TYPE e);
|
||||||
* A Function that does a shallow clone of the PriorityQueue itself.
|
|
||||||
* 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
|
* Allows to notify the Queue to be revalidate its data
|
||||||
* @return a Shallow Copy of the PriorityQueue
|
*/
|
||||||
* @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.
|
||||||
/**
|
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
||||||
* @return the sorter of the Queue, can be null
|
* It can be compared to Cloneable but with less exception risk
|
||||||
*/
|
* @return a Shallow Copy of the PriorityQueue
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
* @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
|
/**
|
||||||
*/
|
* @return the sorter of the Queue, can be null
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
*/
|
||||||
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator();
|
||||||
#endif
|
|
||||||
#if QUEUES_FEATURE
|
#if TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
* @return draining iterator of the PriorityQueue
|
||||||
* @return a new PriorityQueue that is synchronized
|
*/
|
||||||
* @see PRIORITY_QUEUES#synchronize
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
*/
|
|
||||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
#endif
|
||||||
|
#if QUEUES_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||||
* @param mutex is the controller of the synchronization block
|
* @return a new PriorityQueue that is synchronized
|
||||||
* @return a new PriorityQueue Wrapper that is synchronized
|
* @see PRIORITY_QUEUES#synchronize
|
||||||
* @see PRIORITY_QUEUES#synchronize
|
*/
|
||||||
*/
|
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue() { return PRIORITY_QUEUES.synchronize(this); }
|
||||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
|
||||||
|
/**
|
||||||
#endif
|
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||||
/**
|
* @param mutex is the controller of the synchronization block
|
||||||
* A method to drop the contents of the Queue without clearing the queue
|
* @return a new PriorityQueue Wrapper that is synchronized
|
||||||
* @Type(E)
|
* @see PRIORITY_QUEUES#synchronize
|
||||||
* @return the contents of the queue into a seperate array.
|
*/
|
||||||
*/
|
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||||
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
|
||||||
/**
|
#endif
|
||||||
* A method to drop the contents of the Queue without clearing the queue
|
/**
|
||||||
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
* A method to drop the contents of the Queue without clearing the queue
|
||||||
* @Type(E)
|
* @Type(E)
|
||||||
* @return the contents of the queue into a seperate array.
|
* @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
|
*/
|
||||||
*/
|
public default GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY() { return TO_ARRAY(NEW_SPECIAL_KEY_ARRAY(size())); }
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
/**
|
||||||
#if TYPE_OBJECT
|
* A method to drop the contents of the Queue without clearing the queue
|
||||||
/**
|
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||||
* A Helper function that simplifies the process of creating a new Array.
|
* @Type(E)
|
||||||
* @param action the array creation function
|
* @return the contents of the queue into a seperate array.
|
||||||
* @return an array containing all of the elements in this collection
|
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||||
* @see Collection#toArray(Object[])
|
*/
|
||||||
*/
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input);
|
||||||
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
#if TYPE_OBJECT
|
||||||
return TO_ARRAY(action.apply(size()));
|
/**
|
||||||
}
|
* A Helper function that simplifies the process of creating a new Array.
|
||||||
#endif
|
* @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
-1629
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+655
-617
File diff suppressed because it is too large
Load Diff
+897
-861
File diff suppressed because it is too large
Load Diff
+868
-832
File diff suppressed because it is too large
Load Diff
+774
-735
File diff suppressed because it is too large
Load Diff
+742
-702
File diff suppressed because it is too large
Load Diff
+1733
-1694
File diff suppressed because it is too large
Load Diff
+1655
-1655
File diff suppressed because it is too large
Load Diff
+35
@@ -16,6 +16,16 @@ 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
|
#if OBJECT_ASYNC_MODULE
|
||||||
@@ -23,7 +33,9 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
#endif
|
#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;
|
||||||
|
#endif
|
||||||
#if OBJECT_ASYNC_MODULE
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
@@ -59,7 +71,9 @@ import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
#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 && OBJECT_ASYNC_MODULE
|
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||||
@@ -67,7 +81,9 @@ 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 && INT_ASYNC_MODULE
|
#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.ISizeProvider;
|
||||||
@@ -187,6 +203,25 @@ 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
|
#endif
|
||||||
/**
|
/**
|
||||||
* Filters out the unwanted elements out of the Iterable
|
* Filters out the unwanted elements out of the Iterable
|
||||||
|
|||||||
+1036
-1037
File diff suppressed because it is too large
Load Diff
+678
-587
File diff suppressed because it is too large
Load Diff
+1262
-1119
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2
@@ -116,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); } }
|
||||||
|
|||||||
+1219
-1179
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);
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-16
@@ -1,16 +1,16 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import com.google.common.collect.testing.TestListGenerator;
|
import com.google.common.collect.testing.TestListGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_LIST_GENERATOR KEY_GENERIC_TYPE extends TestListGenerator<CLASS_TYPE>, TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
public interface TEST_LIST_GENERATOR KEY_GENERIC_TYPE extends TestListGenerator<CLASS_TYPE>, TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
LIST KEY_GENERIC_TYPE create(Object... elements);
|
LIST KEY_GENERIC_TYPE create(Object... elements);
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -1,13 +1,13 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
public interface TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements);
|
NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -1,13 +1,13 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
public interface TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
ORDERED_SET KEY_GENERIC_TYPE create(Object... elements);
|
ORDERED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
}
|
}
|
||||||
|
|||||||
+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.TestContainerGenerator;
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
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_QUEUE_GENERATOR KEY_GENERIC_TYPE extends TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
public interface TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE extends TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||||
{
|
{
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
public PRIORITY_QUEUE 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 PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements);
|
public PRIORITY_QUEUE 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);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -1,15 +1,15 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import com.google.common.collect.testing.TestSetGenerator;
|
import com.google.common.collect.testing.TestSetGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE, TestSetGenerator<CLASS_TYPE> {
|
public interface TEST_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE, TestSetGenerator<CLASS_TYPE> {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
SET KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
SET KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
SET KEY_GENERIC_TYPE create(Object...elements);
|
SET KEY_GENERIC_TYPE create(Object...elements);
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-38
@@ -1,38 +1,38 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators;
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
public interface TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
SORTED_SET KEY_GENERIC_TYPE create(Object... elements);
|
SORTED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element less than the {@link #samples()} and less than {@link
|
* Returns an element less than the {@link #samples()} and less than {@link
|
||||||
* #belowSamplesGreater()}.
|
* #belowSamplesGreater()}.
|
||||||
*/
|
*/
|
||||||
KEY_TYPE belowSamplesLesser();
|
KEY_TYPE belowSamplesLesser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element less than the {@link #samples()} but greater than {@link
|
* Returns an element less than the {@link #samples()} but greater than {@link
|
||||||
* #belowSamplesLesser()}.
|
* #belowSamplesLesser()}.
|
||||||
*/
|
*/
|
||||||
KEY_TYPE belowSamplesGreater();
|
KEY_TYPE belowSamplesGreater();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element greater than the {@link #samples()} but less than {@link
|
* Returns an element greater than the {@link #samples()} but less than {@link
|
||||||
* #aboveSamplesGreater()}.
|
* #aboveSamplesGreater()}.
|
||||||
*/
|
*/
|
||||||
KEY_TYPE aboveSamplesLesser();
|
KEY_TYPE aboveSamplesLesser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an element greater than the {@link #samples()} and greater than {@link
|
* Returns an element greater than the {@link #samples()} and greater than {@link
|
||||||
* #aboveSamplesLesser()}.
|
* #aboveSamplesLesser()}.
|
||||||
*/
|
*/
|
||||||
KEY_TYPE aboveSamplesGreater();
|
KEY_TYPE aboveSamplesGreater();
|
||||||
}
|
}
|
||||||
|
|||||||
+46
-46
@@ -1,46 +1,46 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators.maps;
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.SampleElements;
|
import com.google.common.collect.testing.SampleElements;
|
||||||
import com.google.common.collect.testing.TestMapGenerator;
|
import com.google.common.collect.testing.TestMapGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
import speiger.src.collections.objects.lists.ObjectList;
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
import speiger.src.testers.objects.utils.ObjectSamples;
|
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TestMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
public interface TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TestMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples();
|
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples();
|
||||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder);
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder);
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
public MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||||
@Override
|
@Override
|
||||||
default MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) {
|
default MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE[] result = new MAP.Entry[elements.length];
|
MAP.Entry KEY_VALUE_GENERIC_TYPE[] result = new MAP.Entry[elements.length];
|
||||||
for(int i = 0;i<elements.length;i++) {
|
for(int i = 0;i<elements.length;i++) {
|
||||||
result[i] = (MAP.Entry KEY_VALUE_GENERIC_TYPE) elements[i];
|
result[i] = (MAP.Entry KEY_VALUE_GENERIC_TYPE) elements[i];
|
||||||
}
|
}
|
||||||
return create(result);
|
return create(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default CLASS_TYPE[] createKeyArray(int length) { return NEW_CLASS_ARRAY(length); }
|
default CLASS_TYPE[] createKeyArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||||
@Override
|
@Override
|
||||||
default CLASS_VALUE_TYPE[] createValueArray(int length) { return NEW_CLASS_VALUE_ARRAY(length); }
|
default CLASS_VALUE_TYPE[] createValueArray(int length) { return NEW_CLASS_VALUE_ARRAY(length); }
|
||||||
@Override
|
@Override
|
||||||
default MAP.Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) { return new MAP.Entry[length]; }
|
default MAP.Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) { return new MAP.Entry[length]; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default SampleElements<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> samples() {
|
default SampleElements<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> samples() {
|
||||||
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = getSamples();
|
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = getSamples();
|
||||||
return new SampleElements<>(
|
return new SampleElements<>(
|
||||||
Helpers.mapEntry(samples.e0().ENTRY_KEY(), samples.e0().ENTRY_VALUE()),
|
Helpers.mapEntry(samples.e0().ENTRY_KEY(), samples.e0().ENTRY_VALUE()),
|
||||||
Helpers.mapEntry(samples.e1().ENTRY_KEY(), samples.e1().ENTRY_VALUE()),
|
Helpers.mapEntry(samples.e1().ENTRY_KEY(), samples.e1().ENTRY_VALUE()),
|
||||||
Helpers.mapEntry(samples.e2().ENTRY_KEY(), samples.e2().ENTRY_VALUE()),
|
Helpers.mapEntry(samples.e2().ENTRY_KEY(), samples.e2().ENTRY_VALUE()),
|
||||||
Helpers.mapEntry(samples.e3().ENTRY_KEY(), samples.e3().ENTRY_VALUE()),
|
Helpers.mapEntry(samples.e3().ENTRY_KEY(), samples.e3().ENTRY_VALUE()),
|
||||||
Helpers.mapEntry(samples.e4().ENTRY_KEY(), samples.e4().ENTRY_VALUE())
|
Helpers.mapEntry(samples.e4().ENTRY_KEY(), samples.e4().ENTRY_VALUE())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -1,13 +1,13 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators.maps;
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public interface TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
default ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (ORDERED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
default ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (ORDERED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||||
@Override
|
@Override
|
||||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-25
@@ -1,25 +1,25 @@
|
|||||||
package speiger.src.testers.PACKAGE.generators.maps;
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
import com.google.common.collect.testing.TestSortedMapGenerator;
|
import com.google.common.collect.testing.TestSortedMapGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public interface TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE, TestSortedMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE>
|
public interface TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE, TestSortedMapGenerator<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
default SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (SORTED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
default SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (SORTED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||||
@Override
|
@Override
|
||||||
SORTED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
SORTED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser();
|
Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser();
|
||||||
@Override
|
@Override
|
||||||
Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater();
|
Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater();
|
||||||
@Override
|
@Override
|
||||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser();
|
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser();
|
||||||
@Override
|
@Override
|
||||||
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater();
|
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater();
|
||||||
}
|
}
|
||||||
|
|||||||
+313
-313
@@ -1,314 +1,314 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl;
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.COPY_ON_WRITE_LIST;
|
import speiger.src.collections.PACKAGE.lists.COPY_ON_WRITE_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.IMMUTABLE_LIST;
|
import speiger.src.collections.PACKAGE.lists.IMMUTABLE_LIST;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.IMMUTABLE_HASH_SET;
|
import speiger.src.collections.PACKAGE.sets.IMMUTABLE_HASH_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
#endif
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.StringSortTest;
|
import speiger.src.collections.objects.utils.StringSortTest;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionConstructorTester;
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionConstructorTester;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class COLLECTION_CONSTRUCTOR_TESTS
|
public class COLLECTION_CONSTRUCTOR_TESTS
|
||||||
{
|
{
|
||||||
public static class ArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class ArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ArrayList() {
|
public ArrayList() {
|
||||||
setSimpleConstructor(ARRAY_LIST::new);
|
setSimpleConstructor(ARRAY_LIST::new);
|
||||||
setSizeConstructor(T -> new ARRAY_LISTBRACES(T));
|
setSizeConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
setPArrayConstructor(T -> new ARRAY_LISTBRACES(T));
|
setPArrayConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
setPCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
setPCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
setCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
setCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LinkedList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class LinkedList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public LinkedList() {
|
public LinkedList() {
|
||||||
setSimpleConstructor(LINKED_LIST::new);
|
setSimpleConstructor(LINKED_LIST::new);
|
||||||
setPArrayConstructor(T -> new LINKED_LISTBRACES(T));
|
setPArrayConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
setPCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
setPCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
setCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
setCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CopyOnWriteArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class CopyOnWriteArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public CopyOnWriteArrayList() {
|
public CopyOnWriteArrayList() {
|
||||||
setSimpleConstructor(COPY_ON_WRITE_LIST::new);
|
setSimpleConstructor(COPY_ON_WRITE_LIST::new);
|
||||||
setPArrayConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
setPArrayConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
setPCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
setPCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
setCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
setCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ImmutableList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class ImmutableList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ImmutableList() {
|
public ImmutableList() {
|
||||||
setPArrayConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
setPArrayConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
setPCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
setPCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
setCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
setCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
public static class HashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class HashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public HashSet() {
|
public HashSet() {
|
||||||
setSimpleConstructor(HASH_SET::new);
|
setSimpleConstructor(HASH_SET::new);
|
||||||
setSizeConstructor(T -> new HASH_SETBRACES(T));
|
setSizeConstructor(T -> new HASH_SETBRACES(T));
|
||||||
setPArrayConstructor(T -> new HASH_SETBRACES(T));
|
setPArrayConstructor(T -> new HASH_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new HASH_SETBRACES(T));
|
setPCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new HASH_SETBRACES(T));
|
setCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LinkedHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class LinkedHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public LinkedHashSet() {
|
public LinkedHashSet() {
|
||||||
setSimpleConstructor(LINKED_HASH_SET::new);
|
setSimpleConstructor(LINKED_HASH_SET::new);
|
||||||
setSizeConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
setSizeConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
setPArrayConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
setPArrayConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
setPCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
setCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class CustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public CustomHashSet() {
|
public CustomHashSet() {
|
||||||
setSimpleConstructor(() -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
setSimpleConstructor(() -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||||
setSizeConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setSizeConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setPArrayConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setPArrayConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setPCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setPCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setCollectionConstructor(T -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LinkedCustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class LinkedCustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public LinkedCustomHashSet() {
|
public LinkedCustomHashSet() {
|
||||||
setSimpleConstructor(() -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
setSimpleConstructor(() -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(HashStrategy.INSTANCE));
|
||||||
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setPArrayConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setPArrayConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setPCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setPCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
setCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
setCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ImmutableHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class ImmutableHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ImmutableHashSet() {
|
public ImmutableHashSet() {
|
||||||
setPArrayConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
setPArrayConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
setPCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
setCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ArraySet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class ArraySet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public ArraySet() {
|
public ArraySet() {
|
||||||
setSimpleConstructor(ARRAY_SET::new);
|
setSimpleConstructor(ARRAY_SET::new);
|
||||||
setSizeConstructor(T -> new ARRAY_SETBRACES(T));
|
setSizeConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
setPArrayConstructor(T -> new ARRAY_SETBRACES(T));
|
setPArrayConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
setPCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
setCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RBTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class RBTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public RBTreeSet() {
|
public RBTreeSet() {
|
||||||
setSimpleConstructor(RB_TREE_SET::new);
|
setSimpleConstructor(RB_TREE_SET::new);
|
||||||
setPArrayConstructor(T -> new RB_TREE_SETBRACES(T));
|
setPArrayConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
setPCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
setCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AVLTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class AVLTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public AVLTreeSet() {
|
public AVLTreeSet() {
|
||||||
setSimpleConstructor(AVL_TREE_SET::new);
|
setSimpleConstructor(AVL_TREE_SET::new);
|
||||||
setPArrayConstructor(T -> new AVL_TREE_SETBRACES(T));
|
setPArrayConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
setPCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
setPCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
setCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
setCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RBTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class RBTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public RBTreeSetComparator() {
|
public RBTreeSetComparator() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
setSimpleConstructor(() -> new RB_TREE_SET<String>(Comparator.naturalOrder()));
|
setSimpleConstructor(() -> new RB_TREE_SET<String>(Comparator.naturalOrder()));
|
||||||
setPArrayConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
setPArrayConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
setPCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
setPCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
setCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
setCollectionConstructor(T -> new RB_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
#else
|
#else
|
||||||
setSimpleConstructor(() -> new RB_TREE_SET(CLASS_TYPE::compare));
|
setSimpleConstructor(() -> new RB_TREE_SET(CLASS_TYPE::compare));
|
||||||
setPArrayConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
setPArrayConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
setPCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
setPCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
setCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
setCollectionConstructor(T -> new RB_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AVLTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
public static class AVLTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public AVLTreeSetComparator() {
|
public AVLTreeSetComparator() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
setSimpleConstructor(() -> new AVL_TREE_SET<String>(Comparator.naturalOrder()));
|
setSimpleConstructor(() -> new AVL_TREE_SET<String>(Comparator.naturalOrder()));
|
||||||
setPArrayConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
setPArrayConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
setPCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
setPCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
setCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
setCollectionConstructor(T -> new AVL_TREE_SET<>(T, Comparator.naturalOrder()));
|
||||||
#else
|
#else
|
||||||
setSimpleConstructor(() -> new AVL_TREE_SET(CLASS_TYPE::compare));
|
setSimpleConstructor(() -> new AVL_TREE_SET(CLASS_TYPE::compare));
|
||||||
setPArrayConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
setPArrayConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
setPCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
setPCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
setCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
setCollectionConstructor(T -> new AVL_TREE_SET(T, CLASS_TYPE::compare));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
protected String[] createKeyElements() {
|
protected String[] createKeyElements() {
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
||||||
static final HashStrategy INSTANCE = new HashStrategy();
|
static final HashStrategy INSTANCE = new HashStrategy();
|
||||||
@Override
|
@Override
|
||||||
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+81
-81
@@ -1,82 +1,82 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl;
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
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.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE implements TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE
|
public class SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE implements TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper;
|
Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
KEY_TYPE[] keys;
|
KEY_TYPE[] keys;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public SIMPLE_QUEUE_TEST_GENERATOR(Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper) {
|
public SIMPLE_QUEUE_TEST_GENERATOR(Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE setElements(KEY_TYPE...keys) {
|
public SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE setElements(KEY_TYPE...keys) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||||
#else if TYPE_BYTE
|
#else if TYPE_BYTE
|
||||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||||
#else if TYPE_SHORT
|
#else if TYPE_SHORT
|
||||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||||
#else if TYPE_CHAR
|
#else if TYPE_CHAR
|
||||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||||
#else if TYPE_OBJECT
|
#else if TYPE_OBJECT
|
||||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||||
#else
|
#else
|
||||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
return mapper.apply(elements);
|
return mapper.apply(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
public PRIORITY_QUEUE 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 mapper.apply(array);
|
return mapper.apply(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), 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 mapper.apply(array);
|
return mapper.apply(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+220
-220
@@ -1,221 +1,221 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl;
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
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;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
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_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.TEST_SORTED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E extends COLLECTION KEY_GENERIC_TYPE> {
|
public class SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E extends COLLECTION KEY_GENERIC_TYPE> {
|
||||||
Function<KEY_TYPE[], E> mapper;
|
Function<KEY_TYPE[], E> mapper;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
KEY_TYPE[] keys;
|
KEY_TYPE[] keys;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public SIMPLE_TEST_GENERATOR(Function<KEY_TYPE[], E> mapper) {
|
public SIMPLE_TEST_GENERATOR(Function<KEY_TYPE[], E> mapper) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E> setElements(KEY_TYPE...keys) {
|
public SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E> setElements(KEY_TYPE...keys) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||||
#else if TYPE_BYTE
|
#else if TYPE_BYTE
|
||||||
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||||
#else if TYPE_SHORT
|
#else if TYPE_SHORT
|
||||||
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||||
#else if TYPE_CHAR
|
#else if TYPE_CHAR
|
||||||
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||||
#else if TYPE_OBJECT
|
#else if TYPE_OBJECT
|
||||||
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||||
#else
|
#else
|
||||||
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
public E create(KEY_TYPE... elements) {
|
public E create(KEY_TYPE... elements) {
|
||||||
return mapper.apply(elements);
|
return mapper.apply(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public E create(Object... elements) {
|
public E 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 mapper.apply(array);
|
return mapper.apply(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
public E create(Object... elements) {
|
public E create(Object... elements) {
|
||||||
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), 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 mapper.apply(array);
|
return mapper.apply(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Collections KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<COLLECTION KEY_GENERIC_TYPE> implements TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
public static class Collections KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<COLLECTION KEY_GENERIC_TYPE> implements TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public Collections(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> mapper) {
|
public Collections(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Lists KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<LIST KEY_GENERIC_TYPE> implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE
|
public static class Lists KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<LIST KEY_GENERIC_TYPE> implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public Lists(Function<KEY_TYPE[], LIST KEY_GENERIC_TYPE> mapper) {
|
public Lists(Function<KEY_TYPE[], LIST KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
public static class Sets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SET KEY_GENERIC_TYPE> implements TEST_SET_GENERATOR KEY_GENERIC_TYPE
|
public static class Sets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SET KEY_GENERIC_TYPE> implements TEST_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public Sets(Function<KEY_TYPE[], SET KEY_GENERIC_TYPE> mapper) {
|
public Sets(Function<KEY_TYPE[], SET KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OrderedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<ORDERED_SET KEY_GENERIC_TYPE> implements TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE
|
public static class OrderedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<ORDERED_SET KEY_GENERIC_TYPE> implements TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public OrderedSets(Function<KEY_TYPE[], ORDERED_SET KEY_GENERIC_TYPE> mapper) {
|
public OrderedSets(Function<KEY_TYPE[], ORDERED_SET KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SortedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SORTED_SET KEY_GENERIC_TYPE> implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
public static class SortedSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<SORTED_SET KEY_GENERIC_TYPE> implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public SortedSets(Function<KEY_TYPE[], SORTED_SET KEY_GENERIC_TYPE> mapper) {
|
public SortedSets(Function<KEY_TYPE[], SORTED_SET KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
insertionOrder.sort(null);
|
insertionOrder.sort(null);
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
insertionOrder.sort(null);
|
insertionOrder.sort(null);
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_CHAR
|
#if TYPE_CHAR
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||||
#else if TYPE_OBJECT
|
#else if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NavigableSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<NAVIGABLE_SET KEY_GENERIC_TYPE> implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE
|
public static class NavigableSets KEY_GENERIC_TYPE extends SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<NAVIGABLE_SET KEY_GENERIC_TYPE> implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public NavigableSets(Function<KEY_TYPE[], NAVIGABLE_SET KEY_GENERIC_TYPE> mapper) {
|
public NavigableSets(Function<KEY_TYPE[], NAVIGABLE_SET KEY_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
insertionOrder.sort(null);
|
insertionOrder.sort(null);
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
insertionOrder.sort(null);
|
insertionOrder.sort(null);
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_CHAR
|
#if TYPE_CHAR
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() { return new SAMPLE_ELEMENTS('a', 'b', 'c', 'd', 'e'); }
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() { return new SAMPLE_ELEMENTS('a', 'b', 'c', 'd', 'e'); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||||
#else if TYPE_OBJECT
|
#else if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() { return -2; }
|
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() { return -1; }
|
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+173
-173
@@ -1,173 +1,173 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl;
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
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.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
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.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_NAVIGABLE_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
public class SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
final Bound to;
|
final Bound to;
|
||||||
final Bound from;
|
final Bound from;
|
||||||
final KEY_TYPE firstInclusive;
|
final KEY_TYPE firstInclusive;
|
||||||
final KEY_TYPE lastInclusive;
|
final KEY_TYPE lastInclusive;
|
||||||
private final COMPARATOR KEY_GENERIC_TYPE comparator;
|
private final COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||||
private final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate;
|
private final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate;
|
||||||
|
|
||||||
public SUB_SORTED_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
public SUB_SORTED_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
this.to = to;
|
this.to = to;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
|
|
||||||
SORTED_SET KEY_GENERIC_TYPE emptySet = delegate.create(NEW_KEY_ARRAY(0));
|
SORTED_SET KEY_GENERIC_TYPE emptySet = delegate.create(NEW_KEY_ARRAY(0));
|
||||||
comparator = emptySet.comparator();
|
comparator = emptySet.comparator();
|
||||||
|
|
||||||
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples = delegate.getSamples();
|
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples = delegate.getSamples();
|
||||||
LIST KEY_GENERIC_TYPE samplesList = new ARRAY_LISTBRACES(samples.asList());
|
LIST KEY_GENERIC_TYPE samplesList = new ARRAY_LISTBRACES(samples.asList());
|
||||||
samplesList.sort(comparator);
|
samplesList.sort(comparator);
|
||||||
firstInclusive = samplesList.GET_KEY(0);
|
firstInclusive = samplesList.GET_KEY(0);
|
||||||
lastInclusive = samplesList.GET_KEY(samplesList.size() - 1);
|
lastInclusive = samplesList.GET_KEY(samplesList.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE getInnerGenerator() {
|
public final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE getInnerGenerator() {
|
||||||
return delegate;
|
return delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Bound getTo() {
|
public final Bound getTo() {
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Bound getFrom() {
|
public final Bound getFrom() {
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
SORTED_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE set, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
SORTED_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE set, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||||
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
|
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
|
||||||
return set.headSet(lastExclusive);
|
return set.headSet(lastExclusive);
|
||||||
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
||||||
return set.tailSet(firstInclusive);
|
return set.tailSet(firstInclusive);
|
||||||
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||||
return set.subSet(firstInclusive, lastExclusive);
|
return set.subSet(firstInclusive, lastExclusive);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesLesser() {
|
public KEY_TYPE belowSamplesLesser() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE belowSamplesGreater() {
|
public KEY_TYPE belowSamplesGreater() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesLesser() {
|
public KEY_TYPE aboveSamplesLesser() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE aboveSamplesGreater() {
|
public KEY_TYPE aboveSamplesGreater() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@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) {
|
||||||
return delegate.order(insertionOrder);
|
return delegate.order(insertionOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
return delegate.order(insertionOrder);
|
return delegate.order(insertionOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE create(KEY_OBJECT_TYPE... elements) {
|
public SORTED_SET KEY_GENERIC_TYPE create(KEY_OBJECT_TYPE... elements) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
LIST KEY_GENERIC_TYPE normalValues = (LIST KEY_GENERIC_TYPE)ARRAY_LIST.wrap(elements);
|
LIST KEY_GENERIC_TYPE normalValues = (LIST KEY_GENERIC_TYPE)ARRAY_LIST.wrap(elements);
|
||||||
#else
|
#else
|
||||||
LIST KEY_GENERIC_TYPE normalValues = ARRAY_LIST.wrap(elements);
|
LIST KEY_GENERIC_TYPE normalValues = ARRAY_LIST.wrap(elements);
|
||||||
#endif
|
#endif
|
||||||
LIST KEY_GENERIC_TYPE extremeValues = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE extremeValues = new ARRAY_LISTBRACES();
|
||||||
KEY_TYPE firstExclusive = delegate.belowSamplesGreater();
|
KEY_TYPE firstExclusive = delegate.belowSamplesGreater();
|
||||||
KEY_TYPE lastExclusive = delegate.aboveSamplesLesser();
|
KEY_TYPE lastExclusive = delegate.aboveSamplesLesser();
|
||||||
if (from != Bound.NO_BOUND) {
|
if (from != Bound.NO_BOUND) {
|
||||||
extremeValues.add(delegate.belowSamplesLesser());
|
extremeValues.add(delegate.belowSamplesLesser());
|
||||||
extremeValues.add(delegate.belowSamplesGreater());
|
extremeValues.add(delegate.belowSamplesGreater());
|
||||||
}
|
}
|
||||||
if (to != Bound.NO_BOUND) {
|
if (to != Bound.NO_BOUND) {
|
||||||
extremeValues.add(delegate.aboveSamplesLesser());
|
extremeValues.add(delegate.aboveSamplesLesser());
|
||||||
extremeValues.add(delegate.aboveSamplesGreater());
|
extremeValues.add(delegate.aboveSamplesGreater());
|
||||||
}
|
}
|
||||||
LIST KEY_GENERIC_TYPE allEntries = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE allEntries = new ARRAY_LISTBRACES();
|
||||||
allEntries.addAll(extremeValues);
|
allEntries.addAll(extremeValues);
|
||||||
allEntries.addAll(normalValues);
|
allEntries.addAll(normalValues);
|
||||||
SORTED_SET KEY_GENERIC_TYPE set = delegate.create(allEntries.toArray());
|
SORTED_SET KEY_GENERIC_TYPE set = delegate.create(allEntries.toArray());
|
||||||
|
|
||||||
return createSubSet(set, firstExclusive, lastExclusive);
|
return createSubSet(set, firstExclusive, lastExclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
public SORTED_SET 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public static final class SUB_NAVIGABLE_SET_CLASS_GENERATOR KEY_GENERIC_TYPE extends SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE {
|
public static final class SUB_NAVIGABLE_SET_CLASS_GENERATOR KEY_GENERIC_TYPE extends SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
public SUB_NAVIGABLE_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
public SUB_NAVIGABLE_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
super(delegate, to, from);
|
super(delegate, to, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE sortedSet, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
NAVIGABLE_SET KEY_GENERIC_TYPE createSubSet(SORTED_SET KEY_GENERIC_TYPE sortedSet, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE set = (NAVIGABLE_SET KEY_GENERIC_TYPE) sortedSet;
|
NAVIGABLE_SET KEY_GENERIC_TYPE set = (NAVIGABLE_SET KEY_GENERIC_TYPE) sortedSet;
|
||||||
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) return set.headSet(lastInclusive, true);
|
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) return set.headSet(lastInclusive, true);
|
||||||
else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) return set.tailSet(firstExclusive, false);
|
else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) return set.tailSet(firstExclusive, false);
|
||||||
else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) return set.subSet(firstExclusive, false, lastExclusive, false);
|
else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) return set.subSet(firstExclusive, false, lastExclusive, false);
|
||||||
else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstExclusive, false, lastInclusive, true);
|
else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstExclusive, false, lastInclusive, true);
|
||||||
else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstInclusive, true, lastInclusive, true);
|
else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstInclusive, true, lastInclusive, true);
|
||||||
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.createSubSet(set, firstExclusive, lastExclusive);
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.createSubSet(set, firstExclusive, lastExclusive);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+550
-550
File diff suppressed because it is too large
Load Diff
+933
-933
File diff suppressed because it is too large
Load Diff
+200
-200
@@ -1,200 +1,200 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl.maps;
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#if TYPE_OBJECT || VALUE_OBJECT
|
#if TYPE_OBJECT || VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.lists.ObjectList;
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
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.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_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.objects.utils.ObjectSamples;
|
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<E extends MAP KEY_VALUE_GENERIC_TYPE>
|
public class SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<E extends MAP KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper;
|
BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper;
|
||||||
#if TYPE_BYTE
|
#if TYPE_BYTE
|
||||||
KEY_TYPE[] keys = new KEY_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
KEY_TYPE[] keys = new KEY_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||||
#else if TYPE_SHORT
|
#else if TYPE_SHORT
|
||||||
KEY_TYPE[] keys = new KEY_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
KEY_TYPE[] keys = new KEY_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||||
#else if TYPE_CHAR
|
#else if TYPE_CHAR
|
||||||
KEY_TYPE[] keys = new KEY_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
KEY_TYPE[] keys = new KEY_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||||
#else if TYPE_OBJECT
|
#else if TYPE_OBJECT
|
||||||
KEY_TYPE[] keys;
|
KEY_TYPE[] keys;
|
||||||
#else
|
#else
|
||||||
KEY_TYPE[] keys = new KEY_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
KEY_TYPE[] keys = new KEY_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_BOOLEAN
|
#if VALUE_BOOLEAN
|
||||||
VALUE_TYPE[] values = new VALUE_TYPE[]{true, true, true, false, true, false, true, false, true};
|
VALUE_TYPE[] values = new VALUE_TYPE[]{true, true, true, false, true, false, true, false, true};
|
||||||
#else if VALUE_BYTE
|
#else if VALUE_BYTE
|
||||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
VALUE_TYPE[] values = new VALUE_TYPE[]{(byte)0, (byte)1, (byte)2, (byte)3, (byte)4, (byte)-2, (byte)-1, (byte)5, (byte)6};
|
||||||
#else if VALUE_SHORT
|
#else if VALUE_SHORT
|
||||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
VALUE_TYPE[] values = new VALUE_TYPE[]{(short)0, (short)1, (short)2, (short)3, (short)4, (short)-2, (short)-1, (short)5, (short)6};
|
||||||
#else if VALUE_CHAR
|
#else if VALUE_CHAR
|
||||||
VALUE_TYPE[] values = new VALUE_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
VALUE_TYPE[] values = new VALUE_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||||
#else if VALUE_OBJECT
|
#else if VALUE_OBJECT
|
||||||
VALUE_TYPE[] values;
|
VALUE_TYPE[] values;
|
||||||
#else
|
#else
|
||||||
VALUE_TYPE[] values = new VALUE_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
VALUE_TYPE[] values = new VALUE_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public SIMPLE_MAP_TEST_GENERATOR(BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper) {
|
public SIMPLE_MAP_TEST_GENERATOR(BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper) {
|
||||||
this.mapper = mapper;
|
this.mapper = mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT || TYPE_CHAR
|
#if TYPE_OBJECT || TYPE_CHAR
|
||||||
public void setKeys(KEY_TYPE... keys) {
|
public void setKeys(KEY_TYPE... keys) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT || VALUE_CHAR
|
#if VALUE_OBJECT || VALUE_CHAR
|
||||||
public void setValues(VALUE_TYPE... values) {
|
public void setValues(VALUE_TYPE... values) {
|
||||||
this.values = values;
|
this.values = values;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||||
return new ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE>(
|
return new ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE>(
|
||||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[0], values[0]),
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[0], values[0]),
|
||||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[1], values[1]),
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[1], values[1]),
|
||||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[2], values[2]),
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[2], values[2]),
|
||||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[3], values[3]),
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[3], values[3]),
|
||||||
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[4], values[4])
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[4], values[4])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public E create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
public E create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
KEY_TYPE[] keys = (T[])ObjectArrays.newArray(getSamples().e0().ENTRY_KEY().getClass(), elements.length);
|
KEY_TYPE[] keys = (T[])ObjectArrays.newArray(getSamples().e0().ENTRY_KEY().getClass(), elements.length);
|
||||||
#else
|
#else
|
||||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(elements.length);
|
KEY_TYPE[] keys = NEW_KEY_ARRAY(elements.length);
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
VALUE_TYPE[] values = (V[])ObjectArrays.newArray(getSamples().e0().ENTRY_VALUE().getClass(), elements.length);
|
VALUE_TYPE[] values = (V[])ObjectArrays.newArray(getSamples().e0().ENTRY_VALUE().getClass(), elements.length);
|
||||||
#else
|
#else
|
||||||
VALUE_TYPE[] values = NEW_VALUE_ARRAY(elements.length);
|
VALUE_TYPE[] values = NEW_VALUE_ARRAY(elements.length);
|
||||||
#endif
|
#endif
|
||||||
for(int i = 0;i<elements.length;i++) {
|
for(int i = 0;i<elements.length;i++) {
|
||||||
keys[i] = elements[i].ENTRY_KEY();
|
keys[i] = elements[i].ENTRY_KEY();
|
||||||
values[i] = elements[i].ENTRY_VALUE();
|
values[i] = elements[i].ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
return mapper.apply(keys, values);
|
return mapper.apply(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Maps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public static class Maps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public Maps(BiFunction<KEY_TYPE[], VALUE_TYPE[], MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
public Maps(BiFunction<KEY_TYPE[], VALUE_TYPE[], MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class OrderedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<ORDERED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public static class OrderedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<ORDERED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public OrderedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], ORDERED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
public OrderedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], ORDERED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConcurrentMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public static class ConcurrentMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter;
|
Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter;
|
||||||
|
|
||||||
public ConcurrentMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> mapper, Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter) {
|
public ConcurrentMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE> mapper, Consumer<ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE>> sorter) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
this.sorter = sorter;
|
this.sorter = sorter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> newList = new ObjectArrayList<>();
|
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> newList = new ObjectArrayList<>();
|
||||||
for(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry : insertionOrder) {
|
for(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry : insertionOrder) {
|
||||||
newList.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), entry.getValue()));
|
newList.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), entry.getValue()));
|
||||||
}
|
}
|
||||||
order(newList);
|
order(newList);
|
||||||
insertionOrder.sort(new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
insertionOrder.sort(new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> key, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> value) {
|
public int compare(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> key, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> value) {
|
||||||
return Integer.signum(indexOf(OBJ_TO_KEY(key.getKey())) - indexOf(OBJ_TO_KEY(value.getKey())));
|
return Integer.signum(indexOf(OBJ_TO_KEY(key.getKey())) - indexOf(OBJ_TO_KEY(value.getKey())));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int indexOf(KEY_TYPE key) {
|
protected int indexOf(KEY_TYPE key) {
|
||||||
for(int i = 0,m=newList.size();i<m;i++) {
|
for(int i = 0,m=newList.size();i<m;i++) {
|
||||||
if(KEY_EQUALS(newList.get(i).ENTRY_KEY(), key)) return i;
|
if(KEY_EQUALS(newList.get(i).ENTRY_KEY(), key)) return i;
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("MAP.entry sorter was corrupting data");
|
throw new IllegalArgumentException("MAP.entry sorter was corrupting data");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
sorter.accept(insertionOrder);
|
sorter.accept(insertionOrder);
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SortedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<SORTED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public static class SortedMaps KEY_VALUE_GENERIC_TYPE extends SIMPLE_MAP_TEST_GENERATOR KEY_VALUE_SPECIAL_GENERIC_TYPE<SORTED_MAP KEY_VALUE_GENERIC_TYPE> implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public SortedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], SORTED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
public SortedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], SORTED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||||
super(mapper);
|
super(mapper);
|
||||||
#if TYPE_CHAR
|
#if TYPE_CHAR
|
||||||
setKeys(new KEY_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
setKeys(new KEY_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_CHAR
|
#if VALUE_CHAR
|
||||||
setValues(new VALUE_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
setValues(new VALUE_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator((Comparator<T>)Comparator.naturalOrder()));
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||||
#else
|
#else
|
||||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator(CLASS_TYPE::compare));
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator(CLASS_TYPE::compare));
|
||||||
#endif
|
#endif
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator((Comparator<T>)Comparator.naturalOrder()));
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||||
#else
|
#else
|
||||||
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator(CLASS_TYPE::compare));
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator(CLASS_TYPE::compare));
|
||||||
#endif
|
#endif
|
||||||
return insertionOrder;
|
return insertionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[5], values[5]); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[5], values[5]); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[6], values[6]); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[6], values[6]); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[7], values[7]); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[7], values[7]); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[8], values[8]); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[8], values[8]); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
package speiger.src.testers.PACKAGE.impl.maps;
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SIMPLE_TEST_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
public class SIMPLE_TEST_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
MAP KEY_VALUE_GENERIC_TYPE map;
|
MAP KEY_VALUE_GENERIC_TYPE map;
|
||||||
|
|
||||||
public SIMPLE_TEST_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
public SIMPLE_TEST_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||||
map = new ARRAY_MAPKV_BRACES(keys, values);
|
map = new ARRAY_MAPKV_BRACES(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
||||||
map.setDefaultReturnValue(v);
|
map.setDefaultReturnValue(v);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
||||||
#if VALUE_PRIMITIVES
|
#if VALUE_PRIMITIVES
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public CLASS_VALUE_TYPE remove(Object key) { return map.remove(key); }
|
public CLASS_VALUE_TYPE remove(Object key) { return map.remove(key); }
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value) { return map.remove(key, value); }
|
public boolean remove(Object key, Object value) { return map.remove(key, value); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
||||||
#if TYPE_OBJECT && !VALUE_OBJECT
|
#if TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
return new AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
return new AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||||
@Override
|
@Override
|
||||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
return new ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = map.ENTRY_SET().iterator();
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = map.ENTRY_SET().iterator();
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
return new ABSTRACT_MAP.BasicEntry KEY_VALUE_GENERIC_TYPE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()) {
|
return new ABSTRACT_MAP.BasicEntry KEY_VALUE_GENERIC_TYPE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()) {
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE setValue(VALUE_TYPE value) {
|
public VALUE_TYPE setValue(VALUE_TYPE value) {
|
||||||
return entry.setValue(value);
|
return entry.setValue(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return map.size();
|
return map.size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+28
-28
@@ -1,28 +1,28 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<COLLECTION KEY_CLASS_GENERIC_TYPE>
|
public class ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<COLLECTION KEY_CLASS_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
protected COLLECTION KEY_GENERIC_TYPE collection;
|
protected COLLECTION KEY_GENERIC_TYPE collection;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() {
|
protected COLLECTION KEY_GENERIC_TYPE actualContents() {
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected COLLECTION KEY_GENERIC_TYPE resetContainer(COLLECTION KEY_GENERIC_TYPE newContents) {
|
protected COLLECTION KEY_GENERIC_TYPE resetContainer(COLLECTION KEY_GENERIC_TYPE newContents) {
|
||||||
collection = super.resetContainer(newContents);
|
collection = super.resetContainer(newContents);
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetCollection() {
|
protected void resetCollection() {
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+187
-187
@@ -1,188 +1,188 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
import com.google.common.collect.testing.TestContainerGenerator;
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
|
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
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.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.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public abstract class ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<E> extends AbstractTester<OneSizeTestContainerGenerator<E, CLASS_TYPE>>
|
public abstract class ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<E> extends AbstractTester<OneSizeTestContainerGenerator<E, CLASS_TYPE>>
|
||||||
{
|
{
|
||||||
protected SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
protected SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
||||||
protected E container;
|
protected E container;
|
||||||
protected TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE primitiveGenerator;
|
protected TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE primitiveGenerator;
|
||||||
protected CollectionSize size;
|
protected CollectionSize size;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@OverridingMethodsMustInvokeSuper
|
@OverridingMethodsMustInvokeSuper
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
setupGenerator();
|
setupGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupGenerator() {
|
protected void setupGenerator() {
|
||||||
TestContainerGenerator<E, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
TestContainerGenerator<E, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||||
if (!(generator instanceof TEST_COLLECTION_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TEST_COLLECTION_GENERATOR");
|
if (!(generator instanceof TEST_COLLECTION_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TEST_COLLECTION_GENERATOR");
|
||||||
primitiveGenerator = (TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE) generator;
|
primitiveGenerator = (TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||||
samples = primitiveGenerator.getSamples();
|
samples = primitiveGenerator.getSamples();
|
||||||
size = getSubjectGenerator().getCollectionSize();
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract COLLECTION KEY_GENERIC_TYPE actualContents();
|
protected abstract COLLECTION KEY_GENERIC_TYPE actualContents();
|
||||||
|
|
||||||
protected E resetContainer() {
|
protected E resetContainer() {
|
||||||
return resetContainer(createTestSubject());
|
return resetContainer(createTestSubject());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected E resetContainer(E newValue) {
|
protected E resetContainer(E newValue) {
|
||||||
container = newValue;
|
container = newValue;
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectContents(KEY_TYPE... elements) {
|
protected void expectContents(KEY_TYPE... elements) {
|
||||||
expectContents(ARRAY_LIST.wrap(elements));
|
expectContents(ARRAY_LIST.wrap(elements));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||||
HELPERS.assertEqualIgnoringOrder(expected, actualContents());
|
HELPERS.assertEqualIgnoringOrder(expected, actualContents());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectUnchanged() {
|
protected void expectUnchanged() {
|
||||||
expectContents(getOrderedElements());
|
expectContents(getOrderedElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void expectAdded(KEY_TYPE... elements) {
|
protected final void expectAdded(KEY_TYPE... elements) {
|
||||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||||
expected.addAll(elements);
|
expected.addAll(elements);
|
||||||
expectContents(expected);
|
expectContents(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void expectAddedIndex(int index, KEY_TYPE... elements) {
|
protected final void expectAddedIndex(int index, KEY_TYPE... elements) {
|
||||||
expectAdded(index, ARRAY_LIST.wrap(elements));
|
expectAdded(index, ARRAY_LIST.wrap(elements));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void expectAdded(int index, COLLECTION KEY_GENERIC_TYPE elements) {
|
protected final void expectAdded(int index, COLLECTION KEY_GENERIC_TYPE elements) {
|
||||||
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||||
expected.addAll(index, elements);
|
expected.addAll(index, elements);
|
||||||
expectContents(expected);
|
expectContents(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectMissing(KEY_TYPE... elements) {
|
protected void expectMissing(KEY_TYPE... elements) {
|
||||||
for (KEY_TYPE element : elements) {
|
for (KEY_TYPE element : elements) {
|
||||||
assertFalse("Should not contain " + element, actualContents().contains(element));
|
assertFalse("Should not contain " + element, actualContents().contains(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KEY_TYPE[] createSamplesArray() {
|
protected KEY_TYPE[] createSamplesArray() {
|
||||||
return getSampleElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
return getSampleElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KEY_TYPE[] createOrderedArray() {
|
protected KEY_TYPE[] createOrderedArray() {
|
||||||
return getOrderedElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
return getOrderedElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ArrayWithDuplicate KEY_GENERIC_TYPE {
|
public static class ArrayWithDuplicate KEY_GENERIC_TYPE {
|
||||||
public final KEY_TYPE[] elements;
|
public final KEY_TYPE[] elements;
|
||||||
public final KEY_TYPE duplicate;
|
public final KEY_TYPE duplicate;
|
||||||
|
|
||||||
private ArrayWithDuplicate(KEY_TYPE[] elements, KEY_TYPE duplicate) {
|
private ArrayWithDuplicate(KEY_TYPE[] elements, KEY_TYPE duplicate) {
|
||||||
this.elements = elements;
|
this.elements = elements;
|
||||||
this.duplicate = duplicate;
|
this.duplicate = duplicate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ArrayWithDuplicate KEY_GENERIC_TYPE createArrayWithDuplicateElement() {
|
protected ArrayWithDuplicate KEY_GENERIC_TYPE createArrayWithDuplicateElement() {
|
||||||
KEY_TYPE[] elements = createSamplesArray();
|
KEY_TYPE[] elements = createSamplesArray();
|
||||||
KEY_TYPE duplicate = elements[(elements.length / 2) - 1];
|
KEY_TYPE duplicate = elements[(elements.length / 2) - 1];
|
||||||
elements[(elements.length / 2) + 1] = duplicate;
|
elements[(elements.length / 2) + 1] = duplicate;
|
||||||
return new ArrayWithDuplicateBRACES(elements, duplicate);
|
return new ArrayWithDuplicateBRACES(elements, duplicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getNumElements() {
|
protected int getNumElements() {
|
||||||
return size.getNumElements();
|
return size.getNumElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements() {
|
protected COLLECTION KEY_GENERIC_TYPE getSampleElements() {
|
||||||
return getSampleElements(getNumElements());
|
return getSampleElements(getNumElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
for (ITERATOR KEY_GENERIC_TYPE iter = primitiveGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
for (ITERATOR KEY_GENERIC_TYPE iter = primitiveGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||||
list.add(iter.NEXT());
|
list.add(iter.NEXT());
|
||||||
}
|
}
|
||||||
return LISTS.unmodifiable(list);
|
return LISTS.unmodifiable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
protected KEY_TYPE[] createDisjointArray() {
|
protected KEY_TYPE[] createDisjointArray() {
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||||
array[0] = e3();
|
array[0] = e3();
|
||||||
array[1] = e4();
|
array[1] = e4();
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
protected KEY_TYPE[] createDisjointArray() {
|
protected KEY_TYPE[] createDisjointArray() {
|
||||||
return new KEY_TYPE[]{e3(), e4()};
|
return new KEY_TYPE[]{e3(), e4()};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
protected KEY_TYPE[] emptyArray() {
|
protected KEY_TYPE[] emptyArray() {
|
||||||
return NEW_KEY_ARRAY(0);
|
return NEW_KEY_ARRAY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE createDisjointCollection() {
|
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE createDisjointCollection() {
|
||||||
return MINIMAL_COLLECTION.of(e3(), e4());
|
return MINIMAL_COLLECTION.of(e3(), e4());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE emptyCollection() {
|
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE emptyCollection() {
|
||||||
return MINIMAL_COLLECTION.of();
|
return MINIMAL_COLLECTION.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KEY_TYPE[] createArray(KEY_TYPE...array) {
|
public KEY_TYPE[] createArray(KEY_TYPE...array) {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE e0() {
|
protected final KEY_TYPE e0() {
|
||||||
return samples.e0();
|
return samples.e0();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE e1() {
|
protected final KEY_TYPE e1() {
|
||||||
return samples.e1();
|
return samples.e1();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE e2() {
|
protected final KEY_TYPE e2() {
|
||||||
return samples.e2();
|
return samples.e2();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE e3() {
|
protected final KEY_TYPE e3() {
|
||||||
return samples.e3();
|
return samples.e3();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE e4() {
|
protected final KEY_TYPE e4() {
|
||||||
return samples.e4();
|
return samples.e4();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected E createTestSubject() {
|
protected E createTestSubject() {
|
||||||
return (E)primitiveGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
return (E)primitiveGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected COLLECTION KEY_GENERIC_TYPE getSampleElements(int howMany) {
|
protected COLLECTION KEY_GENERIC_TYPE getSampleElements(int howMany) {
|
||||||
return new ARRAY_LISTBRACES(samples.asList().subList(0, howMany));
|
return new ARRAY_LISTBRACES(samples.asList().subList(0, howMany));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+27
-27
@@ -1,27 +1,27 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
#endignore
|
#endignore
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public abstract class ABSTRACT_LIST_INDEX_OF_TESTER KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
public abstract class ABSTRACT_LIST_INDEX_OF_TESTER KEY_GENERIC_TYPE extends ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
protected abstract int find(KEY_TYPE o);
|
protected abstract int find(KEY_TYPE o);
|
||||||
|
|
||||||
protected abstract String getMethodName();
|
protected abstract String getMethodName();
|
||||||
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
public void testFind_yes() {
|
public void testFind_yes() {
|
||||||
assertEquals(getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().GET_KEY(0)));
|
assertEquals(getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().GET_KEY(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFind_no() {
|
public void testFind_no() {
|
||||||
assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
|
assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-38
@@ -1,39 +1,39 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
public class ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
protected final LIST KEY_GENERIC_TYPE getList() {
|
protected final LIST KEY_GENERIC_TYPE getList() {
|
||||||
return (LIST KEY_GENERIC_TYPE) collection;
|
return (LIST KEY_GENERIC_TYPE) collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expectedCollection) {
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expectedCollection) {
|
||||||
LIST KEY_GENERIC_TYPE expectedList = HELPERS.copyToList(expectedCollection);
|
LIST KEY_GENERIC_TYPE expectedList = HELPERS.copyToList(expectedCollection);
|
||||||
if (getList().size() != expectedList.size()) {
|
if (getList().size() != expectedList.size()) {
|
||||||
fail("size mismatch: " + reportContext(expectedList));
|
fail("size mismatch: " + reportContext(expectedList));
|
||||||
}
|
}
|
||||||
for (int i = 0; i < expectedList.size(); i++) {
|
for (int i = 0; i < expectedList.size(); i++) {
|
||||||
KEY_TYPE expected = expectedList.GET_KEY(i);
|
KEY_TYPE expected = expectedList.GET_KEY(i);
|
||||||
KEY_TYPE actual = getList().GET_KEY(i);
|
KEY_TYPE actual = getList().GET_KEY(i);
|
||||||
if (KEY_EQUALS_NOT(expected, actual)) {
|
if (KEY_EQUALS_NOT(expected, actual)) {
|
||||||
fail("mismatch at index " + i + ": " + reportContext(expectedList));
|
fail("mismatch at index " + i + ": " + reportContext(expectedList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String reportContext(LIST KEY_GENERIC_TYPE expected) {
|
private String reportContext(LIST KEY_GENERIC_TYPE expected) {
|
||||||
return String.format("expected collection %s; actual collection %s", expected, collection);
|
return String.format("expected collection %s; actual collection %s", expected, collection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+81
-81
@@ -1,81 +1,81 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.TestContainerGenerator;
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
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.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.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ABSTRACT_QUEUE_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<PRIORITY_QUEUE KEY_CLASS_GENERIC_TYPE>
|
public class ABSTRACT_QUEUE_TESTER KEY_GENERIC_TYPE extends ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<PRIORITY_QUEUE KEY_CLASS_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
protected TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE queueGenerator;
|
protected TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE queueGenerator;
|
||||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE queue;
|
protected PRIORITY_QUEUE KEY_GENERIC_TYPE queue;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupGenerator() {
|
protected void setupGenerator() {
|
||||||
TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||||
if (!(generator instanceof TEST_QUEUE_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLongCollectionGenerator");
|
if (!(generator instanceof TEST_QUEUE_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLongCollectionGenerator");
|
||||||
queueGenerator = (TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE) generator;
|
queueGenerator = (TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||||
samples = queueGenerator.getSamples();
|
samples = queueGenerator.getSamples();
|
||||||
size = getSubjectGenerator().getCollectionSize();
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected COLLECTION KEY_GENERIC_TYPE actualContents() { return null; }
|
protected COLLECTION KEY_GENERIC_TYPE actualContents() { return null; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE resetContainer(PRIORITY_QUEUE KEY_GENERIC_TYPE newValue) {
|
protected PRIORITY_QUEUE KEY_GENERIC_TYPE resetContainer(PRIORITY_QUEUE KEY_GENERIC_TYPE newValue) {
|
||||||
queue = super.resetContainer(newValue);
|
queue = super.resetContainer(newValue);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetQueue() {
|
protected void resetQueue() {
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
for (ITERATOR KEY_GENERIC_TYPE iter = queueGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
for (ITERATOR KEY_GENERIC_TYPE iter = queueGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||||
list.add(iter.NEXT());
|
list.add(iter.NEXT());
|
||||||
}
|
}
|
||||||
return LISTS.unmodifiable(list);
|
return LISTS.unmodifiable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PRIORITY_QUEUE KEY_GENERIC_TYPE createTestSubject() {
|
protected PRIORITY_QUEUE KEY_GENERIC_TYPE createTestSubject() {
|
||||||
return queueGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
return queueGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||||
HELPERS.assertContentsAnyOrder(expected, queue.TO_ARRAY());
|
HELPERS.assertContentsAnyOrder(expected, queue.TO_ARRAY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void expectMissing(KEY_TYPE... elements) {
|
protected void expectMissing(KEY_TYPE... elements) {
|
||||||
for (KEY_TYPE element : elements) {
|
for (KEY_TYPE element : elements) {
|
||||||
assertFalse("Should not contain " + element, contains(element));
|
assertFalse("Should not contain " + element, contains(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean contains(KEY_TYPE element) {
|
protected boolean contains(KEY_TYPE element) {
|
||||||
for(int i = 0,m=queue.size();i<m;i++) {
|
for(int i = 0,m=queue.size();i<m;i++) {
|
||||||
if(KEY_EQUALS(queue.peek(i), element)) return true;
|
if(KEY_EQUALS(queue.peek(i), element)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -1,14 +1,14 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base;
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ABSTRACT_SET_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
public class ABSTRACT_SET_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
protected final SET KEY_GENERIC_TYPE getSet() {
|
protected final SET KEY_GENERIC_TYPE getSet() {
|
||||||
return (SET KEY_GENERIC_TYPE)collection;
|
return (SET KEY_GENERIC_TYPE)collection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+243
-243
@@ -1,243 +1,243 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.base.maps;
|
package speiger.src.testers.PACKAGE.tests.base.maps;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.TestContainerGenerator;
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.objects.collections.ObjectCollection;
|
import speiger.src.collections.objects.collections.ObjectCollection;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.objects.lists.ObjectArrayList;
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
import speiger.src.collections.objects.lists.ObjectList;
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
import speiger.src.collections.objects.utils.ObjectLists;
|
import speiger.src.collections.objects.utils.ObjectLists;
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.objects.tests.base.AbstractObjectContainerTester;
|
import speiger.src.testers.objects.tests.base.AbstractObjectContainerTester;
|
||||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE extends AbstractObjectContainerTester<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP KEY_VALUE_GENERIC_TYPE>
|
public class ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE extends AbstractObjectContainerTester<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
protected TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE primitiveMapGenerator;
|
protected TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE primitiveMapGenerator;
|
||||||
|
|
||||||
protected MAP KEY_VALUE_GENERIC_TYPE getMap() {
|
protected MAP KEY_VALUE_GENERIC_TYPE getMap() {
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setupGenerator() {
|
protected void setupGenerator() {
|
||||||
TestContainerGenerator<? extends Map<CLASS_TYPE, CLASS_VALUE_TYPE>, ? extends Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> generator = getSubjectGenerator().getInnerGenerator();
|
TestContainerGenerator<? extends Map<CLASS_TYPE, CLASS_VALUE_TYPE>, ? extends Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> generator = getSubjectGenerator().getInnerGenerator();
|
||||||
if (!(generator instanceof TEST_MAP_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLong2ByteMapGenerator");
|
if (!(generator instanceof TEST_MAP_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TestLong2ByteMapGenerator");
|
||||||
primitiveMapGenerator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) generator;
|
primitiveMapGenerator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) generator;
|
||||||
samples = primitiveMapGenerator.getSamples();
|
samples = primitiveMapGenerator.getSamples();
|
||||||
size = getSubjectGenerator().getCollectionSize();
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MAP KEY_VALUE_GENERIC_TYPE createTestSubject() {
|
protected MAP KEY_VALUE_GENERIC_TYPE createTestSubject() {
|
||||||
return primitiveMapGenerator.create(getSampleElements(size.getNumElements()).toArray(new MAP.Entry[getNumElements()]));
|
return primitiveMapGenerator.create(getSampleElements(size.getNumElements()).toArray(new MAP.Entry[getNumElements()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> getOrderedElements() {
|
protected ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> getOrderedElements() {
|
||||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> list = new ObjectArrayList<>();
|
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> list = new ObjectArrayList<>();
|
||||||
for (ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = primitiveMapGenerator.order(new ObjectArrayList<MAP.Entry KEY_VALUE_GENERIC_TYPE>(getSampleElements())).iterator(); iter.hasNext();) {
|
for (ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = primitiveMapGenerator.order(new ObjectArrayList<MAP.Entry KEY_VALUE_GENERIC_TYPE>(getSampleElements())).iterator(); iter.hasNext();) {
|
||||||
list.add(iter.next());
|
list.add(iter.next());
|
||||||
}
|
}
|
||||||
return ObjectLists.unmodifiable(list);
|
return ObjectLists.unmodifiable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> actualContents() {
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> actualContents() {
|
||||||
return getMap().ENTRY_SET();
|
return getMap().ENTRY_SET();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void resetMap() {
|
protected final void resetMap() {
|
||||||
resetContainer();
|
resetContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void resetMap(MAP.Entry KEY_VALUE_GENERIC_TYPE[] entries) {
|
protected void resetMap(MAP.Entry KEY_VALUE_GENERIC_TYPE[] entries) {
|
||||||
resetContainer(primitiveMapGenerator.create(entries));
|
resetContainer(primitiveMapGenerator.create(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MAP KEY_VALUE_GENERIC_TYPE resetContainer(MAP KEY_VALUE_GENERIC_TYPE newValue) {
|
protected MAP KEY_VALUE_GENERIC_TYPE resetContainer(MAP KEY_VALUE_GENERIC_TYPE newValue) {
|
||||||
newValue.setDefaultReturnValue(INVALID_VALUE);
|
newValue.setDefaultReturnValue(INVALID_VALUE);
|
||||||
return super.resetContainer(newValue);
|
return super.resetContainer(newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectMissingKeys(KEY_TYPE... elements) {
|
protected void expectMissingKeys(KEY_TYPE... elements) {
|
||||||
for (KEY_TYPE element : elements) {
|
for (KEY_TYPE element : elements) {
|
||||||
assertFalse("Should not contain key " + element, getMap().containsKey(element));
|
assertFalse("Should not contain key " + element, getMap().containsKey(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expectMissingValues(VALUE_TYPE... elements) {
|
protected void expectMissingValues(VALUE_TYPE... elements) {
|
||||||
for (VALUE_TYPE element : elements) {
|
for (VALUE_TYPE element : elements) {
|
||||||
assertFalse("Should not contain value " + element, getMap().containsValue(element));
|
assertFalse("Should not contain value " + element, getMap().containsValue(element));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getNumEntries() {
|
protected int getNumEntries() {
|
||||||
return getNumElements();
|
return getNumElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries(int howMany) {
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries(int howMany) {
|
||||||
return getSampleElements(howMany);
|
return getSampleElements(howMany);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries() {
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries() {
|
||||||
return getSampleElements();
|
return getSampleElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void expectMissing(MAP.Entry KEY_VALUE_GENERIC_TYPE... entries) {
|
protected void expectMissing(MAP.Entry KEY_VALUE_GENERIC_TYPE... entries) {
|
||||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : entries) {
|
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : entries) {
|
||||||
assertFalse("Should not contain entry " + entry, actualContents().contains(entry));
|
assertFalse("Should not contain entry " + entry, actualContents().contains(entry));
|
||||||
#if !VALUE_BOOLEAN
|
#if !VALUE_BOOLEAN
|
||||||
assertFalse("Should not contain key " + entry.ENTRY_KEY() + " mapped to value " + entry.ENTRY_VALUE(), valueEquals(getMap().get(entry.ENTRY_KEY()), entry.ENTRY_VALUE()));
|
assertFalse("Should not contain key " + entry.ENTRY_KEY() + " mapped to value " + entry.ENTRY_VALUE(), valueEquals(getMap().get(entry.ENTRY_KEY()), entry.ENTRY_VALUE()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void expectContents(ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected) {
|
protected void expectContents(ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected) {
|
||||||
super.expectContents(expected);
|
super.expectContents(expected);
|
||||||
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : expected) {
|
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : expected) {
|
||||||
assertEquals("Wrong value for key " + entry.ENTRY_KEY(), entry.ENTRY_VALUE(), getMap().GET_VALUE(entry.ENTRY_KEY()));
|
assertEquals("Wrong value for key " + entry.ENTRY_KEY(), entry.ENTRY_VALUE(), getMap().GET_VALUE(entry.ENTRY_KEY()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void expectReplacement(MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
protected final void expectReplacement(MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||||
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected = ObjectHelpers.copyToList(getSampleElements());
|
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected = ObjectHelpers.copyToList(getSampleElements());
|
||||||
replaceValue(expected, newEntry);
|
replaceValue(expected, newEntry);
|
||||||
expectContents(expected);
|
expectContents(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceValue(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected, MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
private void replaceValue(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected, MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||||
for (ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> i = expected.listIterator(); i.hasNext();) {
|
for (ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> i = expected.listIterator(); i.hasNext();) {
|
||||||
if (HELPERS.equals(i.next().ENTRY_KEY(), newEntry.ENTRY_KEY())) {
|
if (HELPERS.equals(i.next().ENTRY_KEY(), newEntry.ENTRY_KEY())) {
|
||||||
i.set(newEntry);
|
i.set(newEntry);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException(String.format(Locale.ROOT, "key %s not found in entries %s", newEntry.ENTRY_KEY(), expected));
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "key %s not found in entries %s", newEntry.ENTRY_KEY(), expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !VALUE_BOOLEAN
|
#if !VALUE_BOOLEAN
|
||||||
private static GENERIC_VALUE_BRACES boolean valueEquals(VALUE_TYPE a, VALUE_TYPE b) {
|
private static GENERIC_VALUE_BRACES boolean valueEquals(VALUE_TYPE a, VALUE_TYPE b) {
|
||||||
return VALUE_EQUALS(a, b);
|
return VALUE_EQUALS(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
protected MAP.Entry KEY_VALUE_GENERIC_TYPE entry(KEY_TYPE key, VALUE_TYPE value) {
|
protected MAP.Entry KEY_VALUE_GENERIC_TYPE entry(KEY_TYPE key, VALUE_TYPE value) {
|
||||||
return new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value);
|
return new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KEY_TYPE[] emptyKeyArray() {
|
protected KEY_TYPE[] emptyKeyArray() {
|
||||||
return NEW_KEY_ARRAY(0);
|
return NEW_KEY_ARRAY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KEY_TYPE[] createDisjointedKeyArray() {
|
protected KEY_TYPE[] createDisjointedKeyArray() {
|
||||||
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||||
array[0] = k3();
|
array[0] = k3();
|
||||||
array[1] = k4();
|
array[1] = k4();
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLASS_TYPE[] emptyKeyObjectArray() {
|
protected CLASS_TYPE[] emptyKeyObjectArray() {
|
||||||
return NEW_CLASS_ARRAY(0);
|
return NEW_CLASS_ARRAY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLASS_TYPE[] createDisjointedKeyObjectArray() {
|
protected CLASS_TYPE[] createDisjointedKeyObjectArray() {
|
||||||
CLASS_TYPE[] array = NEW_CLASS_ARRAY(2);
|
CLASS_TYPE[] array = NEW_CLASS_ARRAY(2);
|
||||||
array[0] = k3();
|
array[0] = k3();
|
||||||
array[1] = k4();
|
array[1] = k4();
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE[] emptyValueArray() {
|
protected VALUE_TYPE[] emptyValueArray() {
|
||||||
return NEW_VALUE_ARRAY(0);
|
return NEW_VALUE_ARRAY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE[] createDisjointedValueArray() {
|
protected VALUE_TYPE[] createDisjointedValueArray() {
|
||||||
VALUE_TYPE[] array = NEW_VALUE_ARRAY(2);
|
VALUE_TYPE[] array = NEW_VALUE_ARRAY(2);
|
||||||
array[0] = v3();
|
array[0] = v3();
|
||||||
array[1] = v4();
|
array[1] = v4();
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLASS_VALUE_TYPE[] emptyValueObjectArray() {
|
protected CLASS_VALUE_TYPE[] emptyValueObjectArray() {
|
||||||
return NEW_CLASS_VALUE_ARRAY(0);
|
return NEW_CLASS_VALUE_ARRAY(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CLASS_VALUE_TYPE[] createDisjointedValueObjectArray() {
|
protected CLASS_VALUE_TYPE[] createDisjointedValueObjectArray() {
|
||||||
CLASS_VALUE_TYPE[] array = NEW_CLASS_VALUE_ARRAY(2);
|
CLASS_VALUE_TYPE[] array = NEW_CLASS_VALUE_ARRAY(2);
|
||||||
array[0] = v3();
|
array[0] = v3();
|
||||||
array[1] = v4();
|
array[1] = v4();
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE get(KEY_TYPE key) {
|
protected VALUE_TYPE get(KEY_TYPE key) {
|
||||||
return getMap().GET_VALUE(key);
|
return getMap().GET_VALUE(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected CLASS_VALUE_TYPE get(CLASS_TYPE key) {
|
protected CLASS_VALUE_TYPE get(CLASS_TYPE key) {
|
||||||
return getMap().get(key);
|
return getMap().get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
protected final KEY_TYPE k0() {
|
protected final KEY_TYPE k0() {
|
||||||
return e0().ENTRY_KEY();
|
return e0().ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final VALUE_TYPE v0() {
|
protected final VALUE_TYPE v0() {
|
||||||
return e0().ENTRY_VALUE();
|
return e0().ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE k1() {
|
protected final KEY_TYPE k1() {
|
||||||
return e1().ENTRY_KEY();
|
return e1().ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final VALUE_TYPE v1() {
|
protected final VALUE_TYPE v1() {
|
||||||
return e1().ENTRY_VALUE();
|
return e1().ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE k2() {
|
protected final KEY_TYPE k2() {
|
||||||
return e2().ENTRY_KEY();
|
return e2().ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final VALUE_TYPE v2() {
|
protected final VALUE_TYPE v2() {
|
||||||
return e2().ENTRY_VALUE();
|
return e2().ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE k3() {
|
protected final KEY_TYPE k3() {
|
||||||
return e3().ENTRY_KEY();
|
return e3().ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final VALUE_TYPE v3() {
|
protected final VALUE_TYPE v3() {
|
||||||
return e3().ENTRY_VALUE();
|
return e3().ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final KEY_TYPE k4() {
|
protected final KEY_TYPE k4() {
|
||||||
return e4().ENTRY_KEY();
|
return e4().ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final VALUE_TYPE v4() {
|
protected final VALUE_TYPE v4() {
|
||||||
return e4().ENTRY_VALUE();
|
return e4().ENTRY_VALUE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user