Compare commits
39
Commits
0.6.1
...
5118ae8b1f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5118ae8b1f | ||
|
|
03b23f0e3c | ||
|
|
ca33c9eb9e | ||
|
|
b4374fdd4d | ||
|
|
455ee64a88 | ||
|
|
893b371017 | ||
|
|
5fa9baae7a | ||
|
|
70d565c785 | ||
|
|
5c27e332cd | ||
|
|
f2d919bae5 | ||
|
|
7d4c77332b | ||
|
|
d1186d4f82 | ||
|
|
3b8a02ac51 | ||
|
|
f356d4ab57 | ||
|
|
b07bc85114 | ||
|
|
c37746cd84 | ||
|
|
fb7c417394 | ||
|
|
ddc58ee221 | ||
|
|
8b5e5a75c1 | ||
|
|
c1862e6b05 | ||
|
|
c2c2780967 | ||
|
|
086d933a0d | ||
|
|
1e7da394a1 | ||
|
|
9eb220194f | ||
|
|
0baf141e4b | ||
|
|
569d4f5c86 | ||
|
|
36f24731b0 | ||
|
|
ea5ace0166 | ||
|
|
663809ff27 | ||
|
|
5d6adb5446 | ||
|
|
212ad1ace2 | ||
|
|
707827929a | ||
|
|
27ad01657d | ||
|
|
e7da7acc08 | ||
|
|
72943cb22c | ||
|
|
068cc4a4f7 | ||
|
|
31b34f5de1 | ||
|
|
4bded1af80 | ||
|
|
100c7fe260 |
@@ -0,0 +1,32 @@
|
|||||||
|
name: Latest Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
jdk: [8, 11, 14, 16, 17, 18]
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up JDK ${{ matrix.jdk }}
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: ${{ matrix.jdk }}
|
||||||
|
|
||||||
|
- name: Validate Gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
||||||
|
|
||||||
|
- name: Make gradlew executable
|
||||||
|
run: chmod +x ./gradlew
|
||||||
|
|
||||||
|
- name: Build with Gradle
|
||||||
|
run: ./gradlew build
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
name: Unit Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Unit Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- 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 Test
|
||||||
|
run: |
|
||||||
|
./gradlew generateTestSource test jacocoTestReport --info -Dfull_test_suite=true
|
||||||
|
./gradlew --stop
|
||||||
|
|
||||||
|
- name: Publish Test Result
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
id: test-results
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
junit_files: build/test-results/**/*.xml
|
||||||
|
fail_on: nothing
|
||||||
|
ignore_runs: true
|
||||||
|
json_thousands_separator: .
|
||||||
|
time_unit: milliseconds
|
||||||
|
|
||||||
|
- name: Create Badge Color
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in
|
||||||
|
success)
|
||||||
|
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV
|
||||||
|
;;
|
||||||
|
failure)
|
||||||
|
echo "BADGE_COLOR=800000" >> $GITHUB_ENV
|
||||||
|
;;
|
||||||
|
neutral)
|
||||||
|
echo "BADGE_COLOR=696969" >> $GITHUB_ENV
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Create Test Badge
|
||||||
|
uses: emibcn/badge-action@v1.2.4
|
||||||
|
with:
|
||||||
|
label: Tests
|
||||||
|
status: '${{ fromJSON( steps.test-results.outputs.json ).conclusion }}, Passed: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_succ }}, Skipped: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_skip }}, Failed: ${{ fromJSON( steps.test-results.outputs.json ).formatted.stats.tests_fail }}'
|
||||||
|
color: ${{ env.BADGE_COLOR }}
|
||||||
|
path: tests.svg
|
||||||
|
|
||||||
|
- name: Create Coverage Badge
|
||||||
|
id: jacoco
|
||||||
|
uses: cicirello/jacoco-badge-generator@v2
|
||||||
|
with:
|
||||||
|
jacoco-csv-file: build/reports/jacoco/test/jacocoTestReport.csv
|
||||||
|
badges-directory: null
|
||||||
|
intervals: 95 80 70 60 50 0
|
||||||
|
|
||||||
|
- name: Upload Test Badge
|
||||||
|
uses: exuanbo/actions-deploy-gist@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GIST_TOKEN }}
|
||||||
|
gist_id: 280257cd19cbe1dda3789bebd4ff65cf
|
||||||
|
file_path: tests.svg
|
||||||
|
|
||||||
|
- name: Upload Coverage Badge
|
||||||
|
uses: exuanbo/actions-deploy-gist@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GIST_TOKEN }}
|
||||||
|
gist_id: 280257cd19cbe1dda3789bebd4ff65cf
|
||||||
|
file_path: jacoco.svg
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
# This workflow uses actions that are not certified by GitHub.
|
|
||||||
# They are provided by a third-party and are governed by
|
|
||||||
# separate terms of service, privacy policy, and support
|
|
||||||
# documentation.
|
|
||||||
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
|
||||||
|
|
||||||
name: Latest Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
jdk: [8, 11, 14, 16, 17]
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up JDK ${{ matrix.jdk }}
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: ${{ matrix.jdk }}
|
|
||||||
- name: Validate Gradle wrapper
|
|
||||||
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b
|
|
||||||
- name: Make gradlew executable
|
|
||||||
run: chmod +x ./gradlew
|
|
||||||
- name: Generate SourceCode with Gradle
|
|
||||||
run: ./gradlew generateGithubSource
|
|
||||||
- name: Build with Gradle
|
|
||||||
run: ./gradlew build
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
name: Unit Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Unit Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- 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 Test
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: ./gradlew generateTestSource test jacocoTestReport --info -Dfull_test_suite=true
|
||||||
|
|
||||||
|
- name: Publish Test Result
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
id: test-results
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
junit_files: build/test-results/**/*.xml
|
||||||
|
fail_on: nothing
|
||||||
|
ignore_runs: true
|
||||||
|
json_thousands_separator: .
|
||||||
|
time_unit: milliseconds
|
||||||
+14
@@ -30,5 +30,19 @@ gradle-app.setting
|
|||||||
/src/main/java/speiger/src/collections/doubles/*
|
/src/main/java/speiger/src/collections/doubles/*
|
||||||
/src/main/java/speiger/src/collections/objects/*
|
/src/main/java/speiger/src/collections/objects/*
|
||||||
|
|
||||||
|
#Generated Tests
|
||||||
|
/src/test/java/speiger/src/testers/booleans/*
|
||||||
|
/src/test/java/speiger/src/testers/bytes/*
|
||||||
|
/src/test/java/speiger/src/testers/shorts/*
|
||||||
|
/src/test/java/speiger/src/testers/chars/*
|
||||||
|
/src/test/java/speiger/src/testers/ints/*
|
||||||
|
/src/test/java/speiger/src/testers/longs/*
|
||||||
|
/src/test/java/speiger/src/testers/floats/*
|
||||||
|
/src/test/java/speiger/src/testers/doubles/*
|
||||||
|
/src/test/java/speiger/src/testers/objects/*
|
||||||
|
/src/test/java/speiger/src/tests/*
|
||||||
|
|
||||||
#Cache result
|
#Cache result
|
||||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
/src/builder/resources/speiger/assets/collections/cache.bin
|
||||||
|
/src/builder/resources/speiger/assets/testers/cache.bin
|
||||||
|
/src/builder/resources/speiger/assets/tests/cache.bin
|
||||||
|
|||||||
@@ -1,5 +1,65 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
|
### Version 0.7.0
|
||||||
|
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
||||||
|
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
||||||
|
- Added: EnumMap specialized forEach implementation.
|
||||||
|
- Added: AbstractMap.remove now delegates to its primitive counterpart.
|
||||||
|
- Added: ConcurrentHashMap now implements ITrimmable
|
||||||
|
- Refactor: Removed a lot of disabled code from ArraySet.
|
||||||
|
- Removed: LinkedList.addAll(index, List) now delegates to LinkedList.addAll(index, Collection) due to no special optimization required.
|
||||||
|
- Fixed: AbstractList.SubList.get/set/swapRemove didn't calculate their List index Properly
|
||||||
|
- Fixed: AbstractList.SubList chains now properly if you create SubLists within SubLists.
|
||||||
|
- Fixed: AbstractList.Iterator.add now respects Immutable/UnmodifiableLists.
|
||||||
|
- Fixed: AbstractList.Iterator.skip/back now keep track of the last returned value for remove function to work properly.
|
||||||
|
- Fixed: CopyOnWriteArrayList.extract/removeElements(int, int) does now proper range checks and remove elements properly.
|
||||||
|
- Fixed: CopyOnWriteArrayList.SubList now works properly. (Reimplemented entirely)
|
||||||
|
- Fixed: CopyOnWriteArrayList.Iterator.previous() was returning the wrong values.
|
||||||
|
- Fixed: CopyOnWriteArrayList.Iterator.skip now skips the right amount of elements and stops where it should.
|
||||||
|
- 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.
|
||||||
|
- 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.
|
||||||
|
- Fixed: LinkedHashMap.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
||||||
|
- Fixed: HashMap.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
||||||
|
- Fixed: HashMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
|
- Fixed: ImmutableMap now compares empty values (0) against nullKeys when Object Variants of the type are used.
|
||||||
|
- Fixed: ArrayMap.iterator(key) now throws NoSuchElementException when the element wasn't found.
|
||||||
|
- Fixed: Linked/EnumMap array constructor was creating the wrong size values array.
|
||||||
|
- Fixed: LinkedEnumMap.getAndMoveToFirst/Last was moving elements even if the element wasn't present.
|
||||||
|
- Fixed: AVL/RBTreeMap.getFirst/LastKey was not throwing a NoSuchElementException if the map was empty.
|
||||||
|
- Fixed: Map.Builder wasn't throwing a IllegalStateException when creating a negative size builder.
|
||||||
|
- Fixed: AVL/RBTreeSet.DecendingSet.subSet(from, fromInclusive, to, toInclusive) was creating a corrupt asending subset.
|
||||||
|
- Fixed: ArraySet throws now a IllegalStateException when trying to create it with a negative size.
|
||||||
|
- Fixed: ArraySet.addMoveToLast(key) was crashing when a key was already present.
|
||||||
|
- Fixed: Immutable/LinkedHashSet now keep track of their iteration index properly.
|
||||||
|
- Fixed: LinkedHashSet.moveToFirst/Last(key) would crash if the Set was empty.
|
||||||
|
- Fixed: LinkedHashSet.clearAndTrim() was checking the wrong value for determining the full reset or clearing of a Map.
|
||||||
|
- Fixed: HashSet.trim/clearToTrim() was using the wrong value to determin if something should be done.
|
||||||
|
|
||||||
|
|
||||||
|
### Version 0.6.2
|
||||||
|
- Added: Array only sorting function return the inputed array. This was done to allow for static final references to use the method in one go without having to make lambda wrappers. Cleaner code.
|
||||||
|
- Added: Iterator Wrappers are now a bit more in Compliance with Java Standards.
|
||||||
|
- Added: AsyncBuilders now Support Array Inputs to create cleaner code.
|
||||||
|
- Changed: LinkedList.addBulk variable definition was triggering a false positive.
|
||||||
|
- Fixed: TreeMap.subMap().entrySet().remove() wouldn't check primitives properly.
|
||||||
|
- Fixed: SortedMap.sub/tail/headMap were looping into themselves.
|
||||||
|
- Fixed: AbstractCollection.retainAll didn't push removed values through the consumer.
|
||||||
|
- Fixed: AbstractCollection.toArray wouldn't reset the last entry if the input array was larger then the elements in the collection.
|
||||||
|
- Fixed: SubList didn't check for ranges properly or didn't use parent list to validate changes.
|
||||||
|
- Fixed: ArrayList.addElements didn't check input array fully and used the wrong variable to move the elements around.
|
||||||
|
- Fixed: LinkedList.addElements(EmptyInput) would crash.
|
||||||
|
- Fixed: LinkedList.swapRemove didn't account for if the removed element was the prelast one.
|
||||||
|
- Fixed: LinkedList.removeElements would break the implementation if the list was almost empty and the middle element was removed.
|
||||||
|
- Fixed: LinkedHashSet.addAndMoveToFirst wouldn't move elements to the first place.
|
||||||
|
- 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.
|
||||||
|
- Fixed: TreeMap keySet implementation was missing the class type implementations to pass keySet tests.
|
||||||
|
- Fixed: TreeMap.SubMap Iterator (primitive Keys) was crashing because a Null was set on to a primitive.
|
||||||
|
|
||||||
|
|
||||||
### Version 0.6.1
|
### Version 0.6.1
|
||||||
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
- Fixed: FIFO queue crashing when the last index is before the first index when peek is called.
|
||||||
- Fixed: FIFO queue only clears the array if it was in use.
|
- Fixed: FIFO queue only clears the array if it was in use.
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||

|

|
||||||
[](https://jitpack.io/#Speiger/Primitive-Collections)
|
[](https://jitpack.io/#Speiger/Primitive-Collections)
|
||||||
[](https://opensource.org/licenses/Apache-2.0)
|
[](https://opensource.org/licenses/Apache-2.0)
|
||||||

|

|
||||||
|

|
||||||
|

|
||||||
|
[](https://codecov.io/gh/Speiger/Primitive-Collections)
|
||||||
|

|
||||||
# Primitive-Collections
|
# Primitive-Collections
|
||||||
This is a Simple Primitive Collections Library aimed to outperform Java's Collection Library and FastUtil.
|
This is a Simple Primitive Collections Library aimed to outperform Java's Collection Library and FastUtil.
|
||||||
Both in Performance and Quality of Life Features.
|
Both in Performance and Quality of Life Features.
|
||||||
@@ -42,43 +46,14 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.Speiger:Primitive-Collections:0.6.1'
|
implementation 'com.github.Speiger:Primitive-Collections:0.7.0'
|
||||||
}
|
|
||||||
```
|
|
||||||
Using Custom Gradle:
|
|
||||||
```gradle
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url = "https://maven.speiger.com/repository/main"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
implementation 'de.speiger:Primitive-Collections:0.6.1'
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
# SourceCode
|
||||||
<summary>Direct: </summary>
|
The generated Sourcecode can be automatically build,
|
||||||
<p>
|
but if you want to just browse around in it.
|
||||||
|
Check out the [Debug Branch](https://github.com/Speiger/Primitive-Collections/tree/debug/src/main/java/speiger/src/collections), which has the entire up to date code.
|
||||||
| Version | Jar | Sources | Java Doc |
|
|
||||||
|--------- |------------------------------------------------------------------------------------------------------------------------------ |-------------------------------------------------------------------------------------------------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| 0.6.1 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.1/Primitive-Collections-0.6.1-javadoc.jar) |
|
|
||||||
| 0.6.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.6.0/Primitive-Collections-0.6.0-javadoc.jar) |
|
|
||||||
| 0.5.3 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.3/Primitive-Collections-0.5.3-javadoc.jar) |
|
|
||||||
| 0.5.2 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.2/Primitive-Collections-0.5.2.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.2/Primitive-Collections-0.5.2-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.2/Primitive-Collections-0.5.2-javadoc.jar) |
|
|
||||||
| 0.5.1 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.1/Primitive-Collections-0.5.1.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.1/Primitive-Collections-0.5.1-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.1/Primitive-Collections-0.5.1-javadoc.jar) |
|
|
||||||
| 0.5.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.0/Primitive-Collections-0.5.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.0/Primitive-Collections-0.5.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.5.0/Primitive-Collections-0.5.0-javadoc.jar) |
|
|
||||||
| 0.4.5 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.5/Primitive-Collections-0.4.5.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.5/Primitive-Collections-0.4.5-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.5/Primitive-Collections-0.4.5-javadoc.jar) |
|
|
||||||
| 0.4.4 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4-javadoc.jar) |
|
|
||||||
| 0.4.3 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3-javadoc.jar) |
|
|
||||||
| 0.4.2 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2-javadoc.jar) |
|
|
||||||
| 0.4.1 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1-javadoc.jar) |
|
|
||||||
| 0.4.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-javadoc.jar) |
|
|
||||||
| 0.3.6 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-javadoc.jar) |
|
|
||||||
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
If you want to contribute.
|
If you want to contribute.
|
||||||
@@ -98,6 +73,5 @@ Please if you want to contribute follow the [Rule-Sheet](RuleSheet.md). It keeps
|
|||||||
The SourceCode can be generated via:
|
The SourceCode can be generated via:
|
||||||
/gradlew.bat generateSource
|
/gradlew.bat generateSource
|
||||||
|
|
||||||
to build the jar:
|
to generate SourceCode and build the jar:
|
||||||
/gradlew.bat build
|
/gradlew.bat build
|
||||||
do not combine the commands because they can not be executed at the same time.
|
|
||||||
|
|||||||
+158
-5
@@ -1,5 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
|
id "jacoco"
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
@@ -18,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.6.1';
|
version = '0.7.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.0.7'
|
builderImplementation 'de.speiger:Simple-Code-Generator:1.1.4'
|
||||||
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'
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ task generateGithubSource(type: JavaExec) {
|
|||||||
description = 'Builds the sourcecode for Github Actions'
|
description = 'Builds the sourcecode for Github Actions'
|
||||||
classpath = sourceSets.builder.runtimeClasspath
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
args = ['false', 'true']
|
args = ['silent']
|
||||||
}
|
}
|
||||||
|
|
||||||
task forceGenerateSource(type: JavaExec) {
|
task forceGenerateSource(type: JavaExec) {
|
||||||
@@ -70,7 +71,15 @@ task forceGenerateSource(type: JavaExec) {
|
|||||||
description = 'Builds the sourcecode forceful'
|
description = 'Builds the sourcecode forceful'
|
||||||
classpath = sourceSets.builder.runtimeClasspath
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
args = ['true']
|
args = ['force']
|
||||||
|
}
|
||||||
|
|
||||||
|
task generateTestSource(type: JavaExec) {
|
||||||
|
group = 'internal'
|
||||||
|
description = 'Builds the sourcecode for the Tests'
|
||||||
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
|
args = ['tests', 'silent']
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
@@ -94,8 +103,152 @@ artifacts {
|
|||||||
archives srcJar
|
archives srcJar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task testBooleans(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Boolean Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.booleans.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
}
|
||||||
|
|
||||||
|
task testBytes(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Byte Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.bytes.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testShorts(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Short Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.shorts.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testChars(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Character Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.chars.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testInts(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Int Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.ints.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testLongs(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Long Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.longs.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testFloats(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Float Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.floats.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testDoubles(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Double Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.doubles.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
task testObjects(type: Test) {
|
||||||
|
group 'tests'
|
||||||
|
description 'Tests all Object Collections'
|
||||||
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
includeTestsMatching "speiger.src.tests.objects.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
maxParallelForks = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
if(System.getProperty("full_test_suite", "false").toBoolean()) {
|
||||||
|
test.dependsOn testBooleans
|
||||||
|
test.dependsOn testBytes
|
||||||
|
test.dependsOn testShorts
|
||||||
|
test.dependsOn testChars
|
||||||
|
test.dependsOn testInts
|
||||||
|
test.dependsOn testLongs
|
||||||
|
test.dependsOn testFloats
|
||||||
|
test.dependsOn testDoubles
|
||||||
|
test.dependsOn testObjects
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnit()
|
filter {
|
||||||
|
excludeTestsMatching "speiger.src.testers.**.*"
|
||||||
|
excludeTestsMatching "speiger.src.tests.**.*"
|
||||||
|
excludeTestsMatching "tests.**.*"
|
||||||
|
}
|
||||||
|
useJUnit()
|
||||||
|
ignoreFailures = true
|
||||||
|
maxHeapSize = "1024m"
|
||||||
|
}
|
||||||
|
|
||||||
|
jacocoTestReport {
|
||||||
|
executionData fileTree(project.buildDir.absolutePath).include("jacoco/*.exec")
|
||||||
|
reports {
|
||||||
|
xml.enabled true
|
||||||
|
html.enabled = true
|
||||||
|
csv.enabled true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
@@ -2,6 +2,5 @@ jdk:
|
|||||||
- openjdk9
|
- openjdk9
|
||||||
install:
|
install:
|
||||||
- chmod +x ./gradlew
|
- chmod +x ./gradlew
|
||||||
- ./gradlew generateGithubSource
|
|
||||||
- ./gradlew build publishToMavenLocal
|
- ./gradlew build publishToMavenLocal
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ package speiger.src.builder;
|
|||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public enum ClassType
|
public enum ClassType
|
||||||
{
|
{
|
||||||
BOOLEAN("boolean", "Boolean", "Boolean", "booleans", "BOOLEAN", "false"),
|
BOOLEAN("boolean", "Boolean", "Boolean", "booleans", "BOOLEAN", "false", "false"),
|
||||||
BYTE("byte", "Byte", "Byte", "bytes", "BYTE", "(byte)0"),
|
BYTE("byte", "Byte", "Byte", "bytes", "BYTE", "(byte)0", "(byte)-1"),
|
||||||
SHORT("short", "Short", "Short", "shorts", "SHORT", "(short)0"),
|
SHORT("short", "Short", "Short", "shorts", "SHORT", "(short)0", "(short)-1"),
|
||||||
CHAR("char", "Character", "Char", "chars", "CHAR", "(char)0"),
|
CHAR("char", "Character", "Char", "chars", "CHAR", "(char)0", "(char)-1"),
|
||||||
INT("int", "Integer", "Int", "ints", "INT", "0"),
|
INT("int", "Integer", "Int", "ints", "INT", "0", "-1"),
|
||||||
LONG("long", "Long", "Long", "longs", "LONG", "0L"),
|
LONG("long", "Long", "Long", "longs", "LONG", "0L", "-1L"),
|
||||||
FLOAT("float", "Float", "Float", "floats", "FLOAT", "0F"),
|
FLOAT("float", "Float", "Float", "floats", "FLOAT", "0F", "-1F"),
|
||||||
DOUBLE("double", "Double", "Double", "doubles", "DOUBLE", "0D"),
|
DOUBLE("double", "Double", "Double", "doubles", "DOUBLE", "0D", "-1D"),
|
||||||
OBJECT("T", "T", "Object", "objects", "OBJECT", "null");
|
OBJECT("T", "T", "Object", "objects", "OBJECT", "null", "null");
|
||||||
|
|
||||||
String keyType;
|
String keyType;
|
||||||
String classType;
|
String classType;
|
||||||
@@ -19,8 +19,9 @@ public enum ClassType
|
|||||||
String pathType;
|
String pathType;
|
||||||
String capType;
|
String capType;
|
||||||
String emptyValue;
|
String emptyValue;
|
||||||
|
String invalidValue;
|
||||||
|
|
||||||
private ClassType(String keyType, String classType, String fileType, String pathType, String capType, String emptyValue)
|
private ClassType(String keyType, String classType, String fileType, String pathType, String capType, String emptyValue, String invalidValue)
|
||||||
{
|
{
|
||||||
this.keyType = keyType;
|
this.keyType = keyType;
|
||||||
this.classType = classType;
|
this.classType = classType;
|
||||||
@@ -28,6 +29,7 @@ public enum ClassType
|
|||||||
this.pathType = pathType;
|
this.pathType = pathType;
|
||||||
this.capType = capType;
|
this.capType = capType;
|
||||||
this.emptyValue = emptyValue;
|
this.emptyValue = emptyValue;
|
||||||
|
this.invalidValue = invalidValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKeyType()
|
public String getKeyType()
|
||||||
@@ -90,6 +92,11 @@ public enum ClassType
|
|||||||
return emptyValue;
|
return emptyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInvalidValue()
|
||||||
|
{
|
||||||
|
return invalidValue;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isObject()
|
public boolean isObject()
|
||||||
{
|
{
|
||||||
return this == OBJECT;
|
return this == OBJECT;
|
||||||
|
|||||||
@@ -35,21 +35,43 @@ public class GlobalVariables
|
|||||||
addSimpleMapper("CLASS_TYPE", type.getClassType());
|
addSimpleMapper("CLASS_TYPE", type.getClassType());
|
||||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
||||||
addSimpleMapper("KEY_TYPE", type.getKeyType());
|
addSimpleMapper("KEY_TYPE", type.getKeyType());
|
||||||
|
addSimpleMapper("KEY_OBJECT_TYPE", type.isObject() ? "Object" : type.getKeyType());
|
||||||
|
addSimpleMapper("KEY_STRING_TYPE", type.isObject() ? "String" : type.getKeyType());
|
||||||
addSimpleMapper("KEY_SPECIAL_TYPE", type.isObject() ? "E" : type.getKeyType());
|
addSimpleMapper("KEY_SPECIAL_TYPE", type.isObject() ? "E" : type.getKeyType());
|
||||||
|
addSimpleMapper("CLASS_OBJECT_TYPE", type.getClassType());
|
||||||
|
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
||||||
|
addSimpleMapper("CLASS_STRING_TYPE", type.isObject() ? "String" : type.getClassType());
|
||||||
|
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
||||||
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
||||||
|
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
||||||
|
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
||||||
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
||||||
|
addSimpleMapper("KEY_JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
||||||
|
addSimpleMapper("VALUE_JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
||||||
|
|
||||||
addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue());
|
addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue());
|
||||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
||||||
|
|
||||||
|
addSimpleMapper("INVALID_KEY_VALUE", type.getInvalidValue());
|
||||||
|
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", type.isObject() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||||
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : "");
|
addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : "");
|
||||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+">" : "");
|
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", type.isObject() ? "<"+type.getClassType()+">" : "");
|
||||||
|
|
||||||
|
|
||||||
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
addSimpleMapper(" VALUE_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(" KEY_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||||
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
||||||
|
addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+type.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces();
|
||||||
|
|
||||||
addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : "");
|
addSimpleMapper(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : "");
|
||||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
addSimpleMapper(" NO_KV_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
||||||
@@ -59,6 +81,10 @@ public class GlobalVariables
|
|||||||
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", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", type.isObject() ? "<? extends "+type.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? extends "+type.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+type.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||||
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
||||||
|
|
||||||
@@ -83,6 +109,7 @@ public class GlobalVariables
|
|||||||
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||||
addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : "");
|
addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : "");
|
||||||
addSimpleMapper("KV_BRACES", type.isObject() || valueType.isObject() ? "<>" : "");
|
addSimpleMapper("KV_BRACES", type.isObject() || valueType.isObject() ? "<>" : "");
|
||||||
|
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
||||||
addSimpleMapper("BRACES", type.isObject() ? "<>" : "");
|
addSimpleMapper("BRACES", type.isObject() ? "<>" : "");
|
||||||
if(type.needsCustomJDKType())
|
if(type.needsCustomJDKType())
|
||||||
{
|
{
|
||||||
@@ -120,6 +147,7 @@ public class GlobalVariables
|
|||||||
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());
|
||||||
|
|
||||||
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();
|
||||||
@@ -135,7 +163,8 @@ public class GlobalVariables
|
|||||||
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();
|
||||||
addInjectMapper("NEW_CLASS"+(value ? "_VALUE" : "")+"_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
if(value) addInjectMapper("NEW_CLASS_VALUE_ARRAY", type.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces();
|
||||||
|
else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlobalVariables createPreFunctions()
|
public GlobalVariables createPreFunctions()
|
||||||
@@ -186,6 +215,42 @@ public class GlobalVariables
|
|||||||
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
||||||
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
||||||
addClassMapper("ARRAY_SET", "ArraySet");
|
addClassMapper("ARRAY_SET", "ArraySet");
|
||||||
|
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||||
|
|
||||||
|
//Final UnitTest Classes
|
||||||
|
addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection");
|
||||||
|
addAbstractMapper("MINIMAL_SET", "Minimal%sSet");
|
||||||
|
addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester");
|
||||||
|
addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester");
|
||||||
|
addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester");
|
||||||
|
addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester");
|
||||||
|
addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester");
|
||||||
|
addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester");
|
||||||
|
addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester");
|
||||||
|
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||||
|
addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester");
|
||||||
|
addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester");
|
||||||
|
addClassMapper("ITERATOR_TESTER", "IteratorTester");
|
||||||
|
addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder");
|
||||||
|
addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder");
|
||||||
|
addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder");
|
||||||
|
addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder");
|
||||||
|
addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder");
|
||||||
|
addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder");
|
||||||
|
addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder");
|
||||||
|
addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder");
|
||||||
|
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||||
|
addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests");
|
||||||
|
addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator");
|
||||||
|
addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator");
|
||||||
|
addClassMapper("LIST_TESTS", "ListTests");
|
||||||
|
addClassMapper("SET_TESTS", "SetTests");
|
||||||
|
addClassMapper("QUEUE_TESTS", "QueueTests");
|
||||||
|
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||||
|
|
||||||
//Abstract Classes
|
//Abstract Classes
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||||
@@ -206,6 +271,24 @@ public class GlobalVariables
|
|||||||
addClassMapper("ITERATORS", "Iterators");
|
addClassMapper("ITERATORS", "Iterators");
|
||||||
addClassMapper("ITERABLES", "Iterables");
|
addClassMapper("ITERABLES", "Iterables");
|
||||||
addBiClassMapper("MAPS", "Maps", "2");
|
addBiClassMapper("MAPS", "Maps", "2");
|
||||||
|
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
||||||
|
|
||||||
|
//UnitTest Helper Classes
|
||||||
|
addClassMapper("HELPERS", "Helpers");
|
||||||
|
addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator");
|
||||||
|
addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator");
|
||||||
|
addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator");
|
||||||
|
addAbstractMapper("TEST_NAVIGABLE_SET_GENERATOR", "Test%sNavigableSetGenerator");
|
||||||
|
addAbstractMapper("TEST_SORTED_SET_GENERATOR", "Test%sSortedSetGenerator");
|
||||||
|
addAbstractMapper("TEST_ORDERED_SET_GENERATOR", "Test%sOrderedSetGenerator");
|
||||||
|
addAbstractMapper("TEST_SET_GENERATOR", "Test%sSetGenerator");
|
||||||
|
addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator");
|
||||||
|
addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator");
|
||||||
|
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
||||||
|
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
||||||
|
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
||||||
|
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
||||||
|
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2");
|
||||||
|
|
||||||
//Interfaces
|
//Interfaces
|
||||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||||
@@ -245,7 +328,6 @@ public class GlobalVariables
|
|||||||
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
||||||
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||||
addSimpleMapper("CONSUMER", "Consumer");
|
addSimpleMapper("CONSUMER", "Consumer");
|
||||||
addSimpleMapper("COMPARATOR", "Comparator");
|
|
||||||
addSimpleMapper("IARRAY", "IObjectArray");
|
addSimpleMapper("IARRAY", "IObjectArray");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -256,9 +338,10 @@ public class GlobalVariables
|
|||||||
addSimpleMapper("CONSUMER", type.getFileType()+"Consumer");
|
addSimpleMapper("CONSUMER", type.getFileType()+"Consumer");
|
||||||
}
|
}
|
||||||
else addClassMapper("CONSUMER", "Consumer");
|
else addClassMapper("CONSUMER", "Consumer");
|
||||||
addClassMapper("COMPARATOR", "Comparator");
|
|
||||||
addFunctionMappers("IARRAY", "I%sArray");
|
addFunctionMappers("IARRAY", "I%sArray");
|
||||||
}
|
}
|
||||||
|
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
|
||||||
|
addSimpleMapper("COMPARATOR", type.isObject() ? "Comparator" : String.format("%sComparator", type.getNonFileType()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,6 +391,7 @@ public class GlobalVariables
|
|||||||
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
||||||
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
||||||
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
||||||
|
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
|
||||||
addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array");
|
addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array");
|
||||||
addSimpleMapper("[SPACE]", " ");
|
addSimpleMapper("[SPACE]", " ");
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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.EnumMap;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -14,6 +16,7 @@ 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.function.Predicate;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
@@ -23,6 +26,7 @@ import speiger.src.builder.processor.TemplateProcessor;
|
|||||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||||
{
|
{
|
||||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
||||||
|
EnumMap<ClassType, List<Predicate<String>>> blockedPredicate = new EnumMap<>(ClassType.class);
|
||||||
Map<String, String> nameRemapper = new HashMap<>();
|
Map<String, String> nameRemapper = new HashMap<>();
|
||||||
Map<String, String> biRequired = new HashMap<>();
|
Map<String, String> biRequired = new HashMap<>();
|
||||||
Set<String> enumRequired = new HashSet<>();
|
Set<String> enumRequired = new HashSet<>();
|
||||||
@@ -30,6 +34,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
List<GlobalVariables> variables = new ArrayList<>();
|
List<GlobalVariables> variables = new ArrayList<>();
|
||||||
List<GlobalVariables> biVariables = new ArrayList<>();
|
List<GlobalVariables> biVariables = new ArrayList<>();
|
||||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
List<GlobalVariables> enumVariables = new ArrayList<>();
|
||||||
|
boolean special = false;
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder()
|
public PrimitiveCollectionsBuilder()
|
||||||
{
|
{
|
||||||
@@ -51,6 +56,19 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PrimitiveCollectionsBuilder setSpecial() {
|
||||||
|
special = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PrimitiveCollectionsBuilder createTests(boolean silent) {
|
||||||
|
return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/tests/templates/"), Paths.get("src/test/java/speiger/src/tests/"), Paths.get("src/builder/resources/speiger/assets/tests/")).setSpecial();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PrimitiveCollectionsBuilder createTesters(boolean silent) {
|
||||||
|
return new PrimitiveCollectionsBuilder(silent, Paths.get("src/builder/resources/speiger/assets/testers/templates/"), Paths.get("src/test/java/speiger/src/testers/"), Paths.get("src/builder/resources/speiger/assets/testers/")).setSpecial();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFileValid(Path fileName)
|
protected boolean isFileValid(Path fileName)
|
||||||
{
|
{
|
||||||
@@ -72,7 +90,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
@Override
|
@Override
|
||||||
protected void afterFinish()
|
protected void afterFinish()
|
||||||
{
|
{
|
||||||
if(getVersion() > 8)
|
if(!special && getVersion() > 8)
|
||||||
{
|
{
|
||||||
Path basePath = Paths.get("src/main/java");
|
Path basePath = Paths.get("src/main/java");
|
||||||
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
try(BufferedWriter writer = Files.newBufferedWriter(basePath.resolve("module-info.java")))
|
||||||
@@ -119,9 +137,50 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
||||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||||
|
|
||||||
|
|
||||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
||||||
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
addBlockage(ClassType.BOOLEAN, "ArraySet", "AVLTreeSet", "RBTreeSet", "SortedSet", "OrderedSet", "NavigableSet", "OpenHashSet", "OpenCustomHashSet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||||
addBlockage(ClassType.BOOLEAN, "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
addBlockage(ClassType.BOOLEAN, "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "ImmutableOpenHashSet", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
||||||
|
|
||||||
|
//UnitTesters
|
||||||
|
nameRemapper.put("AbstractIteratorTester", "Abstract%sIteratorTester");
|
||||||
|
nameRemapper.put("MinimalCollection", "Minimal%sCollection");
|
||||||
|
nameRemapper.put("MinimalSet", "Minimal%sSet");
|
||||||
|
nameRemapper.put("TestCollectionGenerator", "Test%sCollectionGenerator");
|
||||||
|
nameRemapper.put("TestQueueGenerator", "Test%sQueueGenerator");
|
||||||
|
nameRemapper.put("TestListGenerator", "Test%sListGenerator");
|
||||||
|
nameRemapper.put("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
||||||
|
nameRemapper.put("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
||||||
|
nameRemapper.put("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
||||||
|
nameRemapper.put("TestSetGenerator", "Test%sSetGenerator");
|
||||||
|
nameRemapper.put("AbstractContainerTester", "Abstract%sContainerTester");
|
||||||
|
nameRemapper.put("AbstractCollectionTester", "Abstract%sCollectionTester");
|
||||||
|
nameRemapper.put("AbstractQueueTester", "Abstract%sQueueTester");
|
||||||
|
nameRemapper.put("AbstractListTester", "Abstract%sListTester");
|
||||||
|
nameRemapper.put("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
||||||
|
nameRemapper.put("AbstractSetTester", "Abstract%sSetTester");
|
||||||
|
nameRemapper.put("SimpleTestGenerator", "Simple%sTestGenerator");
|
||||||
|
nameRemapper.put("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
||||||
|
nameRemapper.put("TestMapGenerator", "Test%sMapGenerator");
|
||||||
|
nameRemapper.put("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||||
|
nameRemapper.put("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||||
|
nameRemapper.put("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||||
|
nameRemapper.put("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||||
|
nameRemapper.put("AbstractMapTester", "Abstract%sMapTester");
|
||||||
|
nameRemapper.put("TestMap", "Test%sMap");
|
||||||
|
biRequired.put("PairTester", "");
|
||||||
|
|
||||||
|
addBiClass("TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "OrderedMapTestSuiteBuilder", "MapTests", "MapConstructorTests", "TestMap");
|
||||||
|
addBiClass("MapAddToTester", "MapSubFromTester", "MapClearTester", "MapComputeIfAbsentTester", "MapComputeIfPresentTester", "MapComputeTester", "MapCopyTester", "MapContainsTester", "MapContainsKeyTester", "MapContainsValueTester", "MapCreatorTester", "MapEntrySetTester",
|
||||||
|
"MapEqualsTester", "MapForEachTester", "MapGetOrDefaultTester", "MapGetTester", "MapHashCodeTester", "MapIsEmptyTester", "MapMergeTester", "MapMergeBulkTester", "MapPutAllArrayTester", "MapPutAllTester", "MapPutIfAbsentTester", "MapPutTester",
|
||||||
|
"MapRemoveEntryTester", "MapRemoveOrDefaultTester", "MapRemoveTester", "MapReplaceAllTester", "MapReplaceEntryTester", "MapReplaceTester", "MapSizeTester", "MapSupplyIfAbsentTester", "MapToStringTester",
|
||||||
|
"NavigableMapNavigationTester", "SortedMapNavigationTester", "OrderedMapNavigationTester", "OrderedMapMoveTester", "MapConstructorTester");
|
||||||
|
|
||||||
|
addBlockage(ClassType.OBJECT, "CollectionStreamTester", "ListFillBufferTester");
|
||||||
|
addBlockage(ClassType.BOOLEAN, "TestOrderedSetGenerator", "TestSortedSetGenerator", "TestNavigableSetGenerator", "CollectionRemoveIfTester", "CollectionStreamTester", "ListFillBufferTester", "ListReplaceAllTester", "NavigableSetNavigationTester", "SetTests", "MapConstructorTests", "TestMap", "QueueTests");
|
||||||
|
addBlockage(ClassType.BOOLEAN, "OrderedSetMoveTester", "OrderedSetNavigationTester", "SortedSetNaviationTester", "SetTestSuiteBuilder", "OrderedSetTestSuiteBuilder", "SortedSetTestSuiteBuilder", "NavigableSetTestSuiteBuilder", "SortedSetSubsetTestSetGenerator", "OrderedMapNavigationTester", "OrderedMapTestSuiteBuilder", "OrderedSetIterationTester", "SortedSetIterationTester");
|
||||||
|
addBlockage(ClassType.BOOLEAN, "TestMapGenerator", "TestSortedMapGenerator", "TestOrderedMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester", "MapTestSuiteBuilder", "SortedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "MapTests");
|
||||||
|
addBlockage(ClassType.BOOLEAN, T -> T.endsWith("Tester") && (T.startsWith("Iterable") ||T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void create(ClassType mainType, ClassType subType)
|
protected void create(ClassType mainType, ClassType subType)
|
||||||
@@ -146,6 +205,11 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void addBlockage(ClassType type, Predicate<String> filter)
|
||||||
|
{
|
||||||
|
blockedPredicate.computeIfAbsent(type, T -> new ArrayList<>()).add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
protected void addBlockage(ClassType type, String...args)
|
protected void addBlockage(ClassType type, String...args)
|
||||||
{
|
{
|
||||||
for(String s : args)
|
for(String s : args)
|
||||||
@@ -166,17 +230,29 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
String splitter = biRequired.get(name);
|
String splitter = biRequired.get(name);
|
||||||
boolean valueRequired = enumRequired.contains(name);
|
boolean valueRequired = enumRequired.contains(name);
|
||||||
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
||||||
EnumSet<ClassType> types = blocked.get(name);
|
|
||||||
for(int i = 0,m=vars.size();i<m;i++)
|
for(int i = 0,m=vars.size();i<m;i++)
|
||||||
{
|
{
|
||||||
GlobalVariables type = vars.get(i);
|
GlobalVariables type = vars.get(i);
|
||||||
if(types == null || !types.contains(type.getType()))
|
if(isAllowed(type.getType(), name))
|
||||||
{
|
{
|
||||||
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isAllowed(ClassType type, String fileName)
|
||||||
|
{
|
||||||
|
EnumSet<ClassType> types = blocked.get(fileName);
|
||||||
|
if(types != null && types.contains(type)) return false;
|
||||||
|
List<Predicate<String>> list = blockedPredicate.get(type);
|
||||||
|
if(list != null) {
|
||||||
|
for(int i = 0,m=list.size();i<m;i++) {
|
||||||
|
if(list.get(i).test(fileName)) return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
||||||
if(enumRequired.contains(name)) return enumVariables;
|
if(enumRequired.contains(name)) return enumVariables;
|
||||||
if(bi) return biVariables;
|
if(bi) return biVariables;
|
||||||
@@ -236,28 +312,19 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(args.length == 0) {
|
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||||
new PrimitiveCollectionsBuilder().process(false);
|
boolean silent = flags.contains("silent");
|
||||||
} else if(args.length == 1) {
|
boolean force = flags.contains("force");
|
||||||
new PrimitiveCollectionsBuilder().process(Boolean.parseBoolean(args[0]));
|
boolean tests = flags.contains("tests");
|
||||||
} else if(args.length == 2) {
|
boolean forceTests = flags.contains("force-tests");
|
||||||
new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[1])).process(Boolean.parseBoolean(args[0]));
|
|
||||||
} else if(args.length == 3) {
|
new PrimitiveCollectionsBuilder(silent).process(force);
|
||||||
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
|
if(tests) {
|
||||||
} else if(args.length == 4) {
|
createTests(silent).process(force || forceTests);
|
||||||
new PrimitiveCollectionsBuilder(false, Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
createTesters(silent).process(force || forceTests);
|
||||||
} else if(args.length == 4) {
|
}
|
||||||
new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[4]), Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
}
|
||||||
} else {
|
catch(InterruptedException | IOException e)
|
||||||
System.out.println("Invalid argument count passed in");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch(IOException e)
|
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -230,6 +230,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||||||
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);
|
||||||
iter.remove();
|
iter.remove();
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
@@ -256,6 +257,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||||||
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;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE
|
|||||||
public default int back(int amount) {
|
public default int back(int amount) {
|
||||||
if(amount < 0) throw new IllegalStateException("Can't go forward");
|
if(amount < 0) throw new IllegalStateException("Can't go forward");
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(;i<amount && hasPrevious();previous(),i++);
|
for(;i<amount && hasPrevious();PREVIOUS(),i++);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
@@ -149,6 +149,15 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
return ITERABLES.distinct(this);
|
return ITERABLES.distinct(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
default ITERABLE KEY_GENERIC_TYPE repeat(int repeats) {
|
||||||
|
return ITERABLES.repeat(this, repeats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||||
* @param limit the amount of elements it should be limited to
|
* @param limit the amount of elements it should be limited to
|
||||||
|
|||||||
+26
-14
@@ -308,14 +308,14 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
SanityChecks.checkArrayCapacity(size, from, length);
|
SanityChecks.checkArrayCapacity(size, from, length);
|
||||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
return list.getElements(from+this.offset, a, offset, length);
|
return list.getElements(from+parentOffset, a, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeElements(int from, int to) {
|
public void removeElements(int from, int to) {
|
||||||
if(to-from <= 0) return;
|
if(to-from <= 0) return;
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
list.removeElements(from+parentOffset, to+parentOffset);
|
list.removeElements(from+parentOffset, to+parentOffset);
|
||||||
size -= to - from;
|
size -= to - from;
|
||||||
}
|
}
|
||||||
@@ -324,9 +324,9 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
@Override
|
@Override
|
||||||
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
||||||
size -= to - from;
|
size -= result.length;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,9 +334,9 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] extractElements(int from, int to) {
|
public KEY_TYPE[] extractElements(int from, int to) {
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
||||||
size -= to - from;
|
size -= result.length;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,19 +344,25 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_KEY(int index) {
|
public KEY_TYPE GET_KEY(int index) {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
return list.GET_KEY(offset+index);
|
return list.GET_KEY(parentOffset+index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE set(int index, KEY_TYPE element) {
|
public KEY_TYPE set(int index, KEY_TYPE element) {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
return list.set(offset+index, element);
|
return list.set(parentOffset+index, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE swapRemove(int index) {
|
public KEY_TYPE swapRemove(int index) {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
KEY_TYPE result = list.swapRemove(index+parentOffset);
|
if(index == size-1) {
|
||||||
|
KEY_TYPE result = list.REMOVE(parentOffset+size-1);
|
||||||
|
size--;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
KEY_TYPE result = list.set(index+parentOffset, list.GET_KEY(parentOffset+size-1));
|
||||||
|
list.REMOVE(parentOffset+size-1);
|
||||||
size--;
|
size--;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -386,7 +392,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
||||||
SanityChecks.checkArrayCapacity(size, fromIndex, toIndex-fromIndex);
|
SanityChecks.checkArrayCapacity(size, fromIndex, toIndex-fromIndex);
|
||||||
return new SubList(list, offset, fromIndex, toIndex);
|
return new SubList(this, offset, fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSubRange(int index) {
|
protected void checkSubRange(int index) {
|
||||||
@@ -460,15 +466,17 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(KEY_TYPE e) {
|
public void add(KEY_TYPE e) {
|
||||||
list.add(index++, e);
|
list.add(index, e);
|
||||||
|
index++;
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (list.size() - 1) - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,6 +485,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);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -540,15 +549,17 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(KEY_TYPE e) {
|
public void add(KEY_TYPE e) {
|
||||||
ABSTRACT_LIST.this.add(index++, e);
|
ABSTRACT_LIST.this.add(index, e);
|
||||||
|
index++;
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (size() - 1) - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,6 +568,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);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
* @param size the minimum initial size of the Backing array
|
* @param size the minimum initial size of the Backing array
|
||||||
*/
|
*/
|
||||||
public ARRAY_LIST(int size) {
|
public ARRAY_LIST(int size) {
|
||||||
|
if(size < 0) throw new IllegalStateException("Size has to be 0 or greater");
|
||||||
data = NEW_KEY_ARRAY(size);
|
data = NEW_KEY_ARRAY(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,8 +325,9 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
checkAddRange(from);
|
checkAddRange(from);
|
||||||
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
grow(size + length);
|
grow(size + length);
|
||||||
if(from != size) System.arraycopy(data, from, data, from+length, size - length);
|
if(from != size) System.arraycopy(data, from, data, from+length, size - from);
|
||||||
size+=length;
|
size+=length;
|
||||||
System.arraycopy(a, offset, data, from, length);
|
System.arraycopy(a, offset, data, from, length);
|
||||||
}
|
}
|
||||||
@@ -361,11 +363,11 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
int length = to - from;
|
int length = to - from;
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
||||||
|
size -= length;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
for(int i = 0;i<length;i++)
|
for(int i = 0;i<length;i++)
|
||||||
data[i+to] = null;
|
data[i+size] = null;
|
||||||
#endif
|
#endif
|
||||||
size -= length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -381,13 +383,13 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
checkRange(from);
|
checkRange(from);
|
||||||
checkAddRange(to);
|
checkAddRange(to);
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
|
if(length <= 0) return ARRAYS.newArray(type, 0);
|
||||||
K[] a = ARRAYS.newArray(type, length);
|
K[] a = ARRAYS.newArray(type, length);
|
||||||
if(length <= 0) return a;
|
|
||||||
System.arraycopy(data, from, a, 0, length);
|
System.arraycopy(data, from, a, 0, length);
|
||||||
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
if(to != size) System.arraycopy(data, to, data, from, size - to);
|
||||||
for(int i = 0;i<length;i++)
|
|
||||||
data[i+to] = null;
|
|
||||||
size -= length;
|
size -= length;
|
||||||
|
for(int i = 0;i<length;i++)
|
||||||
|
data[i+size] = null;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+427
-39
@@ -9,8 +9,9 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
#if TYPE_OBJECT
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
@@ -155,6 +156,14 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private void setArray(KEY_TYPE[] data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private KEY_TYPE[] getArray() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the specified element to the end of this list.
|
* Appends the specified element to the end of this list.
|
||||||
*
|
*
|
||||||
@@ -365,6 +374,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
int size = data.length;
|
int size = data.length;
|
||||||
if(from < 0 || from > size) throw new IndexOutOfBoundsException("Index: " + from + ", Size: " + size);
|
if(from < 0 || from > size) throw new IndexOutOfBoundsException("Index: " + from + ", Size: " + size);
|
||||||
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
KEY_TYPE[] newElements;
|
KEY_TYPE[] newElements;
|
||||||
if(from == size) {
|
if(from == size) {
|
||||||
newElements = Arrays.copyOf(data, size+length);
|
newElements = Arrays.copyOf(data, size+length);
|
||||||
@@ -409,6 +419,8 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeElements(int from, int to) {
|
public void removeElements(int from, int to) {
|
||||||
|
checkRange(from);
|
||||||
|
checkAddRange(to);
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
ReentrantLock lock = this.lock;
|
ReentrantLock lock = this.lock;
|
||||||
@@ -439,9 +451,11 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
||||||
|
checkRange(from);
|
||||||
|
checkAddRange(to);
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
|
if(length <= 0) return ARRAYS.newArray(type, 0);
|
||||||
K[] a = ARRAYS.newArray(type, length);
|
K[] a = ARRAYS.newArray(type, length);
|
||||||
if(length <= 0) return a;
|
|
||||||
ReentrantLock lock = this.lock;
|
ReentrantLock lock = this.lock;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -449,9 +463,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
System.arraycopy(data, from, a, 0, length);
|
System.arraycopy(data, from, a, 0, length);
|
||||||
if(to == data.length) this.data = Arrays.copyOf(data, data.length - length);
|
if(to == data.length) this.data = Arrays.copyOf(data, data.length - length);
|
||||||
else {
|
else {
|
||||||
int size = data.length-1;
|
int size = data.length;
|
||||||
KEY_TYPE[] newElements = NEW_KEY_ARRAY(size);
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(size-length);
|
||||||
System.arraycopy(data, 0, newElements, 0, from);
|
if(from != 0) System.arraycopy(data, 0, newElements, 0, from);
|
||||||
System.arraycopy(data, to, newElements, from, size - to);
|
System.arraycopy(data, to, newElements, from, size - to);
|
||||||
this.data = newElements;
|
this.data = newElements;
|
||||||
}
|
}
|
||||||
@@ -471,6 +485,8 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] extractElements(int from, int to) {
|
public KEY_TYPE[] extractElements(int from, int to) {
|
||||||
|
checkRange(from);
|
||||||
|
checkAddRange(to);
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
if(length <= 0) return EMPTY_KEY_ARRAY;
|
if(length <= 0) return EMPTY_KEY_ARRAY;
|
||||||
ReentrantLock lock = this.lock;
|
ReentrantLock lock = this.lock;
|
||||||
@@ -481,9 +497,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
System.arraycopy(data, from, a, 0, length);
|
System.arraycopy(data, from, a, 0, length);
|
||||||
if(to == data.length) this.data = Arrays.copyOf(data, data.length - length);
|
if(to == data.length) this.data = Arrays.copyOf(data, data.length - length);
|
||||||
else {
|
else {
|
||||||
int size = data.length-1;
|
int size = data.length;
|
||||||
KEY_TYPE[] newElements = NEW_KEY_ARRAY(size);
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(size-length);
|
||||||
System.arraycopy(data, 0, newElements, 0, from);
|
if(from != 0) System.arraycopy(data, 0, newElements, 0, from);
|
||||||
System.arraycopy(data, to, newElements, from, size - to);
|
System.arraycopy(data, to, newElements, from, size - to);
|
||||||
this.data = newElements;
|
this.data = newElements;
|
||||||
}
|
}
|
||||||
@@ -719,7 +735,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
||||||
SanityChecks.checkArrayCapacity(data.length, fromIndex, toIndex-fromIndex);
|
SanityChecks.checkArrayCapacity(data.length, fromIndex, toIndex-fromIndex);
|
||||||
return new COWSubListBRACES(this, 0, fromIndex, toIndex);
|
return new COWSubListBRACES(this, lock, this::setArray, this::getArray, 0, fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1388,7 +1404,12 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PRIMITIVES
|
protected void checkAddRange(int index) {
|
||||||
|
if (index < 0 || index > data.length)
|
||||||
|
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PRIMITIVES
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
@@ -1435,7 +1456,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return data[index--];
|
return data[--index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1458,7 +1479,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (data.length - 1) - index);
|
int steps = Math.min(amount, data.length - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
@@ -1474,13 +1495,19 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
private static class COWSubList KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
private static class COWSubList KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
final COPY_ON_WRITE_LIST KEY_GENERIC_TYPE list;
|
final ABSTRACT_LIST KEY_GENERIC_TYPE list;
|
||||||
|
final ReentrantLock lock;
|
||||||
|
final Consumer<KEY_TYPE[]> setter;
|
||||||
|
final Supplier<KEY_TYPE[]> getter;
|
||||||
final int parentOffset;
|
final int parentOffset;
|
||||||
final int offset;
|
final int offset;
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
public COWSubList(COPY_ON_WRITE_LIST KEY_GENERIC_TYPE list, int offset, int from, int to) {
|
public COWSubList(ABSTRACT_LIST KEY_GENERIC_TYPE list, ReentrantLock lock, Consumer<KEY_TYPE[]> setter, Supplier<KEY_TYPE[]> getter, int offset, int from, int to) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
|
this.lock = lock;
|
||||||
|
this.setter = setter;
|
||||||
|
this.getter = getter;
|
||||||
this.parentOffset = from;
|
this.parentOffset = from;
|
||||||
this.offset = offset + from;
|
this.offset = offset + from;
|
||||||
this.size = to - from;
|
this.size = to - from;
|
||||||
@@ -1488,7 +1515,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(int index, KEY_TYPE element) {
|
public void add(int index, KEY_TYPE element) {
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkAddSubRange(index);
|
checkAddSubRange(index);
|
||||||
@@ -1504,7 +1530,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
public boolean addAll(int index, Collection<? extends CLASS_TYPE> c) {
|
public boolean addAll(int index, Collection<? extends CLASS_TYPE> c) {
|
||||||
int add = c.size();
|
int add = c.size();
|
||||||
if(add <= 0) return false;
|
if(add <= 0) return false;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkAddSubRange(index);
|
checkAddSubRange(index);
|
||||||
@@ -1521,7 +1546,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
public boolean addAll(int index, COLLECTION KEY_GENERIC_TYPE c) {
|
public boolean addAll(int index, COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
int add = c.size();
|
int add = c.size();
|
||||||
if(add <= 0) return false;
|
if(add <= 0) return false;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkAddSubRange(index);
|
checkAddSubRange(index);
|
||||||
@@ -1538,7 +1562,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) {
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) {
|
||||||
int add = c.size();
|
int add = c.size();
|
||||||
if(add <= 0) return false;
|
if(add <= 0) return false;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkAddSubRange(index);
|
checkAddSubRange(index);
|
||||||
@@ -1554,7 +1577,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkAddSubRange(from);
|
checkAddSubRange(from);
|
||||||
@@ -1570,17 +1592,16 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
SanityChecks.checkArrayCapacity(size, from, length);
|
SanityChecks.checkArrayCapacity(size, from, length);
|
||||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
return list.getElements(from+this.offset, a, offset, length);
|
return list.getElements(from+parentOffset, a, offset, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeElements(int from, int to) {
|
public void removeElements(int from, int to) {
|
||||||
if(to-from <= 0) return;
|
if(to-from <= 0) return;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
list.removeElements(from+parentOffset, to+parentOffset);
|
list.removeElements(from+parentOffset, to+parentOffset);
|
||||||
size -= to - from;
|
size -= to - from;
|
||||||
}
|
}
|
||||||
@@ -1592,13 +1613,12 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
public <K> K[] extractElements(int from, int to, Class<K> type) {
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
K[] result = list.extractElements(from+parentOffset, to+parentOffset, type);
|
||||||
size -= to - from;
|
size -= result.length;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -1609,13 +1629,12 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] extractElements(int from, int to) {
|
public KEY_TYPE[] extractElements(int from, int to) {
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(from);
|
checkSubRange(from);
|
||||||
checkSubRange(to);
|
checkAddSubRange(to);
|
||||||
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
KEY_TYPE[] result = list.extractElements(from+parentOffset, to+parentOffset);
|
||||||
size -= to - from;
|
size -= result.length;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -1627,16 +1646,15 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_KEY(int index) {
|
public KEY_TYPE GET_KEY(int index) {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
return list.GET_KEY(offset+index);
|
return list.GET_KEY(parentOffset+index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE set(int index, KEY_TYPE element) {
|
public KEY_TYPE set(int index, KEY_TYPE element) {
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
return list.set(offset+index, element);
|
return list.set(parentOffset+index, element);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -1645,11 +1663,18 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE swapRemove(int index) {
|
public KEY_TYPE swapRemove(int index) {
|
||||||
ReentrantLock lock = list.lock;
|
if(index < 0 || index >= size) throw new IndexOutOfBoundsException();
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(index);
|
KEY_TYPE[] data = getter.get();
|
||||||
KEY_TYPE result = list.swapRemove(index+parentOffset);
|
KEY_TYPE result = data[offset+index];
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length-1);
|
||||||
|
int end = offset+size-1;
|
||||||
|
System.arraycopy(data, 0, newElements, 0, end);
|
||||||
|
if(end != newElements.length) System.arraycopy(data, end+1, newElements, end, data.length-end-1);
|
||||||
|
if(index+offset != end) newElements[index+offset] = data[end];
|
||||||
|
setter.accept(newElements);
|
||||||
size--;
|
size--;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1660,7 +1685,6 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE(int index) {
|
public KEY_TYPE REMOVE(int index) {
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
checkSubRange(index);
|
checkSubRange(index);
|
||||||
@@ -1673,6 +1697,371 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public boolean REMOVE_KEY(KEY_TYPE type) {
|
||||||
|
int index = indexOf(type);
|
||||||
|
if(index == -1) return false;
|
||||||
|
REMOVE(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object type) {
|
||||||
|
int index = indexOf(type);
|
||||||
|
if(index == -1) return false;
|
||||||
|
REMOVE(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public void sort(Comparator<? super CLASS_TYPE> c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
if(c != null) ARRAYS.stableSort(newData, offset, offset+size, c);
|
||||||
|
else ARRAYS.stableSort(newData, offset, offset+size);
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unstableSort(Comparator<? super CLASS_TYPE> c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
if(c != null) ARRAYS.unstableSort(newData, offset, offset+size, c);
|
||||||
|
else ARRAYS.unstableSort(newData, offset, offset+size);
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public void sort(COMPARATOR c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
if(c != null) ARRAYS.stableSort(newData, offset, offset+size, c);
|
||||||
|
else ARRAYS.stableSort(newData, offset, offset+size);
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unstableSort(COMPARATOR c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
if(c != null) ARRAYS.unstableSort(newData, offset, offset+size, c);
|
||||||
|
else ARRAYS.unstableSort(newData, offset, offset+size);
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean removeAll(Collection<?> c) {
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(!c.contains(KEY_TO_OBJ(data[i]))) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean retainAll(Collection<?> c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
if(size > 0) {
|
||||||
|
clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(c.contains(KEY_TO_OBJ(data[i]))) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean removeIf(Predicate<? super CLASS_TYPE> filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(!filter.test(KEY_TO_OBJ(data[i]))) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(!c.contains(data[i])) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(!c.contains(data[i])) newElements[j++] = data[i];
|
||||||
|
else r.accept(data[i]);
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
if(size > 0) {
|
||||||
|
clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(c.contains(data[i])) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));;
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c, CONSUMER KEY_GENERIC_TYPE r) {
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
if(size > 0) {
|
||||||
|
forEach(r);
|
||||||
|
clear();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i= 0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(c.contains(data[i])) newElements[j++] = data[i];
|
||||||
|
else r.accept(data[i]);
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PRIMITIVES
|
||||||
|
@Override
|
||||||
|
public boolean remIf(JAVA_PREDICATE filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newElements = NEW_KEY_ARRAY(data.length);
|
||||||
|
int j = 0;
|
||||||
|
for(int i=0,m=data.length;i<m;i++) {
|
||||||
|
if(i < offset || i >= offset+size) newElements[j++] = data[i];
|
||||||
|
else if(!filter.test(data[i])) newElements[j++] = data[i];
|
||||||
|
}
|
||||||
|
if(data.length != j) {
|
||||||
|
setter.accept(Arrays.copyOf(newElements, j));
|
||||||
|
size -= data.length - j;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Primitive
|
||||||
|
public void replaceAll(UnaryOperator<CLASS_TYPE> o) {
|
||||||
|
#if PRIMITIVES
|
||||||
|
Objects.requireNonNull(o);
|
||||||
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
|
REPLACE(T -> OBJ_TO_KEY(o.apply(KEY_TO_OBJ(SanityChecks.SANITY_CAST(T)))));
|
||||||
|
#else
|
||||||
|
REPLACE(T -> OBJ_TO_KEY(o.apply(KEY_TO_OBJ(T))));
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
Objects.requireNonNull(o);
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
for(int i = 0,m=size;i<m;i++)
|
||||||
|
newData[i+offset] = OBJ_TO_KEY(o.apply(KEY_TO_OBJ(newData[i+offset])));
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PRIMITIVES
|
||||||
|
@Override
|
||||||
|
public void REPLACE(JAVA_UNARY_OPERATOR o) {
|
||||||
|
Objects.requireNonNull(o);
|
||||||
|
ReentrantLock lock = this.lock;
|
||||||
|
lock.lock();
|
||||||
|
try {
|
||||||
|
KEY_TYPE[] data = getter.get();
|
||||||
|
KEY_TYPE[] newData = Arrays.copyOf(data, data.length);
|
||||||
|
for(int i = 0,m=size;i<m;i++)
|
||||||
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
|
newData[i+offset] = SanityChecks.SANITY_CAST(o.APPLY_CAST(newData[i+offset]));
|
||||||
|
#else
|
||||||
|
newData[i+offset] = o.APPLY(newData[i+offset]);
|
||||||
|
#endif
|
||||||
|
setter.accept(newData);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
@@ -1681,10 +2070,9 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(size == 0) return;
|
if(size == 0) return;
|
||||||
ReentrantLock lock = list.lock;
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
list.removeElements(offset, offset+size);
|
list.removeElements(parentOffset, parentOffset+size);
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -1704,7 +2092,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
public LIST KEY_GENERIC_TYPE subList(int fromIndex, int toIndex) {
|
||||||
SanityChecks.checkArrayCapacity(size, fromIndex, toIndex-fromIndex);
|
SanityChecks.checkArrayCapacity(size, fromIndex, toIndex-fromIndex);
|
||||||
return new COWSubListBRACES(list, offset, fromIndex, toIndex);
|
return new COWSubListBRACES(this, lock, setter, getter, offset, fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkSubRange(int index) {
|
protected void checkSubRange(int index) {
|
||||||
@@ -1772,7 +2160,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (list.size() - 1) - index);
|
int steps = Math.min(amount, list.size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -556,7 +556,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (size() - 1) - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|||||||
+85
-72
@@ -152,10 +152,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
int length = c.size();
|
int length = c.size();
|
||||||
if(length == 0) return false;
|
if(length == 0) return false;
|
||||||
checkAddRange(index);
|
checkAddRange(index);
|
||||||
Entry KEY_GENERIC_TYPE next = null;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
Entry KEY_GENERIC_TYPE prev = null;
|
Entry KEY_GENERIC_TYPE prev;
|
||||||
if(index == size) prev = last;
|
if(index == size) {
|
||||||
else if(index == 0) next = first;
|
prev = last;
|
||||||
|
next = null;
|
||||||
|
}
|
||||||
|
else if(index == 0) {
|
||||||
|
next = first;
|
||||||
|
prev = null;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
next = getNode(index);
|
next = getNode(index);
|
||||||
prev = next.prev;
|
prev = next.prev;
|
||||||
@@ -177,30 +183,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) {
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) {
|
||||||
int length = c.size();
|
return addAll(index, (COLLECTION KEY_GENERIC_TYPE)c); //
|
||||||
if(length == 0) return false;
|
|
||||||
checkAddRange(index);
|
|
||||||
Entry KEY_GENERIC_TYPE next = null;
|
|
||||||
Entry KEY_GENERIC_TYPE prev = null;
|
|
||||||
if(index == size) prev = last;
|
|
||||||
else if(index == 0) next = first;
|
|
||||||
else {
|
|
||||||
next = getNode(index);
|
|
||||||
prev = next.prev;
|
|
||||||
}
|
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();) {
|
|
||||||
Entry KEY_GENERIC_TYPE entry = new EntryBRACES(iter.NEXT(), prev, null);
|
|
||||||
if(prev == null) first = entry;
|
|
||||||
else prev.next = entry;
|
|
||||||
prev = entry;
|
|
||||||
}
|
|
||||||
if(next == null) last = prev;
|
|
||||||
else {
|
|
||||||
prev.next = next;
|
|
||||||
next.prev = prev;
|
|
||||||
}
|
|
||||||
size += length;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -210,10 +193,16 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
int length = c.size();
|
int length = c.size();
|
||||||
if(length == 0) return false;
|
if(length == 0) return false;
|
||||||
checkAddRange(index);
|
checkAddRange(index);
|
||||||
Entry KEY_GENERIC_TYPE next = null;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
Entry KEY_GENERIC_TYPE prev = null;
|
Entry KEY_GENERIC_TYPE prev;
|
||||||
if(index == size) prev = last;
|
if(index == size) {
|
||||||
else if(index == 0) next = first;
|
prev = last;
|
||||||
|
next = null;
|
||||||
|
}
|
||||||
|
else if(index == 0) {
|
||||||
|
next = first;
|
||||||
|
prev = null;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
next = getNode(index);
|
next = getNode(index);
|
||||||
prev = next.prev;
|
prev = next.prev;
|
||||||
@@ -258,12 +247,19 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
|
if(length <= 0) return;
|
||||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
checkAddRange(from);
|
checkAddRange(from);
|
||||||
Entry KEY_GENERIC_TYPE next = null;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
Entry KEY_GENERIC_TYPE prev = null;
|
Entry KEY_GENERIC_TYPE prev;
|
||||||
if(from == size) prev = last;
|
if(from == size) {
|
||||||
else if(from == 0) next = first;
|
prev = last;
|
||||||
|
next = null;
|
||||||
|
}
|
||||||
|
else if(from == 0) {
|
||||||
|
next = first;
|
||||||
|
prev = null;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
next = getNode(from);
|
next = getNode(from);
|
||||||
prev = next.prev;
|
prev = next.prev;
|
||||||
@@ -297,13 +293,13 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE first() {
|
public KEY_TYPE first() {
|
||||||
if(first == null) throw new IllegalStateException();
|
if(first == null) throw new NoSuchElementException();
|
||||||
return first.value;
|
return first.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE last() {
|
public KEY_TYPE last() {
|
||||||
if(last == null) throw new IllegalStateException();
|
if(last == null) throw new NoSuchElementException();
|
||||||
return last.value;
|
return last.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,13 +532,13 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(first == null) throw new IllegalStateException();
|
if(first == null) throw new NoSuchElementException();
|
||||||
return unlinkFirst(first);
|
return unlinkFirst(first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeueLast() {
|
public KEY_TYPE dequeueLast() {
|
||||||
if(last == null) throw new IllegalStateException();
|
if(last == null) throw new NoSuchElementException();
|
||||||
return unlinkLast(last);
|
return unlinkLast(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,12 +589,15 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
first = temp;
|
first = temp;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Entry KEY_GENERIC_TYPE temp = last;
|
else if(before.next != last) {
|
||||||
last = temp.prev;
|
Entry KEY_GENERIC_TYPE temp = last;
|
||||||
last.next = null;
|
last = temp.prev;
|
||||||
temp.next = before.next;
|
last.next = null;
|
||||||
temp.prev = before;
|
temp.next = before.next;
|
||||||
before.next = temp;
|
temp.prev = before;
|
||||||
|
before.next = temp;
|
||||||
|
temp.next.prev = temp;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -623,12 +622,15 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
first = temp;
|
first = temp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Entry KEY_GENERIC_TYPE temp = last;
|
else if(before.next != last) {
|
||||||
last = temp.prev;
|
Entry KEY_GENERIC_TYPE temp = last;
|
||||||
last.next = null;
|
last = temp.prev;
|
||||||
temp.next = before.next;
|
last.next = null;
|
||||||
temp.prev = before;
|
temp.next = before.next;
|
||||||
before.next = temp;
|
temp.prev = before;
|
||||||
|
before.next = temp;
|
||||||
|
temp.next.prev = temp;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -671,16 +673,18 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
if(from < size - to) {
|
if(from < size - to) {
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||||
while(length > 0) {
|
while(length > 0) {
|
||||||
entry = entry.next;
|
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||||
unlink(entry.prev);
|
unlink(entry);
|
||||||
|
entry = next;
|
||||||
length--;
|
length--;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
Entry KEY_GENERIC_TYPE entry = getNode(to-1);
|
||||||
while(length > 0) {
|
while(length > 0) {
|
||||||
entry = entry.prev;
|
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||||
unlink(entry.next);
|
unlink(entry);
|
||||||
|
entry = prev;
|
||||||
length--;
|
length--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -691,20 +695,22 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
checkRange(from);
|
checkRange(from);
|
||||||
checkAddRange(to);
|
checkAddRange(to);
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
|
if(length <= 0) return ARRAYS.newArray(type, 0);
|
||||||
K[] a = ARRAYS.newArray(type, length);
|
K[] a = ARRAYS.newArray(type, length);
|
||||||
if(length <= 0) return a;
|
|
||||||
if(from < size - to) {
|
if(from < size - to) {
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||||
for(int i = 0;length > 0;i++, length--) {
|
for(int i = 0;length > 0;i++, length--) {
|
||||||
entry = entry.next;
|
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||||
a[i] = (K)unlink(entry.prev);
|
a[i] = (K)unlink(entry);
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
Entry KEY_GENERIC_TYPE entry = getNode(to-1);
|
||||||
for(int i = length-1;length > 0;i--) {
|
for(int i = length-1;length > 0;i--, length--) {
|
||||||
entry = entry.prev;
|
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||||
a[i] = (K)unlink(entry.next);
|
a[i] = (K)unlink(entry);
|
||||||
|
entry = prev;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -720,15 +726,17 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
if(from < size - to) {
|
if(from < size - to) {
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
Entry KEY_GENERIC_TYPE entry = getNode(from);
|
||||||
for(int i = 0;length > 0;i++, length--) {
|
for(int i = 0;length > 0;i++, length--) {
|
||||||
entry = entry.next;
|
Entry KEY_GENERIC_TYPE next = entry.next;
|
||||||
d[i] = unlink(entry.prev);
|
d[i] = unlink(entry);
|
||||||
|
entry = next;
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
Entry KEY_GENERIC_TYPE entry = getNode(to);
|
Entry KEY_GENERIC_TYPE entry = getNode(to-1);
|
||||||
for(int i = length-1;length > 0;i--) {
|
for(int i = length-1;length > 0;i--, length--) {
|
||||||
entry = entry.prev;
|
Entry KEY_GENERIC_TYPE prev = entry.prev;
|
||||||
d[i] = unlink(entry.next);
|
d[i] = unlink(entry);
|
||||||
|
entry = prev;
|
||||||
}
|
}
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@@ -1106,6 +1114,11 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
this.prev = prev;
|
this.prev = prev;
|
||||||
this.next = next;
|
this.next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return KEY_TO_STRING(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ListIter implements LIST_ITERATOR KEY_GENERIC_TYPE
|
private class ListIter implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||||
@@ -1239,7 +1252,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long estimateSize() {
|
public long estimateSize() {
|
||||||
return list.size - index;
|
return (long)list.size - (long)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1305,7 +1318,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long estimateSize() {
|
public long estimateSize() {
|
||||||
return list.size - index;
|
return (long)list.size - (long)index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+15
-1
@@ -285,6 +285,16 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_VALUE_TYPE remove(Object key) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
return VALUE_TO_OBJ(REMOVE_VALUE((CLASS_TYPE)key));
|
||||||
|
#else
|
||||||
|
return key instanceof CLASS_TYPE ? VALUE_TO_OBJ(REMOVE_VALUE(CLASS_TO_KEY(key))) : VALUE_TO_OBJ(getDefaultReturnValue());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -306,7 +316,11 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
return VALUE_EQUALS_NOT(ABSTRACT_MAP.this.remove(o), getDefaultReturnValue());
|
if(ABSTRACT_MAP.this.containsKey(o)) {
|
||||||
|
ABSTRACT_MAP.this.remove(o);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+35
-3
@@ -73,6 +73,7 @@ import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
|||||||
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;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A TypeSpecific ConcurrentHashMap implementation that is based on <a href="https://github.com/google/guava">Guavas</a> approach and backing array implementations.
|
* A TypeSpecific ConcurrentHashMap implementation that is based on <a href="https://github.com/google/guava">Guavas</a> approach and backing array implementations.
|
||||||
@@ -84,7 +85,7 @@ import speiger.src.collections.utils.HashUtil;
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
*/
|
*/
|
||||||
public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE
|
public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements CONCURRENT_MAP KEY_VALUE_GENERIC_TYPE, ITrimmable
|
||||||
{
|
{
|
||||||
/** Segment Limit */
|
/** Segment Limit */
|
||||||
private static final int MAX_SEGMENTS = 1 << 16;
|
private static final int MAX_SEGMENTS = 1 << 16;
|
||||||
@@ -538,6 +539,30 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean trim(int size) {
|
||||||
|
int segmentCapacity = size / segments.length;
|
||||||
|
if(segmentCapacity * segments.length < size) {
|
||||||
|
segmentCapacity++;
|
||||||
|
}
|
||||||
|
boolean result = false;
|
||||||
|
for(int i = 0, m=segments.length;i<m;i++) {
|
||||||
|
result |= segments[i].trim(segmentCapacity);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAndTrim(int size) {
|
||||||
|
int segmentCapacity = size / segments.length;
|
||||||
|
if(segmentCapacity * segments.length < size) {
|
||||||
|
segmentCapacity++;
|
||||||
|
}
|
||||||
|
for(int i = 0, m=segments.length;i<m;i++) {
|
||||||
|
segments[i].clearAndTrim(segmentCapacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -2025,7 +2050,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
#if TYPE_OBJECT
|
||||||
if(key == null) {
|
if(key == null) {
|
||||||
|
#else
|
||||||
|
if(key == null || (key instanceof CLASS_TYPE && KEY_EQUALS_NULL(CLASS_TO_KEY(key)))) {
|
||||||
|
#endif
|
||||||
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
||||||
removeNullIndex();
|
removeNullIndex();
|
||||||
return true;
|
return true;
|
||||||
@@ -2202,7 +2231,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
protected boolean trim(int size) {
|
protected boolean trim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size || this.size > Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
if(request >= mask+1 || this.size > Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@@ -2218,7 +2247,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
protected void clearAndTrim(int size) {
|
protected void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= mask+1) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2298,6 +2327,9 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
#endif
|
#endif
|
||||||
protected int findIndex(int hash, Object key) {
|
protected int findIndex(int hash, Object key) {
|
||||||
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
if(KEY_EQUALS_NULL(CLASS_TO_KEY(key))) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#endif
|
||||||
int pos = hash & mask;
|
int pos = hash & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(KEY_EQUALS_NOT_NULL(current)) {
|
if(KEY_EQUALS_NOT_NULL(current)) {
|
||||||
|
|||||||
+10
-13
@@ -22,7 +22,6 @@ 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;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_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.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -57,7 +56,7 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
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.ObjectOrderedSet;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
|
|
||||||
@@ -285,7 +284,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE key) {
|
public boolean moveToFirst(KEY_TYPE key) {
|
||||||
if(strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -307,7 +306,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) {
|
public boolean moveToLast(KEY_TYPE key) {
|
||||||
if(strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -370,8 +369,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
firstIndex = (int)links[pos];
|
onNodeRemoved(pos);
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
||||||
@@ -394,8 +392,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
lastIndex = (int)(links[pos] >>> 32);
|
onNodeRemoved(pos);
|
||||||
if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
||||||
@@ -421,15 +418,15 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
return entrySet;
|
return (ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = new KeySet();
|
if(keySet == null) keySet = new KeySet();
|
||||||
return keySet;
|
return (ORDERED_SET KEY_GENERIC_TYPE)keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -456,7 +453,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -394,7 +394,11 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
Objects.requireNonNull(value);
|
Objects.requireNonNull(value);
|
||||||
|
#if TYPE_OBJECT
|
||||||
if(key == null) {
|
if(key == null) {
|
||||||
|
#else
|
||||||
|
if(key == null || (key instanceof CLASS_TYPE && strategy.equals(CLASS_TO_KEY(key), EMPTY_KEY_VALUE))) {
|
||||||
|
#endif
|
||||||
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
||||||
removeNullIndex();
|
removeNullIndex();
|
||||||
return true;
|
return true;
|
||||||
@@ -628,7 +632,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
@Override
|
@Override
|
||||||
public boolean trim(int size) {
|
public boolean trim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size || this.size > Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
if(request >= nullIndex || this.size > Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
||||||
try {
|
try {
|
||||||
rehash(request);
|
rehash(request);
|
||||||
}
|
}
|
||||||
@@ -639,7 +643,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -669,6 +673,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
protected int findIndex(CLASS_TYPE key) {
|
protected int findIndex(CLASS_TYPE key) {
|
||||||
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
KEY_TYPE keyType = CLASS_TO_KEY(key);
|
KEY_TYPE keyType = CLASS_TO_KEY(key);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
if(strategy.equals(keyType, EMPTY_KEY_VALUE)) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#endif
|
||||||
int pos = HashUtil.mix(strategy.hashCode(keyType)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(keyType)) & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(!strategy.equals(current, EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(current, EMPTY_KEY_VALUE)) {
|
||||||
@@ -942,7 +949,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -1173,7 +1180,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
state = keys[nullIndex];
|
state = keys[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -1329,7 +1336,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
state = values[nullIndex];
|
state = values[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
|
|||||||
+10
-13
@@ -22,7 +22,6 @@ 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;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_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.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
@@ -56,7 +55,7 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
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.ObjectOrderedSet;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
|
|
||||||
@@ -262,7 +261,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE key) {
|
public boolean moveToFirst(KEY_TYPE key) {
|
||||||
if(KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -284,7 +283,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) {
|
public boolean moveToLast(KEY_TYPE key) {
|
||||||
if(KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -374,8 +373,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
firstIndex = (int)links[pos];
|
onNodeRemoved(pos);
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(KEY_EQUALS_NULL(result)) {
|
if(KEY_EQUALS_NULL(result)) {
|
||||||
@@ -398,8 +396,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
lastIndex = (int)(links[pos] >>> 32);
|
onNodeRemoved(pos);
|
||||||
if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(KEY_EQUALS_NULL(result)) {
|
if(KEY_EQUALS_NULL(result)) {
|
||||||
@@ -425,15 +422,15 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
return entrySet;
|
return (ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = new KeySet();
|
if(keySet == null) keySet = new KeySet();
|
||||||
return keySet;
|
return (ORDERED_SET KEY_GENERIC_TYPE)keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -460,7 +457,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-5
@@ -362,7 +362,11 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
@Override
|
@Override
|
||||||
public boolean remove(Object key, Object value) {
|
public boolean remove(Object key, Object value) {
|
||||||
Objects.requireNonNull(value);
|
Objects.requireNonNull(value);
|
||||||
|
#if TYPE_OBJECT
|
||||||
if(key == null) {
|
if(key == null) {
|
||||||
|
#else
|
||||||
|
if(key == null || (key instanceof CLASS_TYPE && KEY_EQUALS_NULL(CLASS_TO_KEY(key)))) {
|
||||||
|
#endif
|
||||||
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
if(containsNull && EQUALS_VALUE_TYPE(values[nullIndex], value)) {
|
||||||
removeNullIndex();
|
removeNullIndex();
|
||||||
return true;
|
return true;
|
||||||
@@ -589,7 +593,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
@Override
|
@Override
|
||||||
public boolean trim(int size) {
|
public boolean trim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size || this.size > Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
if(request >= nullIndex || this.size >= Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
||||||
try {
|
try {
|
||||||
rehash(request);
|
rehash(request);
|
||||||
}
|
}
|
||||||
@@ -600,7 +604,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -629,6 +633,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
#endif
|
#endif
|
||||||
protected int findIndex(Object key) {
|
protected int findIndex(Object key) {
|
||||||
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
if(key instanceof CLASS_TYPE && KEY_EQUALS_NULL(CLASS_TO_KEY(key))) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#endif
|
||||||
int pos = HashUtil.mix(key.hashCode()) & mask;
|
int pos = HashUtil.mix(key.hashCode()) & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(KEY_EQUALS_NOT_NULL(current)) {
|
if(KEY_EQUALS_NOT_NULL(current)) {
|
||||||
@@ -902,7 +909,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
state = new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -1129,7 +1136,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
state = keys[nullIndex];
|
state = keys[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
@@ -1285,7 +1292,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
state = values[nullIndex];
|
state = values[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
|
|||||||
+10
-6
@@ -25,7 +25,9 @@ import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
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;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
@@ -47,7 +49,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
|||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -70,7 +71,7 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
#endif
|
#endif
|
||||||
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.ObjectOrderedSet;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@@ -100,9 +101,9 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
/** The Last Index in the Map */
|
/** The Last Index in the Map */
|
||||||
protected int lastIndex = -1;
|
protected int lastIndex = -1;
|
||||||
/** EntrySet cache */
|
/** EntrySet cache */
|
||||||
protected transient FastEntrySet KEY_VALUE_GENERIC_TYPE entrySet;
|
protected transient FastOrderedSet KEY_VALUE_GENERIC_TYPE entrySet;
|
||||||
/** KeySet cache */
|
/** KeySet cache */
|
||||||
protected transient SET KEY_GENERIC_TYPE keySet;
|
protected transient ORDERED_SET KEY_GENERIC_TYPE keySet;
|
||||||
/** Values cache */
|
/** Values cache */
|
||||||
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||||
|
|
||||||
@@ -429,13 +430,13 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = new KeySet();
|
if(keySet == null) keySet = new KeySet();
|
||||||
return keySet;
|
return keySet;
|
||||||
}
|
}
|
||||||
@@ -516,6 +517,9 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
#endif
|
#endif
|
||||||
protected int findIndex(Object key) {
|
protected int findIndex(Object key) {
|
||||||
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
if(key == null) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
if(KEY_EQUALS_NULL(CLASS_TO_KEY(key))) return containsNull ? nullIndex : -(nullIndex + 1);
|
||||||
|
#endif
|
||||||
int pos = HashUtil.mix(key.hashCode()) & mask;
|
int pos = HashUtil.mix(key.hashCode()) & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(KEY_EQUALS_NOT_NULL(current)) {
|
if(KEY_EQUALS_NOT_NULL(current)) {
|
||||||
|
|||||||
+15
-10
@@ -27,7 +27,6 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_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.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -90,7 +89,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
/** Amount of Elements stored in the ArrayMap */
|
/** Amount of Elements stored in the ArrayMap */
|
||||||
protected int size = 0;
|
protected int size = 0;
|
||||||
/** KeySet cache */
|
/** KeySet cache */
|
||||||
protected SET KEY_GENERIC_TYPE keySet;
|
protected ORDERED_SET KEY_GENERIC_TYPE keySet;
|
||||||
/** Values cache */
|
/** Values cache */
|
||||||
protected VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
protected VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||||
/** EntrySet cache */
|
/** EntrySet cache */
|
||||||
@@ -270,7 +269,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) {
|
public boolean moveToLast(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < size-1) {
|
if(index >= 0 && index < size-1) {
|
||||||
moveIndexToLast(index);
|
moveIndexToLast(index);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -437,7 +436,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = new KeySet();
|
if(keySet == null) keySet = new KeySet();
|
||||||
return keySet;
|
return keySet;
|
||||||
}
|
}
|
||||||
@@ -1234,6 +1233,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public EntryIterator() {}
|
public EntryIterator() {}
|
||||||
public EntryIterator(KEY_TYPE from) {
|
public EntryIterator(KEY_TYPE from) {
|
||||||
index = findIndex(from);
|
index = findIndex(from);
|
||||||
|
if(index == -1) throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1249,7 +1249,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
super.remove();
|
super.remove();
|
||||||
entry.index = -1;
|
if(entry != null && entry.index != -1) {
|
||||||
|
entry.index = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1262,7 +1264,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public KeyIterator() {}
|
public KeyIterator() {}
|
||||||
public KeyIterator(KEY_TYPE element) {
|
public KeyIterator(KEY_TYPE element) {
|
||||||
index = findIndex(element);
|
index = findIndex(element);
|
||||||
|
if(index == -1) throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
return keys[previousEntry()];
|
return keys[previousEntry()];
|
||||||
@@ -1319,8 +1323,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == -1)
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
throw new IllegalStateException();
|
|
||||||
removeIndex(lastReturned);
|
removeIndex(lastReturned);
|
||||||
if(lastReturned < index)
|
if(lastReturned < index)
|
||||||
index--;
|
index--;
|
||||||
@@ -1329,8 +1332,8 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = index;
|
index--;
|
||||||
return index--;
|
return (lastReturned = index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextEntry() {
|
public int nextEntry() {
|
||||||
@@ -1341,8 +1344,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (size() - 1) - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1350,6 +1354,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
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);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-4
@@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -76,8 +77,8 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
||||||
keyType = keys[0].getDeclaringClass();
|
keyType = keys[0].getDeclaringClass();
|
||||||
this.keys = getKeyUniverse(keyType);
|
this.keys = getKeyUniverse(keyType);
|
||||||
this.values = NEW_VALUE_ARRAY(keys.length);
|
this.values = NEW_VALUE_ARRAY(this.keys.length);
|
||||||
present = new long[((keys.length - 1) >> 6) + 1];
|
present = new long[((this.keys.length - 1) >> 6) + 1];
|
||||||
putAll(keys, values);
|
putAll(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,8 +94,8 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
||||||
keyType = keys[0].getDeclaringClass();
|
keyType = keys[0].getDeclaringClass();
|
||||||
this.keys = getKeyUniverse(keyType);
|
this.keys = getKeyUniverse(keyType);
|
||||||
this.values = NEW_VALUE_ARRAY(keys.length);
|
this.values = NEW_VALUE_ARRAY(this.keys.length);
|
||||||
present = new long[((keys.length - 1) >> 6) + 1];
|
present = new long[((this.keys.length - 1) >> 6) + 1];
|
||||||
putAll(keys, values);
|
putAll(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,6 +531,14 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
if(size() <= 0) return;
|
||||||
|
for(int i = 0,m=keys.length;i<m;i++) {
|
||||||
|
if(isSet(i)) action.accept(new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator();
|
return new EntryIterator();
|
||||||
|
|||||||
+13
-14
@@ -17,7 +17,6 @@ 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;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_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.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
@@ -29,7 +28,6 @@ import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
|||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
import speiger.src.collections.objects.lists.ObjectListIterator;
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,9 +66,9 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
||||||
keyType = keys[0].getDeclaringClass();
|
keyType = keys[0].getDeclaringClass();
|
||||||
this.keys = getKeyUniverse(keyType);
|
this.keys = getKeyUniverse(keyType);
|
||||||
this.values = NEW_VALUE_ARRAY(keys.length);
|
this.values = NEW_VALUE_ARRAY(this.keys.length);
|
||||||
present = new long[((keys.length - 1) >> 6) + 1];
|
present = new long[((this.keys.length - 1) >> 6) + 1];
|
||||||
links = new long[keys.length];
|
links = new long[this.keys.length];
|
||||||
putAll(keys, values);
|
putAll(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,9 +84,9 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
if(keys.length != values.length) throw new IllegalArgumentException("Keys and Values have to be the same size");
|
||||||
keyType = keys[0].getDeclaringClass();
|
keyType = keys[0].getDeclaringClass();
|
||||||
this.keys = getKeyUniverse(keyType);
|
this.keys = getKeyUniverse(keyType);
|
||||||
this.values = NEW_VALUE_ARRAY(keys.length);
|
this.values = NEW_VALUE_ARRAY(this.keys.length);
|
||||||
present = new long[((keys.length - 1) >> 6) + 1];
|
present = new long[((this.keys.length - 1) >> 6) + 1];
|
||||||
links = new long[keys.length];
|
links = new long[this.keys.length];
|
||||||
putAll(keys, values);
|
putAll(keys, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,7 +239,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToFirst(T key) {
|
public VALUE_TYPE getAndMoveToFirst(T key) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(!isSet(index)) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index);
|
moveToFirstIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
@@ -249,7 +247,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getAndMoveToLast(T key) {
|
public VALUE_TYPE getAndMoveToLast(T key) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(!isSet(index)) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index);
|
moveToLastIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
@@ -315,15 +313,15 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
return entrySet;
|
return (ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = new KeySet();
|
if(keySet == null) keySet = new KeySet();
|
||||||
return keySet;
|
return (ORDERED_SET KEY_GENERIC_TYPE)keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -830,6 +828,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
previous = from.ordinal() - 1;
|
previous = from.ordinal() - 1;
|
||||||
index = from.ordinal();
|
index = from.ordinal();
|
||||||
next = from.ordinal();
|
next = from.ordinal();
|
||||||
|
if(!isSet(index)) throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
|
|||||||
+151
-51
@@ -30,8 +30,9 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -408,7 +409,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||||
if(tree == null) return EMPTY_KEY_VALUE;
|
if(tree == null) return getDefaultMinValue();
|
||||||
KEY_TYPE result = first.key;
|
KEY_TYPE result = first.key;
|
||||||
removeNode(first);
|
removeNode(first);
|
||||||
return result;
|
return result;
|
||||||
@@ -422,7 +423,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||||
if(tree == null) return EMPTY_KEY_VALUE;
|
if(tree == null) return getDefaultMaxValue();
|
||||||
KEY_TYPE result = last.key;
|
KEY_TYPE result = last.key;
|
||||||
removeNode(last);
|
removeNode(last);
|
||||||
return result;
|
return result;
|
||||||
@@ -682,7 +683,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1022,6 +1023,33 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE lower(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.lowerEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE floor(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.floorEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE higher(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.higherEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE ceiling(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.ceilingEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -1447,7 +1475,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1461,8 +1489,8 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
||||||
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
||||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMinValue() : entry.key; }
|
||||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMaxValue() : entry.key; }
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
||||||
|
|
||||||
@@ -1533,7 +1561,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
map.removeNode(entry);
|
map.removeNode(entry);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return getDefaultMinValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1544,19 +1572,21 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
map.removeNode(entry);
|
map.removeNode(entry);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return getDefaultMaxValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() {
|
public VALUE_TYPE FIRST_ENTRY_VALUE() {
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = subLowest();
|
Node KEY_VALUE_GENERIC_TYPE entry = subLowest();
|
||||||
return entry == null ? map.getDefaultReturnValue() : entry.value;
|
if(entry == null) throw new NoSuchElementException();
|
||||||
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() {
|
public VALUE_TYPE LAST_ENTRY_VALUE() {
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = subHighest();
|
Node KEY_VALUE_GENERIC_TYPE entry = subHighest();
|
||||||
return entry == null ? map.getDefaultReturnValue() : entry.value;
|
if(entry == null) throw new NoSuchElementException();
|
||||||
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1632,7 +1662,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||||
return inRange(key) ? map.REMOVE_VALUE(key) : defaultValue;
|
return inRange(key) ? map.REMOVE_VALUEOrDefault(key, defaultValue) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT && VALUE_OBJECT
|
#if TYPE_OBJECT && VALUE_OBJECT
|
||||||
@@ -1778,7 +1808,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
if (!inRange(key)) return false;
|
if (!inRange(key)) return false;
|
||||||
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
||||||
if (node != null && VALUE_EQUALS(node.getValue(), entry.getValue())) {
|
if (node != null && VALUE_EQUALS(node.ENTRY_VALUE(), entry.ENTRY_VALUE())) {
|
||||||
map.removeNode(node);
|
map.removeNode(node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2023,26 +2053,36 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class DecsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
class DecsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
public DecsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE previous() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE previous() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry();
|
return previousEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry();
|
return nextEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AcsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
class AcsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
public AcsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2061,26 +2101,36 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class DecsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class DecsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DecsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().key;
|
return previousEntry().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().key;
|
return nextEntry().key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AcsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class AcsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AcsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2099,7 +2149,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class AcsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class AcsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AcsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2118,39 +2168,60 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class DecsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class DecsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DecsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().value;
|
return previousEntry().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_NEXT() {
|
public VALUE_TYPE VALUE_NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().value;
|
return nextEntry().value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class SubMapEntryIterator
|
abstract class SubMapEntryIterator
|
||||||
{
|
{
|
||||||
|
final boolean isForward;
|
||||||
boolean wasForward;
|
boolean wasForward;
|
||||||
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
||||||
Node KEY_VALUE_GENERIC_TYPE next;
|
Node KEY_VALUE_GENERIC_TYPE next;
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE previous;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
KEY_TYPE forwardFence;
|
KEY_TYPE forwardFence;
|
||||||
KEY_TYPE backwardFence;
|
KEY_TYPE backwardFence;
|
||||||
|
|
||||||
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence)
|
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence, boolean isForward) {
|
||||||
{
|
|
||||||
next = first;
|
next = first;
|
||||||
this.forwardFence = forwardFence == null ? null : forwardFence.key;
|
previous = first == null ? null : movePrevious(first);
|
||||||
this.backwardFence = backwardFence == null ? null : backwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
unboundBackwardFence = backwardFence == null;
|
unboundBackwardFence = backwardFence == null;
|
||||||
|
this.isForward = isForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -2159,26 +2230,30 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
Node KEY_VALUE_GENERIC_TYPE result = next;
|
||||||
next = next.next();
|
next = moveNext(next);
|
||||||
wasForward = true;
|
wasForward = isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
next = previous;
|
||||||
next = next.previous();
|
Node KEY_VALUE_GENERIC_TYPE result = previous;
|
||||||
wasForward = false;
|
previous = movePrevious(previous);
|
||||||
|
wasForward = !isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(next == lastReturned) next = moveNext(next);
|
||||||
|
if(previous == lastReturned) previous = movePrevious(previous);
|
||||||
if(wasForward && lastReturned.needsSuccessor()) next = lastReturned;
|
if(wasForward && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
map.removeNode(lastReturned);
|
map.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -2492,19 +2567,29 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class DescendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class DescendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DescendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public DescendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().key;
|
return previousEntry().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().key;
|
return nextEntry().key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2512,7 +2597,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
{
|
{
|
||||||
public AscendingMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
public AscendingMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2531,7 +2616,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class AscendingValueIterator extends MapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class AscendingValueIterator extends MapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AscendingValueIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public AscendingValueIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2550,7 +2635,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
class AscendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class AscendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AscendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public AscendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2568,13 +2653,24 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
abstract class MapEntryIterator
|
abstract class MapEntryIterator
|
||||||
{
|
{
|
||||||
|
final boolean isForward;
|
||||||
boolean wasMoved = false;
|
boolean wasMoved = false;
|
||||||
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
||||||
Node KEY_VALUE_GENERIC_TYPE next;
|
Node KEY_VALUE_GENERIC_TYPE next;
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE previous;
|
||||||
|
|
||||||
public MapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
public MapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, boolean isForward) {
|
||||||
{
|
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : movePrevious(first);
|
||||||
|
this.isForward = isForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -2583,26 +2679,30 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
Node KEY_VALUE_GENERIC_TYPE result = next;
|
||||||
next = next.next();
|
next = moveNext(next);
|
||||||
wasMoved = true;
|
wasMoved = isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
next = previous;
|
||||||
next = next.previous();
|
Node KEY_VALUE_GENERIC_TYPE result = previous;
|
||||||
wasMoved = false;
|
previous = movePrevious(previous);
|
||||||
|
wasMoved = !isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(next == lastReturned) next = moveNext(next);
|
||||||
|
if(previous == lastReturned) previous = movePrevious(previous);
|
||||||
if(wasMoved && lastReturned.needsSuccessor()) next = lastReturned;
|
if(wasMoved && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
|
|||||||
+161
-51
@@ -30,8 +30,9 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
@@ -411,7 +412,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() {
|
||||||
if(tree == null) return EMPTY_KEY_VALUE;
|
if(tree == null) return getDefaultMinValue();
|
||||||
KEY_TYPE result = first.key;
|
KEY_TYPE result = first.key;
|
||||||
removeNode(first);
|
removeNode(first);
|
||||||
return result;
|
return result;
|
||||||
@@ -425,7 +426,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() {
|
||||||
if(tree == null) return EMPTY_KEY_VALUE;
|
if(tree == null) return getDefaultMaxValue();
|
||||||
KEY_TYPE result = last.key;
|
KEY_TYPE result = last.key;
|
||||||
removeNode(last);
|
removeNode(last);
|
||||||
return result;
|
return result;
|
||||||
@@ -685,7 +686,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,6 +1081,33 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
public KEY_TYPE ceiling(KEY_TYPE e) { return map.ceilingKey(e); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
public KEY_TYPE higher(KEY_TYPE e) { return map.higherKey(e); }
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE lower(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.lowerEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE floor(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.floorEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE higher(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.higherEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE ceiling(CLASS_TYPE e) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE node = map.ceilingEntry(OBJ_TO_KEY(e));
|
||||||
|
return node != null ? node.getKey() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_FIRST_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -1283,6 +1311,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return keySet;
|
return keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
|
return navigableKeySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
@@ -1369,6 +1402,11 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return keySet;
|
return keySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
|
return navigableKeySet();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(KEY_TYPE fromKey, boolean fromInclusive, KEY_TYPE toKey, boolean toInclusive) {
|
||||||
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
if (!inRange(fromKey, fromInclusive)) throw new IllegalArgumentException("fromKey out of range");
|
||||||
@@ -1504,7 +1542,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1518,8 +1556,8 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
protected abstract BI_ITERATOR KEY_GENERIC_TYPE keyIterator(KEY_TYPE element);
|
||||||
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
protected abstract VALUE_BI_ITERATOR VALUE_GENERIC_TYPE valueIterator();
|
||||||
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
protected abstract BI_ITERATOR KEY_GENERIC_TYPE descendingKeyIterator();
|
||||||
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
protected KEY_TYPE lowKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMinValue() : entry.key; }
|
||||||
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? EMPTY_KEY_VALUE : entry.key; }
|
protected KEY_TYPE highKeyOrNull(Node KEY_VALUE_GENERIC_TYPE entry) { return entry == null ? getDefaultMaxValue() : entry.key; }
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
protected Node KEY_VALUE_GENERIC_TYPE next(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.next(); }
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
protected Node KEY_VALUE_GENERIC_TYPE previous(Node KEY_VALUE_GENERIC_TYPE entry) { return entry.previous(); }
|
||||||
|
|
||||||
@@ -1590,7 +1628,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
map.removeNode(entry);
|
map.removeNode(entry);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return getDefaultMinValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1601,19 +1639,21 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
map.removeNode(entry);
|
map.removeNode(entry);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return getDefaultMaxValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() {
|
public VALUE_TYPE FIRST_ENTRY_VALUE() {
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = subLowest();
|
Node KEY_VALUE_GENERIC_TYPE entry = subLowest();
|
||||||
return entry == null ? map.getDefaultReturnValue() : entry.value;
|
if(entry == null) throw new NoSuchElementException();
|
||||||
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() {
|
public VALUE_TYPE LAST_ENTRY_VALUE() {
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = subHighest();
|
Node KEY_VALUE_GENERIC_TYPE entry = subHighest();
|
||||||
return entry == null ? map.getDefaultReturnValue() : entry.value;
|
if(entry == null) throw new NoSuchElementException();
|
||||||
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1689,7 +1729,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||||
return inRange(key) ? map.REMOVE_VALUE(key) : defaultValue;
|
return inRange(key) ? map.REMOVE_VALUEOrDefault(key, defaultValue) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT && VALUE_OBJECT
|
#if TYPE_OBJECT && VALUE_OBJECT
|
||||||
@@ -1835,7 +1875,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
if (!inRange(key)) return false;
|
if (!inRange(key)) return false;
|
||||||
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE node = map.findNode(key);
|
||||||
if (node != null && VALUE_EQUALS(node.getValue(), entry.getValue())) {
|
if (node != null && VALUE_EQUALS(node.ENTRY_VALUE(), entry.ENTRY_VALUE())) {
|
||||||
map.removeNode(node);
|
map.removeNode(node);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2080,26 +2120,36 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class DecsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
class DecsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
public DecsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE previous() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE previous() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry();
|
return previousEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry();
|
return nextEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AcsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
class AcsendingSubEntryIterator extends SubMapEntryIterator implements ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
||||||
{
|
{
|
||||||
public AcsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2118,26 +2168,36 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class DecsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class DecsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DecsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().key;
|
return previousEntry().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().key;
|
return nextEntry().key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AcsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class AcsendingSubKeyIterator extends SubMapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AcsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubKeyIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2156,7 +2216,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class AcsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class AcsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AcsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public AcsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2175,39 +2235,60 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class DecsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class DecsendingSubValueIterator extends SubMapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DecsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
public DecsendingSubValueIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence) {
|
||||||
super(first, forwardFence, backwardFence);
|
super(first, forwardFence, backwardFence, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().value;
|
return previousEntry().value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_NEXT() {
|
public VALUE_TYPE VALUE_NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().value;
|
return nextEntry().value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class SubMapEntryIterator
|
abstract class SubMapEntryIterator
|
||||||
{
|
{
|
||||||
|
final boolean isForward;
|
||||||
boolean wasForward;
|
boolean wasForward;
|
||||||
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
||||||
Node KEY_VALUE_GENERIC_TYPE next;
|
Node KEY_VALUE_GENERIC_TYPE next;
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE previous;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
KEY_TYPE forwardFence;
|
KEY_TYPE forwardFence;
|
||||||
KEY_TYPE backwardFence;
|
KEY_TYPE backwardFence;
|
||||||
|
|
||||||
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence)
|
public SubMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, Node KEY_VALUE_GENERIC_TYPE forwardFence, Node KEY_VALUE_GENERIC_TYPE backwardFence, boolean isForward) {
|
||||||
{
|
|
||||||
next = first;
|
next = first;
|
||||||
this.forwardFence = forwardFence == null ? null : forwardFence.key;
|
previous = first == null ? null : movePrevious(first);
|
||||||
this.backwardFence = backwardFence == null ? null : backwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
unboundBackwardFence = backwardFence == null;
|
unboundBackwardFence = backwardFence == null;
|
||||||
|
this.isForward = isForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -2216,26 +2297,30 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
Node KEY_VALUE_GENERIC_TYPE result = next;
|
||||||
next = next.next();
|
next = moveNext(next);
|
||||||
wasForward = true;
|
wasForward = isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
next = previous;
|
||||||
next = next.previous();
|
Node KEY_VALUE_GENERIC_TYPE result = previous;
|
||||||
wasForward = false;
|
previous = movePrevious(previous);
|
||||||
|
wasForward = !isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(next == lastReturned) next = moveNext(next);
|
||||||
|
if(previous == lastReturned) previous = movePrevious(previous);
|
||||||
if(wasForward && lastReturned.needsSuccessor()) next = lastReturned;
|
if(wasForward && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
map.removeNode(lastReturned);
|
map.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -2549,19 +2634,29 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class DescendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class DescendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public DescendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public DescendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
return nextEntry().key;
|
return previousEntry().key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return previousEntry().key;
|
return nextEntry().key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2569,7 +2664,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
{
|
{
|
||||||
public AscendingMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
public AscendingMapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2588,7 +2683,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class AscendingValueIterator extends MapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
class AscendingValueIterator extends MapEntryIterator implements VALUE_BI_ITERATOR VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AscendingValueIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public AscendingValueIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2607,7 +2702,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
class AscendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
class AscendingKeyIterator extends MapEntryIterator implements BI_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
public AscendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
public AscendingKeyIterator(Node KEY_VALUE_GENERIC_TYPE first) {
|
||||||
super(first);
|
super(first, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2625,13 +2720,24 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
abstract class MapEntryIterator
|
abstract class MapEntryIterator
|
||||||
{
|
{
|
||||||
|
final boolean isForward;
|
||||||
boolean wasMoved = false;
|
boolean wasMoved = false;
|
||||||
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
Node KEY_VALUE_GENERIC_TYPE lastReturned;
|
||||||
Node KEY_VALUE_GENERIC_TYPE next;
|
Node KEY_VALUE_GENERIC_TYPE next;
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE previous;
|
||||||
|
|
||||||
public MapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first)
|
public MapEntryIterator(Node KEY_VALUE_GENERIC_TYPE first, boolean isForward) {
|
||||||
{
|
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : movePrevious(first);
|
||||||
|
this.isForward = isForward;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE moveNext(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Node KEY_VALUE_GENERIC_TYPE movePrevious(Node KEY_VALUE_GENERIC_TYPE node) {
|
||||||
|
return node.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -2640,26 +2746,30 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE nextEntry() {
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
Node KEY_VALUE_GENERIC_TYPE result = next;
|
||||||
next = next.next();
|
next = moveNext(next);
|
||||||
wasMoved = true;
|
wasMoved = isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
protected Node KEY_VALUE_GENERIC_TYPE previousEntry() {
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
Node KEY_VALUE_GENERIC_TYPE result = next;
|
next = previous;
|
||||||
next = next.previous();
|
Node KEY_VALUE_GENERIC_TYPE result = previous;
|
||||||
wasMoved = false;
|
previous = movePrevious(previous);
|
||||||
|
wasMoved = !isForward;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(next == lastReturned) next = moveNext(next);
|
||||||
|
if(previous == lastReturned) previous = movePrevious(previous);
|
||||||
if(wasMoved && lastReturned.needsSuccessor()) next = lastReturned;
|
if(wasMoved && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
|
|||||||
+2
-1
@@ -557,8 +557,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
*/
|
*/
|
||||||
public KEY_TYPE ENTRY_KEY();
|
public KEY_TYPE ENTRY_KEY();
|
||||||
public default CLASS_TYPE getKey() { return KEY_TO_OBJ(ENTRY_KEY()); }
|
public default CLASS_TYPE getKey() { return KEY_TO_OBJ(ENTRY_KEY()); }
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
* Type Specific getValue method that reduces boxing/unboxing
|
* Type Specific getValue method that reduces boxing/unboxing
|
||||||
@@ -1381,6 +1381,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @param initialSize the requested start capacity
|
* @param initialSize the requested start capacity
|
||||||
*/
|
*/
|
||||||
public BuilderCache(int initialSize) {
|
public BuilderCache(int initialSize) {
|
||||||
|
if(initialSize < 0) throw new IllegalStateException("Minimum Capacity is negative. This is not allowed");
|
||||||
keys = NEW_KEY_ARRAY(initialSize);
|
keys = NEW_KEY_ARRAY(initialSize);
|
||||||
values = NEW_VALUE_ARRAY(initialSize);
|
values = NEW_VALUE_ARRAY(initialSize);
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -34,7 +34,9 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||||||
/** @return a Type Specific pollLastEntry */
|
/** @return a Type Specific pollLastEntry */
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry();
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry();
|
||||||
|
/** @return a Type Specific Navigable Key Set */
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped NavigableMap that is Synchronized
|
* Creates a Wrapped NavigableMap that is Synchronized
|
||||||
* @return a new NavigableMap that is synchronized
|
* @return a new NavigableMap that is synchronized
|
||||||
|
|||||||
+7
@@ -1,6 +1,9 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
||||||
/**
|
/**
|
||||||
@@ -94,6 +97,10 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
|
@Override
|
||||||
|
public ORDERED_SET KEY_GENERIC_TYPE keySet();
|
||||||
|
@Override
|
||||||
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
|
|||||||
+7
-5
@@ -9,9 +9,11 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
|||||||
#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.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +33,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet();
|
public SORTED_SET KEY_GENERIC_TYPE keySet();
|
||||||
@Override
|
@Override
|
||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
||||||
|
|
||||||
@@ -155,11 +157,11 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
public VALUE_TYPE LAST_ENTRY_VALUE();
|
public VALUE_TYPE LAST_ENTRY_VALUE();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, CLASS_TYPE toKey) { return subMap(OBJ_TO_KEY(fromKey), OBJ_TO_KEY(toKey)); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, CLASS_TYPE toKey);
|
||||||
@Override
|
@Override
|
||||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(CLASS_TYPE toKey) { return headMap(OBJ_TO_KEY(toKey)); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE headMap(CLASS_TYPE toKey);
|
||||||
@Override
|
@Override
|
||||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(CLASS_TYPE fromKey) { return tailMap(OBJ_TO_KEY(fromKey)); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(CLASS_TYPE fromKey);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
@@ -434,6 +434,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
KEY_TYPE value = array[index];
|
KEY_TYPE value = array[index];
|
||||||
removeIndex(index);
|
removeIndex(index);
|
||||||
index = ++index % array.length;
|
index = ++index % array.length;
|
||||||
|
|||||||
+2
-1
@@ -187,7 +187,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
|
|
||||||
@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 + (array.length >> 1), 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;
|
||||||
@@ -414,6 +414,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return dequeue();
|
return dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -207,7 +207,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
|
|
||||||
@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 + (array.length >> 1), 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);
|
||||||
}
|
}
|
||||||
@@ -389,6 +389,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return dequeue();
|
return dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-27
@@ -888,15 +888,11 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMaxValue() { return super.getDefaultMinValue(); }
|
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMinValue() { return super.getDefaultMaxValue(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
||||||
if(!inRange(fromElement, fromInclusive)) throw new IllegalArgumentException("fromElement out of range");
|
if(!inRange(fromElement, fromInclusive)) throw new IllegalArgumentException("fromElement out of range");
|
||||||
if(!inRange(toElement, toInclusive)) throw new IllegalArgumentException("toElement out of range");
|
if(!inRange(toElement, toInclusive)) throw new IllegalArgumentException("toElement out of range");
|
||||||
return new DescendingSubSetBRACES(set, false, fromElement, fromInclusive, false, toElement, toInclusive);
|
return new DescendingSubSetBRACES(set, false, toElement, toInclusive, false, fromElement, fromInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -973,21 +969,15 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { set.setDefaultMaxValue(value); }
|
public void setDefaultMaxValue(KEY_TYPE value) { set.setDefaultMaxValue(value); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE getDefaultMaxValue() { return set.getDefaultMaxValue(); }
|
public KEY_TYPE getDefaultMaxValue() { return set.getDefaultMaxValue(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMinValue(KEY_TYPE value) { set.setDefaultMinValue(value); }
|
public void setDefaultMinValue(KEY_TYPE value) { set.setDefaultMinValue(value); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE getDefaultMinValue() { return set.getDefaultMinValue(); }
|
public KEY_TYPE getDefaultMinValue() { return set.getDefaultMinValue(); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
public KEY_TYPE getDefaultMaxValue() { return null; }
|
public KEY_TYPE getDefaultMaxValue() { return null; }
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMinValue() { return null; }
|
public KEY_TYPE getDefaultMinValue() { return null; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
@@ -1298,6 +1288,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
@@ -1307,6 +1298,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public AscendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
public AscendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.previous();
|
||||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
@@ -1322,6 +1314,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.next();
|
next = next.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
@@ -1330,15 +1323,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.previous();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1346,6 +1340,8 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(previous == lastReturned) previous = previous.previous();
|
||||||
|
if(next == lastReturned) next = next.next();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
set.removeNode(lastReturned);
|
set.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1356,6 +1352,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
@@ -1365,6 +1362,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public DescendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
public DescendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.next();
|
||||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
@@ -1380,6 +1378,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.previous();
|
next = next.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
@@ -1388,15 +1387,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.next();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1404,6 +1404,8 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(previous == lastReturned) previous = previous.next();
|
||||||
|
if(next == lastReturned) next = next.previous();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
set.removeNode(lastReturned);
|
set.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1415,11 +1417,13 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
|
|
||||||
public AscendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
public AscendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1431,6 +1435,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.next();
|
next = next.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
@@ -1439,15 +1444,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.previous();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1455,6 +1461,8 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(lastReturned == previous) previous = previous.previous();
|
||||||
|
if(lastReturned == next) next = next.next();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1465,11 +1473,13 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
|
|
||||||
public DescendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
public DescendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1481,6 +1491,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.previous();
|
next = next.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
@@ -1489,15 +1500,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.next();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1505,6 +1517,8 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(lastReturned == previous) previous = previous.next();
|
||||||
|
if(lastReturned == next) next = next.previous();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
* @throws NegativeArraySizeException if the capacity is negative
|
* @throws NegativeArraySizeException if the capacity is negative
|
||||||
*/
|
*/
|
||||||
public ARRAY_SET(int capacity) {
|
public ARRAY_SET(int capacity) {
|
||||||
|
if(capacity < 0) throw new IllegalStateException("Size has to be 0 or greater");
|
||||||
data = NEW_KEY_ARRAY(capacity);
|
data = NEW_KEY_ARRAY(capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +169,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
else if(index != size - 1) {
|
else if(index != size - 1) {
|
||||||
o = data[index];
|
o = data[index];
|
||||||
System.arraycopy(data, index+1, data, index, size - index);
|
System.arraycopy(data, index+1, data, index, size - index - 1);
|
||||||
data[size-1] = o;
|
data[size-1] = o;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -555,347 +556,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disabled until a Proper Implementation can be thought out or it is decided that the interface is thrown out.
|
|
||||||
// private class SubSet extends ABSTRACT_SET KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE {
|
|
||||||
// int offset;
|
|
||||||
// int length;
|
|
||||||
//
|
|
||||||
// SubSet(int offset, int length) {
|
|
||||||
// this.offset = offset;
|
|
||||||
// this.length = length;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int end() { return offset+length; }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean add(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index == -1) {
|
|
||||||
// if(data.length == size) data = Arrays.copyOf(data, size == 0 ? 2 : size * 2);
|
|
||||||
// if(end() != size) System.arraycopy(data, end(), data, end()+1, size-(offset+length));
|
|
||||||
// data[end()] = o;
|
|
||||||
// size++;
|
|
||||||
// length++;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean addAndMoveToFirst(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index == -1) {
|
|
||||||
// if(data.length == size) data = Arrays.copyOf(data, size == 0 ? 2 : size * 2);
|
|
||||||
// System.arraycopy(data, offset, data, offset+1, size-offset);
|
|
||||||
// data[offset] = o;
|
|
||||||
// size++;
|
|
||||||
// length++;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else if(index != 0) {
|
|
||||||
// o = data[index];
|
|
||||||
// System.arraycopy(data, offset, data, offset+1, index-offset);
|
|
||||||
// data[offset] = o;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean addAndMoveToLast(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index == -1) {
|
|
||||||
// if(data.length == size) data = Arrays.copyOf(data, size == 0 ? 2 : size * 2);
|
|
||||||
// System.arraycopy(data, end()+1, data, end(), size-end());
|
|
||||||
// data[end()] = o;
|
|
||||||
// size++;
|
|
||||||
// length++;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else if(index != 0) {
|
|
||||||
// o = data[index];
|
|
||||||
// System.arraycopy(data, offset+1, data, offset, index-offset);
|
|
||||||
// data[offset+length] = o;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean moveToFirst(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index > offset) {
|
|
||||||
// o = data[index];
|
|
||||||
// System.arraycopy(data, offset, data, offset+1, index-offset);
|
|
||||||
// data[offset] = o;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean moveToLast(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index != -1 && index < end()-1) {
|
|
||||||
// o = data[index];
|
|
||||||
// System.arraycopy(data, index+1, data, index, end()-index-1);
|
|
||||||
// data[end()-1] = o;
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#if !TYPE_OBJECT
|
|
||||||
// @Override
|
|
||||||
// public boolean contains(KEY_TYPE e) {
|
|
||||||
// return findIndex(e) != -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#endif
|
|
||||||
// @Override
|
|
||||||
// public boolean contains(Object e) {
|
|
||||||
// return findIndex(e) != -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE FIRST_KEY() {
|
|
||||||
// if(length == 0) throw new NoSuchElementException();
|
|
||||||
// return data[offset];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE LAST_KEY() {
|
|
||||||
// if(length == 0) throw new NoSuchElementException();
|
|
||||||
// return data[end()-1];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#if !TYPE_OBJECT
|
|
||||||
// @Override
|
|
||||||
// public boolean remove(KEY_TYPE o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index != -1) {
|
|
||||||
// size--;
|
|
||||||
// length--;
|
|
||||||
// if(index != size) System.arraycopy(data, index+1, data, index, size - index);
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#endif
|
|
||||||
// @Override
|
|
||||||
// public boolean remove(Object o) {
|
|
||||||
// int index = findIndex(o);
|
|
||||||
// if(index != -1) {
|
|
||||||
// size--;
|
|
||||||
// length--;
|
|
||||||
// if(index != size) System.arraycopy(data, index+1, data, index, size - index);
|
|
||||||
//#if TYPE_OBJECT
|
|
||||||
// data[size] = EMPTY_KEY_VALUE;
|
|
||||||
//#endif
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE POLL_FIRST_KEY() {
|
|
||||||
// if(length == 0) throw new NoSuchElementException();
|
|
||||||
// size--;
|
|
||||||
// length--;
|
|
||||||
// KEY_TYPE result = data[offset];
|
|
||||||
// System.arraycopy(data, offset+1, data, offset, size-offset);
|
|
||||||
//#if TYPE_OBJECT
|
|
||||||
// data[size] = EMPTY_KEY_VALUE;
|
|
||||||
//#endif
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE POLL_LAST_KEY() {
|
|
||||||
// if(length == 0) throw new NoSuchElementException();
|
|
||||||
// KEY_TYPE result = data[offset+length];
|
|
||||||
// size--;
|
|
||||||
// length--;
|
|
||||||
// System.arraycopy(data, end()+1, data, end(), size-end());
|
|
||||||
//#if TYPE_OBJECT
|
|
||||||
// data[size] = EMPTY_KEY_VALUE;
|
|
||||||
//#endif
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
|
||||||
// return new SetIterator(offset);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) {
|
|
||||||
// int index = findIndex(fromElement);
|
|
||||||
// if(index != -1) return new SetIterator(index);
|
|
||||||
// throw new NoSuchElementException();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public SubSet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) {
|
|
||||||
// int fromIndex = findIndex(fromElement);
|
|
||||||
// int toIndex = findIndex(toElement);
|
|
||||||
// if(fromIndex == -1 || toIndex == -1) throw new NoSuchElementException();
|
|
||||||
// return new SubSet(fromIndex, toIndex - fromIndex + 1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public SORTED_SET KEY_GENERIC_TYPE headSet(KEY_TYPE toElement) {
|
|
||||||
// int toIndex = findIndex(toElement);
|
|
||||||
// if(toIndex == -1) throw new NoSuchElementException();
|
|
||||||
// return new SubSet(0, toIndex+1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public SORTED_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) {
|
|
||||||
// int fromIndex = findIndex(fromElement);
|
|
||||||
// if(fromIndex == -1) throw new NoSuchElementException();
|
|
||||||
// return new SubSet(fromIndex, size - fromIndex);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int size() {
|
|
||||||
// return length;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#if !TYPE_OBJECT
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
|
||||||
// if(a == null || a.length < size()) return Arrays.copyOfRange(data, offset, end());
|
|
||||||
// System.arraycopy(data, offset, a, 0, size());
|
|
||||||
// return a;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#endif
|
|
||||||
// @Override
|
|
||||||
// @Deprecated
|
|
||||||
// public Object[] toArray() {
|
|
||||||
// Object[] obj = new Object[size()];
|
|
||||||
// for(int i = 0;i<size();i++)
|
|
||||||
// obj[i] = KEY_TO_OBJ(data[offset+i]);
|
|
||||||
// return obj;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// @Primitive
|
|
||||||
// public <E> E[] toArray(E[] a) {
|
|
||||||
// if(a == null) a = (E[])new Object[size()];
|
|
||||||
// else if(a.length < size()) a = (E[])ObjectArrays.newArray(a.getClass().getComponentType(), size());
|
|
||||||
// for(int i = 0;i<size();i++)
|
|
||||||
// a[i] = (E)KEY_TO_OBJ(data[offset+i]);
|
|
||||||
// return a;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#if !TYPE_OBJECT
|
|
||||||
// protected int findIndex(KEY_TYPE o) {
|
|
||||||
// for(int i = length-1;i>=0;i--)
|
|
||||||
// if(KEY_EQUALS(data[offset+i], o)) return i + offset;
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//#endif
|
|
||||||
// protected int findIndex(Object o) {
|
|
||||||
// for(int i = length-1;i>=0;i--)
|
|
||||||
// if(EQUALS_KEY_TYPE(data[offset+i], o)) return i + offset;
|
|
||||||
// return -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
|
||||||
// int index;
|
|
||||||
// int lastReturned = -1;
|
|
||||||
//
|
|
||||||
// public SetIterator(int index) {
|
|
||||||
// this.index = index;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean hasNext() {
|
|
||||||
// return index < size();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE NEXT() {
|
|
||||||
// if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
// lastReturned = index;
|
|
||||||
// return data[index++];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public boolean hasPrevious() {
|
|
||||||
// return index > 0;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public KEY_TYPE PREVIOUS() {
|
|
||||||
// if(!hasPrevious()) throw new NoSuchElementException();
|
|
||||||
// lastReturned = index;
|
|
||||||
// return data[index--];
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int nextIndex() {
|
|
||||||
// return index;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public int previousIndex() {
|
|
||||||
// return index-1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void remove() {
|
|
||||||
// if(lastReturned == -1)
|
|
||||||
// throw new IllegalStateException();
|
|
||||||
// SubSet.this.remove(data[lastReturned]);
|
|
||||||
// if(lastReturned < index)
|
|
||||||
// index--;
|
|
||||||
// lastReturned = -1;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #if TYPE_OBJECT
|
|
||||||
// @Override
|
|
||||||
// public void set(Object e) { throw new UnsupportedOperationException(); }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void add(Object e) { throw new UnsupportedOperationException(); }
|
|
||||||
//
|
|
||||||
// #else
|
|
||||||
// @Override
|
|
||||||
// public void set(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
//
|
|
||||||
// #endif
|
|
||||||
// @Override
|
|
||||||
// public int skip(int amount) {
|
|
||||||
// if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
// int steps = Math.min(amount, (size() - 1) - index);
|
|
||||||
// index += steps;
|
|
||||||
// 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;
|
|
||||||
// return steps;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
@@ -924,8 +584,8 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = index;
|
--index;
|
||||||
return data[index--];
|
return data[(lastReturned = index)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -964,8 +624,9 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
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, (size() - 1) - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,6 +635,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
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);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-4
@@ -502,6 +502,30 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(next != -1 && result != amount) {
|
||||||
|
current = previous = next;
|
||||||
|
next = (int)(links[current]);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(previous != -1 && result != amount) {
|
||||||
|
current = next = previous;
|
||||||
|
previous = (int)(links[current] >> 32);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return next != -1;
|
return next != -1;
|
||||||
@@ -530,9 +554,8 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
current = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
next = current;
|
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -540,9 +563,8 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
current = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
|
||||||
if(index >= 0) index++;
|
if(index >= 0) index++;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-12
@@ -123,7 +123,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
* @throws IllegalStateException if offset and length causes to step outside of the arrays range
|
* @throws IllegalStateException if offset and length causes to step outside of the arrays range
|
||||||
*/
|
*/
|
||||||
public LINKED_CUSTOM_HASH_SET(KEY_TYPE[] array, int offset, int length, float loadFactor, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
public LINKED_CUSTOM_HASH_SET(KEY_TYPE[] array, int offset, int length, float loadFactor, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
||||||
this(length < 0 ? 0 : length, strategy);
|
this(length, strategy);
|
||||||
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
||||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||||
}
|
}
|
||||||
@@ -237,6 +237,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
|
moveToFirstIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(o)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(o)) & mask;
|
||||||
@@ -249,6 +250,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
keys[pos] = o;
|
keys[pos] = o;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
|
moveToFirstIndex(pos);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return true;
|
return true;
|
||||||
@@ -282,7 +284,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE o) {
|
public boolean moveToFirst(KEY_TYPE o) {
|
||||||
if(strategy.equals(FIRST_KEY(), o)) return false;
|
if(isEmpty() || strategy.equals(FIRST_KEY(), o)) return false;
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -304,7 +306,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE o) {
|
public boolean moveToLast(KEY_TYPE o) {
|
||||||
if(strategy.equals(LAST_KEY(), o)) return false;
|
if(isEmpty() || strategy.equals(LAST_KEY(), o)) return false;
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -370,8 +372,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
public KEY_TYPE POLL_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
firstIndex = (int)links[pos];
|
onNodeRemoved(pos);
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
||||||
@@ -393,8 +394,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
public KEY_TYPE POLL_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
lastIndex = (int)(links[pos] >>> 32);
|
onNodeRemoved(pos);
|
||||||
if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(result, EMPTY_KEY_VALUE)) {
|
||||||
@@ -508,7 +508,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -715,6 +715,30 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
return previous != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(next != -1 && result != amount) {
|
||||||
|
current = previous = next;
|
||||||
|
next = (int)(links[current]);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(previous != -1 && result != amount) {
|
||||||
|
current = next = previous;
|
||||||
|
previous = (int)(links[current] >> 32);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
@@ -773,9 +797,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
current = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
next = current;
|
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -783,9 +806,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
current = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
|
||||||
if(index >= 0) index++;
|
if(index >= 0) index++;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-12
@@ -110,7 +110,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
* @throws IllegalStateException if offset and length causes to step outside of the arrays range
|
* @throws IllegalStateException if offset and length causes to step outside of the arrays range
|
||||||
*/
|
*/
|
||||||
public LINKED_HASH_SET(KEY_TYPE[] array, int offset, int length, float loadFactor) {
|
public LINKED_HASH_SET(KEY_TYPE[] array, int offset, int length, float loadFactor) {
|
||||||
this(length < 0 ? 0 : length);
|
this(length);
|
||||||
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
||||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||||
}
|
}
|
||||||
@@ -208,6 +208,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
|
moveToFirstIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||||
@@ -220,6 +221,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
keys[pos] = o;
|
keys[pos] = o;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
|
moveToFirstIndex(pos);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return true;
|
return true;
|
||||||
@@ -253,7 +255,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE o) {
|
public boolean moveToFirst(KEY_TYPE o) {
|
||||||
if(KEY_EQUALS(FIRST_KEY(), o)) return false;
|
if(isEmpty() || KEY_EQUALS(FIRST_KEY(), o)) return false;
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -275,7 +277,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE o) {
|
public boolean moveToLast(KEY_TYPE o) {
|
||||||
if(KEY_EQUALS(LAST_KEY(), o)) return false;
|
if(isEmpty() || KEY_EQUALS(LAST_KEY(), o)) return false;
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -341,8 +343,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE POLL_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
firstIndex = (int)links[pos];
|
onNodeRemoved(pos);
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(KEY_EQUALS_NULL(result)) {
|
if(KEY_EQUALS_NULL(result)) {
|
||||||
@@ -364,8 +365,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE POLL_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
lastIndex = (int)(links[pos] >>> 32);
|
onNodeRemoved(pos);
|
||||||
if(0 <= lastIndex) links[lastIndex] |= 0xFFFFFFFFL;
|
|
||||||
KEY_TYPE result = keys[pos];
|
KEY_TYPE result = keys[pos];
|
||||||
size--;
|
size--;
|
||||||
if(KEY_EQUALS_NULL(result)) {
|
if(KEY_EQUALS_NULL(result)) {
|
||||||
@@ -599,7 +599,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -676,6 +676,30 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int skip(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(next != -1 && result != amount) {
|
||||||
|
current = previous = next;
|
||||||
|
next = (int)(links[current]);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
int result = 0;
|
||||||
|
while(previous != -1 && result != amount) {
|
||||||
|
current = next = previous;
|
||||||
|
previous = (int)(links[current] >> 32);
|
||||||
|
result++;
|
||||||
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return next != -1;
|
return next != -1;
|
||||||
@@ -744,9 +768,8 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
current = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
next = current;
|
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -754,9 +777,8 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
current = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
|
||||||
if(index >= 0) index++;
|
if(index >= 0) index++;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -373,10 +373,10 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean trim(int size) {
|
public boolean trim(int size) {
|
||||||
int newSize = HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(newSize >= nullIndex || size >= Math.min((int)Math.ceil(newSize * loadFactor), newSize - 1)) return false;
|
if(request >= nullIndex || this.size >= Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
||||||
try {
|
try {
|
||||||
rehash(newSize);
|
rehash(request);
|
||||||
}
|
}
|
||||||
catch(OutOfMemoryError e) { return false; }
|
catch(OutOfMemoryError e) { return false; }
|
||||||
return true;
|
return true;
|
||||||
@@ -385,7 +385,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -589,7 +589,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
state = keys[nullIndex];
|
state = keys[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
|
|||||||
+5
-5
@@ -340,10 +340,10 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean trim(int size) {
|
public boolean trim(int size) {
|
||||||
int newSize = HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(newSize >= nullIndex || size >= Math.min((int)Math.ceil(newSize * loadFactor), newSize - 1)) return false;
|
if(request >= nullIndex || this.size >= Math.min((int)Math.ceil(request * loadFactor), request - 1)) return false;
|
||||||
try {
|
try {
|
||||||
rehash(newSize);
|
rehash(request);
|
||||||
}
|
}
|
||||||
catch(OutOfMemoryError e) { return false; }
|
catch(OutOfMemoryError e) { return false; }
|
||||||
return true;
|
return true;
|
||||||
@@ -352,7 +352,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
int request = Math.max(minCapacity, HashUtil.nextPowerOfTwo((int)Math.ceil(size / loadFactor)));
|
||||||
if(request >= size) {
|
if(request >= nullIndex) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -452,7 +452,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
state = keys[nullIndex];
|
state = keys[nullIndex];
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NULL(keys[i])) continue;
|
if(KEY_EQUALS_NULL(keys[i])) continue;
|
||||||
if(empty) {
|
if(empty) {
|
||||||
empty = false;
|
empty = false;
|
||||||
|
|||||||
+41
-27
@@ -949,15 +949,11 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMaxValue() { return super.getDefaultMinValue(); }
|
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMinValue() { return super.getDefaultMaxValue(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
||||||
if(!inRange(fromElement, fromInclusive)) throw new IllegalArgumentException("fromElement out of range");
|
if(!inRange(fromElement, fromInclusive)) throw new IllegalArgumentException("fromElement out of range");
|
||||||
if(!inRange(toElement, toInclusive)) throw new IllegalArgumentException("toElement out of range");
|
if(!inRange(toElement, toInclusive)) throw new IllegalArgumentException("toElement out of range");
|
||||||
return new DescendingSubSetBRACES(set, false, fromElement, fromInclusive, false, toElement, toInclusive);
|
return new DescendingSubSetBRACES(set, false, toElement, toInclusive, false, fromElement, fromInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1034,21 +1030,15 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { set.setDefaultMaxValue(value); }
|
public void setDefaultMaxValue(KEY_TYPE value) { set.setDefaultMaxValue(value); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE getDefaultMaxValue() { return set.getDefaultMaxValue(); }
|
public KEY_TYPE getDefaultMaxValue() { return set.getDefaultMaxValue(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMinValue(KEY_TYPE value) { set.setDefaultMinValue(value); }
|
public void setDefaultMinValue(KEY_TYPE value) { set.setDefaultMinValue(value); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE getDefaultMinValue() { return set.getDefaultMinValue(); }
|
public KEY_TYPE getDefaultMinValue() { return set.getDefaultMinValue(); }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
public KEY_TYPE getDefaultMaxValue() { return null; }
|
public KEY_TYPE getDefaultMaxValue() { return null; }
|
||||||
|
|
||||||
public KEY_TYPE getDefaultMinValue() { return null; }
|
public KEY_TYPE getDefaultMinValue() { return null; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
@@ -1359,6 +1349,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
@@ -1368,6 +1359,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public AscendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
public AscendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.previous();
|
||||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
@@ -1383,6 +1375,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.next();
|
next = next.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
@@ -1391,15 +1384,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.previous();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1407,6 +1401,8 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(previous == lastReturned) previous = previous.previous();
|
||||||
|
if(next == lastReturned) next = next.next();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
set.removeNode(lastReturned);
|
set.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1417,6 +1413,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
boolean unboundForwardFence;
|
boolean unboundForwardFence;
|
||||||
boolean unboundBackwardFence;
|
boolean unboundBackwardFence;
|
||||||
@@ -1426,6 +1423,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public DescendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
public DescendingSubSetIterator(Entry KEY_GENERIC_TYPE first, Entry KEY_GENERIC_TYPE forwardFence, Entry KEY_GENERIC_TYPE backwardFence)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.next();
|
||||||
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
this.forwardFence = forwardFence == null ? EMPTY_KEY_VALUE : forwardFence.key;
|
||||||
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
this.backwardFence = backwardFence == null ? EMPTY_KEY_VALUE : backwardFence.key;
|
||||||
unboundForwardFence = forwardFence == null;
|
unboundForwardFence = forwardFence == null;
|
||||||
@@ -1441,6 +1439,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.previous();
|
next = next.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
@@ -1449,15 +1448,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null && (unboundBackwardFence || next.key != backwardFence);
|
return previous != null && (unboundBackwardFence || previous.key != backwardFence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.next();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1465,6 +1465,8 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(previous == lastReturned) previous = previous.next();
|
||||||
|
if(next == lastReturned) next = next.previous();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
set.removeNode(lastReturned);
|
set.removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1476,11 +1478,13 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
|
|
||||||
public AscendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
public AscendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1492,6 +1496,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.next();
|
next = next.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
@@ -1500,15 +1505,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.previous();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1516,6 +1522,8 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(lastReturned == previous) previous = previous.previous();
|
||||||
|
if(lastReturned == next) next = next.next();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
@@ -1526,11 +1534,13 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE lastReturned;
|
Entry KEY_GENERIC_TYPE lastReturned;
|
||||||
Entry KEY_GENERIC_TYPE next;
|
Entry KEY_GENERIC_TYPE next;
|
||||||
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
boolean forwards = false;
|
boolean forwards = false;
|
||||||
|
|
||||||
public DescendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
public DescendingSetIterator(Entry KEY_GENERIC_TYPE first)
|
||||||
{
|
{
|
||||||
next = first;
|
next = first;
|
||||||
|
previous = first == null ? null : first.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1542,6 +1552,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = next;
|
||||||
|
previous = next;
|
||||||
KEY_TYPE result = next.key;
|
KEY_TYPE result = next.key;
|
||||||
next = next.previous();
|
next = next.previous();
|
||||||
forwards = false;
|
forwards = false;
|
||||||
@@ -1550,15 +1561,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return next != null;
|
return previous != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
lastReturned = next;
|
lastReturned = previous;
|
||||||
KEY_TYPE result = next.key;
|
next = previous;
|
||||||
next = next.next();
|
KEY_TYPE result = previous.key;
|
||||||
|
previous = previous.next();
|
||||||
forwards = true;
|
forwards = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1566,6 +1578,8 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public void remove() {
|
public void remove() {
|
||||||
if(lastReturned == null) throw new IllegalStateException();
|
if(lastReturned == null) throw new IllegalStateException();
|
||||||
|
if(lastReturned == previous) previous = previous.next();
|
||||||
|
if(lastReturned == next) next = next.previous();
|
||||||
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
if(forwards && lastReturned.needsSuccessor()) next = lastReturned;
|
||||||
removeNode(lastReturned);
|
removeNode(lastReturned);
|
||||||
lastReturned = null;
|
lastReturned = null;
|
||||||
|
|||||||
@@ -348,9 +348,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
|
* @return input array.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] stableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
stableSort(array, 0, array.length, comp);
|
stableSort(array, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -386,9 +388,11 @@ public class ARRAYS
|
|||||||
* Stable sort referres to Mergesort or Insertionsort
|
* Stable sort referres to Mergesort or Insertionsort
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void stableSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] stableSort(KEY_TYPE[] array) {
|
||||||
stableSort(array, 0, array.length);
|
stableSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -423,9 +427,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] unstableSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
unstableSort(array, 0, array.length, comp);
|
unstableSort(array, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -461,9 +467,11 @@ public class ARRAYS
|
|||||||
* Unstable sort referres to QuickSort or SelectionSort
|
* Unstable sort referres to QuickSort or SelectionSort
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void unstableSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] unstableSort(KEY_TYPE[] array) {
|
||||||
unstableSort(array, 0, array.length);
|
unstableSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -496,9 +504,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] insertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
insertionSort(array, 0, array.length, comp);
|
insertionSort(array, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -535,9 +545,11 @@ public class ARRAYS
|
|||||||
* Sorts an array according to the natural ascending order using InsertionSort,
|
* Sorts an array according to the natural ascending order using InsertionSort,
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void insertionSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] insertionSort(KEY_TYPE[] array) {
|
||||||
insertionSort(array, 0, array.length);
|
insertionSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -573,9 +585,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] selectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
selectionSort(array, 0, array.length, comp);
|
selectionSort(array, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -617,9 +631,11 @@ public class ARRAYS
|
|||||||
* Sorts an array according to the natural ascending order using Selection Sort,
|
* Sorts an array according to the natural ascending order using Selection Sort,
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void selectionSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] selectionSort(KEY_TYPE[] array) {
|
||||||
selectionSort(array, 0, array.length);
|
selectionSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -661,9 +677,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] mergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
mergeSort(array, null, 0, array.length, comp);
|
mergeSort(array, null, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -713,9 +731,11 @@ public class ARRAYS
|
|||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void mergeSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] mergeSort(KEY_TYPE[] array) {
|
||||||
mergeSort(array, null, 0, array.length);
|
mergeSort(array, null, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -922,9 +942,11 @@ public class ARRAYS
|
|||||||
* @author Speiger
|
* @author Speiger
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void memFreeMergeSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] memFreeMergeSort(KEY_TYPE[] array) {
|
||||||
memFreeMergeSort(array, 0, array.length);
|
memFreeMergeSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1099,9 +1121,11 @@ public class ARRAYS
|
|||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @param comp the Comparator that decides the sorting order
|
* @param comp the Comparator that decides the sorting order
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] quickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
quickSort(array, 0, array.length, comp);
|
quickSort(array, 0, array.length, comp);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1157,9 +1181,11 @@ public class ARRAYS
|
|||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
|
* @return input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES void quickSort(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] quickSort(KEY_TYPE[] array) {
|
||||||
quickSort(array, 0, array.length);
|
quickSort(array, 0, array.length);
|
||||||
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+20
@@ -113,6 +113,16 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
||||||
|
* @param values that should be wrapped
|
||||||
|
* @Type(T)
|
||||||
|
* @return a AsyncBuilder with the values wrapped
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ASYNC_BUILDER KEY_GENERIC_TYPE of(KEY_TYPE...values) {
|
||||||
|
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the elements to something else
|
* Maps the elements to something else
|
||||||
* @param mapper the mapping function
|
* @param mapper the mapping function
|
||||||
@@ -163,6 +173,16 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repeats the elements inside of the Iterable
|
||||||
|
* @param repeats the amount of times the elements should be repeated
|
||||||
|
* @return self with a repeater applied
|
||||||
|
*/
|
||||||
|
public ASYNC_BUILDER KEY_GENERIC_TYPE repeat(int repeats) {
|
||||||
|
iterable = ITERABLES.repeat(iterable, repeats);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limits how many elements are inside of the Iterable
|
* Limits how many elements are inside of the Iterable
|
||||||
* @param limit how many elements should max be iterated through
|
* @param limit how many elements should max be iterated through
|
||||||
|
|||||||
+24
-7
@@ -186,7 +186,10 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
|
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) { synchronized(mutex) { return c.equals(obj); } }
|
public boolean equals(Object obj) {
|
||||||
|
if(obj == this) return true;
|
||||||
|
synchronized(mutex) { return c.equals(obj); }
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() { synchronized(mutex) { return c.toString(); } }
|
public String toString() { synchronized(mutex) { return c.toString(); } }
|
||||||
@Override
|
@Override
|
||||||
@@ -308,7 +311,7 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() { return c.hashCode(); }
|
public int hashCode() { return c.hashCode(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) { return c.equals(obj); }
|
public boolean equals(Object obj) { return obj == this || c.equals(obj); }
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return c.toString(); }
|
public String toString() { return c.toString(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -350,7 +353,7 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { return false; }
|
public boolean contains(KEY_TYPE o) { return false; }
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return c.isEmpty(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
||||||
#else
|
#else
|
||||||
@@ -362,7 +365,7 @@ public class COLLECTIONS
|
|||||||
public boolean containsAny(Collection<?> c) { return false; }
|
public boolean containsAny(Collection<?> c) { return false; }
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAll(Collection<?> c) { return false; }
|
public boolean containsAll(Collection<?> c) { return c.isEmpty(); }
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return 0; }
|
public int hashCode() { return 0; }
|
||||||
|
|
||||||
@@ -401,14 +404,28 @@ public class COLLECTIONS
|
|||||||
public Object[] toArray() { return ObjectArrays.EMPTY_ARRAY; }
|
public Object[] toArray() { return ObjectArrays.EMPTY_ARRAY; }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public <T> T[] toArray(T[] a) { return a; }
|
public <T> T[] toArray(T[] a) {
|
||||||
|
if(a != null && a.length > 0)
|
||||||
|
a[0] = null;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY() { return ARRAYS.EMPTY_ARRAY; }
|
public KEY_TYPE[] TO_ARRAY() { return ARRAYS.EMPTY_ARRAY; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) { return a; }
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||||
|
if(a != null && a.length > 0)
|
||||||
|
a[0] = EMPTY_KEY_VALUE;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public <E> E[] toArray(E[] a) { return a; }
|
public <E> E[] toArray(E[] a) {
|
||||||
|
if(a != null && a.length > 0)
|
||||||
|
a[0] = EMPTY_KEY_VALUE;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.empty(); }
|
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.empty(); }
|
||||||
|
|||||||
@@ -147,6 +147,28 @@ public class ITERABLES
|
|||||||
return new DistinctIterableBRACES(wrap(iterable));
|
return new DistinctIterableBRACES(wrap(iterable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that repeats the Iterable a specific amount of times
|
||||||
|
* @param iterable that should be repeated
|
||||||
|
* @param repeats the amount of times the iterable should be repeated
|
||||||
|
* @Type(T)
|
||||||
|
* @return a repeating iterable
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERABLE KEY_GENERIC_TYPE repeat(ITERABLE KEY_GENERIC_TYPE iterable, int repeats) {
|
||||||
|
return new RepeatingIterableBRACES(iterable, repeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that repeats the Iterable a specific amount of times from a Java Iterable
|
||||||
|
* @param iterable that should be repeated
|
||||||
|
* @param repeats the amount of times the iterable should be repeated
|
||||||
|
* @Type(T)
|
||||||
|
* @return a repeating iterable
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERABLE KEY_GENERIC_TYPE repeat(Iterable<? extends CLASS_TYPE> iterable, int repeats) {
|
||||||
|
return new RepeatingIterableBRACES(wrap(iterable), repeats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that hard limits the Iterable to a specific size
|
* A Helper function that hard limits the Iterable to a specific size
|
||||||
* @param iterable that should be limited
|
* @param iterable that should be limited
|
||||||
@@ -320,6 +342,42 @@ public class ITERABLES
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class RepeatingIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
ITERABLE KEY_GENERIC_TYPE iterable;
|
||||||
|
int repeats;
|
||||||
|
|
||||||
|
public RepeatingIterable(ITERABLE KEY_GENERIC_TYPE iterable, int repeats) {
|
||||||
|
this.iterable = iterable;
|
||||||
|
this.repeats = repeats;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
|
return ITERATORS.repeat(iterable.iterator(), repeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public void forEach(CONSUMER action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
iterable.forEach(action.andThen(list::add));
|
||||||
|
for(int i = 0;i<repeats;i++)
|
||||||
|
list.forEach(action);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
iterable.forEach(T -> {action.accept(T); list.add(T);});
|
||||||
|
for(int i = 0;i<repeats;i++)
|
||||||
|
list.forEach(action);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
private static class FilteredIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
private static class FilteredIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERABLE KEY_GENERIC_TYPE iterable;
|
ITERABLE KEY_GENERIC_TYPE iterable;
|
||||||
|
|||||||
+67
-12
@@ -34,7 +34,7 @@ public class ITERATORS
|
|||||||
/**
|
/**
|
||||||
* Empty Iterator Reference
|
* Empty Iterator Reference
|
||||||
*/
|
*/
|
||||||
public static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
private static final EmptyIterator NO_GENERIC_TYPE EMPTY = new EmptyIteratorBRACES();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Immutable EmptyIterator instance that is automatically casted.
|
* Returns a Immutable EmptyIterator instance that is automatically casted.
|
||||||
@@ -215,6 +215,28 @@ public class ITERATORS
|
|||||||
return new DistinctIteratorBRACES(wrap(iterator));
|
return new DistinctIteratorBRACES(wrap(iterator));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that repeats the Iterator a specific amount of times
|
||||||
|
* @param iterator that should be repeated
|
||||||
|
* @param repeats the amount of times the iterator should be repeated
|
||||||
|
* @Type(T)
|
||||||
|
* @return a repeating iterator
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE repeat(ITERATOR KEY_GENERIC_TYPE iterator, int repeats) {
|
||||||
|
return new RepeatingIteratorBRACES(iterator, repeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that repeats the Iterator a specific amount of times from a Java Iterator
|
||||||
|
* @param iterator that should be repeated
|
||||||
|
* @param repeats the amount of times the iterator should be repeated
|
||||||
|
* @Type(T)
|
||||||
|
* @return a repeating iterator
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE repeat(Iterator<? extends CLASS_TYPE> iterator, int repeats) {
|
||||||
|
return new RepeatingIteratorBRACES(wrap(iterator), repeats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that hard limits the Iterator to a specific size
|
* A Helper function that hard limits the Iterator to a specific size
|
||||||
* @param iterator that should be limited
|
* @param iterator that should be limited
|
||||||
@@ -299,7 +321,7 @@ public class ITERATORS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return a Iterator that is wrapping a array.
|
* @return a Iterator that is wrapping a array.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) {
|
public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE... a) {
|
||||||
return wrap(a, 0, a.length);
|
return wrap(a, 0, a.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,7 +757,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
return EMPTY_KEY_VALUE;
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -745,7 +767,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
return EMPTY_KEY_VALUE;
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -755,7 +777,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -787,6 +809,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return a[from++];
|
return a[from++];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -854,7 +877,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T next() {
|
public T next() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
T result = last.next();
|
T result = last.next();
|
||||||
foundNext = false;
|
foundNext = false;
|
||||||
return result;
|
return result;
|
||||||
@@ -890,13 +913,45 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T next() {
|
public T next() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
T result = last.next();
|
T result = last.next();
|
||||||
foundNext = false;
|
foundNext = false;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
final int repeats;
|
||||||
|
int index = 0;
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
|
||||||
|
public RepeatingIterator(ITERATOR KEY_GENERIC_TYPE iter, int repeat) {
|
||||||
|
this.iter = iter;
|
||||||
|
this.repeats = repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
if(iter.hasNext()) return true;
|
||||||
|
if(index < repeats) {
|
||||||
|
index++;
|
||||||
|
iter = list.iterator();
|
||||||
|
return iter.hasNext();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
KEY_TYPE value = iter.NEXT();
|
||||||
|
if(index == 0) list.add(value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class SortedIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
private static class SortedIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iterator;
|
ITERATOR KEY_GENERIC_TYPE iterator;
|
||||||
@@ -921,7 +976,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
return sortedElements.GET_KEY(index++);
|
return sortedElements.GET_KEY(index++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -971,7 +1026,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
foundNext = false;
|
foundNext = false;
|
||||||
return lastFound;
|
return lastFound;
|
||||||
}
|
}
|
||||||
@@ -1008,7 +1063,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
foundNext = false;
|
foundNext = false;
|
||||||
return lastFound;
|
return lastFound;
|
||||||
}
|
}
|
||||||
@@ -1031,7 +1086,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
limit--;
|
limit--;
|
||||||
return iterator.NEXT();
|
return iterator.NEXT();
|
||||||
}
|
}
|
||||||
@@ -1054,7 +1109,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new IllegalStateException("End of Iterator");
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
KEY_TYPE result = iterator.NEXT();
|
KEY_TYPE result = iterator.NEXT();
|
||||||
action.accept(result);
|
action.accept(result);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.RandomAccess;
|
import java.util.RandomAccess;
|
||||||
@@ -27,7 +28,7 @@ public class LISTS
|
|||||||
/**
|
/**
|
||||||
* Empty List reference
|
* Empty List reference
|
||||||
*/
|
*/
|
||||||
public static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
private static final EmptyList NO_GENERIC_TYPE EMPTY = new EmptyListBRACES();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Immutable EmptyList instance that is automatically casted.
|
* Returns a Immutable EmptyList instance that is automatically casted.
|
||||||
@@ -356,7 +357,7 @@ public class LISTS
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) { synchronized(mutex) { addElements(from, a, offset, length); } }
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) { synchronized(mutex) { l.addElements(from, a, offset, length); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) { synchronized(mutex) { return l.getElements(from, a, offset, length); } }
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) { synchronized(mutex) { return l.getElements(from, a, offset, length); } }
|
||||||
@@ -601,6 +602,16 @@ public class LISTS
|
|||||||
return ITERATORS.empty();
|
return ITERATORS.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() { return 1; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if(o == this) return true;
|
||||||
|
if(!(o instanceof List)) return false;
|
||||||
|
return ((List<?>)o).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) { throw new UnsupportedOperationException(); }
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Set;
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
||||||
@@ -34,7 +36,7 @@ public class SETS
|
|||||||
/**
|
/**
|
||||||
* Empty Set Variable
|
* Empty Set Variable
|
||||||
*/
|
*/
|
||||||
public static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
private static final SET NO_GENERIC_TYPE EMPTY = new EmptySetBRACES();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EmptySet getter
|
* EmptySet getter
|
||||||
@@ -216,10 +218,10 @@ public class SETS
|
|||||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||||
boolean next = true;
|
boolean next = true;
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() { return next = false; }
|
public boolean hasNext() { return next; }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!next) throw new IllegalStateException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
next = false;
|
next = false;
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
@@ -241,6 +243,13 @@ public class SETS
|
|||||||
@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
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if(o == this) return true;
|
||||||
|
if(!(o instanceof Set)) return false;
|
||||||
|
return ((Set<?>)o).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
||||||
}
|
}
|
||||||
@@ -258,25 +267,38 @@ public class SETS
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { return n.contains(o); }
|
public boolean contains(KEY_TYPE o) { return n.contains(o); }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE lower(CLASS_TYPE e) { return n.lower(e); }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE floor(CLASS_TYPE e) { return n.floor(e); }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE ceiling(CLASS_TYPE e) { return n.ceiling(e); }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE higher(CLASS_TYPE e) { return n.higher(e); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) { return n.contains(o); }
|
public boolean contains(Object o) { return n.contains(o); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE lower(KEY_TYPE e) { return n.lower(e); }
|
public KEY_TYPE lower(KEY_TYPE e) { return n.lower(e); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE floor(KEY_TYPE e) { return n.floor(e); }
|
public KEY_TYPE floor(KEY_TYPE e) { return n.floor(e); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ceiling(KEY_TYPE e) { return n.ceiling(e); }
|
public KEY_TYPE ceiling(KEY_TYPE e) { return n.ceiling(e); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE higher(KEY_TYPE e) { return n.higher(e); }
|
public KEY_TYPE higher(KEY_TYPE e) { return n.higher(e); }
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE pollFirst() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public void setDefaultMaxValue(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -291,7 +313,7 @@ public class SETS
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE copy() { return n.copy(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { return SETS.unmodifiable(n.subSet(fromElement, fromInclusive, toElement, toInclusive)); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { return SETS.unmodifiable(n.subSet(fromElement, fromInclusive, toElement, toInclusive)); }
|
||||||
@@ -454,27 +476,33 @@ public class SETS
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { synchronized(mutex) { return n.contains(o); } }
|
public boolean contains(KEY_TYPE o) { synchronized(mutex) { return n.contains(o); } }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE lower(CLASS_TYPE e) { synchronized(mutex) { return n.lower(e); } }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE floor(CLASS_TYPE e) { synchronized(mutex) { return n.floor(e); } }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE ceiling(CLASS_TYPE e) { synchronized(mutex) { return n.ceiling(e); } }
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CLASS_TYPE higher(CLASS_TYPE e) { synchronized(mutex) { return n.higher(e); } }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE lower(KEY_TYPE e) { synchronized(mutex) { return n.lower(e); } }
|
public KEY_TYPE lower(KEY_TYPE e) { synchronized(mutex) { return n.lower(e); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE floor(KEY_TYPE e) { synchronized(mutex) { return n.floor(e); } }
|
public KEY_TYPE floor(KEY_TYPE e) { synchronized(mutex) { return n.floor(e); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ceiling(KEY_TYPE e) { synchronized(mutex) { return n.ceiling(e); } }
|
public KEY_TYPE ceiling(KEY_TYPE e) { synchronized(mutex) { return n.ceiling(e); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE higher(KEY_TYPE e) { synchronized(mutex) { return n.higher(e); } }
|
public KEY_TYPE higher(KEY_TYPE e) { synchronized(mutex) { return n.higher(e); } }
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE e) { synchronized(mutex) { n.setDefaultMaxValue(e); } }
|
public void setDefaultMaxValue(KEY_TYPE e) { synchronized(mutex) { n.setDefaultMaxValue(e); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE getDefaultMaxValue() { synchronized(mutex) { return n.getDefaultMaxValue(); } }
|
public KEY_TYPE getDefaultMaxValue() { synchronized(mutex) { return n.getDefaultMaxValue(); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMinValue(KEY_TYPE e) { synchronized(mutex) { n.setDefaultMinValue(e); } }
|
public void setDefaultMinValue(KEY_TYPE e) { synchronized(mutex) { n.setDefaultMinValue(e); } }
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -1,6 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
||||||
@@ -329,7 +330,11 @@ public class SPLIT_ITERATORS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() { return array[index++]; }
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
return array[index++];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() { return index < fence; }
|
public boolean hasNext() { return index < fence; }
|
||||||
}
|
}
|
||||||
|
|||||||
+157
-34
@@ -19,8 +19,11 @@ import speiger.src.collections.objects.collections.ObjectIterable;
|
|||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||||
import speiger.src.collections.objects.utils.ObjectSets;
|
import speiger.src.collections.objects.utils.ObjectSets;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
@@ -34,6 +37,8 @@ import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
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.ORDERED_SET;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
@@ -42,6 +47,7 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS;
|
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_COLLECTIONS;
|
||||||
#if !SAME_TYPE && !VALUE_OBJECT
|
#if !SAME_TYPE && !VALUE_OBJECT
|
||||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS;
|
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS;
|
||||||
@@ -57,7 +63,21 @@ public class MAPS
|
|||||||
/**
|
/**
|
||||||
* Empty Map Variable
|
* Empty Map Variable
|
||||||
*/
|
*/
|
||||||
public static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
private static final MAP NO_KV_GENERIC_TYPE EMPTY = new EmptyMapKV_BRACES();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empty Map getter function that autocasts to the desired Key and Value
|
||||||
|
* @Type(T)
|
||||||
|
* @ValueType(V)
|
||||||
|
* @return empty map of desired type
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE empty() {
|
||||||
|
#if TYPE_OBJECT || VALUE_OBJECT
|
||||||
|
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
||||||
|
#else
|
||||||
|
return EMPTY;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
@@ -104,19 +124,6 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
/**
|
|
||||||
* Empty Map getter function that autocasts to the desired Key and Value
|
|
||||||
* @Type(T)
|
|
||||||
* @ValueType(V)
|
|
||||||
* @return empty map of desired type
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE empty() {
|
|
||||||
#if TYPE_OBJECT || VALUE_OBJECT
|
|
||||||
return (MAP KEY_VALUE_GENERIC_TYPE)EMPTY;
|
|
||||||
#else
|
|
||||||
return EMPTY;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function that creates a Helper wrapper to synchronize access into the map.
|
* Helper function that creates a Helper wrapper to synchronize access into the map.
|
||||||
@@ -253,7 +260,7 @@ public class MAPS
|
|||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
* @return a Unmodifyable Entry
|
* @return a Unmodifyable Entry
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifiable(MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { return entry instanceof UnmodifyableEntry ? entry : new UnmodifyableEntryKV_BRACES(entry); }
|
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifiable(MAP.Entry KEY_VALUE_GENERIC_TYPE entry) { return entry instanceof UnmodifyableEntry ? entry : (entry == null ? null : new UnmodifyableEntryKV_BRACES(entry)); }
|
||||||
/**
|
/**
|
||||||
* A Helper function that creates a Unmodifyable Entry
|
* A Helper function that creates a Unmodifyable Entry
|
||||||
* @param entry the Entry that should be made unmodifiable
|
* @param entry the Entry that should be made unmodifiable
|
||||||
@@ -261,7 +268,7 @@ public class MAPS
|
|||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
* @return a Unmodifyable Entry
|
* @return a Unmodifyable Entry
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifiable(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) { return entry instanceof UnmodifyableEntry ? (UnmodifyableEntry KEY_VALUE_GENERIC_TYPE)entry : new UnmodifyableEntryKV_BRACES(entry); }
|
public static GENERIC_KEY_VALUE_BRACES MAP.Entry KEY_VALUE_GENERIC_TYPE unmodifiable(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) { return entry instanceof UnmodifyableEntry ? (UnmodifyableEntry KEY_VALUE_GENERIC_TYPE)entry : (entry == null ? null : new UnmodifyableEntryKV_BRACES(entry)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Singleton map from the provided values.
|
* Creates a Singleton map from the provided values.
|
||||||
@@ -315,6 +322,18 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public SingletonMap KEY_VALUE_GENERIC_TYPE copy() { return new SingletonMapKV_BRACES(key, value); }
|
public SingletonMap KEY_VALUE_GENERIC_TYPE copy() { return new SingletonMapKV_BRACES(key, value); }
|
||||||
@Override
|
@Override
|
||||||
@@ -363,8 +382,20 @@ public class MAPS
|
|||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return getDefaultReturnValue(); }
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return getDefaultReturnValue(); }
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EMPTY_VALUE; }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return defaultValue; }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() { return SETS.empty(); }
|
public SET KEY_GENERIC_TYPE keySet() { return SETS.empty(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -408,10 +439,12 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap() { return MAPS.synchronize(map.descendingMap()); }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap() { return MAPS.unmodifiable(map.descendingMap()); }
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE navigableKeySet() { return SETS.unmodifiable(map.navigableKeySet()); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE navigableKeySet() { return SETS.unmodifiable(map.navigableKeySet()); }
|
||||||
@Override
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() { return SETS.unmodifiable(map.keySet()); }
|
||||||
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { return SETS.unmodifiable(map.descendingKeySet()); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { return SETS.unmodifiable(map.descendingKeySet()); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return MAPS.unmodifiable(map.firstEntry()); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return MAPS.unmodifiable(map.firstEntry()); }
|
||||||
@@ -460,7 +493,7 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return MAPS.unmodifiable(map.ceilingEntry(key)); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return MAPS.unmodifiable(map.ceilingEntry(key)); }
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -491,17 +524,28 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE LAST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
public KEY_TYPE LAST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { return map.POLL_LAST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
|
@Override
|
||||||
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
|
if(keys == null) keys = SETS.unmodifiable(map.keySet());
|
||||||
|
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
|
if(entrySet == null) entrySet = new UnmodifyableOrderedEntrySetKV_BRACES(map.ENTRY_SET());
|
||||||
|
return (ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -526,19 +570,21 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { return MAPS.unmodifiable(map.tailMap(fromKey)); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { return MAPS.unmodifiable(map.tailMap(fromKey)); }
|
||||||
@Override
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE keySet() { return SETS.unmodifiable(map.keySet()); }
|
||||||
|
@Override
|
||||||
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
public KEY_TYPE FIRST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE LAST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
public KEY_TYPE LAST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { return map.POLL_LAST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_LAST_ENTRY_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -575,13 +621,34 @@ public class MAPS
|
|||||||
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key) {
|
||||||
|
VALUE_TYPE type = map.GET_VALUE(key);
|
||||||
|
return VALUE_EQUALS(type, map.getDefaultReturnValue()) && !map.containsKey(key) ? getDefaultReturnValue() : type;
|
||||||
|
}
|
||||||
#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 MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
|
@Override
|
||||||
|
public void clear() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
@@ -602,6 +669,45 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation
|
||||||
|
* @Type(T)
|
||||||
|
* @ValueType(V)
|
||||||
|
*/
|
||||||
|
public static class UnmodifyableOrderedEntrySet KEY_VALUE_GENERIC_TYPE extends UnmodifyableEntrySet KEY_VALUE_GENERIC_TYPE implements ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>
|
||||||
|
{
|
||||||
|
ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> set;
|
||||||
|
|
||||||
|
UnmodifyableOrderedEntrySet(ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> c) {
|
||||||
|
super(c);
|
||||||
|
set = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public boolean addAndMoveToLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public boolean moveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public boolean moveToLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> copy() { return set.copy(); }
|
||||||
|
@Override
|
||||||
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() { return ObjectIterators.unmodifiable(set.iterator()); }
|
||||||
|
@Override
|
||||||
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator(MAP.Entry KEY_VALUE_GENERIC_TYPE fromElement) { return ObjectIterators.unmodifiable(set.iterator(fromElement)); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() { return set.first(); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() { return set.last(); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
|
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -660,9 +766,11 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { synchronized(mutex) { return SETS.synchronize(map.descendingKeySet(), mutex); } }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingKeySet() { synchronized(mutex) { return SETS.synchronize(map.descendingKeySet(), mutex); } }
|
||||||
@Override
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet() { synchronized(mutex) { return SETS.synchronize(map.keySet(), mutex); } }
|
||||||
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { synchronized(mutex) { return map.firstEntry(); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { synchronized(mutex) { return map.firstEntry(); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { synchronized(mutex) { return map.firstEntry(); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { synchronized(mutex) { return map.lastEntry(); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { synchronized(mutex) { return map.pollFirstEntry(); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { synchronized(mutex) { return map.pollFirstEntry(); } }
|
||||||
@Override
|
@Override
|
||||||
@@ -696,8 +804,8 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, boolean fromInclusive, CLASS_TYPE toKey, boolean toInclusive) { synchronized(mutex) { return MAPS.synchronize(map.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, boolean fromInclusive, CLASS_TYPE toKey, boolean toInclusive) { synchronized(mutex) { return MAPS.synchronize(map.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
|
||||||
@@ -794,7 +902,18 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
||||||
|
@Override
|
||||||
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
|
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
||||||
|
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
|
if(entrySet == null) entrySet = ObjectSets.synchronize(map.ENTRY_SET(), mutex);
|
||||||
|
return (ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -824,6 +943,8 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { synchronized(mutex) { return MAPS.synchronize(map.tailMap(fromKey), mutex); } }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE tailMap(KEY_TYPE fromKey) { synchronized(mutex) { return MAPS.synchronize(map.tailMap(fromKey), mutex); } }
|
||||||
@Override
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE keySet() { synchronized(mutex) { return SETS.synchronize(map.keySet(), mutex); } }
|
||||||
|
@Override
|
||||||
public KEY_TYPE FIRST_ENTRY_KEY() { synchronized(mutex) { return map.FIRST_ENTRY_KEY(); } }
|
public KEY_TYPE FIRST_ENTRY_KEY() { synchronized(mutex) { return map.FIRST_ENTRY_KEY(); } }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_FIRST_ENTRY_KEY(); } }
|
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { synchronized(mutex) { return map.POLL_FIRST_ENTRY_KEY(); } }
|
||||||
@@ -836,7 +957,7 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
||||||
@Override
|
@Override
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -940,6 +1061,8 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENT(key, valueProvider); } }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { map.BULK_MERGE(m, mappingFunction); } }
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { map.BULK_MERGE(m, mappingFunction); } }
|
||||||
@@ -950,9 +1073,9 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) { synchronized(mutex) { map.forEach(action); } }
|
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) { synchronized(mutex) { map.forEach(action); } }
|
||||||
@Override
|
@Override
|
||||||
public int size() { synchronized(mutex) { return super.size(); } }
|
public int size() { synchronized(mutex) { return map.size(); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
public MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
||||||
|
|||||||
+93
@@ -0,0 +1,93 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.CollectionTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.testers.CollectionRemoveIfTester;
|
||||||
|
|
||||||
|
import speiger.src.testers.base.tests.collection.JavaCollectionRemoveIfTester;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddAllArrayTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddAllTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionAddTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionClearTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsAllTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsAnyTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionContainsTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionCopyTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionEqualsTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionForEachTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRemoveAllTester;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRemoveIfTester;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionStreamTester;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionRetainAllTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionToArrayTester;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableCountTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableDistinctTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableFilterTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableFindFirstTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableLimitTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableMapTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableMatchesTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterablePeekTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableReduceTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableRepeatTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.iterable.FILE_KEY_TYPEIterableSortedTester;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE extends CollectionTestSuiteBuilder<CLASS_TYPE> {
|
||||||
|
public static GENERIC_KEY_BRACES COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE using(TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
|
return (COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE) new COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
testers.remove(CollectionRemoveIfTester.class);
|
||||||
|
testers.add(JavaCollectionRemoveIfTester.class);
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
testers.add(FILE_KEY_TYPEIterableMapTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableFilterTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableDistinctTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableLimitTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableSortedTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableMatchesTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterablePeekTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableReduceTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableRepeatTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableCountTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEIterableFindFirstTester.class);
|
||||||
|
#endif
|
||||||
|
testers.add(FILE_KEY_TYPECollectionAddAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionAddAllArrayTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionAddTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionClearTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionContainsAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionContainsAnyTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionContainsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionCopyTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionEqualsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionForEachTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionIteratorTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionRemoveAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPECollectionRetainAllTester.class);
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
testers.add(FILE_KEY_TYPECollectionRemoveIfTester.class);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
testers.add(FILE_KEY_TYPECollectionStreamTester.class);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
testers.add(FILE_KEY_TYPECollectionToArrayTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
|
||||||
|
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_TYPEDequeueEnqueueTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.queue.FILE_KEY_TYPEDequeueLastTester;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE)new DEQUEUE_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> tester = super.getTesters();
|
||||||
|
tester.add(FILE_KEY_TYPEDequeueDequeueTester.class);
|
||||||
|
tester.add(FILE_KEY_TYPEDequeueEnqueueTester.class);
|
||||||
|
tester.add(FILE_KEY_TYPEDequeueLastTester.class);
|
||||||
|
return tester;
|
||||||
|
}
|
||||||
|
}
|
||||||
+384
@@ -0,0 +1,384 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
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_INCLUDING_VIEWS;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.ListTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.TestListGenerator;
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListAddAllAtIndexTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListAddAllTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListAddAtIndexTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListAddTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListCreationTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListEqualsTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListGetTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListHashCodeTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListIndexOfTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListLastIndexOfTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListRemoveAllTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListRemoveAtIndexTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListRemoveTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListReplaceAllTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListRetainAllTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListSetTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListSubListTester;
|
||||||
|
import com.google.common.collect.testing.testers.ListToArrayTester;
|
||||||
|
import com.google.common.testing.SerializableTester;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.testers.base.tests.list.JavaListListIteratorTester;
|
||||||
|
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_TYPEListAddAllArrayAtIndexTester;
|
||||||
|
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_TYPEListAddAllTester;
|
||||||
|
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_TYPEListCreationTester;
|
||||||
|
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_TYPEListGetElementsTester;
|
||||||
|
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_TYPEListLastIndexOfTester;
|
||||||
|
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_TYPEListRemoveAllTester;
|
||||||
|
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_TYPEListRemoveTester;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListSortTester;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListFillBufferTester;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.tests.list.FILE_KEY_TYPEListReplaceAllTester;
|
||||||
|
#endif
|
||||||
|
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_TYPEListSubListTester;
|
||||||
|
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_TYPEListToArrayTester;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class LIST_TEST_BUILDER KEY_GENERIC_TYPE extends COLLECTION_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
KEY_TYPE[] prefixes;
|
||||||
|
KEY_TYPE[] suffixes;
|
||||||
|
#else
|
||||||
|
KEY_TYPE[] prefixes = createPrefixes();
|
||||||
|
KEY_TYPE[] suffixes = createSuffixes();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setPrefixes(KEY_TYPE[] prefixes) {
|
||||||
|
this.prefixes = prefixes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LIST_TEST_BUILDER KEY_GENERIC_TYPE setSuffixes(KEY_TYPE[] suffixes) {
|
||||||
|
this.suffixes = suffixes;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
public KEY_TYPE[] createPrefixes() {
|
||||||
|
#if TYPE_BOOLEAN
|
||||||
|
return new KEY_TYPE[]{false, false, false};
|
||||||
|
#else if TYPE_BYTE
|
||||||
|
return new KEY_TYPE[]{(byte)-3, (byte)-2, (byte)-1};
|
||||||
|
#else if TYPE_SHORT
|
||||||
|
return new KEY_TYPE[]{(short)-3, (short)-2, (short)-1};
|
||||||
|
#else if TYPE_CHAR
|
||||||
|
return new KEY_TYPE[]{'^', '_', '`'};
|
||||||
|
#else
|
||||||
|
return new KEY_TYPE[]{-3, -2, -1};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public KEY_TYPE[] createSuffixes() {
|
||||||
|
#if TYPE_BOOLEAN
|
||||||
|
return new KEY_TYPE[]{true, true, true};
|
||||||
|
#else if TYPE_BYTE
|
||||||
|
return new KEY_TYPE[]{(byte)5, (byte)6, (byte)7};
|
||||||
|
#else if TYPE_SHORT
|
||||||
|
return new KEY_TYPE[]{(short)5, (short)6, (short)7};
|
||||||
|
#else if TYPE_CHAR
|
||||||
|
return new KEY_TYPE[]{'f', 'g', 'h'};
|
||||||
|
#else
|
||||||
|
return new KEY_TYPE[]{5, 6, 7};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
|
||||||
|
testers.add(CollectionSerializationEqualTester.class);
|
||||||
|
testers.add(ListAddAllAtIndexTester.class);
|
||||||
|
testers.add(ListAddAllTester.class);
|
||||||
|
testers.add(ListAddAtIndexTester.class);
|
||||||
|
testers.add(ListAddTester.class);
|
||||||
|
testers.add(ListCreationTester.class);
|
||||||
|
testers.add(ListEqualsTester.class);
|
||||||
|
testers.add(ListGetTester.class);
|
||||||
|
testers.add(ListHashCodeTester.class);
|
||||||
|
testers.add(ListIndexOfTester.class);
|
||||||
|
testers.add(ListLastIndexOfTester.class);
|
||||||
|
testers.add(JavaListListIteratorTester.class);
|
||||||
|
testers.add(ListRemoveAllTester.class);
|
||||||
|
testers.add(ListRemoveAtIndexTester.class);
|
||||||
|
testers.add(ListRemoveTester.class);
|
||||||
|
testers.add(ListReplaceAllTester.class);
|
||||||
|
testers.add(ListRetainAllTester.class);
|
||||||
|
testers.add(ListSetTester.class);
|
||||||
|
testers.add(ListSubListTester.class);
|
||||||
|
testers.add(ListToArrayTester.class);
|
||||||
|
|
||||||
|
testers.add(FILE_KEY_TYPEListAddAllAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAddAllListAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAddAllArrayAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAddAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAddAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAddTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListAbsentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListPresentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListCreationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListEqualsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListGetTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListGetElementsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListExtractElementsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListIndexOfTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListLastIndexOfTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListListIteratorTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListRemoveAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListRemoveAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListRemoveTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListRemoveElementsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListSwapRemoveAtIndexTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListSwapRemoveTester.class);
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
testers.add(FILE_KEY_TYPEListSortTester.class);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
testers.add(FILE_KEY_TYPEListFillBufferTester.class);
|
||||||
|
#endif
|
||||||
|
testers.add(FILE_KEY_TYPEListReplaceAllTester.class);
|
||||||
|
#endif
|
||||||
|
testers.add(FILE_KEY_TYPEListRetainAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListSetTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListSubListTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEListToArrayTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestSuite createTestSuite() {
|
||||||
|
#ignore
|
||||||
|
withFeatures(KNOWN_ORDER);
|
||||||
|
#endignore
|
||||||
|
return super.createTestSuite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
|
#ignore
|
||||||
|
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||||
|
#endignore
|
||||||
|
derivedSuites.add(ListTestSuiteBuilder.using(new ReserializedListGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||||
|
.named(getName() + " reserialized")
|
||||||
|
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
}
|
||||||
|
#ignore
|
||||||
|
if(!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||||
|
#endignore
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
if(prefixes != null) {
|
||||||
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, null))
|
||||||
|
.named(getName() + " subSet_prefix")
|
||||||
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
}
|
||||||
|
if(suffixes != null) {
|
||||||
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), null, suffixes))
|
||||||
|
.named(getName() + " subSet_suffixes")
|
||||||
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
}
|
||||||
|
if(prefixes != null && suffixes != null) {
|
||||||
|
derivedSuites.add(LIST_TEST_BUILDER.using(new SubListListGeneratorBRACES(parentBuilder.getSubjectGenerator(), prefixes, suffixes))
|
||||||
|
.named(getName() + " subSet")
|
||||||
|
.withFeatures(computeSubListFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class SubListListGenerator KEY_GENERIC_TYPE implements TEST_LIST_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
TEST_LIST_GENERATOR KEY_GENERIC_TYPE generator;
|
||||||
|
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();
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.suffix = suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SampleElements<CLASS_TYPE> samples() {
|
||||||
|
return generator.samples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CLASS_TYPE[] createArray(int length) {
|
||||||
|
return generator.createArray(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
return generator.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
return generator.getSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
return generator.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return create(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
int length = getLength(prefix);
|
||||||
|
return generator.create(merge(elements)).subList(length, length+elements.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public LIST KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
int length = getLength(prefix);
|
||||||
|
return generator.create(merge(array)).subList(length, length+elements.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private int getLength(KEY_TYPE[] keys) {
|
||||||
|
return keys == null ? 0 : keys.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private KEY_TYPE[] merge(KEY_TYPE[] input) {
|
||||||
|
int prefixLength = getLength(prefix);
|
||||||
|
int suffixLength = getLength(suffix);
|
||||||
|
KEY_TYPE[] result = NEW_KEY_ARRAY(input.length+prefixLength+suffixLength);
|
||||||
|
if(prefixLength != 0) System.arraycopy(prefix, 0, result, 0, prefixLength);
|
||||||
|
System.arraycopy(input, 0, result, prefixLength, input.length);
|
||||||
|
if(suffixLength != 0) System.arraycopy(suffix, 0, result, prefixLength+input.length, suffixLength);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ReserializedListGenerator<E> implements TestListGenerator<E> {
|
||||||
|
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||||
|
|
||||||
|
private ReserializedListGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||||
|
this.gen = gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SampleElements<E> samples() {
|
||||||
|
return gen.samples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<E> create(Object... elements) {
|
||||||
|
return (List<E>) SerializableTester.reserialize(gen.create(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E[] createArray(int length) {
|
||||||
|
return gen.createArray(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<E> order(List<E> insertionOrder) {
|
||||||
|
return gen.order(insertionOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
private static Set<Feature<?>> computeSubListFeatures(Set<Feature<?>> features) {
|
||||||
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
|
#ignore
|
||||||
|
derivedFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||||
|
derivedFeatures.remove(SpecialFeature.COPYING);
|
||||||
|
derivedFeatures.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
|
#endignore
|
||||||
|
return derivedFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||||
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
|
#ignore
|
||||||
|
derivedFeatures.remove(SERIALIZABLE);
|
||||||
|
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||||
|
#endignore
|
||||||
|
return derivedFeatures;
|
||||||
|
}
|
||||||
|
}
|
||||||
+140
@@ -0,0 +1,140 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.DESCENDING_VIEW;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SUBSET_VIEW;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
import com.google.common.collect.testing.testers.NavigableSetNavigationTester;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
|
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.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.utils.SAMPLE_ELEMENTS;
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE) new NAVIGABLE_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
testers.add(NavigableSetNavigationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPENavigableSetNavigationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
if (!parentBuilder.getFeatures().contains(SUBSET_VIEW)) {
|
||||||
|
#endignore
|
||||||
|
// Other combinations are inherited from SortedSetTestSuiteBuilder.
|
||||||
|
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.EXCLUSIVE));
|
||||||
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||||
|
derivedSuites.add(createSubsetSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||||
|
}
|
||||||
|
#ignore
|
||||||
|
if (!parentBuilder.getFeatures().contains(DESCENDING_VIEW)) {
|
||||||
|
#endignore
|
||||||
|
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||||
|
}
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
|
#ignore
|
||||||
|
features.add(DESCENDING_VIEW);
|
||||||
|
features.addAll(parentBuilder.getFeatures());
|
||||||
|
features.remove(SpecialFeature.COPYING);
|
||||||
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
return NAVIGABLE_SET_TEST_BUILDER.using(new TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SampleElements<CLASS_TYPE> samples() {
|
||||||
|
return delegate.samples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
return delegate.getSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
delegate.order(insertionOrder).forEach(list::add);
|
||||||
|
LISTS.reverse(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
for(CLASS_TYPE entry : delegate.order(insertionOrder))
|
||||||
|
{
|
||||||
|
list.add(OBJ_TO_KEY(entry));
|
||||||
|
}
|
||||||
|
LISTS.reverse(list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return delegate.aboveSamplesGreater(); }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return delegate.aboveSamplesLesser(); }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return delegate.belowSamplesGreater(); }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return delegate.belowSamplesLesser(); }
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return delegate.create(elements).descendingSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
return delegate.create(elements).descendingSet();
|
||||||
|
}
|
||||||
|
}).named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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_TYPEOrderedSetIterationTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
testers.add(FILE_KEY_TYPEOrderedSetNavigationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEOrderedSetMoveTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEOrderedSetIterationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestSuite createTestSuite() {
|
||||||
|
#ignore
|
||||||
|
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||||
|
#endignore
|
||||||
|
return super.createTestSuite();
|
||||||
|
}
|
||||||
|
}
|
||||||
+60
@@ -0,0 +1,60 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.PerCollectionSizeTestSuiteBuilder;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
|
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_TYPEQueueEnqueueTester;
|
||||||
|
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.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_TYPEQueueFilterTester;
|
||||||
|
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_TYPEQueueMapTester;
|
||||||
|
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_TYPEQueueForEachTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueReduceTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.queue.iterators.FILE_KEY_TYPEQueueSortedTester;
|
||||||
|
|
||||||
|
@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 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters()
|
||||||
|
{
|
||||||
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
|
testers.add(FILE_KEY_TYPEQueueEnqueueTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueRemoveTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueCountTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueDequeueTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueDistinctTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueFilterTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueFindFirstTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueFirstTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueLimitTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueMapTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueMatchesTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueuePeekTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueForEachTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueReduceTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPEQueueSortedTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+116
@@ -0,0 +1,116 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SERIALIZABLE_INCLUDING_VIEWS;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.SetTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.TestSetGenerator;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
import com.google.common.collect.testing.testers.CollectionSerializationEqualTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetAddAllTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetAddTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetCreationTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetEqualsTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetHashCodeTester;
|
||||||
|
import com.google.common.collect.testing.testers.SetRemoveTester;
|
||||||
|
import com.google.common.testing.SerializableTester;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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_TYPESetAddTester;
|
||||||
|
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_TYPESetRemoveTester;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (SET_TEST_BUILDER KEY_GENERIC_TYPE) new SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
testers.add(CollectionSerializationEqualTester.class);
|
||||||
|
testers.add(SetAddAllTester.class);
|
||||||
|
testers.add(SetAddTester.class);
|
||||||
|
testers.add(SetCreationTester.class);
|
||||||
|
testers.add(SetHashCodeTester.class);
|
||||||
|
testers.add(SetEqualsTester.class);
|
||||||
|
testers.add(SetRemoveTester.class);
|
||||||
|
|
||||||
|
testers.add(FILE_KEY_TYPESetAddAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESetAddTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESetCreationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESetEqualsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESetRemoveTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestSuite> createDerivedSuites(
|
||||||
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
|
List<TestSuite> derivedSuites = new ArrayList<>(super.createDerivedSuites(parentBuilder));
|
||||||
|
|
||||||
|
if (parentBuilder.getFeatures().contains(SERIALIZABLE)) {
|
||||||
|
derivedSuites.add(SetTestSuiteBuilder.using(new ReserializedSetGenerator<CLASS_TYPE>(parentBuilder.getSubjectGenerator()))
|
||||||
|
.named(getName() + " reserialized")
|
||||||
|
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
}
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ReserializedSetGenerator<E> implements TestSetGenerator<E> {
|
||||||
|
final OneSizeTestContainerGenerator<Collection<E>, E> gen;
|
||||||
|
|
||||||
|
private ReserializedSetGenerator(OneSizeTestContainerGenerator<Collection<E>, E> gen) {
|
||||||
|
this.gen = gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SampleElements<E> samples() {
|
||||||
|
return gen.samples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<E> create(Object... elements) {
|
||||||
|
return (Set<E>) SerializableTester.reserialize(gen.create(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public E[] createArray(int length) {
|
||||||
|
return gen.createArray(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<E> order(List<E> insertionOrder) {
|
||||||
|
return gen.order(insertionOrder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<Feature<?>> computeReserializedCollectionFeatures(Set<Feature<?>> features) {
|
||||||
|
Set<Feature<?>> derivedFeatures = new HashSet<>(features);
|
||||||
|
#ignore
|
||||||
|
derivedFeatures.remove(SERIALIZABLE);
|
||||||
|
derivedFeatures.remove(SERIALIZABLE_INCLUDING_VIEWS);
|
||||||
|
#endignore
|
||||||
|
return derivedFeatures;
|
||||||
|
}
|
||||||
|
}
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
import com.google.common.collect.testing.testers.SortedSetNavigationTester;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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.tests.set.FILE_KEY_TYPESortedSetIterationTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPESortedSetNaviationTester;
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE) new SORTED_SET_TEST_BUILDER KEY_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = Helpers.copyToList(super.getTesters());
|
||||||
|
testers.add(SortedSetNavigationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESortedSetIterationTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPESortedSetNaviationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestSuite createTestSuite() {
|
||||||
|
if (!getFeatures().contains(CollectionFeature.KNOWN_ORDER)) {
|
||||||
|
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||||
|
#ignore
|
||||||
|
features.add(CollectionFeature.KNOWN_ORDER);
|
||||||
|
#endignore
|
||||||
|
withFeatures(features);
|
||||||
|
}
|
||||||
|
return super.createTestSuite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestSuite> createDerivedSuites(
|
||||||
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
||||||
|
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
if (!parentBuilder.getFeatures().contains(CollectionFeature.SUBSET_VIEW)) {
|
||||||
|
#endignore
|
||||||
|
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.EXCLUSIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
final TestSuite createSubsetSuite(
|
||||||
|
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder,
|
||||||
|
Bound from, Bound to) {
|
||||||
|
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());
|
||||||
|
#ignore
|
||||||
|
features.remove(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
|
features.add(CollectionFeature.SUBSET_VIEW);
|
||||||
|
features.remove(SpecialFeature.COPYING);
|
||||||
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subSet " + from + "-" + to)
|
||||||
|
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||||
|
.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) {
|
||||||
|
return using(new SUB_SORTED_SET_CLASS_GENERATORBRACES(delegate, to, from));
|
||||||
|
}
|
||||||
|
}
|
||||||
+304
@@ -0,0 +1,304 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.MapTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
import com.google.common.collect.testing.features.MapFeature;
|
||||||
|
import com.google.common.collect.testing.testers.CollectionIteratorTester;
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
import com.google.common.collect.testing.testers.CollectionRemoveTester;
|
||||||
|
import com.google.common.collect.testing.testers.CollectionRetainAllTester;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
||||||
|
#if TYPE_CHAR || TYPE_FLOAT || TYPE_DOUBLE
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionIteratorTester;
|
||||||
|
#if !SAME_TYPE && !VALUE_OBJECT
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
|
#endif
|
||||||
|
#else if TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
|
#endif
|
||||||
|
#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_TYPEMapSubFromTester;
|
||||||
|
#endif
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
#if !TYPE_CHAR && !TYPE_FLOAT && !TYPE_DOUBLE && !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionIteratorTester;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRemoveAllTester;
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.tests.collection.FILE_VALUE_TYPECollectionRetainAllTester;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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_TYPEMapComputeIfPresentTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||||
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionIteratorTester;
|
||||||
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionRemoveAllTester;
|
||||||
|
import speiger.src.testers.objects.tests.collection.ObjectCollectionRetainAllTester;
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
import speiger.src.testers.utils.TestUtils;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder<CLASS_TYPE, CLASS_VALUE_TYPE> {
|
||||||
|
boolean shouldBlockKeys;
|
||||||
|
|
||||||
|
public static GENERIC_KEY_VALUE_BRACES MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE using(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator) {
|
||||||
|
return (MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE shouldBlockKeys(boolean value) {
|
||||||
|
shouldBlockKeys = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsValueTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEntrySetTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapEqualsTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapForEachTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapGetOrDefaultTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapHashCodeTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapIsEmptyTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapMergeBulkTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutTester.class);
|
||||||
|
#if VALUE_PRIMITIVES
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapAddToTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSubFromTester.class);
|
||||||
|
#endif
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutAllArrayTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapPutIfAbsentTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveOrDefaultTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceAllTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceEntryTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSizeTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
||||||
|
List<TestSuite> derivedSuites = new ArrayList<>();
|
||||||
|
derivedSuites.add(createDerivedEntrySetSuite(
|
||||||
|
DERIVED_MAP_GENERATORS.entrySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||||
|
.withFeatures(computeEntrySetFeatures(parentBuilder.getFeatures()))
|
||||||
|
.named(parentBuilder.getName() + " entrySet")
|
||||||
|
.suppressing(getEntrySetSuppressing(parentBuilder.getSuppressedTests())).suppressing(getSuppressing(1))
|
||||||
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||||
|
.createTestSuite());
|
||||||
|
|
||||||
|
derivedSuites.add(createDerivedKeySetSuite(
|
||||||
|
DERIVED_MAP_GENERATORS.keySetGenerator(parentBuilder.getSubjectGenerator()))
|
||||||
|
.withFeatures(computeKeySetFeatures(parentBuilder.getFeatures()))
|
||||||
|
.named(parentBuilder.getName() + " keys").suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(0))
|
||||||
|
.withSetUp(parentBuilder.getSetUp()).withTearDown(parentBuilder.getTearDown())
|
||||||
|
.createTestSuite());
|
||||||
|
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||||
|
derivedSuites.add(createDerivedValueCollectionSuite(
|
||||||
|
new DERIVED_MAP_GENERATORS.MapValueCollectionGeneratorKV_BRACES(parentBuilder.getSubjectGenerator()))
|
||||||
|
.named(parentBuilder.getName() + " values")
|
||||||
|
.withFeatures(computeValuesCollectionFeatures(parentBuilder.getFeatures()))
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).suppressing(getSuppressing(2)).withSetUp(parentBuilder.getSetUp())
|
||||||
|
.withTearDown(parentBuilder.getTearDown()).createTestSuite());
|
||||||
|
#endif
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||||
|
return ObjectSetTestSuiteBuilder.using(entrySetGenerator);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
|
return SET_TEST_BUILDER.using(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VALUE_COLLECTION_TEST_BUILDER VALUE_GENERIC_TYPE createDerivedValueCollectionSuite(VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE generator) {
|
||||||
|
return VALUE_COLLECTION_TEST_BUILDER.using(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Method[] getSuppressing(int type) {
|
||||||
|
#if TYPE_CHAR || TYPE_OBJECT || TYPE_FLOAT || TYPE_DOUBLE
|
||||||
|
if(shouldBlockKeys) {
|
||||||
|
switch(type) {
|
||||||
|
case 0: return TestUtils.getSurpession(FILE_KEY_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
case 1: return TestUtils.getSurpession(ObjectCollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
case 2: {
|
||||||
|
List<Method> result = new ArrayList<>();
|
||||||
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||||
|
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
return result.toArray(new Method[result.size()]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Method[0];
|
||||||
|
#else if VALUE_BOOLEAN
|
||||||
|
if(type == 2) {
|
||||||
|
List<Method> result = new ArrayList<>();
|
||||||
|
TestUtils.getSurpession(result, FILE_VALUE_TYPECollectionIteratorTester.class, "testIterator_unknownOrderRemoveSupported");
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
TestUtils.getSurpession(result, CollectionRemoveTester.class, "testRemove_present");
|
||||||
|
TestUtils.getSurpession(result, CollectionRetainAllTester.class);
|
||||||
|
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);
|
||||||
|
#endif
|
||||||
|
return result.toArray(new Method[result.size()]);
|
||||||
|
}
|
||||||
|
return new Method[0];
|
||||||
|
#else
|
||||||
|
return new Method[0];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
|
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
|
#ignore
|
||||||
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
||||||
|
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
|
entrySetFeatures.add(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entrySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
|
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
||||||
|
#endignore
|
||||||
|
return entrySetFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<Feature<?>> computeKeySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
|
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
|
#ignore
|
||||||
|
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||||
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
||||||
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
|
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
||||||
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
|
keySetFeatures.add(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
|
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
return keySetFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_CHAR && !TYPE_OBJECT && !TYPE_FLOAT && !TYPE_DOUBLE || !VALUE_BOOLEAN
|
||||||
|
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
|
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
|
#ignore
|
||||||
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
||||||
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
|
}
|
||||||
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
||||||
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
|
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
|
#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
@@ -0,0 +1,79 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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_NAVIGABLE_SET_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.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester;
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE)new NAVIGABLE_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPENavigableMapNavigationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
#ignore
|
||||||
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.DESCENDING)) {
|
||||||
|
derivedSuites.add(createDescendingSuite(parentBuilder));
|
||||||
|
}
|
||||||
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||||
|
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.EXCLUSIVE));
|
||||||
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.EXCLUSIVE, Bound.INCLUSIVE));
|
||||||
|
derivedSuites.add(createSubmapSuite(parentBuilder, Bound.INCLUSIVE, Bound.INCLUSIVE));
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
|
#ignore
|
||||||
|
features.add(SpecialFeature.DESCENDING);
|
||||||
|
features.addAll(parentBuilder.getFeatures());
|
||||||
|
features.remove(SpecialFeature.COPYING);
|
||||||
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
|
#endignore
|
||||||
|
return NAVIGABLE_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.DescendingTestMapGeneratorKV_BRACES(delegate))
|
||||||
|
.named(parentBuilder.getName() + " descending").withFeatures(features)
|
||||||
|
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.testers.PACKAGE.builder.ORDERED_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_SET_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_TYPEOrderedMapNavigationTester;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
|
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
||||||
|
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestSuite createTestSuite() {
|
||||||
|
#ignore
|
||||||
|
withFeatures(CollectionFeature.KNOWN_ORDER);
|
||||||
|
#endignore
|
||||||
|
return super.createTestSuite();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
+90
@@ -0,0 +1,90 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.KNOWN_ORDER;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.features.Feature;
|
||||||
|
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
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.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester;
|
||||||
|
import speiger.src.testers.PACKAGE.builder.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_SORTED_SET_GENERATOR;
|
||||||
|
import speiger.src.testers.utils.SpecialFeature;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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) {
|
||||||
|
return (SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE) new SORTED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE().usingGenerator(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPESortedMapNavigationTester.class);
|
||||||
|
return testers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TestSuite createTestSuite() {
|
||||||
|
#ignore
|
||||||
|
if (!getFeatures().contains(KNOWN_ORDER)) {
|
||||||
|
List<Feature<?>> features = Helpers.copyToList(getFeatures());
|
||||||
|
features.add(KNOWN_ORDER);
|
||||||
|
withFeatures(features);
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
return super.createTestSuite();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
#ignore
|
||||||
|
if (!parentBuilder.getFeatures().contains(SpecialFeature.SUBMAP)) {
|
||||||
|
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.EXCLUSIVE));
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
return derivedSuites;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
List<Feature<?>> features = new ArrayList<>();
|
||||||
|
#ignore
|
||||||
|
features.add(SpecialFeature.SUBMAP);
|
||||||
|
features.addAll(parentBuilder.getFeatures());
|
||||||
|
features.remove(SpecialFeature.COPYING);
|
||||||
|
features.remove(SpecialFeature.CHILDREN_COPY);
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
return newBuilderUsing(delegate, to, from).named(parentBuilder.getName() + " subMap " + from + "-" + to)
|
||||||
|
.withFeatures(features).suppressing(parentBuilder.getSuppressedTests())
|
||||||
|
.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) {
|
||||||
|
return using(new DERIVED_MAP_GENERATORS.SortedMapGeneratorKV_BRACES(delegate, to, from));
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.TestCollectionGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE extends TestCollectionGenerator<CLASS_TYPE>
|
||||||
|
{
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
public COLLECTION KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||||
|
#endif
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||||
|
@Override
|
||||||
|
public COLLECTION KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
@Override
|
||||||
|
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||||
|
}
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.TestListGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_LIST_GENERATOR KEY_GENERIC_TYPE extends TestListGenerator<CLASS_TYPE>, TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
LIST KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
LIST KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
ORDERED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE extends TestContainerGenerator<PRIORITY_QUEUE KEY_GENERIC_TYPE, CLASS_TYPE>
|
||||||
|
{
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples();
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||||
|
#endif
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default SampleElements<CLASS_TYPE> samples() {return getSamples().toSamples();}
|
||||||
|
@Override
|
||||||
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
@Override
|
||||||
|
public default CLASS_TYPE[] createArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder);
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.TestSetGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE, TestSetGenerator<CLASS_TYPE> {
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
SET KEY_GENERIC_TYPE create(KEY_TYPE...elements);
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
SET KEY_GENERIC_TYPE create(Object...elements);
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE extends TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements);
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
SORTED_SET KEY_GENERIC_TYPE create(Object... elements);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an element less than the {@link #samples()} and less than {@link
|
||||||
|
* #belowSamplesGreater()}.
|
||||||
|
*/
|
||||||
|
KEY_TYPE belowSamplesLesser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an element less than the {@link #samples()} but greater than {@link
|
||||||
|
* #belowSamplesLesser()}.
|
||||||
|
*/
|
||||||
|
KEY_TYPE belowSamplesGreater();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an element greater than the {@link #samples()} but less than {@link
|
||||||
|
* #aboveSamplesGreater()}.
|
||||||
|
*/
|
||||||
|
KEY_TYPE aboveSamplesLesser();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an element greater than the {@link #samples()} and greater than {@link
|
||||||
|
* #aboveSamplesLesser()}.
|
||||||
|
*/
|
||||||
|
KEY_TYPE aboveSamplesGreater();
|
||||||
|
}
|
||||||
+46
@@ -0,0 +1,46 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.Helpers;
|
||||||
|
import com.google.common.collect.testing.SampleElements;
|
||||||
|
import com.google.common.collect.testing.TestMapGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
|
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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 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);
|
||||||
|
@Override
|
||||||
|
default MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) {
|
||||||
|
MAP.Entry KEY_VALUE_GENERIC_TYPE[] result = new MAP.Entry[elements.length];
|
||||||
|
for(int i = 0;i<elements.length;i++) {
|
||||||
|
result[i] = (MAP.Entry KEY_VALUE_GENERIC_TYPE) elements[i];
|
||||||
|
}
|
||||||
|
return create(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default CLASS_TYPE[] createKeyArray(int length) { return NEW_CLASS_ARRAY(length); }
|
||||||
|
@Override
|
||||||
|
default CLASS_VALUE_TYPE[] createValueArray(int length) { return NEW_CLASS_VALUE_ARRAY(length); }
|
||||||
|
@Override
|
||||||
|
default MAP.Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) { return new MAP.Entry[length]; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default SampleElements<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> samples() {
|
||||||
|
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = getSamples();
|
||||||
|
return new SampleElements<>(
|
||||||
|
Helpers.mapEntry(samples.e0().ENTRY_KEY(), samples.e0().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.e3().ENTRY_KEY(), samples.e3().ENTRY_VALUE()),
|
||||||
|
Helpers.mapEntry(samples.e4().ENTRY_KEY(), samples.e4().ENTRY_VALUE())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public interface TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE extends TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
default ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (ORDERED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||||
|
@Override
|
||||||
|
ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.generators.maps;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.TestSortedMapGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
|
|
||||||
|
@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>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
default SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Object... elements) { return (SORTED_MAP KEY_VALUE_GENERIC_TYPE) TEST_MAP_GENERATOR.super.create(elements); }
|
||||||
|
@Override
|
||||||
|
SORTED_MAP KEY_VALUE_GENERIC_TYPE create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser();
|
||||||
|
@Override
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater();
|
||||||
|
@Override
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser();
|
||||||
|
@Override
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater();
|
||||||
|
}
|
||||||
+314
@@ -0,0 +1,314 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_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.IMMUTABLE_LIST;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_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_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.RB_TREE_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.IMMUTABLE_HASH_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import speiger.src.collections.objects.utils.StringSortTest;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.tests.collection.FILE_KEY_TYPECollectionConstructorTester;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class COLLECTION_CONSTRUCTOR_TESTS
|
||||||
|
{
|
||||||
|
public static class ArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ArrayList() {
|
||||||
|
setSimpleConstructor(ARRAY_LIST::new);
|
||||||
|
setSizeConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
|
setPArrayConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new ARRAY_LISTBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public LinkedList() {
|
||||||
|
setSimpleConstructor(LINKED_LIST::new);
|
||||||
|
setPArrayConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new LINKED_LISTBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CopyOnWriteArrayList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CopyOnWriteArrayList() {
|
||||||
|
setSimpleConstructor(COPY_ON_WRITE_LIST::new);
|
||||||
|
setPArrayConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new COPY_ON_WRITE_LISTBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImmutableList extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ImmutableList() {
|
||||||
|
setPArrayConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new IMMUTABLE_LISTBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
public static class HashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public HashSet() {
|
||||||
|
setSimpleConstructor(HASH_SET::new);
|
||||||
|
setSizeConstructor(T -> new HASH_SETBRACES(T));
|
||||||
|
setPArrayConstructor(T -> new HASH_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new HASH_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public LinkedHashSet() {
|
||||||
|
setSimpleConstructor(LINKED_HASH_SET::new);
|
||||||
|
setSizeConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
|
setPArrayConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new LINKED_HASH_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public CustomHashSet() {
|
||||||
|
setSimpleConstructor(() -> new CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(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));
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedCustomHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public LinkedCustomHashSet() {
|
||||||
|
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));
|
||||||
|
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));
|
||||||
|
setCollectionConstructor(T -> new LINKED_CUSTOM_HASH_SET KEY_STRING_GENERIC_TYPE(T, HashStrategy.INSTANCE));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImmutableHashSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ImmutableHashSet() {
|
||||||
|
setPArrayConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new IMMUTABLE_HASH_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ArraySet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ArraySet() {
|
||||||
|
setSimpleConstructor(ARRAY_SET::new);
|
||||||
|
setSizeConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
|
setPArrayConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new ARRAY_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public RBTreeSet() {
|
||||||
|
setSimpleConstructor(RB_TREE_SET::new);
|
||||||
|
setPArrayConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new RB_TREE_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeSet extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public AVLTreeSet() {
|
||||||
|
setSimpleConstructor(AVL_TREE_SET::new);
|
||||||
|
setPArrayConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
|
setPCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
|
setCollectionConstructor(T -> new AVL_TREE_SETBRACES(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public RBTreeSetComparator() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> new RB_TREE_SET<String>(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor(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()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> new RB_TREE_SET(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor(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));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeSetComparator extends FILE_KEY_TYPECollectionConstructorTester KEY_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public AVLTreeSetComparator() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> new AVL_TREE_SET<String>(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor(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()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> new AVL_TREE_SET(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor(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));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
||||||
|
static final HashStrategy INSTANCE = new HashStrategy();
|
||||||
|
@Override
|
||||||
|
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
||||||
|
@Override
|
||||||
|
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
KEY_TYPE[] keys;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public SIMPLE_QUEUE_TEST_GENERATOR(Function<KEY_TYPE[], PRIORITY_QUEUE KEY_GENERIC_TYPE> mapper) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
public SIMPLE_QUEUE_TEST_GENERATOR KEY_GENERIC_TYPE setElements(KEY_TYPE...keys) {
|
||||||
|
this.keys = keys;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
#if TYPE_BOOLEAN
|
||||||
|
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||||
|
#else if TYPE_BYTE
|
||||||
|
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||||
|
#else if TYPE_SHORT
|
||||||
|
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||||
|
#else if TYPE_CHAR
|
||||||
|
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||||
|
#else if TYPE_OBJECT
|
||||||
|
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||||
|
#else
|
||||||
|
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return mapper.apply(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return mapper.apply(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
public PRIORITY_QUEUE KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return mapper.apply(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
}
|
||||||
+221
@@ -0,0 +1,221 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_LIST_GENERATOR;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
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_SET_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_SORTED_SET_GENERATOR;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E extends COLLECTION KEY_GENERIC_TYPE> {
|
||||||
|
Function<KEY_TYPE[], E> mapper;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
KEY_TYPE[] keys;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public SIMPLE_TEST_GENERATOR(Function<KEY_TYPE[], E> mapper) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
public SIMPLE_TEST_GENERATOR KKS_GENERIC_TYPE<E> setElements(KEY_TYPE...keys) {
|
||||||
|
this.keys = keys;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
#if TYPE_BOOLEAN
|
||||||
|
return new SAMPLE_ELEMENTS(true, false, true, false, true);
|
||||||
|
#else if TYPE_BYTE
|
||||||
|
return new SAMPLE_ELEMENTS((byte)0, (byte)1, (byte)2, (byte)3, (byte)4);
|
||||||
|
#else if TYPE_SHORT
|
||||||
|
return new SAMPLE_ELEMENTS((short)0, (short)1, (short)2, (short)3, (short)4);
|
||||||
|
#else if TYPE_CHAR
|
||||||
|
return new SAMPLE_ELEMENTS((char)0, (char)1, (char)2, (char)3, (char)4);
|
||||||
|
#else if TYPE_OBJECT
|
||||||
|
return new SAMPLE_ELEMENTSBRACES(keys[0], keys[1], keys[2], keys[3], keys[4]);
|
||||||
|
#else
|
||||||
|
return new SAMPLE_ELEMENTS(0, 1, 2, 3, 4);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
public E create(KEY_TYPE... elements) {
|
||||||
|
return mapper.apply(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E create(Object... elements) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return mapper.apply(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
public E create(Object... elements) {
|
||||||
|
T[] array = (T[])ObjectArrays.newArray(keys[0].getClass(), elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return mapper.apply(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> 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 Collections(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> 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 Lists(Function<KEY_TYPE[], LIST KEY_GENERIC_TYPE> mapper) {
|
||||||
|
super(mapper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 Sets(Function<KEY_TYPE[], SET KEY_GENERIC_TYPE> 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 OrderedSets(Function<KEY_TYPE[], ORDERED_SET KEY_GENERIC_TYPE> 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 SortedSets(Function<KEY_TYPE[], SORTED_SET KEY_GENERIC_TYPE> mapper) {
|
||||||
|
super(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
insertionOrder.sort(null);
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
insertionOrder.sort(null);
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_CHAR
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||||
|
#else if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||||
|
#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 NavigableSets(Function<KEY_TYPE[], NAVIGABLE_SET KEY_GENERIC_TYPE> mapper) {
|
||||||
|
super(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
insertionOrder.sort(null);
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
insertionOrder.sort(null);
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_CHAR
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() { return new SAMPLE_ELEMENTS('a', 'b', 'c', 'd', 'e'); }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return '_'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return '`'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return 'f'; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return 'g'; }
|
||||||
|
#else if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return keys[5]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return keys[6]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return keys[7]; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return keys[8]; }
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() { return -2; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() { return -1; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() { return 5; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() { return 6; }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+173
@@ -0,0 +1,173 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Comparator;
|
||||||
|
#endif
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_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_NAVIGABLE_SET_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class SUB_SORTED_SET_CLASS_GENERATOR KEY_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
final Bound to;
|
||||||
|
final Bound from;
|
||||||
|
final KEY_TYPE firstInclusive;
|
||||||
|
final KEY_TYPE lastInclusive;
|
||||||
|
private final COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||||
|
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) {
|
||||||
|
this.to = to;
|
||||||
|
this.from = from;
|
||||||
|
this.delegate = delegate;
|
||||||
|
|
||||||
|
SORTED_SET KEY_GENERIC_TYPE emptySet = delegate.create(NEW_KEY_ARRAY(0));
|
||||||
|
comparator = emptySet.comparator();
|
||||||
|
|
||||||
|
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples = delegate.getSamples();
|
||||||
|
LIST KEY_GENERIC_TYPE samplesList = new ARRAY_LISTBRACES(samples.asList());
|
||||||
|
samplesList.sort(comparator);
|
||||||
|
firstInclusive = samplesList.GET_KEY(0);
|
||||||
|
lastInclusive = samplesList.GET_KEY(samplesList.size() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE getInnerGenerator() {
|
||||||
|
return delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Bound getTo() {
|
||||||
|
return to;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Bound getFrom() {
|
||||||
|
return from;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return set.headSet(lastExclusive);
|
||||||
|
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
||||||
|
return set.tailSet(firstInclusive);
|
||||||
|
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||||
|
return set.subSet(firstInclusive, lastExclusive);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
return delegate.getSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
return delegate.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
return delegate.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE create(KEY_OBJECT_TYPE... elements) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
LIST KEY_GENERIC_TYPE normalValues = (LIST KEY_GENERIC_TYPE)ARRAY_LIST.wrap(elements);
|
||||||
|
#else
|
||||||
|
LIST KEY_GENERIC_TYPE normalValues = ARRAY_LIST.wrap(elements);
|
||||||
|
#endif
|
||||||
|
LIST KEY_GENERIC_TYPE extremeValues = new ARRAY_LISTBRACES();
|
||||||
|
KEY_TYPE firstExclusive = delegate.belowSamplesGreater();
|
||||||
|
KEY_TYPE lastExclusive = delegate.aboveSamplesLesser();
|
||||||
|
if (from != Bound.NO_BOUND) {
|
||||||
|
extremeValues.add(delegate.belowSamplesLesser());
|
||||||
|
extremeValues.add(delegate.belowSamplesGreater());
|
||||||
|
}
|
||||||
|
if (to != Bound.NO_BOUND) {
|
||||||
|
extremeValues.add(delegate.aboveSamplesLesser());
|
||||||
|
extremeValues.add(delegate.aboveSamplesGreater());
|
||||||
|
}
|
||||||
|
LIST KEY_GENERIC_TYPE allEntries = new ARRAY_LISTBRACES();
|
||||||
|
allEntries.addAll(extremeValues);
|
||||||
|
allEntries.addAll(normalValues);
|
||||||
|
SORTED_SET KEY_GENERIC_TYPE set = delegate.create(allEntries.toArray());
|
||||||
|
|
||||||
|
return createSubSet(set, firstExclusive, lastExclusive);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(elements.length);
|
||||||
|
int i = 0;
|
||||||
|
for (Object e : elements) {
|
||||||
|
array[i++] = CLASS_TO_KEY(e);
|
||||||
|
}
|
||||||
|
return create(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 SUB_NAVIGABLE_SET_CLASS_GENERATOR(TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE delegate, Bound to, Bound from) {
|
||||||
|
super(delegate, to, from);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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;
|
||||||
|
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.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.INCLUSIVE && to == Bound.INCLUSIVE) return set.subSet(firstInclusive, true, lastInclusive, true);
|
||||||
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE)super.createSubSet(set, firstExclusive, lastExclusive);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+550
@@ -0,0 +1,550 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.DerivedCollectionGenerators.Bound;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#endif
|
||||||
|
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.Entry;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_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.maps.TEST_MAP_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
|
#if !VALUE_OBJECT && !SAME_TYPE
|
||||||
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERABLE;
|
||||||
|
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST;
|
||||||
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_COMPARATOR;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.generators.VALUE_TEST_COLLECTION_GENERATOR;
|
||||||
|
#if !VALUE_OBJECT && !SAME_TYPE
|
||||||
|
import speiger.src.testers.VALUE_PACKAGE.utils.VALUE_SAMPLE_ELEMENTS;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
|
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectLists;
|
||||||
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class DERIVED_MAP_GENERATORS {
|
||||||
|
public static class NavigableMapGenerator KEY_VALUE_GENERIC_TYPE extends SortedMapGenerator KEY_VALUE_GENERIC_TYPE {
|
||||||
|
public NavigableMapGenerator(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent, Bound to, Bound from) {
|
||||||
|
super(parent, to, from);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE createSubMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE sortedMap, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||||
|
NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map = (NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE) sortedMap;
|
||||||
|
if (from == Bound.NO_BOUND && to == Bound.INCLUSIVE) {
|
||||||
|
return map.headMap(lastInclusive, true);
|
||||||
|
} else if (from == Bound.EXCLUSIVE && to == Bound.NO_BOUND) {
|
||||||
|
return map.tailMap(firstExclusive, false);
|
||||||
|
} else if (from == Bound.EXCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||||
|
return map.subMap(firstExclusive, false, lastExclusive, false);
|
||||||
|
} else if (from == Bound.EXCLUSIVE && to == Bound.INCLUSIVE) {
|
||||||
|
return map.subMap(firstExclusive, false, lastInclusive, true);
|
||||||
|
} else if (from == Bound.INCLUSIVE && to == Bound.INCLUSIVE) {
|
||||||
|
return map.subMap(firstInclusive, true, lastInclusive, true);
|
||||||
|
} else {
|
||||||
|
return (NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE) super.createSubMap(map, firstExclusive, lastExclusive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SortedMapGenerator KEY_VALUE_GENERIC_TYPE extends MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE {
|
||||||
|
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
||||||
|
Bound to;
|
||||||
|
Bound from;
|
||||||
|
KEY_TYPE firstInclusive;
|
||||||
|
KEY_TYPE lastInclusive;
|
||||||
|
Comparator<Entry KEY_VALUE_GENERIC_TYPE> entryComparator;
|
||||||
|
|
||||||
|
public SortedMapGenerator(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent, Bound to, Bound from) {
|
||||||
|
super(parent);
|
||||||
|
this.parent = parent;
|
||||||
|
this.to = to;
|
||||||
|
this.from = from;
|
||||||
|
SORTED_MAP KEY_VALUE_GENERIC_TYPE map = parent.create();
|
||||||
|
entryComparator = DERIVED_MAP_GENERATORS.entryComparator(map.comparator());
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> samples = parent.getSamples().asList();
|
||||||
|
samples.sort(entryComparator);
|
||||||
|
firstInclusive = samples.get(0).ENTRY_KEY();
|
||||||
|
lastInclusive = samples.get(samples.size() - 1).ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE create(Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> entries = new ObjectArrayList<>();
|
||||||
|
if (from != Bound.NO_BOUND) {
|
||||||
|
entries.add(parent.belowSamplesLesser());
|
||||||
|
entries.add(parent.belowSamplesGreater());
|
||||||
|
}
|
||||||
|
if (to != Bound.NO_BOUND) {
|
||||||
|
entries.add(parent.aboveSamplesLesser());
|
||||||
|
entries.add(parent.aboveSamplesGreater());
|
||||||
|
}
|
||||||
|
entries.addAll(elements);
|
||||||
|
return createSubMap(parent.create(entries.toArray(Entry[]::new)), parent.belowSamplesGreater().ENTRY_KEY(), parent.aboveSamplesLesser().ENTRY_KEY());
|
||||||
|
}
|
||||||
|
|
||||||
|
SORTED_MAP KEY_VALUE_GENERIC_TYPE createSubMap(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, KEY_TYPE firstExclusive, KEY_TYPE lastExclusive) {
|
||||||
|
if (from == Bound.NO_BOUND && to == Bound.EXCLUSIVE) {
|
||||||
|
return map.headMap(lastExclusive);
|
||||||
|
} else if (from == Bound.INCLUSIVE && to == Bound.NO_BOUND) {
|
||||||
|
return map.tailMap(firstInclusive);
|
||||||
|
} else if (from == Bound.INCLUSIVE && to == Bound.EXCLUSIVE) {
|
||||||
|
return map.subMap(firstInclusive, lastExclusive);
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class DescendingTestMapGenerator KEY_VALUE_GENERIC_TYPE extends MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
||||||
|
|
||||||
|
public DescendingTestMapGenerator(TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent) {
|
||||||
|
super(parent);
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE create(Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||||
|
return ((NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE)parent.create(elements)).descendingMap();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
|
ObjectList<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> values = ObjectIterators.pour(ObjectIterators.wrap(parent.order(insertionOrder).iterator()));
|
||||||
|
ObjectLists.reverse(values);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIterable<Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> values = parent.order(insertionOrder).pourAsList();
|
||||||
|
ObjectLists.reverse(values);
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() {
|
||||||
|
return parent.aboveSamplesGreater();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() {
|
||||||
|
return parent.aboveSamplesLesser();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() {
|
||||||
|
return parent.belowSamplesGreater();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() {
|
||||||
|
return parent.belowSamplesLesser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
||||||
|
|
||||||
|
public MapGenerator(TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
|
return parent.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectSamples<Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||||
|
return parent.getSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIterable<Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
return parent.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MAP KEY_VALUE_GENERIC_TYPE create(Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||||
|
return parent.create(elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GENERIC_KEY_VALUE_BRACES TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
if(inner.getInnerGenerator() instanceof TEST_ORDERED_MAP_GENERATOR) {
|
||||||
|
ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> set = ((TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator()).create().ENTRY_SET();
|
||||||
|
if(set instanceof ObjectOrderedSet) return new OrderedMapEntrySetGeneratorKV_BRACES(inner);
|
||||||
|
}
|
||||||
|
return new MapEntrySetGeneratorKV_BRACES(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OrderedMapEntrySetGenerator KEY_VALUE_GENERIC_TYPE extends MapEntrySetGenerator KEY_VALUE_GENERIC_TYPE implements TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
|
||||||
|
public OrderedMapEntrySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
super(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectOrderedSet<Entry KEY_VALUE_GENERIC_TYPE> create(Object... elements) {
|
||||||
|
return (ObjectOrderedSet<Entry KEY_VALUE_GENERIC_TYPE>)super.create(elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapEntrySetGenerator KEY_VALUE_GENERIC_TYPE implements TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator;
|
||||||
|
|
||||||
|
public MapEntrySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
generator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectSamples<Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||||
|
return generator.getSamples();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectIterable<Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
return generator.order(insertionOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<Entry KEY_VALUE_GENERIC_TYPE> order(List<Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
return generator.order(new ObjectArrayList<Entry KEY_VALUE_GENERIC_TYPE>(insertionOrder));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entry KEY_VALUE_GENERIC_TYPE[] createArray(int length) {
|
||||||
|
return new Entry[length];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> create(Object... elements) {
|
||||||
|
return generator.create(elements).ENTRY_SET();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GENERIC_KEY_VALUE_BRACES TEST_SET_GENERATOR KEY_GENERIC_TYPE keySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
if (inner.getInnerGenerator() instanceof TEST_SORTED_MAP_GENERATOR) {
|
||||||
|
SET KEY_GENERIC_TYPE set = ((TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator()).create().keySet();
|
||||||
|
if(set instanceof NAVIGABLE_SET) return new MapNavigableKeySetGeneratorKV_BRACES(inner);
|
||||||
|
if(set instanceof SORTED_SET) return new MapSortedKeySetGeneratorKV_BRACES(inner);
|
||||||
|
}
|
||||||
|
if(inner.getInnerGenerator() instanceof TEST_ORDERED_MAP_GENERATOR) {
|
||||||
|
SET KEY_GENERIC_TYPE set = ((TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator()).create().keySet();
|
||||||
|
if(set instanceof ORDERED_SET) return new MapOrderedKeySetGeneratorKV_BRACES(inner);
|
||||||
|
}
|
||||||
|
return new MapKeySetGeneratorKV_BRACES(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapNavigableKeySetGenerator KEY_VALUE_GENERIC_TYPE extends MapSortedKeySetGenerator KEY_VALUE_GENERIC_TYPE implements TEST_NAVIGABLE_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
public MapNavigableKeySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
super(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public NAVIGABLE_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
return (NAVIGABLE_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapSortedKeySetGenerator KEY_VALUE_GENERIC_TYPE extends MapKeySetGenerator KEY_VALUE_GENERIC_TYPE implements TEST_SORTED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator;
|
||||||
|
|
||||||
|
public MapSortedKeySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
super(inner);
|
||||||
|
generator = (TEST_SORTED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return (SORTED_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public SORTED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
return (SORTED_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesLesser() {
|
||||||
|
return generator.belowSamplesLesser().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE belowSamplesGreater() {
|
||||||
|
return generator.belowSamplesGreater().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesLesser() {
|
||||||
|
return generator.aboveSamplesLesser().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE aboveSamplesGreater() {
|
||||||
|
return generator.aboveSamplesGreater().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapOrderedKeySetGenerator KEY_VALUE_GENERIC_TYPE extends MapKeySetGenerator KEY_VALUE_GENERIC_TYPE implements TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
|
public MapOrderedKeySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
super(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
return (ORDERED_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public ORDERED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
return (ORDERED_SET KEY_GENERIC_TYPE) super.create(elements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapKeySetGenerator KEY_VALUE_GENERIC_TYPE implements TEST_SET_GENERATOR KEY_GENERIC_TYPE {
|
||||||
|
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator;
|
||||||
|
SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
||||||
|
|
||||||
|
public MapKeySetGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
generator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator();
|
||||||
|
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = generator.getSamples();
|
||||||
|
this.samples = new SAMPLE_ELEMENTSBRACES(samples.e0().ENTRY_KEY(), samples.e1().ENTRY_KEY(), samples.e2().ENTRY_KEY(), samples.e3().ENTRY_KEY(), samples.e4().ENTRY_KEY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
||||||
|
return samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
||||||
|
VALUE_TYPE value = generator.getSamples().e0().ENTRY_VALUE();
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> entries = new ObjectArrayList<>();
|
||||||
|
for (KEY_TYPE key : insertionOrder) {
|
||||||
|
entries.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value));
|
||||||
|
}
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.order(entries)) {
|
||||||
|
list.add(entry.ENTRY_KEY());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
||||||
|
VALUE_TYPE value = generator.getSamples().e0().ENTRY_VALUE();
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> entries = new ObjectArrayList<>();
|
||||||
|
for (KEY_TYPE key : insertionOrder) {
|
||||||
|
entries.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value));
|
||||||
|
}
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.order(entries)) {
|
||||||
|
list.add(entry.ENTRY_KEY());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE[] result = new Entry[elements.length];
|
||||||
|
int index = 0;
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.getSamples().asList().subList(0, elements.length)) {
|
||||||
|
result[index] = new ABSTRACT_MAP.BasicEntryKV_BRACES(elements[index++], entry.ENTRY_VALUE());
|
||||||
|
}
|
||||||
|
return generator.create(result).keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public SET KEY_GENERIC_TYPE create(Object... elements) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE[] result = new Entry[elements.length];
|
||||||
|
int index = 0;
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.getSamples().asList().subList(0, elements.length)) {
|
||||||
|
result[index] = new ABSTRACT_MAP.BasicEntryKV_BRACES((CLASS_TYPE) elements[index++], entry.getValue());
|
||||||
|
}
|
||||||
|
return generator.create(result).keySet();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class MapValueCollectionGenerator KEY_VALUE_GENERIC_TYPE implements VALUE_TEST_COLLECTION_GENERATOR VALUE_GENERIC_TYPE {
|
||||||
|
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE generator;
|
||||||
|
VALUE_SAMPLE_ELEMENTS VALUE_GENERIC_TYPE samples;
|
||||||
|
|
||||||
|
public MapValueCollectionGenerator(OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> inner) {
|
||||||
|
generator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) inner.getInnerGenerator();
|
||||||
|
ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> samples = generator.getSamples();
|
||||||
|
this.samples = new VALUE_SAMPLE_ELEMENTSVALUE_BRACES(samples.e0().ENTRY_VALUE(), samples.e1().ENTRY_VALUE(), samples.e2().ENTRY_VALUE(), samples.e3().ENTRY_VALUE(), samples.e4().ENTRY_VALUE());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_SAMPLE_ELEMENTS VALUE_GENERIC_TYPE getSamples() {
|
||||||
|
return samples;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_ITERABLE VALUE_GENERIC_TYPE order(VALUE_LIST VALUE_GENERIC_TYPE insertionOrder) {
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> list = generator.order(generator.getSamples().asList()).pourAsList();
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
insertionOrder.sort(new Comparator<VALUE_TYPE>() {
|
||||||
|
#else
|
||||||
|
insertionOrder.sort(new VALUE_COMPARATOR VALUE_GENERIC_TYPE() {
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public int compare(VALUE_TYPE key, VALUE_TYPE value) {
|
||||||
|
return Integer.signum(indexOf(key) - indexOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int indexOf(VALUE_TYPE entry) {
|
||||||
|
for(int i = 0,m=list.size();i<m;i++) {
|
||||||
|
if(VALUE_EQUALS(list.get(i).ENTRY_VALUE(), entry)) return i;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("MAP.values generator can order only sample values");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<CLASS_VALUE_TYPE> order(List<CLASS_VALUE_TYPE> insertionOrder) {
|
||||||
|
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> list = generator.order(generator.getSamples().asList()).pourAsList();
|
||||||
|
insertionOrder.sort(new Comparator<CLASS_VALUE_TYPE>() {
|
||||||
|
@Override
|
||||||
|
public int compare(CLASS_VALUE_TYPE key, CLASS_VALUE_TYPE value) {
|
||||||
|
return Integer.signum(indexOf(key) - indexOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int indexOf(CLASS_VALUE_TYPE entry) {
|
||||||
|
for(int i = 0,m=list.size();i<m;i++) {
|
||||||
|
if(VALUE_EQUALS(list.get(i).ENTRY_VALUE(), OBJ_TO_VALUE(entry))) return i;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("MAP.values generator can order only sample values");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE create(VALUE_TYPE... elements) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE[] result = new Entry[elements.length];
|
||||||
|
int index = 0;
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.getSamples().asList().subList(0, elements.length)) {
|
||||||
|
result[index] = new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.ENTRY_KEY(), elements[index++]);
|
||||||
|
}
|
||||||
|
return generator.create(result).values();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE create(Object... elements) {
|
||||||
|
Entry KEY_VALUE_GENERIC_TYPE[] result = new Entry[elements.length];
|
||||||
|
int index = 0;
|
||||||
|
for (Entry KEY_VALUE_GENERIC_TYPE entry : generator.getSamples().asList().subList(0, elements.length)) {
|
||||||
|
result[index] = new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), (CLASS_VALUE_TYPE)elements[index++]);
|
||||||
|
}
|
||||||
|
return generator.create(result).values();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KEY_VALUE_GENERIC_TYPE Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> entryObjectComparator(Comparator<CLASS_TYPE> keyComparator) {
|
||||||
|
return new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> a, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> b) {
|
||||||
|
if(keyComparator == null) {
|
||||||
|
return COMPAREABLE_TO_KEY(OBJ_TO_KEY(a.getKey()), OBJ_TO_KEY(b.getKey()));
|
||||||
|
}
|
||||||
|
return keyComparator.compare(OBJ_TO_KEY(a.getKey()), OBJ_TO_KEY(b.getKey()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static KEY_VALUE_GENERIC_TYPE Comparator<Entry KEY_VALUE_GENERIC_TYPE> entryComparator(COMPARATOR KEY_GENERIC_TYPE keyComparator) {
|
||||||
|
return new Comparator<Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Entry KEY_VALUE_GENERIC_TYPE a, Entry KEY_VALUE_GENERIC_TYPE b) {
|
||||||
|
if(keyComparator == null) {
|
||||||
|
return COMPAREABLE_TO_KEY(a.ENTRY_KEY(), b.ENTRY_KEY());
|
||||||
|
}
|
||||||
|
return keyComparator.compare(a.ENTRY_KEY(), b.ENTRY_KEY());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+934
@@ -0,0 +1,934 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT || VALUE_OBJECT
|
||||||
|
import java.util.Arrays;
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Comparator;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import org.junit.Assert;
|
||||||
|
#endif
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import com.google.common.collect.testing.AnEnum;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester;
|
||||||
|
#if TYPE_OBJECT || VALUE_OBJECT
|
||||||
|
import speiger.src.collections.objects.utils.StringSortTest;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class MAP_CONSTRUCTOR_TESTS
|
||||||
|
{
|
||||||
|
public static class HashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public HashMap() {
|
||||||
|
setSimpleConstructor(MAP.builder()::map);
|
||||||
|
setSizeConstructor(MAP.builder()::map);
|
||||||
|
setPArrayConstructor(MAP.builder()::map);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(MAP.builder()::map);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(MAP.builder()::map);
|
||||||
|
setMapConstructor(MAP.builder()::map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongLoadFactorSize() {
|
||||||
|
setSizeConstructor(T -> new HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 1 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedHashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public LinkedHashMap() {
|
||||||
|
setSimpleConstructor(MAP.builder()::linkedMap);
|
||||||
|
setSizeConstructor(MAP.builder()::linkedMap);
|
||||||
|
setPArrayConstructor(MAP.builder()::linkedMap);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(MAP.builder()::linkedMap);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(MAP.builder()::linkedMap);
|
||||||
|
setMapConstructor(MAP.builder()::linkedMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongLoadFactorSize() {
|
||||||
|
setSizeConstructor(T -> new LINKED_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new LINKED_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 1 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
public static class EnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum, String>
|
||||||
|
#else
|
||||||
|
public static class EnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
public EnumMap() {
|
||||||
|
setSimpleConstructor(() -> new ENUM_MAP<>(AnEnum.class));
|
||||||
|
setPArrayConstructor(ENUM_MAP::new);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(ENUM_MAP::new);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(ENUM_MAP::new);
|
||||||
|
setMapConstructor(ENUM_MAP::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnumMapConstructor() {
|
||||||
|
if(pMapConstructor == null) return;
|
||||||
|
Assert.assertTrue(pMapConstructor.apply(new ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObjectEnumMapConstructor() {
|
||||||
|
if(pMapConstructor == null) return;
|
||||||
|
Assert.assertTrue(mapConstructor.apply(new ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AnEnum[] createKeyElements() {
|
||||||
|
return AnEnum.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOf(StringSortTest.NAMES, AnEnum.values().length);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
protected int getSize() {
|
||||||
|
return AnEnum.values().length;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
public static class LinkedEnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum, String>
|
||||||
|
#else
|
||||||
|
public static class LinkedEnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum>
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
public LinkedEnumMap() {
|
||||||
|
setSimpleConstructor(() -> new LINKED_ENUM_MAP<>(AnEnum.class));
|
||||||
|
setPArrayConstructor(LINKED_ENUM_MAP::new);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(LINKED_ENUM_MAP::new);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(LINKED_ENUM_MAP::new);
|
||||||
|
setMapConstructor(LINKED_ENUM_MAP::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEnumMapConstructor() {
|
||||||
|
if(pMapConstructor == null) return;
|
||||||
|
Assert.assertTrue(pMapConstructor.apply(new LINKED_ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
Assert.assertTrue(pMapConstructor.apply(new ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testObjectEnumMapConstructor() {
|
||||||
|
if(mapConstructor == null) return;
|
||||||
|
Assert.assertTrue(mapConstructor.apply(new LINKED_ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
Assert.assertTrue(mapConstructor.apply(new ENUM_MAP<>(new LINKED_HASH_MAPKV_BRACES(keys, values))) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AnEnum[] createKeyElements() {
|
||||||
|
return AnEnum.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOf(StringSortTest.NAMES, AnEnum.values().length);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
protected int getSize() {
|
||||||
|
return AnEnum.values().length;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public static class CustomHashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public CustomHashMap() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder().customMap(HashStrategy.INSTANCE));
|
||||||
|
setSizeConstructor(T -> MAP.builder().customMap(T, HashStrategy.INSTANCE));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().customMap(K, V, HashStrategy.INSTANCE));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().customMap(K, V, HashStrategy.INSTANCE));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().customMap(T, HashStrategy.INSTANCE));
|
||||||
|
setMapConstructor(T -> MAP.builder().customMap(T, HashStrategy.INSTANCE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongLoadFactorSize() {
|
||||||
|
setSizeConstructor(T -> new CUSTOM_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F, HashStrategy.INSTANCE));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new CUSTOM_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F, HashStrategy.INSTANCE));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 1 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedCustomHashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public LinkedCustomHashMap() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder().customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
setSizeConstructor(T -> MAP.builder().customLinkedMap(T, HashStrategy.INSTANCE));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().customLinkedMap(K, V, HashStrategy.INSTANCE));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().customLinkedMap(K, V, HashStrategy.INSTANCE));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().customLinkedMap(T, HashStrategy.INSTANCE));
|
||||||
|
setMapConstructor(T -> MAP.builder().customLinkedMap(T, HashStrategy.INSTANCE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongLoadFactorSize() {
|
||||||
|
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F, HashStrategy.INSTANCE));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new LINKED_CUSTOM_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F, HashStrategy.INSTANCE));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 1 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImmutableHashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ImmutableHashMap() {
|
||||||
|
setPArrayConstructor(MAP.builder()::immutable);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(MAP.builder()::immutable);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(MAP.builder()::immutable);
|
||||||
|
setMapConstructor(MAP.builder()::immutable);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConcurrentHashMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ConcurrentHashMap() {
|
||||||
|
setSimpleConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
setSizeConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
setPArrayConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
setMapConstructor(CONCURRENT_HASH_MAP::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongLoadFactorSize() {
|
||||||
|
setSizeConstructor(T -> new CONCURRENT_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new CONCURRENT_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 1 LoadFactor should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testWrongConcurrency() {
|
||||||
|
setSizeConstructor(T -> new CONCURRENT_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 0 Concurrency should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
setSizeConstructor(T -> new CONCURRENT_HASH_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, Integer.MAX_VALUE));
|
||||||
|
try {
|
||||||
|
testSizeConstructor_smallSize();
|
||||||
|
fail("A Constructor using a 65536 or larger Concurrency should error");
|
||||||
|
} catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ArrayMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ArrayMap() {
|
||||||
|
setSimpleConstructor(MAP.builder()::arrayMap);
|
||||||
|
setSizeConstructor(MAP.builder()::arrayMap);
|
||||||
|
setPArrayConstructor(MAP.builder()::arrayMap);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(MAP.builder()::arrayMap);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(MAP.builder()::arrayMap);
|
||||||
|
setMapConstructor(MAP.builder()::arrayMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public RBTreeMap() {
|
||||||
|
setSimpleConstructor(MAP.builder()::rbTreeMap);
|
||||||
|
setPArrayConstructor(RB_TREE_MAP::new);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(RB_TREE_MAP::new);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(RB_TREE_MAP::new);
|
||||||
|
setMapConstructor(RB_TREE_MAP::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeMapComparator extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public RBTreeMapComparator() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPErbTreeMap(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().rbTreeMap(K, V, Comparator.naturalOrder()));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().rbTreeMap(K, V, Comparator.naturalOrder()));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().rbTreeMap(T, Comparator.naturalOrder()));
|
||||||
|
setMapConstructor(T -> MAP.builder().rbTreeMap(T, Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> MAP.builder().rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().rbTreeMap(K, V, CLASS_TYPE::compare));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().rbTreeMap(K, V, CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().rbTreeMap(T, CLASS_TYPE::compare));
|
||||||
|
setMapConstructor(T -> MAP.builder().rbTreeMap(T, CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public AVLTreeMap() {
|
||||||
|
setSimpleConstructor(MAP.builder()::avlTreeMap);
|
||||||
|
setPArrayConstructor(AVL_TREE_MAP::new);
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor(AVL_TREE_MAP::new);
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(AVL_TREE_MAP::new);
|
||||||
|
setMapConstructor(AVL_TREE_MAP::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeMapComparator extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public AVLTreeMapComparator() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEavlTreeMap(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().avlTreeMap(K, V, Comparator.naturalOrder()));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().avlTreeMap(K, V, Comparator.naturalOrder()));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().avlTreeMap(T, Comparator.naturalOrder()));
|
||||||
|
setMapConstructor(T -> MAP.builder().avlTreeMap(T, Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> MAP.builder().avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor((K, V) -> MAP.builder().avlTreeMap(K, V, CLASS_TYPE::compare));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> MAP.builder().avlTreeMap(K, V, CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder().avlTreeMap(T, CLASS_TYPE::compare));
|
||||||
|
setMapConstructor(T -> MAP.builder().avlTreeMap(T, CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class HashStrategy implements STRATEGY KEY_STRING_GENERIC_TYPE {
|
||||||
|
static final HashStrategy INSTANCE = new HashStrategy();
|
||||||
|
@Override
|
||||||
|
public int hashCode(KEY_STRING_TYPE o) { return KEY_TO_HASH(o); }
|
||||||
|
@Override
|
||||||
|
public boolean equals(KEY_STRING_TYPE key, KEY_STRING_TYPE value) { return KEY_EQUALS(key, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class HashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public HashMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().map());
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).map());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).map());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).map());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).map());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).map());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedHashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public LinkedHashMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().linkedMap());
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).linkedMap());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).linkedMap());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).linkedMap());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).linkedMap());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).linkedMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class CustomHashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public CustomHashMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().customMap(HashStrategy.INSTANCE));
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).customMap(HashStrategy.INSTANCE));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).customMap(HashStrategy.INSTANCE));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).customMap(HashStrategy.INSTANCE));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).customMap(HashStrategy.INSTANCE));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).customMap(HashStrategy.INSTANCE));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class LinkedCustomHashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public LinkedCustomHashMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).customLinkedMap(HashStrategy.INSTANCE));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ImmutableHashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ImmutableHashMapBuilder() {
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).immutable());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).immutable());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).immutable());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).immutable());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ConcurrentHashMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ConcurrentHashMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().concurrentMap());
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).concurrentMap());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).concurrentMap());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).concurrentMap());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).concurrentMap());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).concurrentMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ArrayMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public ArrayMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().arrayMap());
|
||||||
|
setSizeConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(T).arrayMap());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).arrayMap());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).arrayMap());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).arrayMap());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).arrayMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public RBTreeMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().rbTreeMap());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RBTreeMapComparatorBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public RBTreeMapComparatorBuilder() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().rbTreeMap(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap(Comparator.naturalOrder()));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap(Comparator.naturalOrder()));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap(Comparator.naturalOrder()));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap(Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).rbTreeMap(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeMapBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public AVLTreeMapBuilder() {
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().avlTreeMap());
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap());
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap());
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap());
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class AVLTreeMapComparatorBuilder extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public AVLTreeMapComparatorBuilder() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().avlTreeMap(Comparator.naturalOrder()));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap(Comparator.naturalOrder()));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap(Comparator.naturalOrder()));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap(Comparator.naturalOrder()));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap(Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
setSimpleConstructor(() -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
setPArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
setArrayConstructor((K, V) -> putAll(MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart(), K, V).avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
setPMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
setMapConstructor(T -> MAP.builder(). KEY_VALUE_STRING_GENERIC_TYPEstart().putAll(T).avlTreeMap(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createKeyElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
protected String[] createValueElements() {
|
||||||
|
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MAP.BuilderCache KEY_VALUE_STRING_GENERIC_TYPE putAll(MAP.BuilderCache KEY_VALUE_STRING_GENERIC_TYPE cache, KEY_STRING_TYPE[] keys, VALUE_STRING_TYPE[] values) {
|
||||||
|
if(keys.length != values.length) throw new IllegalStateException("Keys & Values lengths must match");
|
||||||
|
for(int i = 0;i<keys.length;i++) {
|
||||||
|
cache.put(keys[i], values[i]);
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
|
||||||
|
private static MAP.BuilderCache KEY_VALUE_STRING_GENERIC_TYPE putAll(MAP.BuilderCache KEY_VALUE_STRING_GENERIC_TYPE cache, CLASS_STRING_TYPE[] keys, CLASS_STRING_VALUE_TYPE[] values) {
|
||||||
|
if(keys.length != values.length) throw new IllegalStateException("Keys & Values lengths must match");
|
||||||
|
for(int i = 0;i<keys.length;i++) {
|
||||||
|
cache.put(keys[i], values[i]);
|
||||||
|
}
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+200
@@ -0,0 +1,200 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_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.ORDERED_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
#if TYPE_OBJECT || VALUE_OBJECT
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
|
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_ORDERED_MAP_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_SORTED_MAP_GENERATOR;
|
||||||
|
import speiger.src.testers.objects.utils.ObjectSamples;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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;
|
||||||
|
#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};
|
||||||
|
#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};
|
||||||
|
#else if TYPE_CHAR
|
||||||
|
KEY_TYPE[] keys = new KEY_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||||
|
#else if TYPE_OBJECT
|
||||||
|
KEY_TYPE[] keys;
|
||||||
|
#else
|
||||||
|
KEY_TYPE[] keys = new KEY_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||||
|
#endif
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
VALUE_TYPE[] values = new VALUE_TYPE[]{true, true, true, false, true, false, true, false, true};
|
||||||
|
#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};
|
||||||
|
#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};
|
||||||
|
#else if VALUE_CHAR
|
||||||
|
VALUE_TYPE[] values = new VALUE_TYPE[]{(char)0, (char)1, (char)2, (char)3, (char)4};
|
||||||
|
#else if VALUE_OBJECT
|
||||||
|
VALUE_TYPE[] values;
|
||||||
|
#else
|
||||||
|
VALUE_TYPE[] values = new VALUE_TYPE[]{0, 1, 2, 3, 4, -2, -1, 5, 6};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public SIMPLE_MAP_TEST_GENERATOR(BiFunction<KEY_TYPE[], VALUE_TYPE[], E> mapper) {
|
||||||
|
this.mapper = mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT || TYPE_CHAR
|
||||||
|
public void setKeys(KEY_TYPE... keys) {
|
||||||
|
this.keys = keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT || VALUE_CHAR
|
||||||
|
public void setValues(VALUE_TYPE... values) {
|
||||||
|
this.values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
public ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSamples() {
|
||||||
|
return new ObjectSamples<MAP.Entry KEY_VALUE_GENERIC_TYPE>(
|
||||||
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[0], values[0]),
|
||||||
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[1], values[1]),
|
||||||
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[2], values[2]),
|
||||||
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[3], values[3]),
|
||||||
|
new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[4], values[4])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public E create(MAP.Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
KEY_TYPE[] keys = (T[])ObjectArrays.newArray(getSamples().e0().ENTRY_KEY().getClass(), elements.length);
|
||||||
|
#else
|
||||||
|
KEY_TYPE[] keys = NEW_KEY_ARRAY(elements.length);
|
||||||
|
#endif
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
VALUE_TYPE[] values = (V[])ObjectArrays.newArray(getSamples().e0().ENTRY_VALUE().getClass(), elements.length);
|
||||||
|
#else
|
||||||
|
VALUE_TYPE[] values = NEW_VALUE_ARRAY(elements.length);
|
||||||
|
#endif
|
||||||
|
for(int i = 0;i<elements.length;i++) {
|
||||||
|
keys[i] = elements[i].ENTRY_KEY();
|
||||||
|
values[i] = elements[i].ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
return mapper.apply(keys, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> 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 Maps(BiFunction<KEY_TYPE[], VALUE_TYPE[], MAP KEY_VALUE_GENERIC_TYPE> 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 OrderedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], ORDERED_MAP KEY_VALUE_GENERIC_TYPE> 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
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
this.sorter = sorter;
|
||||||
|
}
|
||||||
|
|
||||||
|
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<>();
|
||||||
|
for(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry : insertionOrder) {
|
||||||
|
newList.add(new ABSTRACT_MAP.BasicEntryKV_BRACES(entry.getKey(), entry.getValue()));
|
||||||
|
}
|
||||||
|
order(newList);
|
||||||
|
insertionOrder.sort(new Comparator<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>() {
|
||||||
|
@Override
|
||||||
|
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())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int indexOf(KEY_TYPE key) {
|
||||||
|
for(int i = 0,m=newList.size();i<m;i++) {
|
||||||
|
if(KEY_EQUALS(newList.get(i).ENTRY_KEY(), key)) return i;
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("MAP.entry sorter was corrupting data");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
sorter.accept(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 SortedMaps(BiFunction<KEY_TYPE[], VALUE_TYPE[], SORTED_MAP KEY_VALUE_GENERIC_TYPE> mapper) {
|
||||||
|
super(mapper);
|
||||||
|
#if TYPE_CHAR
|
||||||
|
setKeys(new KEY_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||||
|
#endif
|
||||||
|
#if VALUE_CHAR
|
||||||
|
setValues(new VALUE_TYPE[]{'a', 'b', 'c', 'd', 'e', '_', '`', 'f', 'g'});
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> order(List<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> insertionOrder) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryObjectComparator(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> order(ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> insertionOrder) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator((Comparator<T>)Comparator.naturalOrder()));
|
||||||
|
#else
|
||||||
|
insertionOrder.sort(DERIVED_MAP_GENERATORS.entryComparator(CLASS_TYPE::compare));
|
||||||
|
#endif
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[5], values[5]); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE belowSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[6], values[6]); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesLesser() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[7], values[7]); }
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE aboveSamplesGreater() { return new ABSTRACT_MAP.BasicEntryKV_BRACES(keys[8], values[8]); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.impl.maps;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class SIMPLE_TEST_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
MAP KEY_VALUE_GENERIC_TYPE map;
|
||||||
|
|
||||||
|
public SIMPLE_TEST_MAP(KEY_TYPE[] keys, VALUE_TYPE[] values) {
|
||||||
|
map = new ARRAY_MAPKV_BRACES(keys, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
||||||
|
map.setDefaultReturnValue(v);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
||||||
|
#if VALUE_PRIMITIVES
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public CLASS_VALUE_TYPE remove(Object key) { return map.remove(key); }
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object key, Object value) { return map.remove(key, value); }
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
||||||
|
#if TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
|
return new AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||||
|
@Override
|
||||||
|
public ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
|
return new ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE>() {
|
||||||
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = map.ENTRY_SET().iterator();
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return iter.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE 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()) {
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE setValue(VALUE_TYPE value) {
|
||||||
|
return entry.setValue(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return map.size();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected COLLECTION KEY_GENERIC_TYPE actualContents() {
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected COLLECTION KEY_GENERIC_TYPE resetContainer(COLLECTION KEY_GENERIC_TYPE newContents) {
|
||||||
|
collection = super.resetContainer(newContents);
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetCollection() {
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+188
@@ -0,0 +1,188 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
|
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
import com.google.errorprone.annotations.OverridingMethodsMustInvokeSuper;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_COLLECTION_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public abstract class ABSTRACT_CONTAINER_TESTER KKS_GENERIC_TYPE<E> extends AbstractTester<OneSizeTestContainerGenerator<E, CLASS_TYPE>>
|
||||||
|
{
|
||||||
|
protected SAMPLE_ELEMENTS KEY_GENERIC_TYPE samples;
|
||||||
|
protected E container;
|
||||||
|
protected TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE primitiveGenerator;
|
||||||
|
protected CollectionSize size;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@OverridingMethodsMustInvokeSuper
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
setupGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setupGenerator() {
|
||||||
|
TestContainerGenerator<E, CLASS_TYPE> generator = getSubjectGenerator().getInnerGenerator();
|
||||||
|
if (!(generator instanceof TEST_COLLECTION_GENERATOR)) throw new IllegalStateException("Test Generator Must extend TEST_COLLECTION_GENERATOR");
|
||||||
|
primitiveGenerator = (TEST_COLLECTION_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||||
|
samples = primitiveGenerator.getSamples();
|
||||||
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract COLLECTION KEY_GENERIC_TYPE actualContents();
|
||||||
|
|
||||||
|
protected E resetContainer() {
|
||||||
|
return resetContainer(createTestSubject());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected E resetContainer(E newValue) {
|
||||||
|
container = newValue;
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectContents(KEY_TYPE... elements) {
|
||||||
|
expectContents(ARRAY_LIST.wrap(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||||
|
HELPERS.assertEqualIgnoringOrder(expected, actualContents());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectUnchanged() {
|
||||||
|
expectContents(getOrderedElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void expectAdded(KEY_TYPE... elements) {
|
||||||
|
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||||
|
expected.addAll(elements);
|
||||||
|
expectContents(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void expectAddedIndex(int index, KEY_TYPE... elements) {
|
||||||
|
expectAdded(index, ARRAY_LIST.wrap(elements));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void expectAdded(int index, COLLECTION KEY_GENERIC_TYPE elements) {
|
||||||
|
LIST KEY_GENERIC_TYPE expected = HELPERS.copyToList(getSampleElements());
|
||||||
|
expected.addAll(index, elements);
|
||||||
|
expectContents(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectMissing(KEY_TYPE... elements) {
|
||||||
|
for (KEY_TYPE element : elements) {
|
||||||
|
assertFalse("Should not contain " + element, actualContents().contains(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected KEY_TYPE[] createSamplesArray() {
|
||||||
|
return getSampleElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected KEY_TYPE[] createOrderedArray() {
|
||||||
|
return getOrderedElements().TO_ARRAY(NEW_KEY_ARRAY(getNumElements()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ArrayWithDuplicate KEY_GENERIC_TYPE {
|
||||||
|
public final KEY_TYPE[] elements;
|
||||||
|
public final KEY_TYPE duplicate;
|
||||||
|
|
||||||
|
private ArrayWithDuplicate(KEY_TYPE[] elements, KEY_TYPE duplicate) {
|
||||||
|
this.elements = elements;
|
||||||
|
this.duplicate = duplicate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArrayWithDuplicate KEY_GENERIC_TYPE createArrayWithDuplicateElement() {
|
||||||
|
KEY_TYPE[] elements = createSamplesArray();
|
||||||
|
KEY_TYPE duplicate = elements[(elements.length / 2) - 1];
|
||||||
|
elements[(elements.length / 2) + 1] = duplicate;
|
||||||
|
return new ArrayWithDuplicateBRACES(elements, duplicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getNumElements() {
|
||||||
|
return size.getNumElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected COLLECTION KEY_GENERIC_TYPE getSampleElements() {
|
||||||
|
return getSampleElements(getNumElements());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
for (ITERATOR KEY_GENERIC_TYPE iter = primitiveGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||||
|
list.add(iter.NEXT());
|
||||||
|
}
|
||||||
|
return LISTS.unmodifiable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
protected KEY_TYPE[] createDisjointArray() {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||||
|
array[0] = e3();
|
||||||
|
array[1] = e4();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
protected KEY_TYPE[] createDisjointArray() {
|
||||||
|
return new KEY_TYPE[]{e3(), e4()};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected KEY_TYPE[] emptyArray() {
|
||||||
|
return NEW_KEY_ARRAY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE createDisjointCollection() {
|
||||||
|
return MINIMAL_COLLECTION.of(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MINIMAL_COLLECTION KEY_GENERIC_TYPE emptyCollection() {
|
||||||
|
return MINIMAL_COLLECTION.of();
|
||||||
|
}
|
||||||
|
|
||||||
|
public KEY_TYPE[] createArray(KEY_TYPE...array) {
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE e0() {
|
||||||
|
return samples.e0();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE e1() {
|
||||||
|
return samples.e1();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE e2() {
|
||||||
|
return samples.e2();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE e3() {
|
||||||
|
return samples.e3();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE e4() {
|
||||||
|
return samples.e4();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected E createTestSubject() {
|
||||||
|
return (E)primitiveGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected COLLECTION KEY_GENERIC_TYPE getSampleElements(int howMany) {
|
||||||
|
return new ARRAY_LISTBRACES(samples.asList().subList(0, howMany));
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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 String getMethodName();
|
||||||
|
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testFind_yes() {
|
||||||
|
assertEquals(getMethodName() + "(firstElement) should return 0", 0, find(getOrderedElements().GET_KEY(0)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFind_no() {
|
||||||
|
assertEquals(getMethodName() + "(notPresent) should return -1", -1, find(e3()));
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class ABSTRACT_LIST_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
protected final LIST KEY_GENERIC_TYPE getList() {
|
||||||
|
return (LIST KEY_GENERIC_TYPE) collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expectedCollection) {
|
||||||
|
LIST KEY_GENERIC_TYPE expectedList = HELPERS.copyToList(expectedCollection);
|
||||||
|
if (getList().size() != expectedList.size()) {
|
||||||
|
fail("size mismatch: " + reportContext(expectedList));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < expectedList.size(); i++) {
|
||||||
|
KEY_TYPE expected = expectedList.GET_KEY(i);
|
||||||
|
KEY_TYPE actual = getList().GET_KEY(i);
|
||||||
|
if (KEY_EQUALS_NOT(expected, actual)) {
|
||||||
|
fail("mismatch at index " + i + ": " + reportContext(expectedList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String reportContext(LIST KEY_GENERIC_TYPE expected) {
|
||||||
|
return String.format("expected collection %s; actual collection %s", expected, collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
+81
@@ -0,0 +1,81 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.TEST_QUEUE_GENERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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 PRIORITY_QUEUE KEY_GENERIC_TYPE queue;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupGenerator() {
|
||||||
|
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");
|
||||||
|
queueGenerator = (TEST_QUEUE_GENERATOR KEY_GENERIC_TYPE) generator;
|
||||||
|
samples = queueGenerator.getSamples();
|
||||||
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected COLLECTION KEY_GENERIC_TYPE actualContents() { return null; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PRIORITY_QUEUE KEY_GENERIC_TYPE resetContainer(PRIORITY_QUEUE KEY_GENERIC_TYPE newValue) {
|
||||||
|
queue = super.resetContainer(newValue);
|
||||||
|
return queue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetQueue() {
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LIST KEY_GENERIC_TYPE getOrderedElements() {
|
||||||
|
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
for (ITERATOR KEY_GENERIC_TYPE iter = queueGenerator.order(new ARRAY_LISTBRACES(getSampleElements())).iterator(); iter.hasNext();) {
|
||||||
|
list.add(iter.NEXT());
|
||||||
|
}
|
||||||
|
return LISTS.unmodifiable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected PRIORITY_QUEUE KEY_GENERIC_TYPE createTestSubject() {
|
||||||
|
return queueGenerator.create(getSampleElements(size.getNumElements()).TO_ARRAY(NEW_KEY_ARRAY(getNumElements())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void expectContents(COLLECTION KEY_GENERIC_TYPE expected) {
|
||||||
|
HELPERS.assertContentsAnyOrder(expected, queue.TO_ARRAY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void expectMissing(KEY_TYPE... elements) {
|
||||||
|
for (KEY_TYPE element : elements) {
|
||||||
|
assertFalse("Should not contain " + element, contains(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean contains(KEY_TYPE element) {
|
||||||
|
for(int i = 0,m=queue.size();i<m;i++) {
|
||||||
|
if(KEY_EQUALS(queue.peek(i), element)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class ABSTRACT_SET_TESTER KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
protected final SET KEY_GENERIC_TYPE getSet() {
|
||||||
|
return (SET KEY_GENERIC_TYPE)collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
+243
@@ -0,0 +1,243 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.base.maps;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
import java.util.Objects;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.TestContainerGenerator;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectCollection;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectArrayList;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectList;
|
||||||
|
import speiger.src.collections.objects.lists.ObjectListIterator;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectLists;
|
||||||
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_MAP_GENERATOR;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.testers.PACKAGE.utils.HELPERS;
|
||||||
|
#endif
|
||||||
|
import speiger.src.testers.objects.tests.base.AbstractObjectContainerTester;
|
||||||
|
import speiger.src.testers.objects.utils.ObjectHelpers;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
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 MAP KEY_VALUE_GENERIC_TYPE getMap() {
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupGenerator() {
|
||||||
|
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");
|
||||||
|
primitiveMapGenerator = (TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) generator;
|
||||||
|
samples = primitiveMapGenerator.getSamples();
|
||||||
|
size = getSubjectGenerator().getCollectionSize();
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MAP KEY_VALUE_GENERIC_TYPE createTestSubject() {
|
||||||
|
return primitiveMapGenerator.create(getSampleElements(size.getNumElements()).toArray(new MAP.Entry[getNumElements()]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> getOrderedElements() {
|
||||||
|
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();) {
|
||||||
|
list.add(iter.next());
|
||||||
|
}
|
||||||
|
return ObjectLists.unmodifiable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> actualContents() {
|
||||||
|
return getMap().ENTRY_SET();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void resetMap() {
|
||||||
|
resetContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void resetMap(MAP.Entry KEY_VALUE_GENERIC_TYPE[] entries) {
|
||||||
|
resetContainer(primitiveMapGenerator.create(entries));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected MAP KEY_VALUE_GENERIC_TYPE resetContainer(MAP KEY_VALUE_GENERIC_TYPE newValue) {
|
||||||
|
newValue.setDefaultReturnValue(INVALID_VALUE);
|
||||||
|
return super.resetContainer(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectMissingKeys(KEY_TYPE... elements) {
|
||||||
|
for (KEY_TYPE element : elements) {
|
||||||
|
assertFalse("Should not contain key " + element, getMap().containsKey(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void expectMissingValues(VALUE_TYPE... elements) {
|
||||||
|
for (VALUE_TYPE element : elements) {
|
||||||
|
assertFalse("Should not contain value " + element, getMap().containsValue(element));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getNumEntries() {
|
||||||
|
return getNumElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries(int howMany) {
|
||||||
|
return getSampleElements(howMany);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> getSampleEntries() {
|
||||||
|
return getSampleElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void expectMissing(MAP.Entry KEY_VALUE_GENERIC_TYPE... entries) {
|
||||||
|
for (MAP.Entry KEY_VALUE_GENERIC_TYPE entry : entries) {
|
||||||
|
assertFalse("Should not contain entry " + entry, actualContents().contains(entry));
|
||||||
|
#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()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void expectContents(ObjectCollection<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected) {
|
||||||
|
super.expectContents(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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void expectReplacement(MAP.Entry KEY_VALUE_GENERIC_TYPE newEntry) {
|
||||||
|
ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> expected = ObjectHelpers.copyToList(getSampleElements());
|
||||||
|
replaceValue(expected, newEntry);
|
||||||
|
expectContents(expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
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();) {
|
||||||
|
if (HELPERS.equals(i.next().ENTRY_KEY(), newEntry.ENTRY_KEY())) {
|
||||||
|
i.set(newEntry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException(String.format(Locale.ROOT, "key %s not found in entries %s", newEntry.ENTRY_KEY(), expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
|
private static GENERIC_VALUE_BRACES boolean valueEquals(VALUE_TYPE a, VALUE_TYPE b) {
|
||||||
|
return VALUE_EQUALS(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected MAP.Entry KEY_VALUE_GENERIC_TYPE entry(KEY_TYPE key, VALUE_TYPE value) {
|
||||||
|
return new ABSTRACT_MAP.BasicEntryKV_BRACES(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected KEY_TYPE[] emptyKeyArray() {
|
||||||
|
return NEW_KEY_ARRAY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected KEY_TYPE[] createDisjointedKeyArray() {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(2);
|
||||||
|
array[0] = k3();
|
||||||
|
array[1] = k4();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CLASS_TYPE[] emptyKeyObjectArray() {
|
||||||
|
return NEW_CLASS_ARRAY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CLASS_TYPE[] createDisjointedKeyObjectArray() {
|
||||||
|
CLASS_TYPE[] array = NEW_CLASS_ARRAY(2);
|
||||||
|
array[0] = k3();
|
||||||
|
array[1] = k4();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE[] emptyValueArray() {
|
||||||
|
return NEW_VALUE_ARRAY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE[] createDisjointedValueArray() {
|
||||||
|
VALUE_TYPE[] array = NEW_VALUE_ARRAY(2);
|
||||||
|
array[0] = v3();
|
||||||
|
array[1] = v4();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CLASS_VALUE_TYPE[] emptyValueObjectArray() {
|
||||||
|
return NEW_CLASS_VALUE_ARRAY(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected CLASS_VALUE_TYPE[] createDisjointedValueObjectArray() {
|
||||||
|
CLASS_VALUE_TYPE[] array = NEW_CLASS_VALUE_ARRAY(2);
|
||||||
|
array[0] = v3();
|
||||||
|
array[1] = v4();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE get(KEY_TYPE key) {
|
||||||
|
return getMap().GET_VALUE(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
protected CLASS_VALUE_TYPE get(CLASS_TYPE key) {
|
||||||
|
return getMap().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected final KEY_TYPE k0() {
|
||||||
|
return e0().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final VALUE_TYPE v0() {
|
||||||
|
return e0().ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE k1() {
|
||||||
|
return e1().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final VALUE_TYPE v1() {
|
||||||
|
return e1().ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE k2() {
|
||||||
|
return e2().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final VALUE_TYPE v2() {
|
||||||
|
return e2().ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE k3() {
|
||||||
|
return e3().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final VALUE_TYPE v3() {
|
||||||
|
return e3().ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final KEY_TYPE k4() {
|
||||||
|
return e4().ENTRY_KEY();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final VALUE_TYPE v4() {
|
||||||
|
return e4().ENTRY_VALUE();
|
||||||
|
}
|
||||||
|
}
|
||||||
+151
@@ -0,0 +1,151 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionAddAllArrayTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
public void testAddAllArray_supportedNothing() {
|
||||||
|
assertFalse("addAll(nothing[]) should return false", collection.addAll(emptyArray()));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
public void testAddAllArray_unsupportedNothing() {
|
||||||
|
try {
|
||||||
|
assertFalse("addAll(nothing[]) should return false or throw", collection.addAll(emptyArray()));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
public void testAddAllArray_supportedNonePresent() {
|
||||||
|
assertTrue("addAll(nonePresent[]) should return true", collection.addAll(createDisjointArray()));
|
||||||
|
expectAdded(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
public void testAddAllArray_unsupportedNonePresent() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointArray());
|
||||||
|
fail("addAll(nonePresent[]) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3(), e4());
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
#endignore
|
||||||
|
public void testAddAllArray_supportedToLargeOffset() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointArray(), 5, 2);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
#endignore
|
||||||
|
public void testAddAllArray_supportedToLargeArray() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointArray(), 3);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
#endignore
|
||||||
|
public void testAddAllArray_supportedToSmallOffset() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointArray(), -1, 2);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
#endignore
|
||||||
|
public void testAddAllArray_supportedAddSubArray() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointArray(), 1);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
expectAdded(e3());
|
||||||
|
expectMissing(e4());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAllArray_supportedSomePresent() {
|
||||||
|
assertTrue("addAll(somePresent[]) should return true", collection.addAll(e3(), e0()));
|
||||||
|
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||||
|
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAllArray_unsupportedSomePresent() {
|
||||||
|
try {
|
||||||
|
collection.addAll(e3(), e0());
|
||||||
|
fail("addAll(somePresent[]) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAllArrayConcurrentWithIteration() {
|
||||||
|
#endignore
|
||||||
|
try {
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||||
|
assertTrue(collection.addAll(e3(), e0()));
|
||||||
|
iterator.NEXT();
|
||||||
|
fail("Expected ConcurrentModificationException");
|
||||||
|
} catch (ConcurrentModificationException expected) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAllArray_unsupportedAllPresent() {
|
||||||
|
try {
|
||||||
|
assertFalse("addAll(allPresent[]) should return false or throw", collection.addAll(e0()));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
#endignore
|
||||||
|
}
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionAddAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
public void testAddAll_supportedNothing() {
|
||||||
|
assertFalse("addAll(nothing) should return false", collection.addAll(emptyCollection()));
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
public void testAddAll_unsupportedNothing() {
|
||||||
|
try {
|
||||||
|
assertFalse("addAll(nothing) should return false or throw", collection.addAll(emptyCollection()));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
public void testAddAll_supportedNonePresent() {
|
||||||
|
assertTrue("addAll(nonePresent) should return true", collection.addAll(createDisjointCollection()));
|
||||||
|
expectAdded(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
public void testAddAll_unsupportedNonePresent() {
|
||||||
|
try {
|
||||||
|
collection.addAll(createDisjointCollection());
|
||||||
|
fail("addAll(nonePresent) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3(), e4());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAll_supportedSomePresent() {
|
||||||
|
#endignore
|
||||||
|
assertTrue("addAll(somePresent) should return true", collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||||
|
assertTrue("should contain " + e3(), collection.contains(e3()));
|
||||||
|
assertTrue("should contain " + e0(), collection.contains(e0()));
|
||||||
|
}
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAll_unsupportedSomePresent() {
|
||||||
|
#endignore
|
||||||
|
try {
|
||||||
|
collection.addAll(MINIMAL_COLLECTION.of(e3(), e0()));
|
||||||
|
fail("addAll(somePresent) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAllConcurrentWithIteration() {
|
||||||
|
#endignore
|
||||||
|
try {
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||||
|
assertTrue(collection.addAll(MINIMAL_COLLECTION.of(e3(), e0())));
|
||||||
|
iterator.NEXT();
|
||||||
|
fail("Expected ConcurrentModificationException");
|
||||||
|
} catch (ConcurrentModificationException expected) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddAll_unsupportedAllPresent() {
|
||||||
|
try {
|
||||||
|
assertFalse("addAll(allPresent) should return false or throw", collection.addAll(MINIMAL_COLLECTION.of(e0())));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_ADD;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionAddTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_ADD)
|
||||||
|
public void testAdd_supportedNotPresent() {
|
||||||
|
assertTrue("add(notPresent) should return true", collection.add(e3()));
|
||||||
|
expectAdded(e3());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
public void testAdd_unsupportedNotPresent() {
|
||||||
|
try {
|
||||||
|
collection.add(e3());
|
||||||
|
fail("add(notPresent) should throw");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
expectMissing(e3());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_ADD)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAdd_unsupportedPresent() {
|
||||||
|
try {
|
||||||
|
assertFalse("add(present) should return false or throw", collection.add(e0()));
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require({ SUPPORTS_ADD, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testAddConcurrentWithIteration() {
|
||||||
|
#endignore
|
||||||
|
try {
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||||
|
assertTrue(collection.add(e3()));
|
||||||
|
iterator.NEXT();
|
||||||
|
fail("Expected ConcurrentModificationException");
|
||||||
|
} catch (ConcurrentModificationException expected) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.FAILS_FAST_ON_CONCURRENT_MODIFICATION;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionFeature.SUPPORTS_REMOVE;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.SEVERAL;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionClearTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
#ignore
|
||||||
|
@CollectionFeature.Require(SUPPORTS_REMOVE)
|
||||||
|
public void testClear() {
|
||||||
|
collection.clear();
|
||||||
|
assertTrue("After clear(), a collection should be empty.", collection.isEmpty());
|
||||||
|
assertEquals(0, collection.size());
|
||||||
|
assertFalse(collection.iterator().hasNext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testClear_unsupported() {
|
||||||
|
try {
|
||||||
|
collection.clear();
|
||||||
|
fail("clear() should throw UnsupportedOperation if a collection does "
|
||||||
|
+ "not support it and is not empty.");
|
||||||
|
} catch (UnsupportedOperationException expected) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
|
||||||
|
@CollectionSize.Require(ZERO)
|
||||||
|
public void testClear_unsupportedByEmptyCollection() {
|
||||||
|
try {
|
||||||
|
collection.clear();
|
||||||
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
|
}
|
||||||
|
expectUnchanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@CollectionFeature.Require({ SUPPORTS_REMOVE, FAILS_FAST_ON_CONCURRENT_MODIFICATION })
|
||||||
|
@CollectionSize.Require(SEVERAL)
|
||||||
|
public void testClearConcurrentWithIteration() {
|
||||||
|
#endignore
|
||||||
|
try {
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iterator = collection.iterator();
|
||||||
|
collection.clear();
|
||||||
|
iterator.NEXT();
|
||||||
|
fail("Expected ConcurrentModificationException");
|
||||||
|
} catch (ConcurrentModificationException expected) {
|
||||||
|
// success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+165
@@ -0,0 +1,165 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public abstract class FILE_KEY_TYPECollectionConstructorTester KEY_GENERIC_TYPE extends TestCase
|
||||||
|
{
|
||||||
|
protected Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor;
|
||||||
|
protected IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor;
|
||||||
|
protected Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
protected Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor;
|
||||||
|
#endif
|
||||||
|
protected Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor;
|
||||||
|
protected Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor;
|
||||||
|
protected KEY_TYPE[] keys = createKeyElements();
|
||||||
|
|
||||||
|
protected void setSimpleConstructor(Supplier<COLLECTION KEY_GENERIC_TYPE> simpleConstructor) {
|
||||||
|
this.simpleConstructor = simpleConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSizeConstructor(IntFunction<COLLECTION KEY_GENERIC_TYPE> sizeConstructor) {
|
||||||
|
this.sizeConstructor = sizeConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setPArrayConstructor(Function<KEY_TYPE[], COLLECTION KEY_GENERIC_TYPE> pArrayConstructor) {
|
||||||
|
this.pArrayConstructor = pArrayConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
protected void setArrayConstructor(Function<CLASS_TYPE[], COLLECTION KEY_GENERIC_TYPE> arrayConstructor) {
|
||||||
|
this.arrayConstructor = arrayConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected void setCollectionConstructor(Function<Collection<? extends CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE> collectionConstructor) {
|
||||||
|
this.collectionConstructor = collectionConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setPCollectionConstructor(Function<COLLECTION KEY_GENERIC_TYPE, COLLECTION KEY_GENERIC_TYPE> pCollectionConstructor) {
|
||||||
|
this.pCollectionConstructor = pCollectionConstructor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPrimitiveArrayConstructor() {
|
||||||
|
if(pArrayConstructor == null) return;
|
||||||
|
Assert.assertTrue(pArrayConstructor.apply(keys) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Test
|
||||||
|
public void testArrayConstructor() {
|
||||||
|
if(arrayConstructor == null) return;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
Assert.assertTrue(arrayConstructor.apply(keys) != null);
|
||||||
|
#else
|
||||||
|
Assert.assertTrue(arrayConstructor.apply(ARRAYS.wrap(keys)) != null);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Test
|
||||||
|
public void testPrimitiveMapsConstructor() {
|
||||||
|
if(pCollectionConstructor == null) return;
|
||||||
|
Assert.assertTrue(pCollectionConstructor.apply(new ARRAY_LISTBRACES(keys)) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMapsConstructor() {
|
||||||
|
if(collectionConstructor == null) return;
|
||||||
|
Assert.assertTrue(collectionConstructor.apply(new ArrayList<>(new ARRAY_LISTBRACES(keys))) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSimpleConstructor() {
|
||||||
|
if(simpleConstructor == null) return;
|
||||||
|
Assert.assertTrue(simpleConstructor.get() != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSizeConstructor_empty() {
|
||||||
|
if(sizeConstructor == null) return;
|
||||||
|
Assert.assertTrue(sizeConstructor.apply(0) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSizeConstructor_smallSize() {
|
||||||
|
if(sizeConstructor == null) return;
|
||||||
|
Assert.assertTrue(sizeConstructor.apply(32) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSizeConstructor_largeSize() {
|
||||||
|
if(sizeConstructor == null) return;
|
||||||
|
Assert.assertTrue(sizeConstructor.apply(25212) != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRehash() {
|
||||||
|
if(sizeConstructor == null) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
COLLECTION KEY_GENERIC_TYPE set = sizeConstructor.apply(0);
|
||||||
|
if(set instanceof ITrimmable) {
|
||||||
|
ITrimmable trim = (ITrimmable)set;
|
||||||
|
set.addAll(keys);
|
||||||
|
set.clear();
|
||||||
|
Assert.assertTrue(trim.trim());
|
||||||
|
Assert.assertFalse(trim.trim());
|
||||||
|
set.addAll(keys);
|
||||||
|
trim.clearAndTrim();
|
||||||
|
set.addAll(keys);
|
||||||
|
trim.clearAndTrim(Short.MAX_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(UnsupportedOperationException e) {
|
||||||
|
//Ignore thats fine
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSizeConstructor_InvalidSize() {
|
||||||
|
if(sizeConstructor == null) return;
|
||||||
|
try {
|
||||||
|
sizeConstructor.apply(-1);
|
||||||
|
Assert.fail("When Inputted Size is negative this should crash");
|
||||||
|
}
|
||||||
|
catch(IllegalStateException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
protected abstract KEY_TYPE[] createKeyElements();
|
||||||
|
|
||||||
|
#else
|
||||||
|
protected KEY_TYPE[] createKeyElements() {
|
||||||
|
KEY_TYPE[] keys = NEW_KEY_ARRAY(100);
|
||||||
|
for(int i = 0;i<100;i++) {
|
||||||
|
#if TYPE_BOOLEAN
|
||||||
|
keys[i] = i % 2 != 0;
|
||||||
|
#else
|
||||||
|
keys[i] = (KEY_TYPE)i;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
+45
@@ -0,0 +1,45 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionContainsAllTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public void testContainsAll_empty() {
|
||||||
|
assertTrue("containsAll(empty) should return true", collection.containsAll(MINIMAL_COLLECTION.of()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testContainsAll_subset() {
|
||||||
|
#endignore
|
||||||
|
assertTrue("containsAll(subset) should return true", collection.containsAll(MINIMAL_COLLECTION.of(e0())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testContainsAll_sameElements() {
|
||||||
|
assertTrue("containsAll(sameElements) should return true", collection.containsAll(MINIMAL_COLLECTION.of(createSamplesArray())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testContainsAll_self() {
|
||||||
|
assertTrue("containsAll(this) should return true", collection.containsAll(collection));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testContainsAll_partialOverlap() {
|
||||||
|
assertFalse("containsAll(partialOverlap) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e0(), e3())));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testContainsAll_disjoint() {
|
||||||
|
assertFalse("containsAll(disjoint) should return false", collection.containsAll(MINIMAL_COLLECTION.of(e3())));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
package speiger.src.testers.PACKAGE.tests.collection;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
||||||
|
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
||||||
|
#endignore
|
||||||
|
|
||||||
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
|
|
||||||
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
import speiger.src.testers.PACKAGE.utils.MINIMAL_COLLECTION;
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FILE_KEY_TYPECollectionContainsAnyTester KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION_TESTER KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
public void testContainsAny_empty() {
|
||||||
|
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||||
|
}
|
||||||
|
#ignore
|
||||||
|
@CollectionSize.Require(absent = ZERO)
|
||||||
|
public void testContainsAny_subset() {
|
||||||
|
#endignore
|
||||||
|
assertTrue("containsAny(subset) should return true", collection.containsAny(MINIMAL_COLLECTION.of(e0())));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
public void testContainsAny_subSetElement() {
|
||||||
|
#endignore
|
||||||
|
assertFalse("containsAny(empty) should return false", collection.containsAny(MINIMAL_COLLECTION.of()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#ignore
|
||||||
|
@CollectionSize.Require(ONE)
|
||||||
|
public void testContainsAny_subSetElements() {
|
||||||
|
#endignore
|
||||||
|
assertTrue("containsAny(subset) should return true", collection.containsAny(getSampleElements(5)));
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user