Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dd3a4a6e8 | ||
|
|
efd29bbe7e | ||
|
|
96458bd8b6 | ||
|
|
477f3c9f40 | ||
|
|
3f6e7fbb88 | ||
|
|
5650c6e69b | ||
|
|
61df32b7b2 | ||
|
|
859d00da16 | ||
|
|
9df95c0fc3 | ||
|
|
d6d2c0a396 | ||
|
|
127eb71968 | ||
|
|
6005d0fd39 | ||
|
|
290e626f07 | ||
|
|
e30d011273 | ||
|
|
4c52636c23 | ||
|
|
aa580c1772 | ||
|
|
8f7d49b280 | ||
|
|
342b0cece9 | ||
|
|
3ce52668df | ||
|
|
ce9343348e | ||
|
|
8d9f7a6761 | ||
|
|
1b1ec4b87a | ||
|
|
cc92ef953a | ||
|
|
8d8c30c9a7 | ||
|
|
d44ad2d42e | ||
|
|
2ed090e989 | ||
|
|
dafb162797 | ||
|
|
57280b8285 | ||
|
|
c9fc963670 | ||
|
|
cc87cae145 | ||
|
|
f53d61a5bc | ||
|
|
b29874189c | ||
|
|
6722f399db | ||
|
|
8e39acef45 | ||
|
|
b065ebe9ba | ||
|
|
25a7cd060a | ||
|
|
21f330260e | ||
|
|
99e9afe7b1 | ||
|
|
5118ae8b1f | ||
|
|
03b23f0e3c | ||
|
|
ca33c9eb9e | ||
|
|
b4374fdd4d | ||
|
|
455ee64a88 | ||
|
|
893b371017 | ||
|
|
5fa9baae7a | ||
|
|
70d565c785 | ||
|
|
5c27e332cd | ||
|
|
f2d919bae5 | ||
|
|
7d4c77332b | ||
|
|
d1186d4f82 | ||
|
|
3b8a02ac51 | ||
|
|
f356d4ab57 | ||
|
|
b07bc85114 | ||
|
|
c37746cd84 | ||
|
|
fb7c417394 |
@@ -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,36 +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: 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,25 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
|
### Version 0.8.0
|
||||||
|
- Added: ISizeProvider interface (Optimization Helper)
|
||||||
|
- Added: ISizeProvider into most Iterable implementations (Distinct/Filter/FlatMap/ArrayFlatMap don't support it, for obvious reasons)
|
||||||
|
- Added: ToArray function into Iterable which uses ISizeProvider to reduce overhead of duplicating arrays.
|
||||||
|
- Added: Functions that have the same type, Int2IntFunction as example, have now a identity function.
|
||||||
|
- Added: Functions of a BooleanValue have now alwaysTrue/False function.
|
||||||
|
- Added: ForEachIndexed for all Iterable implementations
|
||||||
|
- Added: RandomGenerator support (Java17), though requires self compilation
|
||||||
|
- Added: Optimizations for HashUtils next power of function.
|
||||||
|
- Added: toArray() now returns a cached empty array if the collection is empty.
|
||||||
|
- Added: toArray function for AsyncBuilder
|
||||||
|
- Added: Modularization to the library where feature can be disabled as needed. (Requires Self-Compilation)
|
||||||
|
- Fixed: putIfAbsent now replaces defaultValues
|
||||||
|
- Fixed: OpenHashSet/Map and their Custom Variants no longer rely on List implementations.
|
||||||
|
- Fixed: ObjectCopyOnWriteList.of did create a ObjectArrayList instead of the CopyOnWrite variant.
|
||||||
|
- Removed: BooleanSet and Maps that start with a Boolean classes since they can not be used anyways.
|
||||||
|
- Breaking Change: Function classes now use the "apply/applyAs/test" format from Java itself, instead of the "get" format. This cleans up a lot of things. But will break existing function class implementations
|
||||||
|
- Breaking Change: Classes that used PrimitiveCollection functions now default to java functions where applicable, this is to increase compat.
|
||||||
|
- Breaking Change: Some function classes now get closer to javas terms. (Predicate/UnaryOperator etc)
|
||||||
|
|
||||||
### Version 0.7.0
|
### Version 0.7.0
|
||||||
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
- Added: Over 11 Million Unit Tests to this library to ensure quality.
|
||||||
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
- Added: ArrayList size constructor now throws IllegalStateException if the size parameter is negative
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
### Extra Features
|
||||||
|
|
||||||
|
Primitive Collections comes with a few extra features that are disabled by default.
|
||||||
|
These will be enabled as soon they become relevant or never at all.
|
||||||
|
|
||||||
|
But some of these can be already unlocked when the target version changes.
|
||||||
|
|
||||||
|
If you compile the library for yourself you will automatically gain access to said features.
|
||||||
|
|
||||||
|
### Java17 Exclusive Features
|
||||||
|
Java17 has some new features that can sadly not really be back-ported but the library still supports them if it is compiled with java17
|
||||||
|
|
||||||
|
- RandomGenerator: Java17 has added [RandomGenerator.class](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/random/RandomGenerator.html).
|
||||||
|
This allows to use custom random implementations without having to re-implement them yourselves.
|
||||||
|
|
||||||
|
|
||||||
|
### ModuleSettings
|
||||||
|
Primitive Collections is a huge library.
|
||||||
|
But maybe you only use like 5-10 different classes.
|
||||||
|
Normally you would use tools like "Proguard" to get rid of classes that you don't use.
|
||||||
|
But since a lot of classes have dependencies on each other this would only do so much.
|
||||||
|
|
||||||
|
This is where the [ModuleSettings](ModuleSettings.json) come into play.
|
||||||
|
It allows you to turn of implementations as you wish and adjusts the code that everything still works.
|
||||||
|
|
||||||
|
There is 3 layers of control inside of the ModuleSettings.
|
||||||
|
- Modules directly at the top that turn off everything.
|
||||||
|
- Type Specific configurations, where you can for example turn of everything thats "Long" based.
|
||||||
|
- And then there is each type specific module settings.
|
||||||
|
|
||||||
|
Allowing for greater control without having to edit hundreds of lines of code.
|
||||||
|
On top of that:
|
||||||
|
Any Setting that isn't "Present" is counted as "Enabled".
|
||||||
|
So if you want to disable just 1 thing you can keep that 1 thing and delete the rest of the Setting.
|
||||||
|
It will still work as the same.
|
||||||
|
The default settings just come with everything so you can see what is controllable.
|
||||||
|
|
||||||
|
How to compile the Code with the ModuleSettings enabled:
|
||||||
|
```
|
||||||
|
/gradlew.bat generateLimitSource build -x test
|
||||||
|
```
|
||||||
+2624
File diff suppressed because it is too large
Load Diff
@@ -1,8 +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)
|
[](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.
|
||||||
@@ -14,6 +17,10 @@ Benchmarks can be found here: [[Charts]](https://github.com/Speiger/Primitive-Co
|
|||||||
[Here](features.md) you find a set of features added to Primitive Collections.
|
[Here](features.md) you find a set of features added to Primitive Collections.
|
||||||
These are designed to improve performance or to provide Quality of Life.
|
These are designed to improve performance or to provide Quality of Life.
|
||||||
|
|
||||||
|
[Here](EXTRAS.md) you also find features that can be used when you compile the library for yourself.
|
||||||
|
These features are not used by default to have a wider range of compat, or require self compilation.
|
||||||
|
Such as pruning classes that are not needed in your code.
|
||||||
|
|
||||||
## Main Features:
|
## Main Features:
|
||||||
- ArrayLists / LinkedLists / CopyOnWriteLists
|
- ArrayLists / LinkedLists / CopyOnWriteLists
|
||||||
- HashSets/Maps (Linked & HashControl)
|
- HashSets/Maps (Linked & HashControl)
|
||||||
@@ -68,7 +75,11 @@ Please if you want to contribute follow the [Rule-Sheet](RuleSheet.md). It keeps
|
|||||||
# How to Build
|
# How to Build
|
||||||
|
|
||||||
The SourceCode can be generated via:
|
The SourceCode can be generated via:
|
||||||
|
```
|
||||||
/gradlew.bat generateSource
|
/gradlew.bat generateSource
|
||||||
|
```
|
||||||
|
|
||||||
to generate SourceCode and build the jar:
|
to generate SourceCode and build the jar:
|
||||||
|
```
|
||||||
/gradlew.bat build
|
/gradlew.bat build
|
||||||
|
```
|
||||||
|
|||||||
+167
-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.7.0';
|
version = '0.8.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
@@ -44,7 +45,8 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.1.4'
|
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||||
|
builderImplementation 'de.speiger:Simple-Code-Generator:1.2.2'
|
||||||
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 +64,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 +72,23 @@ 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 generateLimitSource(type: JavaExec) {
|
||||||
|
group = 'internal'
|
||||||
|
description = 'Builds the Sourcecode with the ModuleSettings.json applied'
|
||||||
|
classpath = sourceSets.builder.runtimeClasspath
|
||||||
|
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||||
|
args = ['silent', 'load']
|
||||||
}
|
}
|
||||||
|
|
||||||
task javadocJar(type: Jar) {
|
task javadocJar(type: Jar) {
|
||||||
@@ -94,8 +112,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 {
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -50,6 +52,11 @@ public enum ClassType
|
|||||||
return classType;
|
return classType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getClassPath()
|
||||||
|
{
|
||||||
|
return this == OBJECT ? "Object" : classType;
|
||||||
|
}
|
||||||
|
|
||||||
public String getClassType(boolean value)
|
public String getClassType(boolean value)
|
||||||
{
|
{
|
||||||
return value && this == OBJECT ? "V" : classType;
|
return value && this == OBJECT ? "V" : classType;
|
||||||
@@ -90,6 +97,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;
|
||||||
@@ -102,7 +114,7 @@ public enum ClassType
|
|||||||
|
|
||||||
public boolean needsCustomJDKType()
|
public boolean needsCustomJDKType()
|
||||||
{
|
{
|
||||||
return this == BYTE || this == SHORT || this == CHAR || this == FLOAT;
|
return this == BOOLEAN || this == BYTE || this == SHORT || this == CHAR || this == FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsCast()
|
public boolean needsCast()
|
||||||
@@ -121,6 +133,12 @@ public enum ClassType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getApply(ClassType other) {
|
||||||
|
if(other == BOOLEAN) return "test";
|
||||||
|
if(other == ClassType.OBJECT) return "apply";
|
||||||
|
return "applyAs"+other.getFileType();
|
||||||
|
}
|
||||||
|
|
||||||
public String getEquals(boolean not)
|
public String getEquals(boolean not)
|
||||||
{
|
{
|
||||||
switch(this)
|
switch(this)
|
||||||
|
|||||||
@@ -1,452 +0,0 @@
|
|||||||
package speiger.src.builder;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
import speiger.src.builder.mappers.ArgumentMapper;
|
|
||||||
import speiger.src.builder.mappers.IMapper;
|
|
||||||
import speiger.src.builder.mappers.InjectMapper;
|
|
||||||
import speiger.src.builder.mappers.LineMapper;
|
|
||||||
import speiger.src.builder.mappers.SimpleMapper;
|
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class GlobalVariables
|
|
||||||
{
|
|
||||||
List<IMapper> operators = new ArrayList<>();
|
|
||||||
Set<String> flags = new LinkedHashSet<>();
|
|
||||||
ClassType type;
|
|
||||||
ClassType valueType;
|
|
||||||
|
|
||||||
public GlobalVariables(ClassType type, ClassType subType)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
valueType = subType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createVariables()
|
|
||||||
{
|
|
||||||
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
|
||||||
addSimpleMapper("PACKAGE", type.getPathType());
|
|
||||||
addSimpleMapper("CLASS_TYPE", type.getClassType());
|
|
||||||
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
|
||||||
addSimpleMapper("KEY_TYPE", type.getKeyType());
|
|
||||||
addSimpleMapper("KEY_SPECIAL_TYPE", type.isObject() ? "E" : type.getKeyType());
|
|
||||||
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
|
||||||
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
|
||||||
|
|
||||||
addSimpleMapper("EMPTY_KEY_VALUE", type.getEmptyValue());
|
|
||||||
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", "+type.getKeyType()+">" : "");
|
|
||||||
|
|
||||||
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
|
||||||
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+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(" NO_GENERIC_TYPE", type.isObject() ? "<?>" : "");
|
|
||||||
addSimpleMapper(" NO_KV_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
|
||||||
addSimpleMapper(" KEY_COMPAREABLE_TYPE", type.isObject() ? "<"+type.getKeyType()+" extends Comparable<T>>" : "");
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", type.isObject() ? "<? super "+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
|
||||||
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<? super "+type.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+type.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
|
||||||
|
|
||||||
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : "<"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
|
||||||
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", type.isObject() ? (valueType.isObject() ? "<"+type.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+type.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
|
||||||
|
|
||||||
addInjectMapper(" KEY_SPECIAL_GENERIC_TYPE", type.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" KSK_GENERIC_TYPE", type.isObject() ? "<%s, "+type.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" KKS_GENERIC_TYPE", type.isObject() ? "<"+type.getKeyType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addArgumentMapper(" KSS_GENERIC_TYPE", type.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" VSV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" VVS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
|
||||||
addArgumentMapper(" VSS_GENERIC_TYPE", valueType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
|
||||||
|
|
||||||
addSimpleMapper(" GENERIC_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+">" : "");
|
|
||||||
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
|
||||||
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", type.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
|
||||||
addSimpleMapper(" GENERIC_KEY_ENUM_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">, "+valueType.getValueType()+">" : " <"+type.getKeyType()+" extends Enum<"+type.getKeyType()+">>") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
|
||||||
|
|
||||||
addInjectMapper(" GENERIC_KEY_SPECIAL_BRACES", type.isObject() ? " <"+type.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
|
||||||
addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
|
||||||
|
|
||||||
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", type.isObject() ? (valueType.isObject() ? " <"+type.getKeyType()+", "+valueType.getValueType()+">" : " <"+type.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
|
||||||
addSimpleMapper(" COMPAREABLE_KEY_BRACES", type.isObject() ? " <"+type.getKeyType()+" extends Comparable<T>>" : "");
|
|
||||||
addSimpleMapper("KV_BRACES", type.isObject() || valueType.isObject() ? "<>" : "");
|
|
||||||
addSimpleMapper("BRACES", type.isObject() ? "<>" : "");
|
|
||||||
if(type.needsCustomJDKType())
|
|
||||||
{
|
|
||||||
addSimpleMapper("JAVA_TYPE", type.getCustomJDKType().getKeyType());
|
|
||||||
addSimpleMapper("SANITY_CAST", "castTo"+type.getFileType());
|
|
||||||
}
|
|
||||||
addSimpleMapper("JAVA_CLASS", type.getCustomJDKType().getClassType());
|
|
||||||
if(valueType.needsCustomJDKType())
|
|
||||||
{
|
|
||||||
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
|
||||||
}
|
|
||||||
addComment("@ArrayType", "@param <%s> the type of array that the operation should be applied");
|
|
||||||
addComment("@Type", "@param <%s> the type of elements maintained by this Collection");
|
|
||||||
addValueComment("@ValueArrayType", "@param <%s> the type of array that the operation should be applied");
|
|
||||||
addValueComment("@ValueType", "@param <%s> the type of elements maintained by this Collection");
|
|
||||||
addAnnontion("@PrimitiveOverride", "@Override");
|
|
||||||
addSimpleMapper("@PrimitiveDoc", "");
|
|
||||||
addAnnontion("@Primitive", "@Deprecated");
|
|
||||||
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
|
||||||
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createHelperVariables()
|
|
||||||
{
|
|
||||||
createHelperVars(type, false, "KEY");
|
|
||||||
createHelperVars(valueType, true, "VALUE");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createHelperVars(ClassType type, boolean value, String fix)
|
|
||||||
{
|
|
||||||
addArgumentMapper("EQUALS_"+fix+"_TYPE", "Objects.equals(%2$s, "+(type.isObject() ? "%1$s" : fix+"_TO_OBJ(%1$s)")+")").removeBraces();
|
|
||||||
addInjectMapper(fix+"_EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
|
||||||
addInjectMapper(fix+"_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
|
||||||
addArgumentMapper(fix+"_EQUALS_NOT", type.getEquals(true)).removeBraces();
|
|
||||||
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
|
||||||
|
|
||||||
addArgumentMapper("COMPAREABLE_TO_"+fix, type.isObject() ? "((Comparable<"+type.getKeyType(value)+">)%1$s).compareTo(("+type.getKeyType(value)+")%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
|
||||||
addArgumentMapper("COMPARE_TO_"+fix, type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
|
||||||
|
|
||||||
addInjectMapper(fix+"_TO_OBJ", type.isObject() ? "%s" : type.getClassType(value)+".valueOf(%s)").removeBraces();
|
|
||||||
addInjectMapper("OBJ_TO_"+fix, type.isObject() ? "%s" : "%s."+type.getKeyType(value)+"Value()").removeBraces();
|
|
||||||
addInjectMapper("CLASS_TO_"+fix, type.isObject() ? "("+type.getKeyType(value)+")%s" : "(("+type.getClassType(value)+")%s)."+type.getKeyType(value)+"Value()").removeBraces();
|
|
||||||
|
|
||||||
addInjectMapper(fix+"_TO_HASH", type.isObject() ? "Objects.hashCode(%s)" : type.getClassType(value)+".hashCode(%s)").removeBraces();
|
|
||||||
addInjectMapper(fix+"_TO_STRING", type.isObject() ? "Objects.toString(%s)" : type.getClassType(value)+".toString(%s)").removeBraces();
|
|
||||||
|
|
||||||
addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : "");
|
|
||||||
addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY");
|
|
||||||
addInjectMapper("NEW_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
|
||||||
addInjectMapper("NEW_SPECIAL_"+fix+"_ARRAY", type.isObject() ? "(E[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
|
||||||
addInjectMapper("NEW_CLASS"+(value ? "_VALUE" : "")+"_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createPreFunctions()
|
|
||||||
{
|
|
||||||
addSimpleMapper("ENTRY_SET", type.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createClassTypes()
|
|
||||||
{
|
|
||||||
addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate");
|
|
||||||
addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer");
|
|
||||||
addSimpleMapper("JAVA_SUPPLIER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Supplier");
|
|
||||||
addSimpleMapper("JAVA_FUNCTION", type.getFunctionClass(valueType));
|
|
||||||
addSimpleMapper("JAVA_BINARY_OPERATOR", type == ClassType.BOOLEAN ? "" : (type.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+type.getCustomJDKType().getFileType()+"BinaryOperator"));
|
|
||||||
addSimpleMapper("JAVA_UNARY_OPERATOR", type.isObject() ? "BinaryOperator" : type == ClassType.BOOLEAN ? "" : type.getCustomJDKType().getFileType()+"UnaryOperator");
|
|
||||||
addSimpleMapper("JAVA_SPLIT_ITERATOR", type.isPrimitiveBlocking() ? "Spliterator" : "Of"+type.getCustomJDKType().getFileType());
|
|
||||||
addSimpleMapper("JAVA_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Stream");
|
|
||||||
addSimpleMapper("JAVA_BUFFER", type.getFileType()+"Buffer");
|
|
||||||
|
|
||||||
//Final Classes
|
|
||||||
addClassMapper("ARRAY_LIST", "ArrayList");
|
|
||||||
addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList");
|
|
||||||
addClassMapper("ASYNC_BUILDER", "AsyncBuilder");
|
|
||||||
addClassMapper("LINKED_LIST", "LinkedList");
|
|
||||||
addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList");
|
|
||||||
addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue");
|
|
||||||
addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue");
|
|
||||||
addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue");
|
|
||||||
addClassMapper("LINKED_CUSTOM_HASH_SET", "LinkedOpenCustomHashSet");
|
|
||||||
addClassMapper("LINKED_HASH_SET", "LinkedOpenHashSet");
|
|
||||||
addAbstractMapper("IMMUTABLE_HASH_SET", "Immutable%sOpenHashSet");
|
|
||||||
addClassMapper("CUSTOM_HASH_SET", "OpenCustomHashSet");
|
|
||||||
addClassMapper("HASH_SET", "OpenHashSet");
|
|
||||||
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
|
||||||
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
|
||||||
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
|
||||||
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
|
||||||
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
|
||||||
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
|
||||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
|
||||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
|
||||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
|
||||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
|
||||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
|
||||||
addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", "");
|
|
||||||
addBiClassMapper("MUTABLE_PAIR", "MutablePair", "");
|
|
||||||
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
|
||||||
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
|
||||||
addClassMapper("ARRAY_SET", "ArraySet");
|
|
||||||
|
|
||||||
//Abstract Classes
|
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
|
||||||
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
|
||||||
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
|
||||||
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
|
||||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
|
||||||
addClassMapper("SUB_LIST", "SubList");
|
|
||||||
addAbstractMapper("BASE_TASK", "Base%sTask");
|
|
||||||
|
|
||||||
//Helper Classes
|
|
||||||
addClassMapper("LISTS", "Lists");
|
|
||||||
addClassMapper("SETS", "Sets");
|
|
||||||
addClassMapper("COLLECTIONS", "Collections");
|
|
||||||
addClassMapper("ARRAYS", "Arrays");
|
|
||||||
addClassMapper("PRIORITY_QUEUES", "PriorityQueues");
|
|
||||||
addClassMapper("SPLIT_ITERATORS", "Splititerators");
|
|
||||||
addClassMapper("ITERATORS", "Iterators");
|
|
||||||
addClassMapper("ITERABLES", "Iterables");
|
|
||||||
addBiClassMapper("MAPS", "Maps", "2");
|
|
||||||
|
|
||||||
//Interfaces
|
|
||||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
|
||||||
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
|
||||||
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
|
||||||
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
|
||||||
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
|
||||||
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
|
||||||
addClassMapper("ITERATOR", "Iterator");
|
|
||||||
addClassMapper("ITERABLE", "Iterable");
|
|
||||||
addClassMapper("COLLECTION", "Collection");
|
|
||||||
addClassMapper("TO_OBJECT_FUNCTION", "2ObjectFunction");
|
|
||||||
addBiClassMapper("FUNCTION", "Function", "2");
|
|
||||||
addClassMapper("LIST_ITER", "ListIter");
|
|
||||||
addClassMapper("LIST", "List");
|
|
||||||
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
|
||||||
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
|
||||||
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
|
||||||
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
|
||||||
addBiClassMapper("MAP", "Map", "2");
|
|
||||||
addClassMapper("NAVIGABLE_SET", "NavigableSet");
|
|
||||||
addBiClassMapper("PAIR", "Pair", "");
|
|
||||||
addClassMapper("PRIORITY_QUEUE", "PriorityQueue");
|
|
||||||
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
|
|
||||||
addClassMapper("PREDICATE", "2BooleanFunction");
|
|
||||||
addClassMapper("SORTED_SET", "SortedSet");
|
|
||||||
addClassMapper("ORDERED_SET", "OrderedSet");
|
|
||||||
addClassMapper("SET", "Set");
|
|
||||||
addClassMapper("STRATEGY", "Strategy");
|
|
||||||
addClassMapper("STACK", "Stack");
|
|
||||||
addClassMapper("SUPPLIER", "Supplier");
|
|
||||||
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
|
||||||
addClassMapper("TASK", "Task");
|
|
||||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
|
||||||
if(type.isObject())
|
|
||||||
{
|
|
||||||
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
|
||||||
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
|
||||||
addSimpleMapper("CONSUMER", "Consumer");
|
|
||||||
addSimpleMapper("COMPARATOR", "Comparator");
|
|
||||||
addSimpleMapper("IARRAY", "IObjectArray");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(valueType.isObject())
|
|
||||||
{
|
|
||||||
addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
|
||||||
addSimpleMapper("CONSUMER", type.getFileType()+"Consumer");
|
|
||||||
}
|
|
||||||
else addClassMapper("CONSUMER", "Consumer");
|
|
||||||
addClassMapper("COMPARATOR", "Comparator");
|
|
||||||
addFunctionMappers("IARRAY", "I%sArray");
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createFunctions()
|
|
||||||
{
|
|
||||||
addSimpleMapper("APPLY_KEY_VALUE", type.isObject() ? "apply" : "applyAs"+type.getNonFileType());
|
|
||||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
|
||||||
addSimpleMapper("APPLY_CAST", "applyAs"+type.getCustomJDKType().getNonFileType());
|
|
||||||
addSimpleMapper("APPLY", type.isObject() ? "apply" : "applyAs"+type.getNonFileType());
|
|
||||||
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
|
||||||
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
|
||||||
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
|
||||||
addFunctionValueMapper("COMPUTE", "compute");
|
|
||||||
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
|
||||||
addFunctionMapper("DEQUEUE", "dequeue");
|
|
||||||
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
|
||||||
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
|
||||||
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
|
||||||
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
|
||||||
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
|
||||||
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
|
||||||
addFunctionMapper("FIRST_KEY", "first");
|
|
||||||
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
|
||||||
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
|
||||||
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
|
||||||
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
|
||||||
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
|
||||||
addFunctionMapper("GET_KEY", "get");
|
|
||||||
if(type.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
|
||||||
else addSimpleMapper("GET_VALUE", "get");
|
|
||||||
addSimpleMapper("GET_JAVA", type.isObject() ? "get" : "getAs"+type.getCustomJDKType().getNonFileType());
|
|
||||||
addFunctionMapper("LAST_KEY", "last");
|
|
||||||
addFunctionValueMapper("MERGE", "merge");
|
|
||||||
addFunctionMapper("NEXT", "next");
|
|
||||||
addFunctionMapper("PREVIOUS", "previous");
|
|
||||||
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
|
||||||
if(type.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
|
||||||
else addSimpleMapper("REMOVE_VALUE", "remove");
|
|
||||||
addFunctionMapper("REMOVE_KEY", "rem");
|
|
||||||
addFunctionMapper("REMOVE_LAST", "removeLast");
|
|
||||||
addFunctionMapper("REMOVE", "remove");
|
|
||||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
|
||||||
addFunctionMappers("REPLACE", type.isObject() ? "replaceObjects" : "replace%ss");
|
|
||||||
addFunctionMappers("SORT", "sort%ss");
|
|
||||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
|
||||||
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
|
||||||
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
|
||||||
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
|
||||||
addSimpleMapper("TO_ARRAY", "to"+type.getNonFileType()+"Array");
|
|
||||||
addSimpleMapper("[SPACE]", " ");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GlobalVariables createFlags()
|
|
||||||
{
|
|
||||||
flags.add("TYPE_"+type.getCapType());
|
|
||||||
flags.add("VALUE_"+valueType.getCapType());
|
|
||||||
if(type == valueType) flags.add("SAME_TYPE");
|
|
||||||
if(type.hasFunction(valueType)) flags.add("JDK_FUNCTION");
|
|
||||||
if(!type.needsCustomJDKType()) flags.add("JDK_TYPE");
|
|
||||||
if(!type.isPrimitiveBlocking()) flags.add("PRIMITIVES");
|
|
||||||
if(!valueType.isPrimitiveBlocking()) flags.add("VALUE_PRIMITIVES");
|
|
||||||
if(valueType.needsCustomJDKType()) flags.add("JDK_VALUE");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TemplateProcess create(String fileName, String splitter, boolean valueOnly)
|
|
||||||
{
|
|
||||||
TemplateProcess process = new TemplateProcess(String.format(fileName+".java", (splitter != null ? type.getFileType()+splitter+valueType.getFileType() : (valueOnly ? valueType : type).getFileType())));
|
|
||||||
process.setPathBuilder(new PathBuilder(type.getPathType()));
|
|
||||||
process.addFlags(flags);
|
|
||||||
process.addMappers(operators);
|
|
||||||
return process;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassType getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addClassMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, valueType.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addBiClassMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[KEY_"+pattern+"]", "KEY_"+pattern, type.getFileType()+splitter+type.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, type.getFileType()+splitter+valueType.getFileType()+replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAbstractMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, String.format(replacement, valueType.getFileType())));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAbstractBiMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getFileType()+splitter+valueType.getFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, replacement+valueType.getNonFileType()));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+type.getNonFileType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionValueMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement+valueType.getNonFileType()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionMappers(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"[VALUE_"+pattern+"]", "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType())));
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, type.getNonFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addFunctionValueMappers(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, String.format(replacement, valueType.getNonFileType())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSimpleMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, replacement));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addAnnontion(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(type == ClassType.OBJECT) operators.add(new LineMapper(type.name()+"["+pattern+"]", pattern));
|
|
||||||
else operators.add(new SimpleMapper(type.name()+"["+pattern+"]", pattern, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addValueAnnontion(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(valueType == ClassType.OBJECT) operators.add(new LineMapper(valueType.name()+"["+pattern+"]", pattern));
|
|
||||||
else operators.add(new SimpleMapper(valueType.name()+"["+pattern+"]", pattern, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addComment(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(type == ClassType.OBJECT) operators.add(new InjectMapper(type.name()+"["+pattern+"]", pattern, value).removeBraces());
|
|
||||||
else operators.add(new LineMapper(type.name()+"["+pattern+"]", pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addValueComment(String pattern, String value)
|
|
||||||
{
|
|
||||||
if(valueType == ClassType.OBJECT) operators.add(new InjectMapper(valueType.name()+"["+pattern+"]", pattern, value).removeBraces());
|
|
||||||
else operators.add(new LineMapper(valueType.name()+"["+pattern+"]", pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
private InjectMapper addInjectMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
InjectMapper mapper = new InjectMapper(type.name()+"["+pattern+"]", pattern, replacement);
|
|
||||||
operators.add(mapper);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArgumentMapper addArgumentMapper(String pattern, String replacement)
|
|
||||||
{
|
|
||||||
return addArgumentMapper(pattern, replacement, ", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter)
|
|
||||||
{
|
|
||||||
ArgumentMapper mapper = new ArgumentMapper(type.name()+"["+pattern+"]", pattern, replacement, splitter);
|
|
||||||
operators.add(mapper);
|
|
||||||
return mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
class PathBuilder implements UnaryOperator<Path>
|
|
||||||
{
|
|
||||||
String before;
|
|
||||||
|
|
||||||
public PathBuilder(String before)
|
|
||||||
{
|
|
||||||
this.before = before;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path apply(Path t)
|
|
||||||
{
|
|
||||||
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,155 @@
|
|||||||
|
package speiger.src.builder;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
|
import speiger.src.builder.mappers.IMapper;
|
||||||
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class ModulePackage
|
||||||
|
{
|
||||||
|
private static final BiConsumer<String, RequiredType> VOID = (K, V) -> {};
|
||||||
|
public static final ClassType[] TYPE = ClassType.values();
|
||||||
|
final ClassType keyType;
|
||||||
|
final ClassType valueType;
|
||||||
|
Set<String> blocked = new HashSet<>();
|
||||||
|
Map<String, String> nameRemapper = new HashMap<>();
|
||||||
|
Map<String, String> splitters = new HashMap<>();
|
||||||
|
List<Predicate<String>> blockedFilters = new ArrayList<>();
|
||||||
|
List<IMapper> mappers = new ArrayList<>();
|
||||||
|
Set<String> flags = new LinkedHashSet<>();
|
||||||
|
Set<String> globalFlags;
|
||||||
|
Map<String, Integer> flaggedValues = new HashMap<>();
|
||||||
|
BiConsumer<String, RequiredType> requirements = VOID;
|
||||||
|
|
||||||
|
public ModulePackage(Set<String> globalFlags, ClassType keyType, ClassType valueType) {
|
||||||
|
this.globalFlags = globalFlags;
|
||||||
|
this.keyType = keyType;
|
||||||
|
this.valueType = valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void finish() {
|
||||||
|
requirements = VOID;
|
||||||
|
mappers.sort(Comparator.comparing(IMapper::getSearchValue, Comparator.comparingInt(String::length).reversed()));
|
||||||
|
mappers.sort(Comparator.comparing(IMapper::getSearchValue, this::sort));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequirements(BiConsumer<String, RequiredType> requirements) {
|
||||||
|
this.requirements = requirements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSame() {
|
||||||
|
return keyType == valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnumValid() {
|
||||||
|
return keyType == ClassType.OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassType getKeyType() {
|
||||||
|
return keyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassType getValueType() {
|
||||||
|
return valueType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFlag(String flag) {
|
||||||
|
flags.add(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addGlobalFlag(String flag) {
|
||||||
|
globalFlags.add(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addValue(String key, int value) {
|
||||||
|
flaggedValues.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRequirement(String fileName, RequiredType type) {
|
||||||
|
requirements.accept(fileName, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMapper(IMapper mapper) {
|
||||||
|
mappers.add(mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBlockedFilter(Predicate<String> filter) {
|
||||||
|
blockedFilters.add(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addBlockedFiles(String... names) {
|
||||||
|
blocked.addAll(Arrays.asList(names));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSplitter(String fileName, String splitter) {
|
||||||
|
splitters.put(fileName, splitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addRemapper(String fileName, String actualName) {
|
||||||
|
nameRemapper.put(fileName, actualName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process(String fileName, Consumer<TemplateProcess> result) {
|
||||||
|
if(isBlocked(fileName)) return;
|
||||||
|
String splitter = String.format(splitters.getOrDefault(fileName, keyType.getFileType()), keyType.getFileType(), valueType.getFileType());
|
||||||
|
String newName = String.format(nameRemapper.getOrDefault(fileName, "%s"+fileName), splitter);
|
||||||
|
TemplateProcess process = new TemplateProcess(newName+".java");
|
||||||
|
process.setPathBuilder(new PathBuilder(keyType.getPathType()));
|
||||||
|
process.addFlags(flags);
|
||||||
|
process.addFlags(globalFlags);
|
||||||
|
process.addMappers(mappers);
|
||||||
|
process.addValues(flaggedValues);
|
||||||
|
result.accept(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isBlocked(String fileName) {
|
||||||
|
if(blocked.contains(fileName)) return true;
|
||||||
|
for(int i = 0,m=blockedFilters.size();i<m;i++) {
|
||||||
|
if(blockedFilters.get(i).test(fileName)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<ModulePackage> createPackages(Set<String> globalFlags) {
|
||||||
|
List<ModulePackage> list = new ArrayList<>();
|
||||||
|
for(ClassType key : TYPE) {
|
||||||
|
for(ClassType value : TYPE) {
|
||||||
|
list.add(new ModulePackage(globalFlags, key, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int sort(String key, String value) {
|
||||||
|
if(value.contains(key)) return 1;
|
||||||
|
else if(key.contains(value)) return -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class PathBuilder implements UnaryOperator<Path> {
|
||||||
|
String before;
|
||||||
|
|
||||||
|
public PathBuilder(String before) {
|
||||||
|
this.before = before;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path apply(Path t) {
|
||||||
|
return t.subpath(0, 6).resolve(before).resolve(t.subpath(6, t.getNameCount()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +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.EnumSet;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,20 +17,33 @@ import java.util.StringJoiner;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import speiger.src.builder.modules.AsyncModule;
|
||||||
|
import speiger.src.builder.modules.BaseModule;
|
||||||
|
import speiger.src.builder.modules.CollectionModule;
|
||||||
|
import speiger.src.builder.modules.FunctionModule;
|
||||||
|
import speiger.src.builder.modules.JavaModule;
|
||||||
|
import speiger.src.builder.modules.ListModule;
|
||||||
|
import speiger.src.builder.modules.MapModule;
|
||||||
|
import speiger.src.builder.modules.PairModule;
|
||||||
|
import speiger.src.builder.modules.PrioQueueModule;
|
||||||
|
import speiger.src.builder.modules.SetModule;
|
||||||
import speiger.src.builder.processor.TemplateProcess;
|
import speiger.src.builder.processor.TemplateProcess;
|
||||||
import speiger.src.builder.processor.TemplateProcessor;
|
import speiger.src.builder.processor.TemplateProcessor;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||||
{
|
{
|
||||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
private static final int SPECIAL = 0x1; //Detects if the Builder is generating tests
|
||||||
Map<String, String> nameRemapper = new HashMap<>();
|
private static final int LOAD = 0x2; //If Configs should be loaded
|
||||||
Map<String, String> biRequired = new HashMap<>();
|
private static final int ANTI_SAVE = SPECIAL | LOAD; //If save should be disabled since load/save shouldn't happen at the same time.
|
||||||
Set<String> enumRequired = new HashSet<>();
|
private static final int SAVE = 0x4; //if the configuration should be created
|
||||||
public static final ClassType[] TYPE = ClassType.values();
|
Set<String> globalFlags = new HashSet<>();
|
||||||
List<GlobalVariables> variables = new ArrayList<>();
|
List<ModulePackage> simplePackages = new ArrayList<>();
|
||||||
List<GlobalVariables> biVariables = new ArrayList<>();
|
List<ModulePackage> biPackages = new ArrayList<>();
|
||||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
List<ModulePackage> enumPackages = new ArrayList<>();
|
||||||
|
Map<String, RequiredType> requirements = new HashMap<>();
|
||||||
|
SettingsManager manager = new SettingsManager();
|
||||||
|
int flags;
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder()
|
public PrimitiveCollectionsBuilder()
|
||||||
{
|
{
|
||||||
@@ -51,6 +65,28 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PrimitiveCollectionsBuilder setFlags(int flags) {
|
||||||
|
this.flags = flags;
|
||||||
|
if((flags & ANTI_SAVE) != 0) {
|
||||||
|
this.flags &= ~SAVE;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PrimitiveCollectionsBuilder createTests(boolean silent, int flags) {
|
||||||
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
|
Paths.get("src/builder/resources/speiger/assets/tests/templates/"),
|
||||||
|
Paths.get("src/test/java/speiger/src/tests/"),
|
||||||
|
Paths.get("src/builder/resources/speiger/assets/tests/")).setFlags(flags | SPECIAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PrimitiveCollectionsBuilder createTesters(boolean silent, int flags) {
|
||||||
|
return new PrimitiveCollectionsBuilder(silent,
|
||||||
|
Paths.get("src/builder/resources/speiger/assets/testers/templates/"),
|
||||||
|
Paths.get("src/test/java/speiger/src/testers/"),
|
||||||
|
Paths.get("src/builder/resources/speiger/assets/testers/")).setFlags(flags | SPECIAL);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFileValid(Path fileName)
|
protected boolean isFileValid(Path fileName)
|
||||||
{
|
{
|
||||||
@@ -72,7 +108,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
@Override
|
@Override
|
||||||
protected void afterFinish()
|
protected void afterFinish()
|
||||||
{
|
{
|
||||||
if(getVersion() > 8)
|
if((flags & SPECIAL) == 0 && 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")))
|
||||||
@@ -86,101 +122,77 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<BaseModule> createModules()
|
||||||
|
{
|
||||||
|
List<BaseModule> modules = new ArrayList<>();
|
||||||
|
modules.add(JavaModule.INSTANCE);
|
||||||
|
modules.add(FunctionModule.INSTANCE);
|
||||||
|
modules.add(CollectionModule.INSTANCE);
|
||||||
|
modules.add(PrioQueueModule.INSTANCE);
|
||||||
|
modules.add(ListModule.INSTANCE);
|
||||||
|
modules.add(SetModule.INSTANCE);
|
||||||
|
modules.add(MapModule.INSTANCE);
|
||||||
|
modules.add(PairModule.INSTANCE);
|
||||||
|
modules.add(AsyncModule.INSTANCE);
|
||||||
|
return modules;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init()
|
protected void init()
|
||||||
{
|
{
|
||||||
variables.clear();
|
prepPackages();
|
||||||
for(ClassType clzType : TYPE)
|
//Init Modules here
|
||||||
{
|
addModules(createModules());
|
||||||
for(ClassType subType : TYPE)
|
finishPackages();
|
||||||
{
|
}
|
||||||
create(clzType, subType);
|
|
||||||
}
|
public void addModules(List<BaseModule> modules)
|
||||||
|
{
|
||||||
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
|
modules.get(i).setManager(manager);
|
||||||
}
|
}
|
||||||
enumRequired.add("EnumMap");
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
enumRequired.add("LinkedEnumMap");
|
biPackages.forEach(modules.get(i)::init);
|
||||||
biRequired.put("BiConsumer", "");
|
}
|
||||||
biRequired.put("UnaryOperator", "");
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
biRequired.put("Pair", "");
|
modules.get(i).cleanup();
|
||||||
biRequired.put("MutablePair", "");
|
|
||||||
biRequired.put("ImmutablePair", "");
|
|
||||||
addBiClass("Function", "Maps", "Map", "SortedMap", "OrderedMap", "NavigableMap", "ConcurrentMap", "AbstractMap", "ConcurrentOpenHashMap", "ImmutableOpenHashMap", "OpenHashMap", "LinkedOpenHashMap", "OpenCustomHashMap", "LinkedOpenCustomHashMap", "ArrayMap", "RBTreeMap", "AVLTreeMap");
|
|
||||||
nameRemapper.put("BiConsumer", "%sConsumer");
|
|
||||||
nameRemapper.put("IArray", "I%sArray");
|
|
||||||
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
|
||||||
nameRemapper.put("AbstractCollection", "Abstract%sCollection");
|
|
||||||
nameRemapper.put("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
|
||||||
nameRemapper.put("AbstractSet", "Abstract%sSet");
|
|
||||||
nameRemapper.put("AbstractList", "Abstract%sList");
|
|
||||||
nameRemapper.put("EnumMap", "Enum2%sMap");
|
|
||||||
nameRemapper.put("LinkedEnumMap", "LinkedEnum2%sMap");
|
|
||||||
nameRemapper.put("ImmutableList", "Immutable%sList");
|
|
||||||
nameRemapper.put("CopyOnWriteList", "CopyOnWrite%sArrayList");
|
|
||||||
nameRemapper.put("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
|
||||||
nameRemapper.put("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
|
||||||
|
|
||||||
addBlockage(ClassType.OBJECT, "Consumer", "Comparator", "Stack");
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void create(ClassType mainType, ClassType subType)
|
|
||||||
{
|
|
||||||
GlobalVariables type = new GlobalVariables(mainType, subType);
|
|
||||||
type.createFlags();
|
|
||||||
type.createHelperVariables();
|
|
||||||
type.createVariables();
|
|
||||||
type.createPreFunctions();
|
|
||||||
type.createClassTypes();
|
|
||||||
type.createFunctions();
|
|
||||||
if(mainType == subType) variables.add(type);
|
|
||||||
biVariables.add(type);
|
|
||||||
if(mainType.isObject()) enumVariables.add(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addBiClass(String...classNames)
|
|
||||||
{
|
|
||||||
for(String s : classNames)
|
|
||||||
{
|
|
||||||
biRequired.put(s, "2");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addBlockage(ClassType type, String...args)
|
private void finishPackages()
|
||||||
{
|
{
|
||||||
for(String s : args)
|
biPackages.forEach(ModulePackage::finish);
|
||||||
|
if((flags & SAVE) != 0) manager.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepPackages()
|
||||||
|
{
|
||||||
|
if((flags & LOAD) != 0) manager.load();
|
||||||
|
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
||||||
{
|
{
|
||||||
EnumSet<ClassType> set = blocked.get(s);
|
entry.setRequirements(requirements::put);
|
||||||
if(set == null)
|
biPackages.add(entry);
|
||||||
{
|
if(entry.isSame()) simplePackages.add(entry);
|
||||||
set = EnumSet.noneOf(ClassType.class);
|
if(entry.isEnumValid()) enumPackages.add(entry);
|
||||||
blocked.put(s, set);
|
|
||||||
}
|
|
||||||
set.add(type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createProcesses(String name, Consumer<TemplateProcess> acceptor)
|
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
||||||
{
|
{
|
||||||
String splitter = biRequired.get(name);
|
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||||
boolean valueRequired = enumRequired.contains(name);
|
for(int i = 0,m=packages.size();i<m;i++)
|
||||||
List<GlobalVariables> vars = getVariablesByClass(name, splitter != null);
|
|
||||||
EnumSet<ClassType> types = blocked.get(name);
|
|
||||||
for(int i = 0,m=vars.size();i<m;i++)
|
|
||||||
{
|
{
|
||||||
GlobalVariables type = vars.get(i);
|
packages.get(i).process(fileName, process);
|
||||||
if(types == null || !types.contains(type.getType()))
|
|
||||||
{
|
|
||||||
acceptor.accept(type.create(nameRemapper.getOrDefault(name, "%s"+name), splitter, valueRequired));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<GlobalVariables> getVariablesByClass(String name, boolean bi) {
|
protected List<ModulePackage> getPackagesByRequirement(RequiredType type) {
|
||||||
if(enumRequired.contains(name)) return enumVariables;
|
if(type == null) return simplePackages;
|
||||||
if(bi) return biVariables;
|
if(type == RequiredType.BI_CLASS) return biPackages;
|
||||||
return variables;
|
if(type == RequiredType.ENUM) return enumPackages;
|
||||||
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getModuleInfo(Path basePath) {
|
private String getModuleInfo(Path basePath) {
|
||||||
@@ -236,28 +248,21 @@ 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]));
|
boolean load = flags.contains("load");
|
||||||
} else if(args.length == 3) {
|
boolean save = flags.contains("save");
|
||||||
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
|
int flag = (load ? LOAD : 0) | (save ? SAVE : 0);
|
||||||
} else if(args.length == 4) {
|
new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force);
|
||||||
new PrimitiveCollectionsBuilder(false, Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
if(tests) {
|
||||||
} else if(args.length == 4) {
|
createTests(silent, flag).process(force || forceTests);
|
||||||
new PrimitiveCollectionsBuilder(Boolean.parseBoolean(args[4]), Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(Boolean.parseBoolean(args[3]));
|
createTesters(silent, flag).process(force || forceTests);
|
||||||
} else {
|
}
|
||||||
System.out.println("Invalid argument count passed in");
|
}
|
||||||
System.exit(1);
|
catch(InterruptedException | IOException e)
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(InterruptedException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
catch(IOException e)
|
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package speiger.src.builder;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public enum RequiredType
|
||||||
|
{
|
||||||
|
BI_CLASS,
|
||||||
|
ENUM
|
||||||
|
}
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
package speiger.src.builder;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.internal.Streams;
|
||||||
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
|
import speiger.src.builder.modules.BaseModule;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class SettingsManager
|
||||||
|
{
|
||||||
|
boolean loaded;
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
Set<String> moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
|
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType) {
|
||||||
|
if(!loaded) return true;
|
||||||
|
if(!isEnabled(data, base.getModuleName())) return false;
|
||||||
|
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||||
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
|
if(base.isBiModule()) {
|
||||||
|
result = getObject(result, valueType.getClassPath(), false);
|
||||||
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
|
}
|
||||||
|
result = getObject(result, base.getModuleName(), false);
|
||||||
|
return (result.size() <= 0 || isEnabled(result, "Enabled")) && base.areDependenciesLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry)
|
||||||
|
{
|
||||||
|
if(!loaded) return true;
|
||||||
|
if(!isEnabled(data, base.getModuleName())) return false;
|
||||||
|
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||||
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
|
if(base.isBiModule()) {
|
||||||
|
result = getObject(result, valueType.getClassPath(), false);
|
||||||
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
|
}
|
||||||
|
result = getObject(result, base.getModuleName(), false);
|
||||||
|
return (result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry))) && base.areDependenciesLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addModule(BaseModule module) {
|
||||||
|
if(loaded) return;
|
||||||
|
String moduleName = module.getModuleName();
|
||||||
|
moduleNames.add(moduleName);
|
||||||
|
data.addProperty(moduleName, true);
|
||||||
|
if(module.isBiModule()) {
|
||||||
|
for(ClassType keyType : ModulePackage.TYPE) {
|
||||||
|
for(ClassType valueType : ModulePackage.TYPE) {
|
||||||
|
if(!module.isModuleValid(keyType, valueType)) continue;
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("Enabled", true);
|
||||||
|
for(String key : module.getModuleKeys(keyType, valueType)) {
|
||||||
|
obj.addProperty(key, true);
|
||||||
|
}
|
||||||
|
addModule(keyType, valueType, true, moduleName, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(ClassType keyType : ModulePackage.TYPE) {
|
||||||
|
if(!module.isModuleValid(keyType, keyType)) continue;
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("Enabled", true);
|
||||||
|
for(String key : module.getModuleKeys(keyType, keyType)) {
|
||||||
|
obj.addProperty(key, true);
|
||||||
|
}
|
||||||
|
addModule(keyType, keyType, false, moduleName, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
try(BufferedReader reader = Files.newBufferedReader(Paths.get("ModulSettings.json"))) {
|
||||||
|
data = JsonParser.parseReader(reader).getAsJsonObject();
|
||||||
|
loaded = true;
|
||||||
|
}
|
||||||
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
data.asMap().keySet().removeAll(moduleNames);
|
||||||
|
JsonObject result = new JsonObject();
|
||||||
|
for(String s : moduleNames) {
|
||||||
|
result.addProperty(s, true);
|
||||||
|
}
|
||||||
|
result.asMap().putAll(data.asMap());
|
||||||
|
|
||||||
|
try(JsonWriter writer = new JsonWriter(Files.newBufferedWriter(Paths.get("ModulSettings.json")))) {
|
||||||
|
writer.setIndent("\t");
|
||||||
|
Streams.write(result, writer);
|
||||||
|
}
|
||||||
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) {
|
||||||
|
JsonObject result = getObject(data, keyType.getClassPath(), true);
|
||||||
|
if(bi) {
|
||||||
|
result = getObject(result, valueType.getClassPath(), true);
|
||||||
|
}
|
||||||
|
result.add(moduleName, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonObject getObject(JsonObject data, String name, boolean create) {
|
||||||
|
JsonObject obj = data.getAsJsonObject(name);
|
||||||
|
if(obj == null) {
|
||||||
|
obj = new JsonObject();
|
||||||
|
data.add(name, obj);
|
||||||
|
if(create) obj.addProperty("Enabled", true);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEnabled(JsonObject obj, String key) {
|
||||||
|
if(obj.has(key)) return obj.getAsJsonPrimitive(key).getAsBoolean();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class AsyncModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new AsyncModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Async"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers() {}
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses() {}
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions() {}
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades() {
|
||||||
|
if(!isModuleEnabled()) {
|
||||||
|
addBlockedFiles("AsyncBuilder", "Task");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {
|
||||||
|
if(isModuleEnabled()) {
|
||||||
|
addKeyFlag("ASYNC_MODULE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("ASYNC_BUILDER", "AsyncBuilder");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("BASE_TASK", "Base%sTask");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addClassMapper("TASK", "Task");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
import speiger.src.builder.ModulePackage;
|
||||||
|
import speiger.src.builder.RequiredType;
|
||||||
|
import speiger.src.builder.SettingsManager;
|
||||||
|
import speiger.src.builder.mappers.ArgumentMapper;
|
||||||
|
import speiger.src.builder.mappers.InjectMapper;
|
||||||
|
import speiger.src.builder.mappers.LineMapper;
|
||||||
|
import speiger.src.builder.mappers.SimpleMapper;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public abstract class BaseModule
|
||||||
|
{
|
||||||
|
SettingsManager manager;
|
||||||
|
ModulePackage entry;
|
||||||
|
protected ClassType keyType;
|
||||||
|
protected ClassType valueType;
|
||||||
|
|
||||||
|
public final void setManager(SettingsManager manager) {
|
||||||
|
this.manager = manager;
|
||||||
|
manager.addModule(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void init(ModulePackage entry) {
|
||||||
|
this.entry = entry;
|
||||||
|
keyType = entry.getKeyType();
|
||||||
|
valueType = entry.getValueType();
|
||||||
|
loadVariables();
|
||||||
|
loadClasses();
|
||||||
|
loadTestClasses();
|
||||||
|
loadFunctions();
|
||||||
|
loadRemappers();
|
||||||
|
loadBlockades();
|
||||||
|
loadFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void cleanup() {
|
||||||
|
entry = null;
|
||||||
|
keyType = null;
|
||||||
|
valueType = null;
|
||||||
|
manager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void loadVariables();
|
||||||
|
protected abstract void loadClasses();
|
||||||
|
protected abstract void loadTestClasses();
|
||||||
|
protected abstract void loadFunctions();
|
||||||
|
protected abstract void loadRemappers();
|
||||||
|
protected abstract void loadBlockades();
|
||||||
|
protected abstract void loadFlags();
|
||||||
|
|
||||||
|
public abstract String getModuleName();
|
||||||
|
public boolean isBiModule() { return false; }
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||||
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||||
|
|
||||||
|
protected boolean isModuleEnabled() {
|
||||||
|
return manager == null || manager.isModuleEnabled(this, keyType, valueType);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isModuleEnabled(String name) {
|
||||||
|
return manager == null || manager.isModuleEnabled(this, keyType, valueType, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDependencyLoaded(BaseModule module) {
|
||||||
|
return isDependencyLoaded(module, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isDependencyLoaded(BaseModule module, boolean key) {
|
||||||
|
return manager == null || (module.isBiModule() ? manager.isModuleEnabled(module, keyType, valueType) : (key ? manager.isModuleEnabled(module, keyType, keyType) : manager.isModuleEnabled(module, valueType, valueType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean areDependenciesLoaded() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFlag(String name) {
|
||||||
|
entry.addFlag(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addValue(String name, int value) {
|
||||||
|
entry.addValue(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addKeyFlag(String name) {
|
||||||
|
entry.addFlag(name);
|
||||||
|
entry.addGlobalFlag(keyType.getCapType()+"_"+name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addBiRequirement(String fileName) {
|
||||||
|
entry.addRequirement(fileName, RequiredType.BI_CLASS);
|
||||||
|
entry.addSplitter(fileName, "%1$s2%2$s");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addEnumRequirement(String fileName) {
|
||||||
|
entry.addRequirement(fileName, RequiredType.ENUM);
|
||||||
|
entry.addSplitter(fileName, "%2$s");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addBiRequirement(String fileName, String splitter) {
|
||||||
|
entry.addRequirement(fileName, RequiredType.BI_CLASS);
|
||||||
|
entry.addSplitter(fileName, "%1$s"+splitter+"%2$s");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addRequirement(String fileName, String splitter, RequiredType type) {
|
||||||
|
entry.addRequirement(fileName, type);
|
||||||
|
entry.addSplitter(fileName, splitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addRemapper(String fileName, String actualName) {
|
||||||
|
entry.addRemapper(fileName, actualName);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addBlockedFiles(String... name) {
|
||||||
|
entry.addBlockedFiles(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addBlockedFilter(Predicate<String> filter) {
|
||||||
|
entry.addBlockedFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addClassMapper(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+replacement));
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addBiClassMapper(String pattern, String replacement, String splitter) {
|
||||||
|
entry.addMapper(new SimpleMapper("KEY_"+pattern, "KEY_"+pattern, keyType.getFileType()+splitter+keyType.getFileType()+replacement));
|
||||||
|
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, valueType.getFileType()+splitter+valueType.getFileType()+replacement));
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, keyType.getFileType()+splitter+valueType.getFileType()+replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAbstractMapper(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getFileType())));
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAbstractBiMapper(String pattern, String replacement, String splitter) {
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getFileType()+splitter+valueType.getFileType())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFunctionMapper(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, replacement+valueType.getNonFileType()));
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+keyType.getNonFileType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFunctionValueMapper(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, replacement+valueType.getNonFileType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFunctionMappers(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper("VALUE_"+pattern, "VALUE_"+pattern, String.format(replacement, valueType.getNonFileType())));
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, keyType.getNonFileType())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addFunctionValueMappers(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, String.format(replacement, valueType.getNonFileType())));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSimpleMapper(String pattern, String replacement) {
|
||||||
|
entry.addMapper(new SimpleMapper(pattern, pattern, replacement));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addAnnontion(String pattern, String value) {
|
||||||
|
if(keyType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
|
||||||
|
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addValueAnnontion(String pattern, String value) {
|
||||||
|
if(valueType == ClassType.OBJECT) entry.addMapper(new LineMapper(pattern, pattern));
|
||||||
|
else entry.addMapper(new SimpleMapper(pattern, pattern, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addComment(String pattern, String value) {
|
||||||
|
if(keyType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
|
||||||
|
else entry.addMapper(new LineMapper(pattern, pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addValueComment(String pattern, String value) {
|
||||||
|
if(valueType == ClassType.OBJECT) entry.addMapper(new InjectMapper(pattern, pattern, value).removeBraces());
|
||||||
|
else entry.addMapper(new LineMapper(pattern, pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InjectMapper addInjectMapper(String pattern, String replacement) {
|
||||||
|
InjectMapper mapper = new InjectMapper(pattern, pattern, replacement);
|
||||||
|
entry.addMapper(mapper);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArgumentMapper addArgumentMapper(String pattern, String replacement) {
|
||||||
|
return addArgumentMapper(pattern, replacement, ", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ArgumentMapper addArgumentMapper(String pattern, String replacement, String splitter) {
|
||||||
|
ArgumentMapper mapper = new ArgumentMapper(pattern, pattern, replacement, splitter);
|
||||||
|
entry.addMapper(mapper);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class CollectionModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new CollectionModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Collection"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded(){ return isDependencyLoaded(JavaModule.INSTANCE); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType)
|
||||||
|
{
|
||||||
|
return new TreeSet<>(Arrays.asList("Streams", "Splititerators", "IArray", "Strategy"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {
|
||||||
|
if(isModuleEnabled()) addKeyFlag("COLLECTION_MODULE");
|
||||||
|
if(isModuleEnabled("Streams")) addKeyFlag("STREAM_FEATURE");
|
||||||
|
if(isModuleEnabled("Splititerators")) addKeyFlag("SPLIT_ITERATOR_FEATURE");
|
||||||
|
if(isModuleEnabled("IArray")) addKeyFlag("IARRAY_FEATURE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades() {
|
||||||
|
if(!isModuleEnabled()) {
|
||||||
|
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
||||||
|
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
|
||||||
|
}
|
||||||
|
if(!isModuleEnabled("Splititerators")) addBlockedFiles("Splititerator", "Splititerators");
|
||||||
|
if(!isModuleEnabled("IArray")) addBlockedFiles("IArray");
|
||||||
|
if(!isModuleEnabled("Strategy")) addBlockedFiles("Strategy");
|
||||||
|
|
||||||
|
if(keyType.isObject()) {
|
||||||
|
addBlockedFiles("Stack");
|
||||||
|
addBlockedFiles("CollectionStreamTester");
|
||||||
|
}
|
||||||
|
if(keyType == ClassType.BOOLEAN) {
|
||||||
|
addBlockedFiles("CollectionRemoveIfTester", "CollectionStreamTester");
|
||||||
|
addBlockedFilter(T -> T.endsWith("Tester") && T.startsWith("Iterable"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers()
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addRemapper("IArray", "I%sArray");
|
||||||
|
addRemapper("AbstractCollection", "Abstract%sCollection");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addRemapper("AbstractIteratorTester", "Abstract%sIteratorTester");
|
||||||
|
addRemapper("MinimalCollection", "Minimal%sCollection");
|
||||||
|
addRemapper("TestCollectionGenerator", "Test%sCollectionGenerator");
|
||||||
|
addRemapper("AbstractContainerTester", "Abstract%sContainerTester");
|
||||||
|
addRemapper("AbstractCollectionTester", "Abstract%sCollectionTester");
|
||||||
|
addRemapper("SimpleTestGenerator", "Simple%sTestGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addFunctionMapper("NEXT", "next");
|
||||||
|
addSimpleMapper("NEW_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getKeyType()+"Stream");
|
||||||
|
addFunctionMapper("PREVIOUS", "previous");
|
||||||
|
addFunctionMapper("REMOVE_KEY", "rem");
|
||||||
|
addSimpleMapper("TO_ARRAY", "to"+keyType.getNonFileType()+"Array");
|
||||||
|
addSimpleMapper("VALUE_TO_ARRAY", "to"+valueType.getNonFileType()+"Array");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addClassMapper("ARRAYS", "Arrays");
|
||||||
|
addClassMapper("COLLECTIONS", "Collections");
|
||||||
|
addClassMapper("ITERABLES", "Iterables");
|
||||||
|
addClassMapper("SPLIT_ITERATORS", "Splititerators");
|
||||||
|
addClassMapper("ITERATORS", "Iterators");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addClassMapper("COLLECTION", "Collection");
|
||||||
|
addClassMapper("ITERABLE", "Iterable");
|
||||||
|
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
||||||
|
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||||
|
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
||||||
|
addClassMapper("ITERATOR", "Iterator");
|
||||||
|
if(keyType.isObject()) addSimpleMapper("STACK", "Stack");
|
||||||
|
else addClassMapper("STACK", "Stack");
|
||||||
|
addClassMapper("STRATEGY", "Strategy");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addAbstractMapper("MINIMAL_COLLECTION", "Minimal%sCollection");
|
||||||
|
addClassMapper("BIDIRECTIONAL_ITERATOR_TESTER", "BidirectionalteratorTester");
|
||||||
|
addClassMapper("LIST_ITERATOR_TESTER", "ListIteratorTester");
|
||||||
|
addClassMapper("ITERATOR_TESTER", "IteratorTester");
|
||||||
|
addClassMapper("COLLECTION_TEST_BUILDER", "CollectionTestSuiteBuilder");
|
||||||
|
addClassMapper("COLLECTION_CONSTRUCTOR_TESTS", "CollectionConstructorTests");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_COLLECTION_TESTER", "Abstract%sCollectionTester");
|
||||||
|
addAbstractMapper("ABSTRACT_CONTAINER_TESTER", "Abstract%sContainerTester");
|
||||||
|
addAbstractMapper("ABSTRACT_ITERATOR_TESTER", "Abstract%sIteratorTester");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addAbstractMapper("TEST_COLLECTION_GENERATOR", "Test%sCollectionGenerator");
|
||||||
|
addAbstractMapper("SIMPLE_TEST_GENERATOR", "Simple%sTestGenerator");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
import speiger.src.builder.RequiredType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class FunctionModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new FunctionModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Function"; }
|
||||||
|
@Override
|
||||||
|
public boolean isBiModule() { return true; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {}
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades()
|
||||||
|
{
|
||||||
|
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers()
|
||||||
|
{
|
||||||
|
addBiRequirement("BiConsumer", "");
|
||||||
|
addBiRequirement("UnaryOperator", "");
|
||||||
|
if(valueType == ClassType.BOOLEAN) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"Predicate");
|
||||||
|
}
|
||||||
|
else if(keyType.isObject() && !valueType.isObject()) {
|
||||||
|
addRequirement("Function", "%2$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", "To%sFunction");
|
||||||
|
}
|
||||||
|
else if(keyType == valueType) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", (keyType.isObject() ? "" : "%s")+"UnaryOperator");
|
||||||
|
}
|
||||||
|
else if(valueType.isObject()) {
|
||||||
|
addRequirement("Function", "%1$s", RequiredType.BI_CLASS);
|
||||||
|
addRemapper("Function", "%sFunction");
|
||||||
|
}
|
||||||
|
else addBiRequirement("Function");
|
||||||
|
addRemapper("BiConsumer", "%sConsumer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||||
|
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
|
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getCustomJDKType().getNonFileType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Interfaces
|
||||||
|
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
||||||
|
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
||||||
|
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
||||||
|
addAbstractMapper("BI_FROM_INT_CONSUMER", "Int%sConsumer");
|
||||||
|
if(keyType.isObject()) {
|
||||||
|
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"UnaryOperator");
|
||||||
|
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addSimpleMapper("TO_OBJECT_FUNCTION", keyType.getNonFileType()+"Function");
|
||||||
|
addSimpleMapper("VALUE_TO_OBJECT_FUNCTION", valueType.isObject() ? "UnaryOperator" : valueType.getFileType()+"Function");
|
||||||
|
}
|
||||||
|
if(valueType == ClassType.BOOLEAN) addFunctionMappers("FUNCTION", "%sPredicate");
|
||||||
|
else if(keyType.isObject() && !valueType.isObject()) addFunctionValueMappers("FUNCTION", "To%sFunction");
|
||||||
|
else if(keyType == valueType) addFunctionMappers("FUNCTION", "%sUnaryOperator");
|
||||||
|
else if(valueType.isObject()) addFunctionMappers("FUNCTION", "%sFunction");
|
||||||
|
else addBiClassMapper("FUNCTION", "Function", "2");
|
||||||
|
|
||||||
|
addFunctionMappers("PREDICATE", "%sPredicate");
|
||||||
|
addClassMapper("SUPPLIER", "Supplier");
|
||||||
|
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
||||||
|
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
||||||
|
if(keyType.isObject())
|
||||||
|
{
|
||||||
|
if(!valueType.isObject()) addSimpleMapper("VALUE_CONSUMER", valueType.getFileType()+"Consumer");
|
||||||
|
else addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||||
|
addSimpleMapper("CONSUMER", "Consumer");
|
||||||
|
addSimpleMapper("IARRAY", "IObjectArray");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(valueType.isObject())
|
||||||
|
{
|
||||||
|
addSimpleMapper("VALUE_CONSUMER", "Consumer");
|
||||||
|
addSimpleMapper("CONSUMER", keyType.getFileType()+"Consumer");
|
||||||
|
}
|
||||||
|
else addClassMapper("CONSUMER", "Consumer");
|
||||||
|
addFunctionMappers("IARRAY", "I%sArray");
|
||||||
|
}
|
||||||
|
addSimpleMapper("VALUE_COMPARATOR", valueType.isObject() ? "Comparator" : String.format("%sComparator", valueType.getNonFileType()));
|
||||||
|
addSimpleMapper("COMPARATOR", keyType.isObject() ? "Comparator" : String.format("%sComparator", keyType.getNonFileType()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,221 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class JavaModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new JavaModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Base"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables()
|
||||||
|
{
|
||||||
|
createHelperVars(keyType, false, "KEY");
|
||||||
|
createHelperVars(valueType, true, "VALUE");
|
||||||
|
loadBaseVariables();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags()
|
||||||
|
{
|
||||||
|
addFlag("TYPE_"+keyType.getCapType());
|
||||||
|
addFlag("VALUE_"+valueType.getCapType());
|
||||||
|
addValue("JAVA_VERSION", getVersion());
|
||||||
|
if(keyType == valueType) addFlag("SAME_TYPE");
|
||||||
|
if(keyType.hasFunction(valueType)) addFlag("JDK_FUNCTION");
|
||||||
|
if(!keyType.needsCustomJDKType()) addFlag("JDK_TYPE");
|
||||||
|
if(!keyType.isPrimitiveBlocking()) addFlag("PRIMITIVES");
|
||||||
|
if(!valueType.isPrimitiveBlocking()) addFlag("VALUE_PRIMITIVES");
|
||||||
|
if(!valueType.needsCustomJDKType()) addFlag("JDK_VALUE");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getVersion() {
|
||||||
|
String version = System.getProperty("java.version");
|
||||||
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
|
int dot = version.indexOf(".");
|
||||||
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers() {}
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
||||||
|
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
||||||
|
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
|
|
||||||
|
//Shared by Maps and Pairs so moved to java.
|
||||||
|
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||||
|
addFunctionValueMappers("ENTRY_VALUE", "get%sValue");
|
||||||
|
addFunctionMappers("KEY_ENTRY", "set%sKey");
|
||||||
|
addFunctionValueMappers("VALUE_ENTRY", "set%sValue");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
if(getVersion() >= 17) addSimpleMapper("RANDOM", "RandomGenerator");
|
||||||
|
else addSimpleMapper("RANDOM", "Random");
|
||||||
|
addSimpleMapper("JAVA_PREDICATE", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Predicate");
|
||||||
|
addSimpleMapper("JAVA_CONSUMER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Consumer");
|
||||||
|
addSimpleMapper("JAVA_SUPPLIER", keyType.isPrimitiveBlocking() ? "" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"Supplier");
|
||||||
|
addSimpleMapper("JAVA_FUNCTION", keyType.getFunctionClass(valueType));
|
||||||
|
addSimpleMapper("JAVA_BINARY_OPERATOR", keyType == ClassType.BOOLEAN ? "" : (keyType.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+keyType.getCustomJDKType().getFileType()+"BinaryOperator"));
|
||||||
|
addSimpleMapper("JAVA_UNARY_OPERATOR", keyType.isObject() ? "BinaryOperator" : keyType == ClassType.BOOLEAN ? "" : keyType.getCustomJDKType().getFileType()+"UnaryOperator");
|
||||||
|
addSimpleMapper("JAVA_SPLIT_ITERATOR", keyType.isPrimitiveBlocking() ? "Spliterator" : "Of"+keyType.getCustomJDKType().getFileType());
|
||||||
|
addSimpleMapper("JAVA_STREAM", keyType.isPrimitiveBlocking() ? "" : keyType.getCustomJDKType().getFileType()+"Stream");
|
||||||
|
addSimpleMapper("JAVA_BUFFER", keyType.getFileType()+"Buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
addClassMapper("HELPERS", "Helpers");
|
||||||
|
addClassMapper("SAMPLE_ELEMENTS", "Samples");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadBaseVariables()
|
||||||
|
{
|
||||||
|
addSimpleMapper("VALUE_PACKAGE", valueType.getPathType());
|
||||||
|
addSimpleMapper("PACKAGE", keyType.getPathType());
|
||||||
|
addSimpleMapper("CLASS_TYPE", keyType.getClassType());
|
||||||
|
addSimpleMapper("CLASS_VALUE_TYPE", valueType.getClassValueType());
|
||||||
|
addSimpleMapper("KEY_TYPE", keyType.getKeyType());
|
||||||
|
addSimpleMapper("KEY_OBJECT_TYPE", keyType.isObject() ? "Object" : keyType.getKeyType());
|
||||||
|
addSimpleMapper("KEY_STRING_TYPE", keyType.isObject() ? "String" : keyType.getKeyType());
|
||||||
|
addSimpleMapper("KEY_SPECIAL_TYPE", keyType.isObject() ? "E" : keyType.getKeyType());
|
||||||
|
addSimpleMapper("CLASS_OBJECT_TYPE", keyType.getClassType());
|
||||||
|
addSimpleMapper("CLASS_OBJECT_VALUE_TYPE", valueType.getClassValueType());
|
||||||
|
addSimpleMapper("CLASS_STRING_TYPE", keyType.isObject() ? "String" : keyType.getClassType());
|
||||||
|
addSimpleMapper("CLASS_STRING_VALUE_TYPE", valueType.isObject() ? "String" : valueType.getClassValueType());
|
||||||
|
addSimpleMapper("VALUE_TYPE", valueType.getValueType());
|
||||||
|
addSimpleMapper("VALUE_OBJECT_TYPE", valueType.isObject() ? "Object" : valueType.getValueType());
|
||||||
|
addSimpleMapper("VALUE_STRING_TYPE", valueType.isObject() ? "String" : valueType.getValueType());
|
||||||
|
addSimpleMapper("VALUE_SPECIAL_TYPE", valueType.isObject() ? "E" : valueType.getKeyType());
|
||||||
|
addSimpleMapper("KEY_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
|
addSimpleMapper("VALUE_JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
|
|
||||||
|
addSimpleMapper("EMPTY_KEY_VALUE", keyType.getEmptyValue());
|
||||||
|
addSimpleMapper("EMPTY_VALUE", valueType.getEmptyValue());
|
||||||
|
|
||||||
|
addSimpleMapper("INVALID_KEY_VALUE", keyType.getInvalidValue());
|
||||||
|
addSimpleMapper("INVALID_VALUE", valueType.getInvalidValue());
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_STRING_GENERIC_TYPE", keyType.isObject() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" VALUE_STRING_GENERIC_TYPE", valueType.isObject() ? "<String>" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_STRING_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<String, String>" : "<String>") : (valueType.isObject() ? "<String>" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_SAME_GENERIC_TYPE", keyType.isObject() ? "<T, T>" : "");
|
||||||
|
addSimpleMapper(" VALUE_SAME_GENERIC_TYPE", keyType.isObject() ? "<V, V>" : "");
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_KEY_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", "+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_CLASS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getClassType()+">" : "");
|
||||||
|
|
||||||
|
|
||||||
|
addSimpleMapper(" VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_VALUE_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_CLASS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getClassValueType()+">" : "");
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||||
|
addSimpleMapper(" KEY_VALUE_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+", "+valueType.getValueType()+">" : ""));
|
||||||
|
addInjectMapper(" KEY_VALUE_SPECIAL_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+", %s>" : "<"+keyType.getKeyType()+", %s>") : (valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>")).setBraceType("<>").removeBraces();
|
||||||
|
|
||||||
|
addSimpleMapper(" NO_GENERIC_TYPE", keyType.isObject() ? "<?>" : "");
|
||||||
|
addSimpleMapper(" NO_KV_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<?, ?>" : "<?>") : valueType.isObject() ? "<?>" : "");
|
||||||
|
addSimpleMapper(" KEY_COMPAREABLE_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_SUPER_GENERIC_TYPE", keyType.isObject() ? "<? super "+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_SUPER_GENERIC_TYPE", valueType.isObject() ? "<? super "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_SUPER_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? super "+keyType.getKeyType()+", ? super "+valueType.getValueType()+">" : "<? super "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? super "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? "<? extends "+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" VALUE_UNKNOWN_GENERIC_TYPE", valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : "");
|
||||||
|
addSimpleMapper(" KEY_VALUE_UNKNOWN_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<? extends "+keyType.getKeyType()+", ? extends "+valueType.getValueType()+">" : "<? extends "+keyType.getKeyType()+">") : (valueType.isObject() ? "<? extends "+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
addSimpleMapper(" KEY_ENUM_VALUE_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : "<"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? "<"+valueType.getValueType()+">" : ""));
|
||||||
|
addSimpleMapper(" KEY_VALUE_ENUM_GENERIC_TYPE", keyType.isObject() ? (valueType.isObject() ? "<"+keyType.getKeyType()+", "+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : "<"+keyType.getKeyType()+">") : (valueType.isObject() ? "<"+valueType.getValueType()+" extends Enum<"+valueType.getValueType()+">>" : ""));
|
||||||
|
|
||||||
|
addInjectMapper(" KEY_SPECIAL_GENERIC_TYPE", keyType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" VALUE_SPECIAL_GENERIC_TYPE", valueType.isObject() ? "<%s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" KSK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" KKS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
|
addArgumentMapper(" KSS_GENERIC_TYPE", keyType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" SK_GENERIC_TYPE", keyType.isObject() ? "<%s, "+keyType.getKeyType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" KS_GENERIC_TYPE", keyType.isObject() ? "<"+keyType.getKeyType()+", %s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" VSV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" VVS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "<%s>").removeBraces().setBraceType("<>");
|
||||||
|
addArgumentMapper(" VSS_GENERIC_TYPE", valueType.isObject() ? "<%1$s, %2$s>" : "<%2$s>").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" SV_GENERIC_TYPE", valueType.isObject() ? "<%s, "+valueType.getValueType()+">" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" VS_GENERIC_TYPE", valueType.isObject() ? "<"+valueType.getValueType()+", %s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
|
||||||
|
|
||||||
|
addSimpleMapper(" GENERIC_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+">" : "");
|
||||||
|
addSimpleMapper(" GENERIC_VALUE_BRACES", valueType.isObject() ? " <"+valueType.getValueType()+">" : "");
|
||||||
|
addInjectMapper(" GENERIC_SPECIAL_KEY_BRACES", keyType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" GENERIC_SPECIAL_VALUE_BRACES", valueType.isObject() ? " <%s>" : "").removeBraces().setBraceType("<>");
|
||||||
|
addSimpleMapper(" GENERIC_KEY_ENUM_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">, "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+" extends Enum<"+keyType.getKeyType()+">>") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||||
|
|
||||||
|
addInjectMapper(" GENERIC_KEY_SPECIAL_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
||||||
|
addInjectMapper(" GENERIC_VALUE_SPECIAL_BRACES", valueType.isObject() ? " <"+valueType.getKeyType()+", %s>" : " <%s>").removeBraces().setBraceType("<>");
|
||||||
|
|
||||||
|
addSimpleMapper(" GENERIC_KEY_VALUE_BRACES", keyType.isObject() ? (valueType.isObject() ? " <"+keyType.getKeyType()+", "+valueType.getValueType()+">" : " <"+keyType.getKeyType()+">") : (valueType.isObject() ? " <"+valueType.getValueType()+">" : ""));
|
||||||
|
addSimpleMapper(" COMPAREABLE_KEY_BRACES", keyType.isObject() ? " <"+keyType.getKeyType()+" extends Comparable<T>>" : "");
|
||||||
|
addSimpleMapper("KV_BRACES", keyType.isObject() || valueType.isObject() ? "<>" : "");
|
||||||
|
addSimpleMapper("VALUE_BRACES", valueType.isObject() ? "<>" : "");
|
||||||
|
addSimpleMapper("BRACES", keyType.isObject() ? "<>" : "");
|
||||||
|
if(keyType.needsCustomJDKType())
|
||||||
|
{
|
||||||
|
addSimpleMapper("JAVA_TYPE", keyType.getCustomJDKType().getKeyType());
|
||||||
|
addSimpleMapper("SANITY_CAST", "castTo"+keyType.getFileType());
|
||||||
|
}
|
||||||
|
addSimpleMapper("JAVA_CLASS", keyType.getCustomJDKType().getClassType());
|
||||||
|
if(valueType.needsCustomJDKType())
|
||||||
|
{
|
||||||
|
addSimpleMapper("SANITY_CAST_VALUE", "castTo"+valueType.getFileType());
|
||||||
|
}
|
||||||
|
addSimpleMapper("[SPACE]", " ");
|
||||||
|
addComment("@ArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
||||||
|
addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection");
|
||||||
|
addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
||||||
|
addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection");
|
||||||
|
addAnnontion("@PrimitiveOverride", "@Override");
|
||||||
|
addSimpleMapper("@PrimitiveDoc", "");
|
||||||
|
addAnnontion("@Primitive", "@Deprecated");
|
||||||
|
addValueAnnontion("@ValuePrimitiveOverride", "@Override");
|
||||||
|
addValueAnnontion("@ValuePrimitive", "@Deprecated");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createHelperVars(ClassType type, boolean value, String fix)
|
||||||
|
{
|
||||||
|
addArgumentMapper("EQUALS_"+fix+"_TYPE", "Objects.equals(%2$s, "+(type.isObject() ? "%1$s" : fix+"_TO_OBJ(%1$s)")+")").removeBraces();
|
||||||
|
addInjectMapper(fix+"_EQUALS_NOT_NULL", type.getComparableValue()+" != "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
||||||
|
addInjectMapper(fix+"_EQUALS_NULL", type.getComparableValue()+" == "+(type.isPrimitiveBlocking() || type.needsCast() ? type.getEmptyValue() : "0")).removeBraces();
|
||||||
|
addArgumentMapper(fix+"_EQUALS_NOT", type.getEquals(true)).removeBraces();
|
||||||
|
addArgumentMapper(fix+"_EQUALS", type.getEquals(false)).removeBraces();
|
||||||
|
addSimpleMapper("FILE_"+fix+"_TYPE", type.getFileType());
|
||||||
|
|
||||||
|
addArgumentMapper("COMPAREABLE_TO_"+fix, type.isObject() ? "((Comparable<"+type.getKeyType(value)+">)%1$s).compareTo(("+type.getKeyType(value)+")%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||||
|
addArgumentMapper("COMPARE_TO_"+fix, type.isObject() ? "%1$s.compareTo(%2$s)" : type.getClassType(value)+".compare(%1$s, %2$s)").removeBraces();
|
||||||
|
|
||||||
|
addInjectMapper(fix+"_TO_OBJ", type.isObject() ? "%s" : type.getClassType(value)+".valueOf(%s)").removeBraces();
|
||||||
|
addInjectMapper("OBJ_TO_"+fix, type.isObject() ? "%s" : "%s."+type.getKeyType(value)+"Value()").removeBraces();
|
||||||
|
addInjectMapper("CLASS_TO_"+fix, type.isObject() ? "("+type.getKeyType(value)+")%s" : "(("+type.getClassType(value)+")%s)."+type.getKeyType(value)+"Value()").removeBraces();
|
||||||
|
|
||||||
|
addInjectMapper(fix+"_TO_HASH", type.isObject() ? "Objects.hashCode(%s)" : type.getClassType(value)+".hashCode(%s)").removeBraces();
|
||||||
|
addInjectMapper(fix+"_TO_STRING", type.isObject() ? "Objects.toString(%s)" : type.getClassType(value)+".toString(%s)").removeBraces();
|
||||||
|
|
||||||
|
addSimpleMapper("CAST_"+fix+"_ARRAY ", type.isObject() ? "("+fix+"_TYPE[])" : "");
|
||||||
|
addSimpleMapper("EMPTY_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])ARRAYS.EMPTY_ARRAY" : "ARRAYS.EMPTY_ARRAY");
|
||||||
|
addInjectMapper("NEW_"+fix+"_ARRAY", type.isObject() ? "("+fix+"_TYPE[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||||
|
addInjectMapper("NEW_SPECIAL_"+fix+"_ARRAY", type.isObject() ? "(E[])new Object[%s]" : "new "+fix+"_TYPE[%s]").removeBraces();
|
||||||
|
if(value) addInjectMapper("NEW_CLASS_VALUE_ARRAY", type.isObject() ? "(CLASS_VALUE_TYPE[])new Object[%s]" : "new CLASS_VALUE_TYPE[%s]").removeBraces();
|
||||||
|
else addInjectMapper("NEW_CLASS_ARRAY", type.isObject() ? "(CLASS_TYPE[])new Object[%s]" : "new CLASS_TYPE[%s]").removeBraces();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class ListModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new ListModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "List"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {
|
||||||
|
if(isModuleEnabled()) addKeyFlag("LIST_MODULE");
|
||||||
|
if(isModuleEnabled("Wrappers")) addKeyFlag("LISTS_FEATURE");
|
||||||
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
|
if(implementations && isModuleEnabled("ArrayList")) addKeyFlag("ARRAY_LIST_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("LinkedList")) addKeyFlag("LINKED_LIST_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("ImmutableList")) addKeyFlag("IMMUTABLE_LIST_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("CopyOnWriteList")) addKeyFlag("COPY_ON_WRITE_LIST_FEATURE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades()
|
||||||
|
{
|
||||||
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Lists");
|
||||||
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
|
if(implementations || !isModuleEnabled("ArrayList")) addBlockedFiles("ArrayList");
|
||||||
|
if(implementations || !isModuleEnabled("LinkedList")) addBlockedFiles("LinkedList");
|
||||||
|
if(implementations || !isModuleEnabled("ImmutableList")) addBlockedFiles("ImmutableList");
|
||||||
|
if(implementations || !isModuleEnabled("CopyOnWriteList")) addBlockedFiles("CopyOnWriteList");
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("List", "AbstractList");
|
||||||
|
|
||||||
|
if(keyType.isObject()) addBlockedFiles("ListFillBufferTester");
|
||||||
|
if(keyType == ClassType.BOOLEAN) addBlockedFiles("ListFillBufferTester", "ListReplaceAllTester");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
return new TreeSet<>(Arrays.asList("Implementations", "Wrappers", "ArrayList", "LinkedList", "ImmutableList", "CopyOnWriteList"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded() {
|
||||||
|
return isDependencyLoaded(CollectionModule.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers()
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addRemapper("AbstractList", "Abstract%sList");
|
||||||
|
addRemapper("ImmutableList", "Immutable%sList");
|
||||||
|
addRemapper("CopyOnWriteList", "CopyOnWrite%sArrayList");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addRemapper("AbstractListTester", "Abstract%sListTester");
|
||||||
|
addRemapper("AbstractListIndexOfTester", "Abstract%sListIndexOfTester");
|
||||||
|
addRemapper("TestListGenerator", "Test%sListGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addFunctionMapper("GET_KEY", "get");
|
||||||
|
addFunctionMapper("REMOVE_LAST", "removeLast");
|
||||||
|
addFunctionMapper("REMOVE_SWAP", "swapRemove");
|
||||||
|
addFunctionMappers("REPLACE", keyType.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
|
addFunctionMappers("SORT", "sort%ss");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("ARRAY_LIST", "ArrayList");
|
||||||
|
addAbstractMapper("COPY_ON_WRITE_LIST", "CopyOnWrite%sArrayList");
|
||||||
|
addClassMapper("LINKED_LIST", "LinkedList");
|
||||||
|
addAbstractMapper("IMMUTABLE_LIST", "Immutable%sList");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
||||||
|
|
||||||
|
//SubClasses
|
||||||
|
addClassMapper("SUB_LIST", "SubList");
|
||||||
|
addClassMapper("LIST_ITER", "ListIter");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addClassMapper("LISTS", "Lists");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addClassMapper("LIST", "List");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("LIST_TEST_BUILDER", "ListTestSuiteBuilder");
|
||||||
|
addClassMapper("LIST_TESTS", "ListTests");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_LIST_INDEX_OF_TESTER", "Abstract%sListIndexOfTester");
|
||||||
|
addAbstractMapper("ABSTRACT_LIST_TESTER", "Abstract%sListTester");
|
||||||
|
|
||||||
|
//Helper classes
|
||||||
|
addAbstractMapper("TEST_LIST_GENERATOR", "Test%sListGenerator");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class MapModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new MapModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Map"; }
|
||||||
|
@Override
|
||||||
|
public boolean isBiModule() { return true; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
Set<String> sets = new TreeSet<>();
|
||||||
|
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||||
|
sets.addAll(Arrays.asList("OrderedMap", "SortedMap"));
|
||||||
|
sets.addAll(Arrays.asList("ArrayMap", "ConcurrentMap", "ImmutableMap"));
|
||||||
|
sets.addAll(Arrays.asList("HashMap", "LinkedHashMap"));
|
||||||
|
sets.addAll(Arrays.asList("CustomHashMap", "LinkedCustomHashMap"));
|
||||||
|
sets.addAll(Arrays.asList("EnumMap", "LinkedEnumMap"));
|
||||||
|
sets.addAll(Arrays.asList("AVLTreeMap", "RBTreeMap"));
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags()
|
||||||
|
{
|
||||||
|
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||||
|
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||||
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
|
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||||
|
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||||
|
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||||
|
|
||||||
|
if(isModuleEnabled("OrderedMap")) {
|
||||||
|
addFlag("ORDERED_MAP_FEATURE");
|
||||||
|
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||||
|
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||||
|
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||||
|
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||||
|
}
|
||||||
|
if(isModuleEnabled("SortedMap")) {
|
||||||
|
addFlag("SORTED_MAP_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("AVLTreeMap")) addFlag("AVL_TREE_MAP_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("RBTreeMap")) addFlag("RB_TREE_MAP_FEATURE");
|
||||||
|
}
|
||||||
|
if(implementations && isModuleEnabled("ConcurrentMap")) addFlag("CONCURRENT_MAP_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("ImmutableMap")) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||||
|
if(hashMap) addFlag("MAP_FEATURE");
|
||||||
|
if(customHashMap) addFlag("CUSTOM_MAP_FEATURE");
|
||||||
|
if(enumMap) addFlag("ENUM_MAP_FEATURE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades()
|
||||||
|
{
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||||
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||||
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
|
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||||
|
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
|
|
||||||
|
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||||
|
if(ordered) addBlockedFiles("OrderedMap");
|
||||||
|
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||||
|
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||||
|
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||||
|
|
||||||
|
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||||
|
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||||
|
if(customHashMap || ordered || !isModuleEnabled("LinkedCustomHashMap")) addBlockedFiles("LinkedOpenCustomHashMap");
|
||||||
|
|
||||||
|
boolean enumMap = implementations || !isModuleEnabled("EnumMap");
|
||||||
|
if(enumMap) addBlockedFiles("EnumMap");
|
||||||
|
if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap");
|
||||||
|
|
||||||
|
if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap");
|
||||||
|
|
||||||
|
boolean sorted = !isModuleEnabled("SortedMap");
|
||||||
|
if(sorted) addBlockedFiles("SortedMap", "NavigableMap");
|
||||||
|
if(implementations || sorted || !isModuleEnabled("AVLTreeMap")) addBlockedFiles("AVLTreeMap");
|
||||||
|
if(implementations || sorted || !isModuleEnabled("RBTreeMap")) addBlockedFiles("RBTreeMap");
|
||||||
|
|
||||||
|
if(keyType == ClassType.BOOLEAN)
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addBlockedFiles("SortedMap", "NavigableMap", "RBTreeMap", "AVLTreeMap");
|
||||||
|
addBlockedFiles("OrderedMap", "ArrayMap", "LinkedOpenHashMap", "LinkedOpenCustomHashMap");
|
||||||
|
addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
|
addBlockedFiles("Map", "Maps", "AbstractMap", "ImmutableOpenHashMap", "OpenHashMap", "OpenCustomHashMap");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addBlockedFiles("TestMap", "MapTests", "MapTestSuiteBuilder", "MapConstructorTests", "TestMapGenerator", "SimpleMapTestGenerator", "DerivedMapGenerators", "AbstractMapTester");
|
||||||
|
addBlockedFiles("TestSortedMapGenerator", "OrderedMapTestSuiteBuilder", "NavigableMapTestSuiteBuilder", "SortedMapTestSuiteBuilder");
|
||||||
|
addBlockedFiles("TestOrderedMapGenerator");
|
||||||
|
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers()
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addBiRequirement("Map");
|
||||||
|
addBiRequirement("SortedMap");
|
||||||
|
addBiRequirement("OrderedMap");
|
||||||
|
addBiRequirement("NavigableMap");
|
||||||
|
addBiRequirement("ConcurrentMap");
|
||||||
|
addBiRequirement("AbstractMap");
|
||||||
|
addEnumRequirement("EnumMap");
|
||||||
|
addEnumRequirement("LinkedEnumMap");
|
||||||
|
addBiRequirement("ConcurrentOpenHashMap");
|
||||||
|
addBiRequirement("ImmutableOpenHashMap");
|
||||||
|
addBiRequirement("OpenHashMap");
|
||||||
|
addBiRequirement("LinkedOpenHashMap");
|
||||||
|
addBiRequirement("OpenCustomHashMap");
|
||||||
|
addBiRequirement("LinkedOpenCustomHashMap");
|
||||||
|
addBiRequirement("ArrayMap");
|
||||||
|
addBiRequirement("RBTreeMap");
|
||||||
|
addBiRequirement("AVLTreeMap");
|
||||||
|
addBiRequirement("Maps");
|
||||||
|
|
||||||
|
addRemapper("AbstractMap", "Abstract%sMap");
|
||||||
|
addRemapper("EnumMap", "Enum2%sMap");
|
||||||
|
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||||
|
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addBiRequirement("TestMapGenerator");
|
||||||
|
addBiRequirement("TestSortedMapGenerator");
|
||||||
|
addBiRequirement("TestOrderedMapGenerator");
|
||||||
|
addBiRequirement("SimpleMapTestGenerator");
|
||||||
|
addBiRequirement("DerivedMapGenerators");
|
||||||
|
addBiRequirement("AbstractMapTester");
|
||||||
|
addBiRequirement("MapTestSuiteBuilder");
|
||||||
|
addBiRequirement("SortedMapTestSuiteBuilder");
|
||||||
|
addBiRequirement("NavigableMapTestSuiteBuilder");
|
||||||
|
addBiRequirement("OrderedMapTestSuiteBuilder");
|
||||||
|
addBiRequirement("MapTests");
|
||||||
|
addBiRequirement("MapConstructorTests");
|
||||||
|
addBiRequirement("TestMap");
|
||||||
|
addBiRequirement("MapAddToTester");
|
||||||
|
addBiRequirement("MapSubFromTester");
|
||||||
|
addBiRequirement("MapClearTester");
|
||||||
|
addBiRequirement("MapComputeIfAbsentTester");
|
||||||
|
addBiRequirement("MapComputeIfPresentTester");
|
||||||
|
addBiRequirement("MapComputeTester");
|
||||||
|
addBiRequirement("MapCopyTester");
|
||||||
|
addBiRequirement("MapContainsTester");
|
||||||
|
addBiRequirement("MapContainsKeyTester");
|
||||||
|
addBiRequirement("MapContainsValueTester");
|
||||||
|
addBiRequirement("MapCreatorTester");
|
||||||
|
addBiRequirement("MapEntrySetTester");
|
||||||
|
addBiRequirement("MapEqualsTester");
|
||||||
|
addBiRequirement("MapForEachTester");
|
||||||
|
addBiRequirement("MapGetOrDefaultTester");
|
||||||
|
addBiRequirement("MapGetTester");
|
||||||
|
addBiRequirement("MapHashCodeTester");
|
||||||
|
addBiRequirement("MapIsEmptyTester");
|
||||||
|
addBiRequirement("MapMergeTester");
|
||||||
|
addBiRequirement("MapMergeBulkTester");
|
||||||
|
addBiRequirement("MapPutAllArrayTester");
|
||||||
|
addBiRequirement("MapPutAllTester");
|
||||||
|
addBiRequirement("MapPutIfAbsentTester");
|
||||||
|
addBiRequirement("MapPutTester");
|
||||||
|
addBiRequirement("MapRemoveEntryTester");
|
||||||
|
addBiRequirement("MapRemoveOrDefaultTester");
|
||||||
|
addBiRequirement("MapRemoveTester");
|
||||||
|
addBiRequirement("MapReplaceAllTester");
|
||||||
|
addBiRequirement("MapReplaceEntryTester");
|
||||||
|
addBiRequirement("MapReplaceTester");
|
||||||
|
addBiRequirement("MapSizeTester");
|
||||||
|
addBiRequirement("MapSupplyIfAbsentTester");
|
||||||
|
addBiRequirement("MapToStringTester");
|
||||||
|
addBiRequirement("NavigableMapNavigationTester");
|
||||||
|
addBiRequirement("SortedMapNavigationTester");
|
||||||
|
addBiRequirement("OrderedMapNavigationTester");
|
||||||
|
addBiRequirement("OrderedMapMoveTester");
|
||||||
|
addBiRequirement("MapConstructorTester");
|
||||||
|
|
||||||
|
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||||
|
addRemapper("TestSortedMapGenerator", "Test%sSortedMapGenerator");
|
||||||
|
addRemapper("TestOrderedMapGenerator", "Test%sOrderedMapGenerator");
|
||||||
|
addRemapper("SimpleMapTestGenerator", "Simple%sMapTestGenerator");
|
||||||
|
addRemapper("DerivedMapGenerators", "Derived%sMapGenerators");
|
||||||
|
addRemapper("AbstractMapTester", "Abstract%sMapTester");
|
||||||
|
addRemapper("TestMap", "Test%sMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addFunctionValueMapper("BULK_MERGE", "mergeAll");
|
||||||
|
addFunctionValueMappers("COMPUTE_IF_ABSENT", "compute%sIfAbsent");
|
||||||
|
addFunctionValueMappers("COMPUTE_IF_PRESENT", "compute%sIfPresent");
|
||||||
|
addFunctionValueMapper("COMPUTE", "compute");
|
||||||
|
addFunctionMapper("DEQUEUE_LAST", "dequeueLast");
|
||||||
|
addFunctionMapper("DEQUEUE", "dequeue");
|
||||||
|
addSimpleMapper("ENTRY_SET", keyType.getFileType().toLowerCase()+"2"+valueType.getFileType()+"EntrySet");
|
||||||
|
addFunctionMappers("FIRST_ENTRY_KEY", "first%sKey");
|
||||||
|
addFunctionValueMappers("FIRST_ENTRY_VALUE", "first%sValue");
|
||||||
|
if(keyType.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||||
|
else addSimpleMapper("GET_VALUE", "get");
|
||||||
|
addFunctionMappers("LAST_ENTRY_KEY", "last%sKey");
|
||||||
|
addFunctionValueMappers("LAST_ENTRY_VALUE", "last%sValue");
|
||||||
|
addFunctionValueMapper("MERGE", "merge");
|
||||||
|
addFunctionMappers("POLL_FIRST_ENTRY_KEY", "pollFirst%sKey");
|
||||||
|
addFunctionMappers("POLL_LAST_ENTRY_KEY", "pollLast%sKey");
|
||||||
|
if(keyType.isObject()) addFunctionMapper("REMOVE_VALUE", "rem");
|
||||||
|
else addSimpleMapper("REMOVE_VALUE", "remove");
|
||||||
|
addFunctionMapper("REMOVE", "remove");
|
||||||
|
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
|
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addAbstractBiMapper("IMMUTABLE_HASH_MAP", "Immutable%sOpenHashMap", "2");
|
||||||
|
addBiClassMapper("LINKED_CUSTOM_HASH_MAP", "LinkedOpenCustomHashMap", "2");
|
||||||
|
addBiClassMapper("LINKED_HASH_MAP", "LinkedOpenHashMap", "2");
|
||||||
|
addBiClassMapper("CUSTOM_HASH_MAP", "OpenCustomHashMap", "2");
|
||||||
|
addBiClassMapper("CONCURRENT_HASH_MAP", "ConcurrentOpenHashMap", "2");
|
||||||
|
addBiClassMapper("AVL_TREE_MAP", "AVLTreeMap", "2");
|
||||||
|
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||||
|
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||||
|
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||||
|
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||||
|
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addBiClassMapper("MAPS", "Maps", "2");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addBiClassMapper("NAVIGABLE_MAP", "NavigableMap", "2");
|
||||||
|
addBiClassMapper("ORDERED_MAP", "OrderedMap", "2");
|
||||||
|
addBiClassMapper("SORTED_MAP", "SortedMap", "2");
|
||||||
|
addBiClassMapper("CONCURRENT_MAP", "ConcurrentMap", "2");
|
||||||
|
addBiClassMapper("MAP", "Map", "2");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addAbstractBiMapper("SIMPLE_TEST_MAP", "Test%sMap", "2");
|
||||||
|
addBiClassMapper("MAP_TESTS", "MapTests", "2");
|
||||||
|
addAbstractBiMapper("NAVIGABLE_MAP_TEST_BUILDER", "%sNavigableMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("SORTED_MAP_TEST_BUILDER", "%sSortedMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("ORDERED_MAP_TEST_BUILDER", "%sOrderedMapTestSuiteBuilder", "2");
|
||||||
|
addAbstractBiMapper("MAP_TEST_BUILDER", "%sMapTestSuiteBuilder", "2");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractBiMapper("ABSTRACT_MAP_TESTER", "Abstract%sMapTester", "2");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addAbstractBiMapper("MAP_CONSTRUCTOR_TESTS", "%sMapConstructorTests", "2");
|
||||||
|
addAbstractBiMapper("SIMPLE_MAP_TEST_GENERATOR", "Simple%sMapTestGenerator", "2");
|
||||||
|
addAbstractBiMapper("DERIVED_MAP_GENERATORS", "Derived%sMapGenerators", "2");
|
||||||
|
addAbstractBiMapper("TEST_ORDERED_MAP_GENERATOR", "Test%sOrderedMapGenerator", "2");
|
||||||
|
addAbstractBiMapper("TEST_SORTED_MAP_GENERATOR", "Test%sSortedMapGenerator", "2");
|
||||||
|
addAbstractBiMapper("TEST_MAP_GENERATOR", "Test%sMapGenerator", "2");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class PairModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new PairModule();
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Pair"; }
|
||||||
|
@Override
|
||||||
|
public boolean isBiModule() { return true; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions() {}
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses() {}
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return new TreeSet<>(Arrays.asList("Mutable", "Immutable")); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {
|
||||||
|
if(isModuleEnabled()) addFlag("PAIR_MODULE");
|
||||||
|
if(isModuleEnabled("Mutable")) addFlag("MUTABLE_PAIR");
|
||||||
|
if(isModuleEnabled("Immutable")) addFlag("IMMUTABLE_PAIR");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades() {
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("Pair");
|
||||||
|
if(!isModuleEnabled("Mutable")) addBlockedFiles("MutablePair");
|
||||||
|
if(!isModuleEnabled("Immutable")) addBlockedFiles("ImmutablePair");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers() {
|
||||||
|
//Main Classes
|
||||||
|
addBiRequirement("Pair", "");
|
||||||
|
addBiRequirement("MutablePair", "");
|
||||||
|
addBiRequirement("ImmutablePair", "");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addBiRequirement("PairTester", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses() {
|
||||||
|
//Implementations
|
||||||
|
addBiClassMapper("IMMUTABLE_PAIR", "ImmutablePair", "");
|
||||||
|
addBiClassMapper("MUTABLE_PAIR", "MutablePair", "");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addBiClassMapper("PAIR", "Pair", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class PrioQueueModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new PrioQueueModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "PriorityQueue"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions() {}
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
return new TreeSet<>(Arrays.asList("Wrappers", "Implementations", "Dequeue", "FiFoQueue", "HeapQueue", "ArrayPrioQueue"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags() {
|
||||||
|
if(isModuleEnabled()) addFlag("QUEUE_MODULE");
|
||||||
|
if(isModuleEnabled("Wrappers")) addKeyFlag("QUEUES_FEATURE");
|
||||||
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
|
if(isModuleEnabled("Dequeue")) {
|
||||||
|
addKeyFlag("DEQUEUE_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("FiFoQueue")) addKeyFlag("FIFO_QUEUE_FEATURE");
|
||||||
|
}
|
||||||
|
if(implementations && isModuleEnabled("HeapQueue")) addKeyFlag("HEAP_QUEUE_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("ArrayPrioQueue")) addKeyFlag("ARRAY_QUEUE_FEATURE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades() {
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("PriorityQueue", "AbstractPriorityQueue");
|
||||||
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("PriorityQueues");
|
||||||
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
|
boolean dequeue = !isModuleEnabled("Dequeue");
|
||||||
|
if(dequeue) addBlockedFiles("PriorityDequeue");
|
||||||
|
if(dequeue || implementations || !isModuleEnabled("FiFoQueue")) addBlockedFiles("ArrayFIFOQueue");
|
||||||
|
if(implementations || !isModuleEnabled("HeapQueue")) addBlockedFiles("HeapPriorityQueue");
|
||||||
|
if(implementations || !isModuleEnabled("ArrayPrioQueue")) addBlockedFiles("ArrayPriorityQueue");
|
||||||
|
|
||||||
|
if(keyType == ClassType.BOOLEAN) {
|
||||||
|
addBlockedFiles("QueueTests");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers() {
|
||||||
|
//Main Classes
|
||||||
|
addRemapper("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addRemapper("TestQueueGenerator", "Test%sQueueGenerator");
|
||||||
|
addRemapper("AbstractQueueTester", "Abstract%sQueueTester");
|
||||||
|
addRemapper("SimpleQueueTestGenerator", "Simple%sQueueTestGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses() {
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("ARRAY_FIFO_QUEUE", "ArrayFIFOQueue");
|
||||||
|
addClassMapper("ARRAY_PRIORITY_QUEUE", "ArrayPriorityQueue");
|
||||||
|
addClassMapper("HEAP_PRIORITY_QUEUE", "HeapPriorityQueue");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addClassMapper("PRIORITY_QUEUES", "PriorityQueues");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addClassMapper("PRIORITY_QUEUE", "PriorityQueue");
|
||||||
|
addClassMapper("PRIORITY_DEQUEUE", "PriorityDequeue");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("DEQUEUE_TEST_BUILDER", "DequeueTestSuiteBuilder");
|
||||||
|
addClassMapper("QUEUE_TEST_BUILDER", "QueueTestSuiteBuilder");
|
||||||
|
addClassMapper("QUEUE_TESTS", "QueueTests");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_QUEUE_TESTER", "Abstract%sQueueTester");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addAbstractMapper("SIMPLE_QUEUE_TEST_GENERATOR", "Simple%sQueueTestGenerator");
|
||||||
|
addAbstractMapper("TEST_QUEUE_GENERATOR", "Test%sQueueGenerator");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
import speiger.src.builder.ClassType;
|
||||||
|
|
||||||
|
@SuppressWarnings("javadoc")
|
||||||
|
public class SetModule extends BaseModule
|
||||||
|
{
|
||||||
|
public static final BaseModule INSTANCE = new SetModule();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModuleName() { return "Set"; }
|
||||||
|
@Override
|
||||||
|
protected void loadVariables() {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||||
|
@Override
|
||||||
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||||
|
@Override
|
||||||
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) {
|
||||||
|
Set<String> sets = new TreeSet<>();
|
||||||
|
sets.addAll(Arrays.asList("Wrappers", "Implementations"));
|
||||||
|
sets.addAll(Arrays.asList("OrderedSet", "SortedSet"));
|
||||||
|
sets.addAll(Arrays.asList("ArraySet", "ImmutableSet"));
|
||||||
|
sets.addAll(Arrays.asList("HashSet", "LinkedHashSet"));
|
||||||
|
sets.addAll(Arrays.asList("CustomHashSet", "LinkedCustomHashSet"));
|
||||||
|
sets.addAll(Arrays.asList("AVLTreeSet", "RBTreeSet"));
|
||||||
|
return sets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFlags()
|
||||||
|
{
|
||||||
|
if(isModuleEnabled()) addFlag("SET_MODULE");
|
||||||
|
if(isModuleEnabled("Wrappers")) addFlag("SETS_FEATURE");
|
||||||
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
|
boolean hashSet = implementations && isModuleEnabled("HashSet");
|
||||||
|
boolean customHashSet = implementations && isModuleEnabled("CustomHashSet");
|
||||||
|
|
||||||
|
if(isModuleEnabled("OrderedSet")) {
|
||||||
|
addFlag("ORDERED_SET_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("ArraySet")) addFlag("ARRAY_SET_FEATURE");
|
||||||
|
if(hashSet && isModuleEnabled("LinkedHashSet")) addFlag("LINKED_SET_FEATURE");
|
||||||
|
if(customHashSet && isModuleEnabled("LinkedCustomHashSet")) addFlag("LINKED_CUSTOM_SET_FEATURE");
|
||||||
|
}
|
||||||
|
if(isModuleEnabled("SortedSet")) {
|
||||||
|
addFlag("SORTED_SET_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("AVLTreeSet")) addFlag("AVL_TREE_SET_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("RBTreeSet")) addFlag("RB_TREE_SET_FEATURE");
|
||||||
|
}
|
||||||
|
if(implementations && isModuleEnabled("ImmutableSet")) addFlag("IMMUTABLE_SET_FEATURE");
|
||||||
|
if(hashSet) addFlag("HASH_SET_FEATURE");
|
||||||
|
if(customHashSet) addFlag("CUSTOM_HASH_SET_FEATURE");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadBlockades()
|
||||||
|
{
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("Set", "AbstractSet");
|
||||||
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Sets");
|
||||||
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
|
if(implementations || !isModuleEnabled("ImmutableSet")) addBlockedFiles("ImmutableOpenHashSet");
|
||||||
|
|
||||||
|
boolean ordered = !isModuleEnabled("OrderedSet");
|
||||||
|
if(ordered) addBlockedFiles("OrderedSet");
|
||||||
|
boolean hashSet = implementations || !isModuleEnabled("HashSet");
|
||||||
|
if(hashSet) addBlockedFiles("OpenHashSet");
|
||||||
|
if(hashSet || ordered || !isModuleEnabled("LinkedHashSet")) addBlockedFiles("LinkedOpenHashSet");
|
||||||
|
|
||||||
|
boolean customHashSet = implementations || !isModuleEnabled("CustomHashSet");
|
||||||
|
if(customHashSet) addBlockedFiles("OpenCustomHashSet");
|
||||||
|
if(customHashSet || ordered || !isModuleEnabled("LinkedCustomHashSet")) addBlockedFiles("LinkedOpenCustomHashSet");
|
||||||
|
|
||||||
|
if(implementations || ordered || !isModuleEnabled("ArraySet")) addBlockedFiles("ArraySet");
|
||||||
|
|
||||||
|
boolean sorted = !isModuleEnabled("SortedSet");
|
||||||
|
if(sorted) addBlockedFiles("SortedSet", "NavigableSet");
|
||||||
|
if(implementations || sorted || !isModuleEnabled("AVLTreeSet")) addBlockedFiles("AVLTreeSet");
|
||||||
|
if(implementations || sorted || !isModuleEnabled("RBTreeSet")) addBlockedFiles("RBTreeSet");
|
||||||
|
|
||||||
|
if(keyType == ClassType.BOOLEAN)
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addBlockedFiles("SortedSet", "NavigableSet", "AVLTreeSet", "RBTreeSet");
|
||||||
|
addBlockedFiles("OrderedSet", "ArraySet", "LinkedOpenHashSet", "LinkedOpenCustomHashSet");
|
||||||
|
addBlockedFiles("Set", "Sets", "AbstractSet", "OpenHashSet", "OpenCustomHashSet", "ImmutableOpenHashSet");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addBlockedFiles("SetTests", "SetTestSuiteBuilder", "TestSetGenerator");
|
||||||
|
addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedSetIterationTester");
|
||||||
|
addBlockedFiles("SortedSetTestSuiteBuilder", "TestSortedSetGenerator", "SortedSetNaviationTester", "SortedSetSubsetTestSetGenerator", "SortedSetIterationTester", "SortedSetNaviationTester");
|
||||||
|
addBlockedFiles("NavigableSetTestSuiteBuilder", "TestNavigableSetGenerator", "NavigableSetNavigationTester");
|
||||||
|
addBlockedFiles("MinimalSet", "AbstractSetTester", "SetAddAllTester", "SetAddTester", "SetCreationTester", "SetEqualsTester", "SetRemoveTester");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadRemappers()
|
||||||
|
{
|
||||||
|
//Main Classes
|
||||||
|
addRemapper("AbstractSet", "Abstract%sSet");
|
||||||
|
addRemapper("ImmutableOpenHashSet", "Immutable%sOpenHashSet");
|
||||||
|
|
||||||
|
//Test Classes
|
||||||
|
addRemapper("MinimalSet", "Minimal%sSet");
|
||||||
|
addRemapper("TestNavigableSetGenerator", "Test%sNavigableSetGenerator");
|
||||||
|
addRemapper("TestSortedSetGenerator", "Test%sSortedSetGenerator");
|
||||||
|
addRemapper("TestOrderedSetGenerator", "Test%sOrderedSetGenerator");
|
||||||
|
addRemapper("TestSetGenerator", "Test%sSetGenerator");
|
||||||
|
addRemapper("AbstractSetTester", "Abstract%sSetTester");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadFunctions()
|
||||||
|
{
|
||||||
|
addFunctionMapper("POLL_FIRST_KEY", "pollFirst");
|
||||||
|
addFunctionMapper("POLL_LAST_KEY", "pollLast");
|
||||||
|
addFunctionMapper("FIRST_KEY", "first");
|
||||||
|
addFunctionMapper("LAST_KEY", "last");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadTestClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addAbstractMapper("MINIMAL_SET", "Minimal%sSet");
|
||||||
|
addClassMapper("ORDERED_SET_TEST_BUILDER", "OrderedSetTestSuiteBuilder");
|
||||||
|
addClassMapper("SORTED_SET_TEST_BUILDER", "SortedSetTestSuiteBuilder");
|
||||||
|
addClassMapper("NAVIGABLE_SET_TEST_BUILDER", "NavigableSetTestSuiteBuilder");
|
||||||
|
addClassMapper("SET_TEST_BUILDER", "SetTestSuiteBuilder");
|
||||||
|
addClassMapper("SET_TESTS", "SetTests");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_SET_TESTER", "Abstract%sSetTester");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addClassMapper("SUB_SORTED_SET_CLASS_GENERATOR", "SortedSetSubsetTestSetGenerator");
|
||||||
|
addClassMapper("SUB_NAVIGABLE_SET_CLASS_GENERATOR", "NavigableSetSubsetTestSetGenerator");
|
||||||
|
addAbstractMapper("TEST_NAVIGABLE_SET_GENERATOR", "Test%sNavigableSetGenerator");
|
||||||
|
addAbstractMapper("TEST_SORTED_SET_GENERATOR", "Test%sSortedSetGenerator");
|
||||||
|
addAbstractMapper("TEST_ORDERED_SET_GENERATOR", "Test%sOrderedSetGenerator");
|
||||||
|
addAbstractMapper("TEST_SET_GENERATOR", "Test%sSetGenerator");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void loadClasses()
|
||||||
|
{
|
||||||
|
//Implementation Classes
|
||||||
|
addClassMapper("LINKED_CUSTOM_HASH_SET", "LinkedOpenCustomHashSet");
|
||||||
|
addClassMapper("LINKED_HASH_SET", "LinkedOpenHashSet");
|
||||||
|
addAbstractMapper("IMMUTABLE_HASH_SET", "Immutable%sOpenHashSet");
|
||||||
|
addClassMapper("CUSTOM_HASH_SET", "OpenCustomHashSet");
|
||||||
|
addClassMapper("HASH_SET", "OpenHashSet");
|
||||||
|
addClassMapper("RB_TREE_SET", "RBTreeSet");
|
||||||
|
addClassMapper("AVL_TREE_SET", "AVLTreeSet");
|
||||||
|
addClassMapper("ARRAY_SET", "ArraySet");
|
||||||
|
|
||||||
|
//Abstract Classes
|
||||||
|
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
||||||
|
|
||||||
|
//Helper Classes
|
||||||
|
addClassMapper("SETS", "Sets");
|
||||||
|
|
||||||
|
//Interfaces
|
||||||
|
addClassMapper("NAVIGABLE_SET", "NavigableSet");
|
||||||
|
addClassMapper("SORTED_SET", "SortedSet");
|
||||||
|
addClassMapper("ORDERED_SET", "OrderedSet");
|
||||||
|
addClassMapper("SET", "Set");
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
@@ -11,6 +11,7 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract Type Specific Collection that reduces boxing/unboxing
|
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||||
@@ -245,6 +246,7 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY() {
|
public KEY_TYPE[] TO_ARRAY() {
|
||||||
|
if(isEmpty()) return ARRAYS.EMPTY_ARRAY;
|
||||||
return TO_ARRAY(new KEY_TYPE[size()]);
|
return TO_ARRAY(new KEY_TYPE[size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-4
@@ -5,24 +5,29 @@ import java.util.Collection;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
import java.util.function.IntFunction;
|
||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE
|
public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
@@ -177,8 +182,8 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
* @see Collection#toArray(Object[])
|
* @see Collection#toArray(Object[])
|
||||||
*/
|
*/
|
||||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
return TO_ARRAY(action.get(size()));
|
return TO_ARRAY(action.apply(size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -290,6 +295,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||||||
*/
|
*/
|
||||||
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
public default COLLECTION KEY_GENERIC_TYPE unmodifiable() { return COLLECTIONS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
@@ -302,11 +308,15 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
*/
|
*/
|
||||||
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
default JAVA_STREAM parallelPrimitiveStream() { return StreamSupport.NEW_STREAM(SPLIT_ITERATORS.createJavaSplititerator(this, 0), true); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if STREAM_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
* @return type specific splititerator
|
* @return type specific splititerator
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 0); }
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+138
-12
@@ -2,6 +2,10 @@ package speiger.src.collections.PACKAGE.collections;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -9,23 +13,58 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#else
|
#else
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
#else
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if SET_MODULE && !TYPE_BOOLEAN
|
||||||
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if LINKED_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||||
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||||
|
#else if SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||||
|
#else if CUSTOM_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||||
|
#else if RB_TREE_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||||
|
#else if AVL_TREE_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||||
|
#else if ARRAY_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
#if ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
import speiger.src.collections.PACKAGE.utils.ASYNC_BUILDER;
|
||||||
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
import speiger.src.collections.PACKAGE.utils.ITERABLES;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
|
#if !LINKED_HASH_SET_FEATURE && LINKED_CUSTOM_HASH_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||||
@@ -72,6 +111,17 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||||
|
* @param action The action to be performed for each element
|
||||||
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
*/
|
||||||
|
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();action.accept(index++, iter.NEXT()));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
* Helper function to reduce Lambda usage and allow for more method references, since these are faster/cleaner.
|
||||||
* @param input the object that should be included
|
* @param input the object that should be included
|
||||||
@@ -84,6 +134,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
iterator().forEachRemaining(input, action);
|
iterator().forEachRemaining(input, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
* @return type specific splititerator
|
* @return type specific splititerator
|
||||||
@@ -91,6 +142,8 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
@Override
|
@Override
|
||||||
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
default SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createUnknownSplititerator(iterator(), 0); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Creates a Async Builder for moving work of the thread.
|
* Creates a Async Builder for moving work of the thread.
|
||||||
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
||||||
@@ -101,6 +154,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
return new ASYNC_BUILDERBRACES(this);
|
return new ASYNC_BUILDERBRACES(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
* @param mapper the mapping function
|
* @param mapper the mapping function
|
||||||
@@ -117,6 +171,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param <V> The return type supplier.
|
* @param <V> The return type supplier.
|
||||||
* @param <E> The return type.
|
* @param <E> The return type.
|
||||||
* @return a new Iterable that returns the desired result
|
* @return a new Iterable that returns the desired result
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
*/
|
*/
|
||||||
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
||||||
return ITERABLES.flatMap(this, mapper);
|
return ITERABLES.flatMap(this, mapper);
|
||||||
@@ -127,6 +182,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param mapper the flatMapping function
|
* @param mapper the flatMapping function
|
||||||
* @param <E> The return type.
|
* @param <E> The return type.
|
||||||
* @return a new Iterable that returns the desired result
|
* @return a new Iterable that returns the desired result
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
*/
|
*/
|
||||||
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
default <E> ObjectIterable<E> arrayflatMap(TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
||||||
return ITERABLES.arrayFlatMap(this, mapper);
|
return ITERABLES.arrayFlatMap(this, mapper);
|
||||||
@@ -136,6 +192,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||||
* @param filter the elements that should be kept.
|
* @param filter the elements that should be kept.
|
||||||
* @return a Iterable that filtered out all unwanted elements
|
* @return a Iterable that filtered out all unwanted elements
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
*/
|
*/
|
||||||
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
default ITERABLE KEY_GENERIC_TYPE filter(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
return ITERABLES.filter(this, filter);
|
return ITERABLES.filter(this, filter);
|
||||||
@@ -144,11 +201,21 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||||
* @return a Iterable that filtered out all duplicated elements
|
* @return a Iterable that filtered out all duplicated elements
|
||||||
|
* @note does not support TO_ARRAY optimizations.
|
||||||
*/
|
*/
|
||||||
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
default ITERABLE KEY_GENERIC_TYPE distinct() {
|
||||||
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
|
||||||
@@ -187,21 +254,80 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||||
* @return a new ArrayList of all elements
|
* @return a new ArrayList of all elements
|
||||||
*/
|
*/
|
||||||
default LIST KEY_GENERIC_TYPE pourAsList() {
|
default LIST KEY_GENERIC_TYPE pourAsList() {
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
return pour(new ARRAY_LISTBRACES());
|
return pour(new ARRAY_LISTBRACES());
|
||||||
|
#else
|
||||||
|
return pour(new LINKED_LISTBRACES());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#endif
|
||||||
|
#if !TYPE_BOOLEAN && SET_MODULE
|
||||||
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a LinkedHashSet
|
||||||
* @return a new LinkedHashSet of all elements
|
* @return a new LinkedHashSet of all elements
|
||||||
*/
|
*/
|
||||||
default SET KEY_GENERIC_TYPE pourAsSet() {
|
default SET KEY_GENERIC_TYPE pourAsSet() {
|
||||||
|
#if LINKED_SET_FEATURE
|
||||||
return pour(new LINKED_HASH_SETBRACES());
|
return pour(new LINKED_HASH_SETBRACES());
|
||||||
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
|
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
|
#else if SET_FEATURE
|
||||||
|
return pour(new HASH_SETBRACES());
|
||||||
|
#else if CUSTOM_SET_FEATURE
|
||||||
|
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
|
#else if RB_TREE_SET_FEATURE
|
||||||
|
return pour(new RB_Tree_SETBRACES());
|
||||||
|
#else if AVL_TREE_SET_FEATURE
|
||||||
|
return pour(new AVL_Tree_SETBRACES());
|
||||||
|
#else if ARRAY_SET_FEATURE
|
||||||
|
return pour(new ARRAY_SETBRACES());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
|
* @param action is the creator function of said Array to ensure type is kept.
|
||||||
|
* @return a new Array of all elements
|
||||||
|
*/
|
||||||
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
|
if(prov != null) {
|
||||||
|
int size = prov.size();
|
||||||
|
if(size >= 0) {
|
||||||
|
E[] array = action.apply(size);
|
||||||
|
ITERATORS.unwrap(array, iterator());
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ARRAYS.pour(iterator(), action);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
|
* @return a new Array of all elements
|
||||||
|
*/
|
||||||
|
default KEY_TYPE[] TO_ARRAY() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
|
if(prov != null) {
|
||||||
|
int size = prov.size();
|
||||||
|
if(size >= 0) {
|
||||||
|
KEY_TYPE[] array = NEW_KEY_ARRAY(size);
|
||||||
|
ITERATORS.unwrap(array, iterator());
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ARRAYS.pour(iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -213,7 +339,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
default boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) return true;
|
if(filter.test(iter.NEXT())) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -226,7 +352,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
default boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) return false;
|
if(filter.test(iter.NEXT())) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -239,7 +365,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
default boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(!filter.TEST_VALUE(iter.NEXT())) return false;
|
if(!filter.test(iter.NEXT())) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -253,7 +379,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
if(filter.TEST_VALUE(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -324,7 +450,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) result++;
|
if(filter.test(iter.NEXT())) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-8
@@ -15,12 +15,5 @@ public interface SUPPLIER KEY_GENERIC_TYPE
|
|||||||
/**
|
/**
|
||||||
* @return the supplied value
|
* @return the supplied value
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_KEY();
|
public KEY_TYPE SUPPLY_GET();
|
||||||
#if JDK_TYPE && PRIMITIVES
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public default KEY_TYPE GET_JAVA() {
|
|
||||||
return GET_KEY();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
+73
-18
@@ -1,6 +1,6 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions.function;
|
package speiger.src.collections.PACKAGE.functions.function;
|
||||||
|
|
||||||
#if JDK_FUNCTION && VALUE_BOOLEAN
|
#if VALUE_BOOLEAN || SAME_TYPE
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -21,12 +21,67 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||||||
* @param k the value that should be processed
|
* @param k the value that should be processed
|
||||||
* @return the result of the function
|
* @return the result of the function
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE k);
|
public VALUE_TYPE APPLY(KEY_TYPE k);
|
||||||
|
|
||||||
#if JDK_FUNCTION
|
#if SAME_TYPE
|
||||||
|
/**
|
||||||
|
* Creates a Default function that returns the input provided.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a input returning function
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES FUNCTION KEY_SAME_GENERIC_TYPE identity() {
|
||||||
|
return T -> T;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a composed function that first applies the {@code before}
|
||||||
|
* function to its input, and then applies this function to the result.
|
||||||
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
|
* the caller of the composed function.
|
||||||
|
*
|
||||||
|
* @Type(I)
|
||||||
|
* @param before the function that should be used first
|
||||||
|
* @return a composed function with a different starting function.
|
||||||
|
*/
|
||||||
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION SV_GENERIC_TYPE<I> compose(FUNCTION SK_GENERIC_TYPE<I> before) {
|
||||||
|
Objects.requireNonNull(before);
|
||||||
|
return T -> APPLY(before.APPLY(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a composed function that first applies this function to
|
||||||
|
* its input, and then applies the {@code after} function to the result.
|
||||||
|
* If evaluation of either function throws an exception, it is relayed to
|
||||||
|
* the caller of the composed function.
|
||||||
|
*
|
||||||
|
* @Type(I)
|
||||||
|
* @param after the function that should be used last
|
||||||
|
* @return a composed function with a different starting function.
|
||||||
|
*/
|
||||||
|
public default GENERIC_SPECIAL_VALUE_BRACES<I> FUNCTION KS_GENERIC_TYPE<I> andThen(FUNCTION VS_GENERIC_TYPE<I> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return T -> after.APPLY(APPLY(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#if VALUE_BOOLEAN
|
#if VALUE_BOOLEAN
|
||||||
@Override
|
/**
|
||||||
public default VALUE_TYPE test(KEY_TYPE k) { return GET_VALUE(k); }
|
* Creates a Always true function that may be useful if you don't need to process information or just want a default.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a default returning function
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysTrue() {
|
||||||
|
return T -> true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Always false function that may be useful if you don't need to process information or just want a default.
|
||||||
|
* @Type(T)
|
||||||
|
* @return a default returning function
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES FUNCTION KEY_GENERIC_TYPE alwaysFalse() {
|
||||||
|
return T -> false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type specific and-function helper function that reduces boxing/unboxing
|
* A Type specific and-function helper function that reduces boxing/unboxing
|
||||||
@@ -35,19 +90,26 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE andType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) && other.GET_VALUE(T);
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_FUNCTION
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE and(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) && other.test(T);
|
return T -> APPLY(T) && other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* A type specific inverter function
|
||||||
|
* @return the same function but inverts the result
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE negate() {
|
||||||
return T -> !GET_VALUE(T);
|
return T -> !APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,23 +119,16 @@ public interface FUNCTION KEY_VALUE_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE orType(FUNCTION KEY_VALUE_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) || other.GET_VALUE(T);
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JDK_FUNCTION
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
public default FUNCTION KEY_VALUE_GENERIC_TYPE or(JAVA_FUNCTION KEY_VALUE_SUPER_GENERIC_TYPE other) {
|
||||||
Objects.requireNonNull(other);
|
Objects.requireNonNull(other);
|
||||||
return T -> GET_VALUE(T) || other.test(T);
|
return T -> APPLY(T) || other.APPLY(T);
|
||||||
}
|
}
|
||||||
#else if VALUE_OBJECT
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public default VALUE_TYPE apply(KEY_TYPE k) { return GET_VALUE(k); }
|
|
||||||
#else
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public default VALUE_TYPE APPLY_VALUE(KEY_TYPE k) { return GET_VALUE(k); }
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+38
-20
@@ -8,13 +8,21 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
#endif
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
|
#if !TYPE_OBJECT && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
#endif
|
#endif
|
||||||
@@ -29,42 +37,48 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.utils.Stack;
|
import speiger.src.collections.utils.Stack;
|
||||||
#else
|
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
|
||||||
#endif
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
|
#if IARRAY_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.IARRAY;
|
import speiger.src.collections.PACKAGE.utils.IARRAY;
|
||||||
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
|
#if !IARRAY_FEATURE
|
||||||
|
import speiger.src.collections.utils.IArray;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
|
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
|
||||||
*
|
*
|
||||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link Stack}
|
#if IARRAY_FEATURE
|
||||||
|
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
|
||||||
|
#else
|
||||||
|
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IArray}, {@link STACK}
|
||||||
|
#endif
|
||||||
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
|
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
|
||||||
*
|
*
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY<KEY_TYPE>, Stack<KEY_TYPE>
|
#if IARRAY_FEATURE
|
||||||
|
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
|
||||||
#else
|
#else
|
||||||
/**
|
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IArray, STACK KEY_GENERIC_TYPE
|
||||||
* A Type-Specific Array-based implementation of list that is written to reduce (un)boxing
|
|
||||||
*
|
|
||||||
* <p>This implementation is optimized to improve how data is processed with interfaces like {@link IARRAY}, {@link STACK}
|
|
||||||
* and with optimized functions that use type-specific implementations for primitives and optimized logic for bulkactions.
|
|
||||||
*/
|
|
||||||
public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements IARRAY, STACK
|
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static final int DEFAULT_ARRAY_SIZE = 10;
|
static final int DEFAULT_ARRAY_SIZE = 10;
|
||||||
@@ -587,6 +601,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return data[(size() - 1) - index];
|
return data[(size() - 1) - index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IARRAY_FEATURE
|
||||||
/**
|
/**
|
||||||
* Provides the Underlying Array in the Implementation
|
* Provides the Underlying Array in the Implementation
|
||||||
* @return underlying Array
|
* @return underlying Array
|
||||||
@@ -606,6 +621,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return data.getClass() != Object[].class;
|
return data.getClass() != Object[].class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
@@ -639,7 +655,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -648,7 +664,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -657,7 +673,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -666,7 +682,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -715,7 +731,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1026,6 +1042,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(size == 0) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[size];
|
Object[] obj = new Object[size];
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
@@ -1159,8 +1176,8 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES && STREAM_FEATURE
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
@@ -1177,4 +1194,5 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, size, 16464); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, size, 16464); }
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+24
-11
@@ -14,10 +14,15 @@ import java.util.function.Supplier;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
|
#if !TYPE_OBJECT && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
#endif
|
#endif
|
||||||
@@ -32,21 +37,24 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.utils.Stack;
|
import speiger.src.collections.utils.Stack;
|
||||||
#else
|
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
|
||||||
#endif
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES && STREAM_FEATURE && SPLIT_ITERATOR_FEATURE
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@@ -148,8 +156,8 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a typed List
|
* @return a typed List
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
public static GENERIC_KEY_BRACES COPY_ON_WRITE_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
||||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
COPY_ON_WRITE_LIST KEY_GENERIC_TYPE list = new COPY_ON_WRITE_LISTBRACES();
|
||||||
list.data = (KEY_TYPE[])ObjectArrays.newArray(c, 0);
|
list.data = (KEY_TYPE[])ObjectArrays.newArray(c, 0);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -773,7 +781,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -783,7 +791,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -793,7 +801,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -803,7 +811,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -856,7 +864,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 result = 0;
|
int result = 0;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1282,6 +1290,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
int size = data.length;
|
int size = data.length;
|
||||||
|
if(size == 0) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[size];
|
Object[] obj = new Object[size];
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
@@ -1409,7 +1418,8 @@ 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
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
|
#if PRIMITIVES && STREAM_FEATURE
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
@@ -1427,6 +1437,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
||||||
|
|
||||||
|
#endif
|
||||||
static final class COWIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
static final class COWIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
KEY_TYPE[] data;
|
KEY_TYPE[] data;
|
||||||
@@ -2080,9 +2091,11 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 16464); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createSplititerator(this, 16464); }
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
||||||
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
||||||
|
|||||||
+21
-8
@@ -13,8 +13,13 @@ import java.util.function.Consumer;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
#if !TYPE_OBJECT && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -25,16 +30,20 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -129,7 +138,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public KEY_TYPE[] getElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
SanityChecks.checkArrayCapacity(data.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
|
SanityChecks.checkArrayCapacity(data.length, from, length);
|
||||||
System.arraycopy(data, from, a, offset, length);
|
System.arraycopy(data, from, a, offset, length);
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
@@ -301,7 +311,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -310,7 +320,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -319,7 +329,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -328,7 +338,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -377,7 +387,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -436,6 +446,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(data.length == 0) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[data.length];
|
Object[] obj = new Object[data.length];
|
||||||
for(int i = 0,m=data.length;i<m;i++)
|
for(int i = 0,m=data.length;i<m;i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
@@ -487,7 +498,8 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + data.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if PRIMITIVES
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
|
#if PRIMITIVES && STREAM_FEATURE
|
||||||
/**
|
/**
|
||||||
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
* Returns a Java-Type-Specific Stream to reduce boxing/unboxing.
|
||||||
* @return a Stream of the closest java type
|
* @return a Stream of the closest java type
|
||||||
@@ -505,6 +517,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return SPLIT_ITERATORS.createArraySplititerator(data, data.length, 16464); }
|
||||||
|
|
||||||
|
#endif
|
||||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
|
|||||||
+64
-28
@@ -1,7 +1,10 @@
|
|||||||
package speiger.src.collections.PACKAGE.lists;
|
package speiger.src.collections.PACKAGE.lists;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
#endif
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#else if PRIMITIVES
|
#else if PRIMITIVES
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
@@ -16,31 +19,44 @@ import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
import java.util.function.IntFunction;
|
||||||
|
#endif
|
||||||
|
#if !TYPE_OBJECT && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.STACK;
|
import speiger.src.collections.PACKAGE.collections.STACK;
|
||||||
#else
|
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.utils.Stack;
|
import speiger.src.collections.utils.Stack;
|
||||||
#else
|
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
|
||||||
#endif
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
@@ -62,10 +78,10 @@ import speiger.src.collections.utils.SanityChecks;
|
|||||||
*
|
*
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
#if TYPE_OBJECT
|
#if DEQUEUE_FEATURE
|
||||||
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, Stack KEY_GENERIC_TYPE
|
|
||||||
#else
|
|
||||||
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
|
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, STACK KEY_GENERIC_TYPE
|
||||||
|
#else
|
||||||
|
public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE implements STACK KEY_GENERIC_TYPE
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE first;
|
Entry KEY_GENERIC_TYPE first;
|
||||||
@@ -222,6 +238,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
add(e);
|
add(e);
|
||||||
@@ -232,6 +249,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
add(0, e);
|
add(0, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void push(KEY_TYPE e) {
|
public void push(KEY_TYPE e) {
|
||||||
add(e);
|
add(e);
|
||||||
@@ -291,6 +309,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE first() {
|
public KEY_TYPE first() {
|
||||||
if(first == null) throw new NoSuchElementException();
|
if(first == null) throw new NoSuchElementException();
|
||||||
@@ -303,11 +322,11 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return last.value;
|
return last.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
return GET_KEY((size() - 1) - index);
|
return GET_KEY((size() - 1) - index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_KEY(int index) {
|
public KEY_TYPE GET_KEY(int index) {
|
||||||
checkRange(index);
|
checkRange(index);
|
||||||
@@ -401,6 +420,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next)
|
||||||
|
action.accept(index++, entry.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -412,7 +439,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.TEST_VALUE(entry.value)) return true;
|
if(filter.test(entry.value)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -421,7 +448,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.TEST_VALUE(entry.value)) return false;
|
if(filter.test(entry.value)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -430,7 +457,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(!filter.TEST_VALUE(entry.value)) return false;
|
if(!filter.test(entry.value)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -439,7 +466,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.TEST_VALUE(entry.value)) return entry.value;
|
if(filter.test(entry.value)) return entry.value;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -488,7 +515,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.TEST_VALUE(entry.value)) result++;
|
if(filter.test(entry.value)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -525,6 +552,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {}
|
public void onChanged() {}
|
||||||
@Override
|
@Override
|
||||||
@@ -538,25 +566,24 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeueLast() {
|
public KEY_TYPE dequeueLast() {
|
||||||
|
return pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE pop() {
|
||||||
if(last == null) throw new NoSuchElementException();
|
if(last == null) throw new NoSuchElementException();
|
||||||
return unlinkLast(last);
|
return unlinkLast(last);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
#if DEQUEUE_FEATURE
|
||||||
public KEY_TYPE pop() {
|
|
||||||
return dequeueLast();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
if(size == 0) return false;
|
#if TYPE_OBJECT
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
return remove(e);
|
||||||
if(KEY_EQUALS(entry.value, e)) {
|
#else
|
||||||
unlink(entry);
|
return REMOVE_KEY(e);
|
||||||
return true;
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -571,6 +598,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE swapRemove(int index) {
|
public KEY_TYPE swapRemove(int index) {
|
||||||
checkRange(index);
|
checkRange(index);
|
||||||
@@ -653,7 +681,14 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean REMOVE_KEY(KEY_TYPE e) {
|
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||||
return removeFirst(e);
|
if(size == 0) return false;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
|
if(KEY_EQUALS(entry.value, e)) {
|
||||||
|
unlink(entry);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -931,6 +966,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(size == 0) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[size];
|
Object[] obj = new Object[size];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
@@ -965,7 +1001,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public T[] toArray(Int2ObjectFunction<T[]> action) {
|
public <E> E[] toArray(IntFunction<E[]> action) {
|
||||||
return super.toArray(action);
|
return super.toArray(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,22 +5,25 @@ import java.nio.JAVA_BUFFER;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
import java.util.function.UnaryOperator;
|
#endif
|
||||||
#else if TYPE_OBJECT
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Comparator;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
#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.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
#if LISTS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
@@ -358,6 +361,16 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* A Indexed forEach implementation that allows you to keep track of how many elements were already iterated over.
|
||||||
|
* @param action The action to be performed for each element
|
||||||
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public default void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0,m=size();i<m;action.accept(i, GET_KEY(i++)));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A Type-Specific Iterator of listIterator
|
* A Type-Specific Iterator of listIterator
|
||||||
* @see java.util.List#listIterator
|
* @see java.util.List#listIterator
|
||||||
@@ -379,6 +392,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to);
|
public LIST KEY_GENERIC_TYPE subList(int from, int to);
|
||||||
|
|
||||||
|
#if LISTS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped List that is Synchronized
|
* Creates a Wrapped List that is Synchronized
|
||||||
* @return a new List that is synchronized
|
* @return a new List that is synchronized
|
||||||
@@ -401,6 +415,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
*/
|
*/
|
||||||
public default LIST KEY_GENERIC_TYPE unmodifiable() { return LISTS.unmodifiable(this); }
|
public default LIST KEY_GENERIC_TYPE unmodifiable() { return LISTS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A function to ensure the elements are within the requested size.
|
* A function to ensure the elements are within the requested size.
|
||||||
* If smaller then the stored elements they get removed as needed.
|
* If smaller then the stored elements they get removed as needed.
|
||||||
|
|||||||
+36
-12
@@ -3,15 +3,22 @@ package speiger.src.collections.PACKAGE.maps.abstracts;
|
|||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if VALUE_BOOLEAN && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
@@ -19,6 +26,7 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -47,6 +55,22 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ObjectIterable<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterable(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
|
return MAPS.fastIterable(map);
|
||||||
|
#else
|
||||||
|
return map.ENTRY_SET();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> getFastIterator(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
|
return MAPS.fastIterator(map);
|
||||||
|
#else
|
||||||
|
return map.ENTRY_SET().iterator();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
@@ -63,14 +87,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#if VALUE_PRIMITIVES
|
#if VALUE_PRIMITIVES
|
||||||
@Override
|
@Override
|
||||||
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void addToAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
addTo(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void putAll(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(m);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(m);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
@@ -101,7 +125,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void putAllIfAbsent(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
putIfAbsent(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +185,14 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
|
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) {
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m))
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m))
|
||||||
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
replace(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
|
entry.setValue(mappingFunction.APPLY_VALUE(entry.ENTRY_KEY(), entry.ENTRY_VALUE()));
|
||||||
}
|
}
|
||||||
@@ -195,7 +219,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
@@ -209,7 +233,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
VALUE_TYPE value;
|
VALUE_TYPE value;
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
@@ -246,7 +270,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
VALUE_TYPE oldValue = GET_VALUE(key);
|
VALUE_TYPE oldValue = GET_VALUE(key);
|
||||||
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = VALUE_EQUALS(oldValue, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(oldValue, entry.ENTRY_VALUE());
|
||||||
@@ -298,7 +322,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
public void forEach(BI_CONSUMER KEY_VALUE_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);iter.hasNext();) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);iter.hasNext();) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
action.accept(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
@@ -332,7 +356,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new ITERATOR KEY_GENERIC_TYPE() {
|
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
@@ -383,7 +407,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
|
return new VALUE_ITERATOR VALUE_GENERIC_TYPE() {
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(ABSTRACT_MAP.this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(ABSTRACT_MAP.this);
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return iter.hasNext();
|
return iter.hasNext();
|
||||||
@@ -423,7 +447,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(this);
|
ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(this);
|
||||||
while(iter.hasNext()) hash += iter.next().hashCode();
|
while(iter.hasNext()) hash += iter.next().hashCode();
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|||||||
+109
-32
@@ -6,8 +6,14 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.locks.StampedLock;
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Predicate;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@@ -17,13 +23,22 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
@@ -43,6 +58,7 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_BI_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_BI_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||||
@@ -54,18 +70,14 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -668,6 +680,26 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
|
long stamp = seg.readLock();
|
||||||
|
try {
|
||||||
|
int index = seg.firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, new BasicEntryKV_BRACES(seg.keys[index], seg.values[index]));
|
||||||
|
index = (int)seg.links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
seg.unlockRead(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -688,7 +720,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -698,7 +730,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(seg.keys[index], seg.values[index]);
|
entry.set(seg.keys[index], seg.values[index]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -710,7 +742,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -720,7 +752,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(seg.keys[index], seg.values[index]);
|
entry.set(seg.keys[index], seg.values[index]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -732,7 +764,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -742,7 +774,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(seg.keys[index], seg.values[index]);
|
entry.set(seg.keys[index], seg.values[index]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,7 +835,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -813,7 +845,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(seg.keys[index], seg.values[index]);
|
entry.set(seg.keys[index], seg.values[index]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -825,7 +857,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
@@ -836,7 +868,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(seg.keys[index], seg.values[index]);
|
entry.set(seg.keys[index], seg.values[index]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -977,6 +1009,26 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
|
long stamp = seg.readLock();
|
||||||
|
try {
|
||||||
|
int index = seg.firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, seg.keys[index]);
|
||||||
|
index = (int)seg.links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
seg.unlockRead(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1005,7 +1057,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(seg.keys[index])) return true;
|
if(filter.test(seg.keys[index])) return true;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1025,7 +1077,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(seg.keys[index])) return false;
|
if(filter.test(seg.keys[index])) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1097,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(!filter.TEST_VALUE(seg.keys[index])) return false;
|
if(!filter.test(seg.keys[index])) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1138,7 +1190,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(seg.keys[index])) return seg.keys[index];
|
if(filter.test(seg.keys[index])) return seg.keys[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1159,7 +1211,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(seg.keys[index])) result++;
|
if(filter.test(seg.keys[index])) result++;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1225,6 +1277,26 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
|
long stamp = seg.readLock();
|
||||||
|
try {
|
||||||
|
int index = seg.firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, seg.values[index]);
|
||||||
|
index = (int)seg.links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
seg.unlockRead(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1253,7 +1325,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return true;
|
if(filter.test(seg.values[index])) return true;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1273,7 +1345,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return false;
|
if(filter.test(seg.values[index])) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1293,7 +1365,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.VALUE_TEST_VALUE(seg.values[index])) return false;
|
if(!filter.test(seg.values[index])) return false;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1387,7 +1459,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) return seg.values[index];
|
if(filter.test(seg.values[index])) return seg.values[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1408,7 +1480,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(seg.values[index])) result++;
|
if(filter.test(seg.values[index])) result++;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1812,6 +1884,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
insert(-slot-1, key, value);
|
insert(-slot-1, key, value);
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
else if(VALUE_EQUALS(values[slot], getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE oldValue = values[slot];
|
||||||
|
values[slot] = value;
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
return values[slot];
|
return values[slot];
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -2136,14 +2213,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = findIndex(hash, key);
|
int index = findIndex(hash, key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = mappingFunction.GET_VALUE(key);
|
newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -2159,14 +2236,14 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = findIndex(hash, key);
|
int index = findIndex(hash, key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = valueProvider.VALUE_GET_KEY();
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
|
|||||||
+74
-27
@@ -3,16 +3,30 @@ package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
|||||||
import java.util.Arrays;
|
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.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Objects;
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
@@ -36,18 +50,15 @@ import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
||||||
@@ -683,6 +694,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -695,42 +718,42 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -768,21 +791,21 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
@@ -790,7 +813,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -944,6 +967,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -961,7 +996,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -973,7 +1008,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -985,7 +1020,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1043,7 +1078,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
@@ -1056,7 +1091,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1107,6 +1142,18 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, values[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1124,7 +1171,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
if(filter.test(values[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1136,7 +1183,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1148,7 +1195,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(!filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1206,7 +1253,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -1219,7 +1266,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
if(filter.test(values[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+111
-57
@@ -7,26 +7,39 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
|
||||||
#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;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
@@ -42,6 +55,7 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
@@ -52,18 +66,15 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
@@ -270,6 +281,11 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
insert(-slot-1, key, value);
|
insert(-slot-1, key, value);
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
else if(VALUE_EQUALS(values[slot], getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE oldValue = values[slot];
|
||||||
|
values[slot] = value;
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
return values[slot];
|
return values[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,14 +553,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = mappingFunction.GET_VALUE(key);
|
newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -556,14 +572,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = valueProvider.VALUE_GET_KEY();
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -604,7 +620,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||||
@@ -864,6 +880,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -875,54 +901,54 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -962,37 +988,37 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1101,6 +1127,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, keys[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1115,9 +1151,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1126,9 +1162,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1137,9 +1173,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1196,9 +1232,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i];
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1208,9 +1244,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1257,6 +1293,16 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, values[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1271,9 +1317,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true;
|
if(containsNull && filter.test(values[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return true;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1282,9 +1328,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
if(containsNull && filter.test(values[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1293,9 +1339,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
if(containsNull && !filter.test(values[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1352,9 +1398,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex];
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1364,9 +1410,9 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
if(containsNull && filter.test(values[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1415,7 +1461,8 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
int nextIndex = Integer.MIN_VALUE;
|
int nextIndex = Integer.MIN_VALUE;
|
||||||
boolean returnNull = containsNull;
|
boolean returnNull = containsNull;
|
||||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
KEY_TYPE[] wrapped = null;
|
||||||
|
int wrappedIndex = 0;
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(nextIndex == Integer.MIN_VALUE) {
|
if(nextIndex == Integer.MIN_VALUE) {
|
||||||
@@ -1427,7 +1474,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
{
|
{
|
||||||
while(true) {
|
while(true) {
|
||||||
if(--pos < 0) {
|
if(--pos < 0) {
|
||||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||||
nextIndex = -pos - 1;
|
nextIndex = -pos - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1446,7 +1493,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
returnedPos = pos;
|
returnedPos = pos;
|
||||||
if(nextIndex < 0){
|
if(nextIndex < 0){
|
||||||
lastReturned = Integer.MAX_VALUE;
|
lastReturned = Integer.MAX_VALUE;
|
||||||
int value = findIndex(wrapped.GET_KEY(nextIndex));
|
int value = findIndex(wrapped[nextIndex]);
|
||||||
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
||||||
nextIndex = Integer.MIN_VALUE;
|
nextIndex = Integer.MIN_VALUE;
|
||||||
return value;
|
return value;
|
||||||
@@ -1465,7 +1512,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||||
else {
|
else {
|
||||||
CUSTOM_HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
CUSTOM_HASH_MAP.this.remove(wrapped[-returnedPos - 1]);
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1488,13 +1535,20 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
startPos = ++startPos & mask;
|
startPos = ++startPos & mask;
|
||||||
}
|
}
|
||||||
if(startPos < last) {
|
if(startPos < last) addWrapper(keys[startPos]);
|
||||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
|
||||||
wrapped.add(keys[startPos]);
|
|
||||||
}
|
|
||||||
keys[last] = current;
|
keys[last] = current;
|
||||||
values[last] = values[startPos];
|
values[last] = values[startPos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addWrapper(KEY_TYPE value) {
|
||||||
|
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||||
|
else if(wrappedIndex >= wrapped.length) {
|
||||||
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||||
|
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||||
|
wrapped = newArray;
|
||||||
|
}
|
||||||
|
wrapped[wrappedIndex++] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+74
-27
@@ -3,16 +3,30 @@ package speiger.src.collections.PACKAGE.maps.impl.hash;
|
|||||||
import java.util.Arrays;
|
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.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Objects;
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
@@ -35,18 +49,15 @@ import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOperator;
|
||||||
@@ -687,6 +698,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -699,42 +722,42 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -772,21 +795,21 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
@@ -794,7 +817,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -943,6 +966,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -960,7 +995,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -972,7 +1007,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -984,7 +1019,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1042,7 +1077,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
@@ -1055,7 +1090,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1107,6 +1142,18 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, values[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1124,7 +1171,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
if(filter.test(values[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1136,7 +1183,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1148,7 +1195,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(!filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1206,7 +1253,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -1219,7 +1266,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
if(filter.test(values[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+110
-57
@@ -7,26 +7,39 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
|
||||||
#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;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
@@ -51,18 +64,15 @@ import speiger.src.collections.objects.functions.function.ObjectObjectUnaryOpera
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
@@ -245,6 +255,11 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
insert(-slot-1, key, value);
|
insert(-slot-1, key, value);
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
else if(VALUE_EQUALS(values[slot], getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE oldValue = values[slot];
|
||||||
|
values[slot] = value;
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
return values[slot];
|
return values[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,14 +513,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = mappingFunction.GET_VALUE(key);
|
newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -517,14 +532,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insert(-index-1, key, newValue);
|
insert(-index-1, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = valueProvider.VALUE_GET_KEY();
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -565,7 +580,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||||
@@ -824,6 +839,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -835,54 +860,54 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -922,37 +947,37 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
entry.set(keys[nullIndex], values[nullIndex]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1057,6 +1082,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, keys[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1071,9 +1106,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1082,9 +1117,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1093,9 +1128,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1152,9 +1187,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i];
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1164,9 +1199,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1213,6 +1248,16 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(values[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, values[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, values[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1227,9 +1272,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return true;
|
if(containsNull && filter.test(values[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return true;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1238,9 +1283,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
if(containsNull && filter.test(values[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1249,9 +1294,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.VALUE_TEST_VALUE(values[nullIndex])) return false;
|
if(containsNull && !filter.test(values[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1308,9 +1353,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) return values[nullIndex];
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1320,9 +1365,9 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
if(containsNull && filter.test(values[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1371,7 +1416,8 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
int nextIndex = Integer.MIN_VALUE;
|
int nextIndex = Integer.MIN_VALUE;
|
||||||
boolean returnNull = containsNull;
|
boolean returnNull = containsNull;
|
||||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
KEY_TYPE[] wrapped = null;
|
||||||
|
int wrappedIndex = 0;
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(nextIndex == Integer.MIN_VALUE) {
|
if(nextIndex == Integer.MIN_VALUE) {
|
||||||
@@ -1383,7 +1429,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
{
|
{
|
||||||
while(true) {
|
while(true) {
|
||||||
if(--pos < 0) {
|
if(--pos < 0) {
|
||||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||||
nextIndex = -pos - 1;
|
nextIndex = -pos - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1402,7 +1448,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
returnedPos = pos;
|
returnedPos = pos;
|
||||||
if(nextIndex < 0){
|
if(nextIndex < 0){
|
||||||
lastReturned = Integer.MAX_VALUE;
|
lastReturned = Integer.MAX_VALUE;
|
||||||
int value = findIndex(wrapped.GET_KEY(nextIndex));
|
int value = findIndex(wrapped[nextIndex]);
|
||||||
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
if(value < 0) throw new IllegalStateException("Entry ["+nextIndex+"] was removed during Iteration");
|
||||||
nextIndex = Integer.MIN_VALUE;
|
nextIndex = Integer.MIN_VALUE;
|
||||||
return value;
|
return value;
|
||||||
@@ -1421,7 +1467,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||||
else {
|
else {
|
||||||
HASH_MAP.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
HASH_MAP.this.remove(wrapped[-returnedPos - 1]);
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1444,13 +1490,20 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
startPos = ++startPos & mask;
|
startPos = ++startPos & mask;
|
||||||
}
|
}
|
||||||
if(startPos < last) {
|
if(startPos < last) addWrapper(keys[startPos]);
|
||||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
|
||||||
wrapped.add(keys[startPos]);
|
|
||||||
}
|
|
||||||
keys[last] = current;
|
keys[last] = current;
|
||||||
values[last] = values[startPos];
|
values[last] = values[startPos];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addWrapper(KEY_TYPE value) {
|
||||||
|
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||||
|
else if(wrappedIndex >= wrapped.length) {
|
||||||
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||||
|
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||||
|
wrapped = newArray;
|
||||||
|
}
|
||||||
|
wrapped[wrappedIndex++] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+76
-28
@@ -6,17 +6,33 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -28,25 +44,21 @@ import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
#endif
|
#endif
|
||||||
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;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
#endif
|
#endif
|
||||||
@@ -215,7 +227,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
KEY_TYPE[] keys = NEW_KEY_ARRAY(map.size());
|
KEY_TYPE[] keys = NEW_KEY_ARRAY(map.size());
|
||||||
VALUE_TYPE[] values = NEW_VALUE_ARRAY(keys.length);
|
VALUE_TYPE[] values = NEW_VALUE_ARRAY(keys.length);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(map)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(map)) {
|
||||||
keys[index] = entry.ENTRY_KEY();
|
keys[index] = entry.ENTRY_KEY();
|
||||||
values[index] = entry.ENTRY_VALUE();
|
values[index] = entry.ENTRY_VALUE();
|
||||||
index++;
|
index++;
|
||||||
@@ -659,6 +671,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -671,42 +695,42 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -744,21 +768,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
@@ -766,7 +790,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -887,6 +911,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -904,7 +940,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -916,7 +952,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -928,7 +964,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -986,7 +1022,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return EMPTY_KEY_VALUE;
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
@@ -999,7 +1035,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1048,6 +1084,18 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1){
|
||||||
|
action.accept(count++, values[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1065,7 +1113,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return true;
|
if(filter.test(values[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -1077,7 +1125,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1089,7 +1137,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(!filter.VALUE_TEST_VALUE(values[index])) return false;
|
if(!filter.test(values[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -1147,7 +1195,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) return values[index];
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -1160,7 +1208,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
if(filter.test(values[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+70
-34
@@ -6,17 +6,33 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -27,7 +43,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.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;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
@@ -42,18 +57,15 @@ import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -176,7 +188,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
*/
|
*/
|
||||||
public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
public ARRAY_MAP(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
this(map.size());
|
this(map.size());
|
||||||
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = MAPS.fastIterator(map);iter.hasNext();size++) {
|
for(ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iter = getFastIterator(map);iter.hasNext();size++) {
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
MAP.Entry KEY_VALUE_GENERIC_TYPE entry = iter.next();
|
||||||
keys[size] = entry.ENTRY_KEY();
|
keys[size] = entry.ENTRY_KEY();
|
||||||
values[size] = entry.ENTRY_VALUE();
|
values[size] = entry.ENTRY_VALUE();
|
||||||
@@ -202,6 +214,11 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
insertIndex(size++, key, value);
|
insertIndex(size++, key, value);
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
else if(VALUE_EQUALS(values[index], getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE oldValue = values[index];
|
||||||
|
values[index] = value;
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -494,14 +511,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insertIndex(size++, key, newValue);
|
insertIndex(size++, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = mappingFunction.GET_VALUE(key);
|
newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -513,14 +530,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
insertIndex(size++, key, newValue);
|
insertIndex(size++, key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = valueProvider.VALUE_GET_KEY();
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -561,7 +578,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
VALUE_TYPE newValue = index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||||
@@ -783,6 +800,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
|
action.accept(i, new BasicEntryKV_BRACES(keys[i], values[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -792,37 +817,37 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.test(entry)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.test(entry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -854,26 +879,26 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(keys[i], values[i]);
|
entry.set(keys[i], values[i]);
|
||||||
if(filter.getBoolean(entry)) result++;
|
if(filter.test(entry)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -981,11 +1006,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
for(int i = 0;i<size;action.accept(keys[i++]));
|
for(int i = 0;i<size;action.accept(keys[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;action.accept(i, keys[i++]));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<size;action.accept(input, keys[i++]));
|
for(int i = 0;i<size;action.accept(input, keys[i++]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -993,7 +1023,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(keys[i])) return true;
|
if(filter.test(keys[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1002,7 +1032,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(keys[i])) return false;
|
if(filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1011,7 +1041,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(keys[i])) return false;
|
if(!filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1059,7 +1089,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(keys[i])) return keys[i];
|
if(filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1069,7 +1099,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(keys[i])) result++;
|
if(filter.test(keys[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1115,11 +1145,17 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
for(int i = 0;i<size;action.accept(values[i++]));
|
for(int i = 0;i<size;action.accept(values[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;action.accept(i, values[i++]));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.VALUE_TEST_VALUE(values[i])) return true;
|
if(filter.test(values[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1128,7 +1164,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1137,7 +1173,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.VALUE_TEST_VALUE(values[i])) return false;
|
if(!filter.test(values[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1185,7 +1221,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.VALUE_TEST_VALUE(values[i])) return values[i];
|
if(filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1195,7 +1231,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.VALUE_TEST_VALUE(values[i])) result++;
|
if(filter.test(values[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-7
@@ -5,6 +5,10 @@ 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 java.util.function.Consumer;
|
||||||
|
#if VALUE_BOOLEAN
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#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;
|
||||||
@@ -18,8 +22,9 @@ import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
|||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#if !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
#endif
|
||||||
import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.objects.maps.interfaces.MAP;
|
import speiger.src.collections.objects.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||||
@@ -161,7 +166,14 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putIfAbsent(T key, VALUE_TYPE value) {
|
public VALUE_TYPE putIfAbsent(T key, VALUE_TYPE value) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
if(isSet(index)) return values[index];
|
if(isSet(index)) {
|
||||||
|
if(VALUE_EQUALS(values[index], getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE oldValue = values[index];
|
||||||
|
values[index] = value;
|
||||||
|
return oldValue;
|
||||||
|
}
|
||||||
|
return values[index];
|
||||||
|
}
|
||||||
set(index);
|
set(index);
|
||||||
values[index] = value;
|
values[index] = value;
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@@ -370,7 +382,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
if(!isSet(index)) {
|
if(!isSet(index)) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
set(index);
|
set(index);
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
@@ -378,7 +390,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = mappingFunction.GET_VALUE(key);
|
newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -389,7 +401,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
if(!isSet(index)) {
|
if(!isSet(index)) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
set(index);
|
set(index);
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
@@ -397,7 +409,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
}
|
}
|
||||||
VALUE_TYPE newValue = values[index];
|
VALUE_TYPE newValue = values[index];
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
newValue = valueProvider.VALUE_GET_KEY();
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
}
|
}
|
||||||
@@ -442,7 +454,7 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
T key = entry.ENTRY_KEY();
|
T key = entry.ENTRY_KEY();
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
VALUE_TYPE newValue = !isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = !isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(values[index], entry.ENTRY_VALUE());
|
||||||
|
|||||||
+106
-50
@@ -9,6 +9,14 @@ import java.util.Objects;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -16,11 +24,20 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -33,7 +50,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
#endif
|
#endif
|
||||||
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;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
@@ -48,18 +64,15 @@ import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -280,7 +293,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
int compare = 0;
|
int compare = 0;
|
||||||
Node KEY_VALUE_GENERIC_TYPE parent = tree;
|
Node KEY_VALUE_GENERIC_TYPE parent = tree;
|
||||||
while(true) {
|
while(true) {
|
||||||
if((compare = compare(key, parent.key)) == 0) return parent.value;
|
if((compare = compare(key, parent.key)) == 0) {
|
||||||
|
if(VALUE_EQUALS(parent.value, getDefaultReturnValue())) return parent.setValue(value);
|
||||||
|
return parent.value;
|
||||||
|
}
|
||||||
if(compare < 0) {
|
if(compare < 0) {
|
||||||
if(parent.left == null) break;
|
if(parent.left == null) break;
|
||||||
parent = parent.left;
|
parent = parent.left;
|
||||||
@@ -553,13 +569,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
#endif
|
#endif
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
if(entry == null) {
|
if(entry == null) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
}
|
}
|
||||||
@@ -574,13 +590,13 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
#endif
|
#endif
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
if(entry == null) {
|
if(entry == null) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
}
|
}
|
||||||
@@ -624,7 +640,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||||
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||||
@@ -1144,6 +1160,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
action.accept(entry.key);
|
action.accept(entry.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1155,7 +1179,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1163,7 +1187,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1171,7 +1195,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1216,7 +1240,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1225,7 +1249,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1832,6 +1856,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
|
action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1840,37 +1872,37 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return true;
|
if(filter.test(subEntry)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return false;
|
if(filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(!filter.getBoolean(subEntry)) return false;
|
if(!filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1902,26 +1934,26 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return subEntry;
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
if(filter.test(subEntry)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1964,6 +1996,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
action.accept(entry.value);
|
action.accept(entry.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
|
action.accept(index++, entry.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1975,7 +2015,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
if(filter.test(entry.value)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1983,7 +2023,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1991,7 +2031,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(!filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2036,7 +2076,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2045,7 +2085,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
if(filter.test(entry.value)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2312,6 +2352,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
action.accept(entry.value);
|
action.accept(entry.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
|
action.accept(index++, entry.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -2323,7 +2371,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
if(filter.test(entry.value)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2331,7 +2379,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2339,7 +2387,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(!filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2384,7 +2432,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2393,7 +2441,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
if(filter.test(entry.value)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2469,6 +2517,14 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
|
action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -2477,37 +2533,37 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return true;
|
if(filter.test(subEntry)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return false;
|
if(filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(!filter.getBoolean(subEntry)) return false;
|
if(!filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2539,26 +2595,26 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return subEntry;
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
if(filter.test(subEntry)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+105
-50
@@ -9,6 +9,13 @@ import java.util.Objects;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
|
import java.util.function.VALUE_PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -16,11 +23,20 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
||||||
|
#endif
|
||||||
|
#if !SAME_TYPE
|
||||||
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
|
#endif
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -33,7 +49,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
#endif
|
#endif
|
||||||
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;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
@@ -48,18 +63,15 @@ import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
|||||||
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT || !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
import speiger.src.collections.objects.functions.consumer.ObjectObjectConsumer;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || !VALUE_BOOLEAN
|
|
||||||
#if !VALUE_OBJECT || SAME_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.Object2BooleanFunction;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -280,7 +292,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
int compare = 0;
|
int compare = 0;
|
||||||
Node KEY_VALUE_GENERIC_TYPE parent = tree;
|
Node KEY_VALUE_GENERIC_TYPE parent = tree;
|
||||||
while(true) {
|
while(true) {
|
||||||
if((compare = compare(key, parent.key)) == 0) return parent.value;
|
if((compare = compare(key, parent.key)) == 0) {
|
||||||
|
if(VALUE_EQUALS(parent.value, getDefaultReturnValue())) return parent.setValue(value);
|
||||||
|
return parent.value;
|
||||||
|
}
|
||||||
if(compare < 0) {
|
if(compare < 0) {
|
||||||
if(parent.left == null) break;
|
if(parent.left == null) break;
|
||||||
parent = parent.left;
|
parent = parent.left;
|
||||||
@@ -556,13 +571,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
#endif
|
#endif
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
if(entry == null) {
|
if(entry == null) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||||
VALUE_TYPE newValue = mappingFunction.GET_VALUE(key);
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
}
|
}
|
||||||
@@ -577,13 +592,13 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
#endif
|
#endif
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
if(entry == null) {
|
if(entry == null) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
put(key, newValue);
|
put(key, newValue);
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(entry.value, getDefaultReturnValue())) {
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
}
|
}
|
||||||
@@ -627,7 +642,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
@Override
|
@Override
|
||||||
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public void BULK_MERGE(MAP KEY_VALUE_GENERIC_TYPE m, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : MAPS.fastIterable(m)) {
|
for(MAP.Entry KEY_VALUE_GENERIC_TYPE entry : getFastIterable(m)) {
|
||||||
KEY_TYPE key = entry.ENTRY_KEY();
|
KEY_TYPE key = entry.ENTRY_KEY();
|
||||||
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE subEntry = findNode(key);
|
||||||
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
VALUE_TYPE newValue = subEntry == null || VALUE_EQUALS(subEntry.value, getDefaultReturnValue()) ? entry.ENTRY_VALUE() : mappingFunction.APPLY_VALUE(subEntry.value, entry.ENTRY_VALUE());
|
||||||
@@ -1201,6 +1216,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
action.accept(entry.key);
|
action.accept(entry.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1212,7 +1235,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1220,7 +1243,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1228,7 +1251,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1273,7 +1296,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1282,7 +1305,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1899,6 +1922,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
|
action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1907,37 +1938,37 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return true;
|
if(filter.test(subEntry)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return false;
|
if(filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(!filter.getBoolean(subEntry)) return false;
|
if(!filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1969,26 +2000,26 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return subEntry;
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
if(filter.test(subEntry)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -2031,6 +2062,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
action.accept(entry.value);
|
action.accept(entry.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
|
action.accept(index++, entry.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -2042,7 +2081,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
if(filter.test(entry.value)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2050,7 +2089,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2058,7 +2097,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(!filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2103,7 +2142,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2112,7 +2151,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
if(filter.test(entry.value)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2379,6 +2418,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
action.accept(entry.value);
|
action.accept(entry.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(VALUE_BI_FROM_INT_CONSUMER VALUE_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
|
action.accept(index++, entry.value);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -2390,7 +2437,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAny(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return true;
|
if(filter.test(entry.value)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2398,7 +2445,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesNone(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2406,7 +2453,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public boolean matchesAll(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(!filter.VALUE_TEST_VALUE(entry.value)) return false;
|
if(!filter.test(entry.value)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2451,7 +2498,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2460,7 +2507,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
if(filter.test(entry.value)) result++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2536,6 +2583,14 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(IntObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
|
action.accept(index++, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -2544,37 +2599,37 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAny(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return true;
|
if(filter.test(subEntry)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesNone(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return false;
|
if(filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public boolean matchesAll(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(!filter.getBoolean(subEntry)) return false;
|
if(!filter.test(subEntry)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2606,26 +2661,26 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return null;
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) return subEntry;
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public int count(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
if(filter.test(subEntry)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+110
-4
@@ -10,36 +10,72 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
#if VALUE_BOOLEAN && JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN && SORTED_MAP_FEATURE
|
||||||
|
#if AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.LINKED_CUSTOM_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.customHash.CUSTOM_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.hash.LINKED_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.hash.HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.immutable.IMMUTABLE_HASH_MAP;
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
||||||
|
#endif
|
||||||
|
#if CONCURRENT_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
||||||
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if ENUM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||||
|
#endif
|
||||||
|
#if LINKED_ENUM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
#if CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
#endif
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
@@ -102,6 +138,26 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
*/
|
*/
|
||||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value);
|
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper method that allows to put int a MAP.Entry into a map.
|
||||||
|
* @param entry then Entry that should be inserted.
|
||||||
|
* @return the last present value or default return value.
|
||||||
|
*/
|
||||||
|
public default VALUE_TYPE put(Entry KEY_VALUE_GENERIC_TYPE entry) {
|
||||||
|
return put(entry.ENTRY_KEY(), entry.ENTRY_VALUE());
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Helper method that allows to put int a Map.Entry into a map.
|
||||||
|
* @param entry then Entry that should be inserted.
|
||||||
|
* @return the last present value or default return value.
|
||||||
|
*/
|
||||||
|
public default CLASS_VALUE_TYPE put(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) {
|
||||||
|
return put(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Type Specific array method to bulk add elements into a map without creating a wrapper and increasing performances
|
* Type Specific array method to bulk add elements into a map without creating a wrapper and increasing performances
|
||||||
* @param keys the keys that should be added
|
* @param keys the keys that should be added
|
||||||
@@ -384,13 +440,19 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return VALUE_TO_OBJ(replace(OBJ_TO_KEY(key), OBJ_TO_VALUE(value)));
|
return VALUE_TO_OBJ(replace(OBJ_TO_KEY(key), OBJ_TO_VALUE(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public default VALUE_TYPE APPLY(KEY_TYPE key) {
|
||||||
|
return GET_VALUE(key);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* A Type Specific get method to reduce boxing/unboxing
|
* A Type Specific get method to reduce boxing/unboxing
|
||||||
* @param key the key that is searched for
|
* @param key the key that is searched for
|
||||||
* @return the searched value or default return value
|
* @return the searched value or default return value
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key);
|
public VALUE_TYPE GET_VALUE(KEY_TYPE key);
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific getOrDefault method to reduce boxing/unboxing
|
* A Type Specific getOrDefault method to reduce boxing/unboxing
|
||||||
* @param key the key that is searched for
|
* @param key the key that is searched for
|
||||||
@@ -485,7 +547,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
*/
|
*/
|
||||||
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
public ObjectSet<Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped Map that is Synchronized
|
* Creates a Wrapped Map that is Synchronized
|
||||||
* @return a new Map that is synchronized
|
* @return a new Map that is synchronized
|
||||||
@@ -638,6 +700,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -711,6 +774,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new HASH_MAPKV_BRACES(map);
|
return new HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -784,6 +849,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keys the keys that should be inserted
|
* @param keys the keys that should be inserted
|
||||||
@@ -836,7 +903,9 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
return new IMMUTABLE_HASH_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
#if ENUM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keyType the EnumClass that should be used
|
* @param keyType the EnumClass that should be used
|
||||||
@@ -904,6 +973,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ENUM_MAPKV_BRACES(map);
|
return new ENUM_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_ENUM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param keyType the EnumClass that should be used
|
* @param keyType the EnumClass that should be used
|
||||||
@@ -970,7 +1041,10 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
|
public GENERIC_KEY_ENUM_VALUE_BRACES LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE linkedEnumMap(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
return new LINKED_ENUM_MAPKV_BRACES(map);
|
return new LINKED_ENUM_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param strategy the Hash Controller
|
* @param strategy the Hash Controller
|
||||||
@@ -1050,6 +1124,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
return new CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @param strategy the Hash Controller
|
* @param strategy the Hash Controller
|
||||||
@@ -1129,6 +1205,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
return new LINKED_CUSTOM_HASH_MAPKV_BRACES(map, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1202,7 +1280,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ARRAY_MAPKV_BRACES(map);
|
return new ARRAY_MAPKV_BRACES(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1280,6 +1359,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new RB_TREE_MAPKV_BRACES(map, comp);
|
return new RB_TREE_MAPKV_BRACES(map, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function to unify code
|
* Helper function to unify code
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1356,6 +1437,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
public GENERIC_KEY_VALUE_BRACES AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(Map<? extends CLASS_TYPE, ? extends CLASS_VALUE_TYPE> map, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
return new AVL_TREE_MAPKV_BRACES(map, comp);
|
return new AVL_TREE_MAPKV_BRACES(map, comp);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1434,7 +1516,11 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
|
public BuilderCache KEY_VALUE_GENERIC_TYPE putAll(MAP KEY_VALUE_GENERIC_TYPE map) {
|
||||||
|
#if MAPS_FEATURE
|
||||||
return putAll(MAPS.fastIterable(map));
|
return putAll(MAPS.fastIterable(map));
|
||||||
|
#else
|
||||||
|
return putAll(map.ENTRY_SET());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1463,11 +1549,14 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if MAP_FEATURE || LINKED_MAP_FEATURE || CUSTOM_MAP_FEATURE || LINKED_CUSTOM_MAP_FEATURE || AVL_TREE_MAP_FEATURE || RB_TREE_MAP_FEATURE || CONCURRENT_MAP_FEATURE
|
||||||
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
|
private <E extends MAP KEY_VALUE_GENERIC_TYPE> E putElements(E e){
|
||||||
e.putAll(keys, values, 0, size);
|
e.putAll(keys, values, 0, size);
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Hash Map
|
* Builds the Keys and Values into a Hash Map
|
||||||
* @return a HASH_MAP
|
* @return a HASH_MAP
|
||||||
@@ -1476,6 +1565,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new HASH_MAPKV_BRACES(size));
|
return putElements(new HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Linked Hash Map
|
* Builds the Keys and Values into a Linked Hash Map
|
||||||
* @return a LINKED_HASH_MAP
|
* @return a LINKED_HASH_MAP
|
||||||
@@ -1484,6 +1575,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
|
return putElements(new LINKED_HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if IMMUTABLE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Immutable Hash Map
|
* Builds the Keys and Values into a Immutable Hash Map
|
||||||
* @return a IMMUTABLE_HASH_MAP
|
* @return a IMMUTABLE_HASH_MAP
|
||||||
@@ -1492,6 +1585,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
|
return new IMMUTABLE_HASH_MAPKV_BRACES(Arrays.copyOf(keys, size), Arrays.copyOf(values, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Custom Hash Map
|
* Builds the Keys and Values into a Custom Hash Map
|
||||||
* @param strategy the that controls the keys and values
|
* @param strategy the that controls the keys and values
|
||||||
@@ -1501,6 +1596,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
return putElements(new CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if LINKED_CUSTOM_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Linked Custom Hash Map
|
* Builds the Keys and Values into a Linked Custom Hash Map
|
||||||
* @param strategy the that controls the keys and values
|
* @param strategy the that controls the keys and values
|
||||||
@@ -1510,6 +1607,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
return putElements(new LINKED_CUSTOM_HASH_MAPKV_BRACES(size, strategy));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if CONCURRENT_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Concurrent Hash Map
|
* Builds the Keys and Values into a Concurrent Hash Map
|
||||||
* @return a CONCURRENT_HASH_MAP
|
* @return a CONCURRENT_HASH_MAP
|
||||||
@@ -1518,6 +1617,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
return putElements(new CONCURRENT_HASH_MAPKV_BRACES(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a Array Map
|
* Builds the Keys and Values into a Array Map
|
||||||
* @return a ARRAY_MAP
|
* @return a ARRAY_MAP
|
||||||
@@ -1526,6 +1627,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return new ARRAY_MAPKV_BRACES(keys, values, size);
|
return new ARRAY_MAPKV_BRACES(keys, values, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if RB_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a RedBlack TreeMap
|
* Builds the Keys and Values into a RedBlack TreeMap
|
||||||
* @return a RB_TREE_MAP
|
* @return a RB_TREE_MAP
|
||||||
@@ -1543,6 +1646,8 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
return putElements(new RB_TREE_MAPKV_BRACES(comp));
|
return putElements(new RB_TREE_MAPKV_BRACES(comp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if AVL_TREE_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Builds the Keys and Values into a AVL TreeMap
|
* Builds the Keys and Values into a AVL TreeMap
|
||||||
* @return a AVL_TREE_MAP
|
* @return a AVL_TREE_MAP
|
||||||
@@ -1559,6 +1664,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
|
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE avlTreeMap(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
|
return putElements(new AVL_TREE_MAPKV_BRACES(comp));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+5
@@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.maps.interfaces;
|
|||||||
|
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Navigable Map interface with a couple helper methods
|
* A Type Specific Navigable Map interface with a couple helper methods
|
||||||
@@ -37,6 +39,8 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||||||
/** @return a Type Specific Navigable Key Set */
|
/** @return a Type Specific Navigable Key Set */
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
public NAVIGABLE_SET KEY_GENERIC_TYPE keySet();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped NavigableMap that is Synchronized
|
* Creates a Wrapped NavigableMap that is Synchronized
|
||||||
* @return a new NavigableMap that is synchronized
|
* @return a new NavigableMap that is synchronized
|
||||||
@@ -59,6 +63,7 @@ public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VAL
|
|||||||
*/
|
*/
|
||||||
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||||
|
|||||||
+4
@@ -1,6 +1,8 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
#endif
|
#endif
|
||||||
@@ -102,6 +104,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
* @return a new SortedMap that is synchronized
|
* @return a new SortedMap that is synchronized
|
||||||
@@ -127,6 +130,7 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
|
|||||||
+4
@@ -10,7 +10,9 @@ import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
import speiger.src.collections.objects.sets.ObjectSortedSet;
|
||||||
#endif
|
#endif
|
||||||
@@ -37,6 +39,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values();
|
||||||
|
|
||||||
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
* @return a new SortedMap that is synchronized
|
* @return a new SortedMap that is synchronized
|
||||||
@@ -59,6 +62,7 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
*/
|
*/
|
||||||
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default SORTED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific SubMap method to reduce boxing/unboxing
|
* A Type Specific SubMap method to reduce boxing/unboxing
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package speiger.src.collections.PACKAGE.misc.pairs;
|
package speiger.src.collections.PACKAGE.misc.pairs;
|
||||||
|
|
||||||
|
#if IMMUTABLE_PAIR
|
||||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.IMMUTABLE_PAIR;
|
import speiger.src.collections.PACKAGE.misc.pairs.impl.IMMUTABLE_PAIR;
|
||||||
|
#endif
|
||||||
|
#if MUTABLE_PAIR
|
||||||
import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key Value Pair Interface that allows to reduce boxing/unboxing.
|
* Key Value Pair Interface that allows to reduce boxing/unboxing.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -9,6 +14,7 @@ import speiger.src.collections.PACKAGE.misc.pairs.impl.MUTABLE_PAIR;
|
|||||||
*/
|
*/
|
||||||
public interface PAIR KEY_VALUE_GENERIC_TYPE
|
public interface PAIR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
|
#if IMMUTABLE_PAIR
|
||||||
/**
|
/**
|
||||||
* Empty Reference for Immutable Pairs
|
* Empty Reference for Immutable Pairs
|
||||||
*/
|
*/
|
||||||
@@ -68,6 +74,8 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||||||
return new IMMUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
return new IMMUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if MUTABLE_PAIR
|
||||||
/**
|
/**
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
@@ -118,6 +126,7 @@ public interface PAIR KEY_VALUE_GENERIC_TYPE
|
|||||||
return new MUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
return new MUTABLE_PAIRKV_BRACES(pair.ENTRY_KEY(), pair.ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Sets the Key of the Pair.
|
* Sets the Key of the Pair.
|
||||||
* @param key the key that should be set.
|
* @param key the key that should be set.
|
||||||
|
|||||||
+20
-5
@@ -8,14 +8,20 @@ import java.util.function.BiFunction;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
@@ -257,6 +263,15 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(first == last) return;
|
||||||
|
for(int i = 0,m=size();i<m;i++)
|
||||||
|
action.accept(i, array[(first + i) % array.length]);
|
||||||
|
clearAndTrim(0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -270,7 +285,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return true;
|
if(filter.test(array[(first + i) % array.length])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -279,7 +294,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
if(filter.test(array[(first + i) % array.length])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -288,7 +303,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(!filter.TEST_VALUE(array[(first + i) % array.length])) return false;
|
if(!filter.test(array[(first + i) % array.length])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -298,7 +313,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
int index = (first + i) % array.length;
|
int index = (first + i) % array.length;
|
||||||
if(filter.TEST_VALUE(array[index])) {
|
if(filter.test(array[index])) {
|
||||||
KEY_TYPE data = array[index];
|
KEY_TYPE data = array[index];
|
||||||
removeIndex(index);
|
removeIndex(index);
|
||||||
return data;
|
return data;
|
||||||
@@ -351,7 +366,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) result++;
|
if(filter.test(array[(first + i) % array.length])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-5
@@ -8,6 +8,9 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
@@ -15,8 +18,11 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
@@ -209,6 +215,13 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE first() {
|
||||||
|
if(isEmpty()) throw new NoSuchElementException();
|
||||||
|
if(firstIndex == -1) findFirstIndex();
|
||||||
|
return array[firstIndex];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
@@ -263,6 +276,12 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -273,7 +292,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) return true;
|
if(filter.test(array[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -282,7 +301,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) return false;
|
if(filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -291,7 +310,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(array[i])) return false;
|
if(!filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -339,7 +358,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return data;
|
return data;
|
||||||
@@ -353,7 +372,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
if(filter.test(array[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-5
@@ -8,6 +8,9 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
@@ -15,8 +18,11 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
@@ -250,6 +256,12 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -260,7 +272,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) return true;
|
if(filter.test(array[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -269,7 +281,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) return false;
|
if(filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -278,7 +290,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(array[i])) return false;
|
if(!filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -326,7 +338,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return data;
|
return data;
|
||||||
@@ -340,7 +352,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
if(filter.test(array[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -6,7 +6,9 @@ import java.util.Iterator;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if QUEUES_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
||||||
@@ -81,6 +83,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
*/
|
*/
|
||||||
public default KEY_TYPE last() { return peek(size()-1); }
|
public default KEY_TYPE last() { return peek(size()-1); }
|
||||||
|
|
||||||
|
#if QUEUES_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped PriorityDequeue that is Synchronized
|
* Creates a Wrapped PriorityDequeue that is Synchronized
|
||||||
* @return a new PriorityDequeue that is synchronized
|
* @return a new PriorityDequeue that is synchronized
|
||||||
@@ -96,6 +99,7 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
*/
|
*/
|
||||||
public default PRIORITY_DEQUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
public default PRIORITY_DEQUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
||||||
}
|
}
|
||||||
+8
-5
@@ -4,15 +4,16 @@ package speiger.src.collections.PACKAGE.queues;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
import speiger.src.collections.ints.functions.function.Int2ObjectFunction;
|
|
||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if QUEUES_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
import speiger.src.collections.PACKAGE.utils.PRIORITY_QUEUES;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,8 +148,9 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
* @return draining iterator of the PriorityQueue
|
* @return draining iterator of the PriorityQueue
|
||||||
*/
|
*/
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if QUEUES_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped PriorityQueue that is Synchronized
|
* Creates a Wrapped PriorityQueue that is Synchronized
|
||||||
* @return a new PriorityQueue that is synchronized
|
* @return a new PriorityQueue that is synchronized
|
||||||
@@ -164,6 +166,7 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
*/
|
*/
|
||||||
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
public default PRIORITY_QUEUE KEY_GENERIC_TYPE synchronizeQueue(Object mutex) { return PRIORITY_QUEUES.synchronize(this, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A method to drop the contents of the Queue without clearing the queue
|
* A method to drop the contents of the Queue without clearing the queue
|
||||||
* @Type(E)
|
* @Type(E)
|
||||||
@@ -185,8 +188,8 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
* @return an array containing all of the elements in this collection
|
* @return an array containing all of the elements in this collection
|
||||||
* @see Collection#toArray(Object[])
|
* @see Collection#toArray(Object[])
|
||||||
*/
|
*/
|
||||||
default KEY_TYPE[] TO_ARRAY(Int2ObjectFunction<KEY_TYPE[]> action) {
|
default <E> E[] TO_ARRAY(IntFunction<E[]> action) {
|
||||||
return TO_ARRAY(action.get(size()));
|
return TO_ARRAY(action.apply(size()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+35
-10
@@ -10,13 +10,20 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
@@ -353,6 +360,15 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -364,7 +380,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -373,7 +389,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -382,7 +398,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -391,7 +407,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -440,7 +456,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1192,6 +1208,15 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1203,7 +1228,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1212,7 +1237,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1221,7 +1246,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1269,7 +1294,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1279,7 +1304,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,15 +9,21 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if PRIMITIVES
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if PRIMITIVES && !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -391,6 +397,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
for(int i = 0;i<size;action.accept(data[i++]));
|
for(int i = 0;i<size;action.accept(data[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;action.accept(i, data[i++]));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -402,7 +414,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return true;
|
if(filter.test(data[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -411,7 +423,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return false;
|
if(filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -420,7 +432,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(!filter.TEST_VALUE(data[i])) return false;
|
if(!filter.test(data[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -429,7 +441,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) return data[i];
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -478,7 +490,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
if(filter.test(data[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -539,6 +551,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public Object[] toArray() {
|
public Object[] toArray() {
|
||||||
|
if(isEmpty()) return ObjectArrays.EMPTY_ARRAY;
|
||||||
Object[] obj = new Object[size()];
|
Object[] obj = new Object[size()];
|
||||||
for(int i = 0;i<size();i++)
|
for(int i = 0;i<size();i++)
|
||||||
obj[i] = KEY_TO_OBJ(data[i]);
|
obj[i] = KEY_TO_OBJ(data[i]);
|
||||||
|
|||||||
+22
-5
@@ -9,6 +9,9 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
@@ -16,8 +19,11 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
@@ -323,6 +329,17 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -338,7 +355,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -349,7 +366,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -360,7 +377,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -415,7 +432,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -427,7 +444,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+22
-5
@@ -9,6 +9,9 @@ import java.util.Objects;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -20,8 +23,11 @@ import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
@@ -532,6 +538,17 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -547,7 +564,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -558,7 +575,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -569,7 +586,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -624,7 +641,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -636,7 +653,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+22
-5
@@ -9,6 +9,9 @@ import java.util.Objects;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -18,8 +21,11 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -387,6 +393,17 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int count = 0;
|
||||||
|
int index = firstIndex;
|
||||||
|
while(index != -1) {
|
||||||
|
action.accept(count++, keys[index]);
|
||||||
|
index = (int)links[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -402,7 +419,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.test(keys[index])) return true;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -413,7 +430,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -424,7 +441,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.test(keys[index])) return false;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -479,7 +496,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
@@ -491,7 +508,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
if(filter.test(keys[index])) result++;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
+3
-1
@@ -4,7 +4,9 @@ import java.util.NavigableSet;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +121,7 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped NavigableSet that is Synchronized
|
* Creates a Wrapped NavigableSet that is Synchronized
|
||||||
* @return a new NavigableSet that is synchronized
|
* @return a new NavigableSet that is synchronized
|
||||||
|
|||||||
+43
-20
@@ -10,17 +10,21 @@ import java.util.Objects;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
|
||||||
@@ -503,6 +507,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex]);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
@@ -510,6 +515,16 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, keys[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(index++, keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -524,9 +539,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return true;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -535,9 +550,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -546,9 +561,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.TEST_VALUE(keys[i])) return false;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && !filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -605,9 +620,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) return keys[i];
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -617,9 +632,9 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -630,7 +645,8 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
int nextIndex = Integer.MIN_VALUE;
|
int nextIndex = Integer.MIN_VALUE;
|
||||||
boolean returnNull = containsNull;
|
boolean returnNull = containsNull;
|
||||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
KEY_TYPE[] wrapped = null;
|
||||||
|
int wrappedIndex = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -642,7 +658,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
else {
|
else {
|
||||||
while(true) {
|
while(true) {
|
||||||
if(--pos < 0) {
|
if(--pos < 0) {
|
||||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||||
nextIndex = -pos - 1;
|
nextIndex = -pos - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -662,7 +678,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
returnedPos = pos;
|
returnedPos = pos;
|
||||||
if(nextIndex < 0){
|
if(nextIndex < 0){
|
||||||
lastReturned = Integer.MAX_VALUE;
|
lastReturned = Integer.MAX_VALUE;
|
||||||
KEY_TYPE value = wrapped.GET_KEY(nextIndex);
|
KEY_TYPE value = wrapped[nextIndex];
|
||||||
nextIndex = Integer.MIN_VALUE;
|
nextIndex = Integer.MIN_VALUE;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -680,7 +696,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||||
else {
|
else {
|
||||||
CUSTOM_HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
CUSTOM_HASH_SET.this.remove(wrapped[-returnedPos - 1]);
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -702,12 +718,19 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
startPos = ++startPos & mask;
|
startPos = ++startPos & mask;
|
||||||
}
|
}
|
||||||
if(startPos < last) {
|
if(startPos < last) addWrapper(keys[startPos]);
|
||||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
|
||||||
wrapped.add(keys[startPos]);
|
|
||||||
}
|
|
||||||
keys[last] = current;
|
keys[last] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addWrapper(KEY_TYPE value) {
|
||||||
|
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||||
|
else if(wrappedIndex >= wrapped.length) {
|
||||||
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||||
|
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||||
|
wrapped = newArray;
|
||||||
|
}
|
||||||
|
wrapped[wrappedIndex++] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+42
-20
@@ -10,17 +10,21 @@ import java.util.Objects;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
@@ -373,6 +377,16 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(0, keys[nullIndex]);
|
||||||
|
for(int i = nullIndex-1, index = containsNull ? 1 : 0;i>=0;i--) {
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(index++, keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -387,9 +401,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return false;
|
if(size() <= 0) return false;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return true;
|
if(containsNull && filter.test(keys[nullIndex])) return true;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return true;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -398,9 +412,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -409,9 +423,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return true;
|
if(size() <= 0) return true;
|
||||||
if(containsNull && !filter.TEST_VALUE(keys[nullIndex])) return false;
|
if(containsNull && !filter.test(keys[nullIndex])) return false;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.TEST_VALUE(keys[i])) return false;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && !filter.test(keys[i])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -468,9 +482,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return EMPTY_VALUE;
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) return keys[nullIndex];
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) return keys[i];
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -480,9 +494,9 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return 0;
|
if(size() <= 0) return 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
if(containsNull && filter.test(keys[nullIndex])) result++;
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -597,7 +611,8 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
int nextIndex = Integer.MIN_VALUE;
|
int nextIndex = Integer.MIN_VALUE;
|
||||||
boolean returnNull = containsNull;
|
boolean returnNull = containsNull;
|
||||||
LIST KEY_GENERIC_TYPE wrapped = null;
|
KEY_TYPE[] wrapped = null;
|
||||||
|
int wrappedIndex = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
@@ -610,7 +625,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
{
|
{
|
||||||
while(true) {
|
while(true) {
|
||||||
if(--pos < 0) {
|
if(--pos < 0) {
|
||||||
if(wrapped == null || wrapped.size() <= -pos - 1) break;
|
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||||
nextIndex = -pos - 1;
|
nextIndex = -pos - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -630,7 +645,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
returnedPos = pos;
|
returnedPos = pos;
|
||||||
if(nextIndex < 0){
|
if(nextIndex < 0){
|
||||||
lastReturned = Integer.MAX_VALUE;
|
lastReturned = Integer.MAX_VALUE;
|
||||||
KEY_TYPE value = wrapped.GET_KEY(nextIndex);
|
KEY_TYPE value = wrapped[nextIndex];
|
||||||
nextIndex = Integer.MIN_VALUE;
|
nextIndex = Integer.MIN_VALUE;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@@ -648,7 +663,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
}
|
}
|
||||||
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||||
else {
|
else {
|
||||||
HASH_SET.this.remove(wrapped.GET_KEY(-returnedPos - 1));
|
HASH_SET.this.remove(wrapped[-returnedPos - 1]);
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -670,12 +685,19 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
startPos = ++startPos & mask;
|
startPos = ++startPos & mask;
|
||||||
}
|
}
|
||||||
if(startPos < last) {
|
if(startPos < last) addWrapper(keys[startPos]);
|
||||||
if(wrapped == null) wrapped = new ARRAY_LISTBRACES(2);
|
|
||||||
wrapped.add(keys[startPos]);
|
|
||||||
}
|
|
||||||
keys[last] = current;
|
keys[last] = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addWrapper(KEY_TYPE value) {
|
||||||
|
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||||
|
else if(wrappedIndex >= wrapped.length) {
|
||||||
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||||
|
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||||
|
wrapped = newArray;
|
||||||
|
}
|
||||||
|
wrapped[wrappedIndex++] = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,9 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +89,7 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
public KEY_TYPE POLL_LAST_KEY();
|
public KEY_TYPE POLL_LAST_KEY();
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped OrderedSet that is Synchronized
|
* Creates a Wrapped OrderedSet that is Synchronized
|
||||||
* @return a new OrderedSet that is synchronized
|
* @return a new OrderedSet that is synchronized
|
||||||
|
|||||||
+34
-10
@@ -10,13 +10,20 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
@@ -353,6 +360,14 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -364,7 +379,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -373,7 +388,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -382,7 +397,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -430,7 +445,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -440,7 +455,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1253,6 +1268,15 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
|
action.accept(index++, entry.key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1264,7 +1288,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return true;
|
if(filter.test(entry.key)) return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1273,7 +1297,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return false;
|
if(filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1282,7 +1306,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(!filter.TEST_VALUE(entry.key)) return false;
|
if(!filter.test(entry.key)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1330,7 +1354,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
@@ -1340,7 +1364,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int result = 0;
|
int result = 0;
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
if(filter.test(entry.key)) result++;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import java.util.Set;
|
|||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
@@ -64,7 +64,7 @@ public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GE
|
|||||||
public KEY_TYPE addOrGet(KEY_TYPE o);
|
public KEY_TYPE addOrGet(KEY_TYPE o);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped Set that is Synchronized
|
* Creates a Wrapped Set that is Synchronized
|
||||||
* @return a new Set that is synchronized
|
* @return a new Set that is synchronized
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import java.util.Comparator;
|
|||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,7 +43,7 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
|||||||
*/
|
*/
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedSet that is Synchronized
|
* Creates a Wrapped SortedSet that is Synchronized
|
||||||
* @return a new SortedSet that is synchronized
|
* @return a new SortedSet that is synchronized
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
#if JAVA_VERSION>=17
|
||||||
|
import java.util.random.RANDOM;
|
||||||
|
#else
|
||||||
|
import java.util.RANDOM;
|
||||||
|
#endif
|
||||||
import java.util.concurrent.RecursiveAction;
|
import java.util.concurrent.RecursiveAction;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#else
|
#else
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,10 +137,39 @@ public class ARRAYS
|
|||||||
* @return array with all requested elements of the iterator
|
* @return array with all requested elements of the iterator
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
||||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
|
||||||
ITERATORS.pour(iter, list, max);
|
ITERATORS.pour(iter, list, max);
|
||||||
return list.TO_ARRAY(NEW_KEY_ARRAY(list.size()));
|
return list.TO_ARRAY(NEW_KEY_ARRAY(list.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Helper function that pours all elements of a iterator into a Array
|
||||||
|
* @param iter the elements that should be gathered.
|
||||||
|
* @ArrayType(T)
|
||||||
|
* @param action that is creating the Array to be poured into
|
||||||
|
* @return array with all elements of the iterator
|
||||||
|
*/
|
||||||
|
public static <T, E> E[] pour(ITERATOR KEY_GENERIC_TYPE iter, IntFunction<E[]> action) {
|
||||||
|
return pour(iter, Integer.MAX_VALUE, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that pours all elements of a iterator into a Array
|
||||||
|
* @param iter the elements that should be gathered.
|
||||||
|
* @param max how many elements should be added
|
||||||
|
* @param action that is creating the Array to be poured into
|
||||||
|
* @ArrayType(T)
|
||||||
|
* @return array with all requested elements of the iterator
|
||||||
|
*/
|
||||||
|
public static <T, E> E[] pour(ITERATOR KEY_GENERIC_TYPE iter, int max, IntFunction<E[]> action) {
|
||||||
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE list = COLLECTIONS.wrapper();
|
||||||
|
ITERATORS.pour(iter, list, max);
|
||||||
|
return list.TO_ARRAY(action.apply(list.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to validate if the current value is the lowest value in the heap
|
* Method to validate if the current value is the lowest value in the heap
|
||||||
* @param data the current heap.
|
* @param data the current heap.
|
||||||
@@ -262,7 +296,7 @@ public class ARRAYS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return the provided sorted array
|
* @return the provided sorted array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, Random random) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, RANDOM random) {
|
||||||
for(int i = array.length-1; i>=0;i--) {
|
for(int i = array.length-1; i>=0;i--) {
|
||||||
int p = random.nextInt(i + 1);
|
int p = random.nextInt(i + 1);
|
||||||
KEY_TYPE t = array[i];
|
KEY_TYPE t = array[i];
|
||||||
@@ -280,7 +314,7 @@ public class ARRAYS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return the provided sorted array
|
* @return the provided sorted array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, int length, Random random) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, int length, RANDOM random) {
|
||||||
return shuffle(array, 0, length, random);
|
return shuffle(array, 0, length, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,7 +327,7 @@ public class ARRAYS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return the provided sorted array
|
* @return the provided sorted array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, int offset, int length, Random random) {
|
public static GENERIC_KEY_BRACES KEY_TYPE[] shuffle(KEY_TYPE[] array, int offset, int length, RANDOM random) {
|
||||||
for(int i = length-1; i>=0;i--) {
|
for(int i = length-1; i>=0;i--) {
|
||||||
int p = offset + random.nextInt(i + 1);
|
int p = offset + random.nextInt(i + 1);
|
||||||
KEY_TYPE t = array[offset+i];
|
KEY_TYPE t = array[offset+i];
|
||||||
|
|||||||
+161
-31
@@ -12,35 +12,65 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#else
|
#else
|
||||||
|
import java.util.function.IntFunction;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.TASK;
|
import speiger.src.collections.PACKAGE.functions.TASK;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
#else if LINKED_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if !TYPE_BOOLEAN && OBJECT_ASYNC_MODULE
|
||||||
|
#if SET_MODULE
|
||||||
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if LINKED_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.LINKED_HASH_SET;
|
||||||
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.LINKED_CUSTOM_HASH_SET;
|
||||||
|
#else if SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
||||||
|
#else if CUSTOM_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.CUSTOM_HASH_SET;
|
||||||
|
#else if RB_TREE_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.RB_TREE_SET;
|
||||||
|
#else if AVL_TREE_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.AVL_TREE_SET;
|
||||||
|
#else if ARRAY_SET_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT
|
#if !TYPE_INT && INT_ASYNC_MODULE
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -113,6 +143,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
return new ASYNC_BUILDERBRACES(ITERABLES.wrap(iterable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
* Helper function that automatically wraps a array into a AsyncBuilder since it forces this collections Iterable.
|
||||||
* @param values that should be wrapped
|
* @param values that should be wrapped
|
||||||
@@ -123,6 +154,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
return new ASYNC_BUILDERBRACES(ARRAY_LIST.wrap(values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Maps the elements to something else
|
* Maps the elements to something else
|
||||||
* @param mapper the mapping function
|
* @param mapper the mapping function
|
||||||
@@ -154,6 +187,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Filters out the unwanted elements out of the Iterable
|
* Filters out the unwanted elements out of the Iterable
|
||||||
* @param filter the elements that should be kept
|
* @param filter the elements that should be kept
|
||||||
@@ -173,6 +207,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
|
||||||
@@ -204,6 +248,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Iterates over the Iterable with a desired action
|
* Iterates over the Iterable with a desired action
|
||||||
* @param action that should be applied
|
* @param action that should be applied
|
||||||
@@ -213,6 +258,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action));
|
return new ObjectAsyncBuilder<>(new ForEachTask<>(iterable.iterator(), action));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Reduces the elements inside of the Iterable down to one element
|
* Reduces the elements inside of the Iterable down to one element
|
||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
@@ -247,23 +293,66 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* Pours all elements of the Iterable down into a Array.
|
||||||
|
* @param action creates the final array that should be copied into.
|
||||||
|
* @return a new Builder with the ToArray function applied
|
||||||
|
*/
|
||||||
|
public ObjectAsyncBuilder<KEY_TYPE[]> TO_ARRAY(IntFunction<KEY_TYPE[]> action) {
|
||||||
|
return new ObjectAsyncBuilder<>(new ArrayTaskBRACES(iterable, action));
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/**
|
||||||
|
* Pours all elements of the Iterable down into a Array.
|
||||||
|
* @return a new Builder with the ToArray function applied
|
||||||
|
*/
|
||||||
|
public ObjectAsyncBuilder<KEY_TYPE[]> TO_ARRAY() {
|
||||||
|
return new ObjectAsyncBuilder<>(new ArrayTaskBRACES(iterable));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
/**
|
/**
|
||||||
* Pours all elements into a List that can be later
|
* Pours all elements into a List that can be later
|
||||||
* @return a new Builder with the pour function applied
|
* @return a new Builder with the pour function applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<LIST KEY_GENERIC_TYPE> pourAsList() {
|
public ObjectAsyncBuilder<LIST KEY_GENERIC_TYPE> pourAsList() {
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
return pour(new ARRAY_LISTBRACES());
|
return pour(new ARRAY_LISTBRACES());
|
||||||
|
#else
|
||||||
|
return pour(new LINKED_LISTBRACES());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#endif
|
||||||
|
#if !TYPE_BOOLEAN && SET_MODULE
|
||||||
|
#if LINKED_SET_FEATURE || LINKED_CUSTOM_SET_FEATURE || SET_FEATURE || CUSTOM_SET_FEATURE || RB_TREE_SET_FEATURE || AVL_TREE_SET_FEATURE || ARRAY_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Pours all elements into a Set that can be later
|
* Pours all elements into a Set that can be later
|
||||||
* @return a new Builder with the pour function applied
|
* @return a new Builder with the pour function applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
|
public ObjectAsyncBuilder<SET KEY_GENERIC_TYPE> pourAsSet() {
|
||||||
|
#if LINKED_SET_FEATURE
|
||||||
return pour(new LINKED_HASH_SETBRACES());
|
return pour(new LINKED_HASH_SETBRACES());
|
||||||
|
#else if LINKED_CUSTOM_SET_FEATURE
|
||||||
|
return pour(new LINKED_CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
|
#else if SET_FEATURE
|
||||||
|
return pour(new HASH_SETBRACES());
|
||||||
|
#else if CUSTOM_SET_FEATURE
|
||||||
|
return pour(new CUSTOM_HASH_SETBRACES(STRATEGY.normalStrategy()));
|
||||||
|
#else if RB_TREE_SET_FEATURE
|
||||||
|
return pour(new RB_Tree_SETBRACES());
|
||||||
|
#else if AVL_TREE_SET_FEATURE
|
||||||
|
return pour(new AVL_Tree_SETBRACES());
|
||||||
|
#else if ARRAY_SET_FEATURE
|
||||||
|
return pour(new ARRAY_SETBRACES());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Pours all elements into a collection that can be later
|
* Pours all elements into a collection that can be later
|
||||||
@@ -275,6 +364,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection));
|
return new ObjectAsyncBuilder<>(new CollectTask<>(iterable.iterator(), collection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if BOOLEAN_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Searches through the elements of the Iterable to find if the desired element is present.
|
* Searches through the elements of the Iterable to find if the desired element is present.
|
||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
@@ -302,6 +393,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2));
|
return new BooleanAsyncBuilder(new MatchTaskBRACES(iterable.iterator(), filter, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Searches through the elements of the Iterable to find if the desired element.
|
* Searches through the elements of the Iterable to find if the desired element.
|
||||||
* If not present it will return the default value of the type
|
* If not present it will return the default value of the type
|
||||||
@@ -313,6 +405,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_ASYNC_MODULE
|
||||||
/**
|
/**
|
||||||
* Counts all desired elements inside the Iterable
|
* Counts all desired elements inside the Iterable
|
||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
@@ -322,6 +415,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter));
|
return new IntAsyncBuilder(new CountTaskBRACES(iterable.iterator(), filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Optional way to add a custom executor that runs this offthread task.
|
* Optional way to add a custom executor that runs this offthread task.
|
||||||
* Can only be set after the action was decided on.
|
* Can only be set after the action was decided on.
|
||||||
@@ -502,6 +596,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if BOOLEAN_ASYNC_MODULE
|
||||||
private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask
|
private static class MatchTask KEY_GENERIC_TYPE extends BaseBooleanTask
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -520,11 +615,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case 0:
|
case 0:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(true);
|
setResult(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -532,11 +623,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(false);
|
setResult(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -544,11 +631,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
#if TYPE_OBJECT
|
if(!filter.test(iter.NEXT())) {
|
||||||
if(!filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(!filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(false);
|
setResult(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -570,6 +653,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -584,11 +668,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
protected boolean execute() throws Exception {
|
protected boolean execute() throws Exception {
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
#if TYPE_OBJECT
|
if(filter.test(iter.NEXT())) {
|
||||||
if(filter.getBoolean(iter.NEXT())) {
|
|
||||||
#else
|
|
||||||
if(filter.GET_VALUE(iter.NEXT())) {
|
|
||||||
#endif
|
|
||||||
setResult(entry);
|
setResult(entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -604,6 +684,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if INT_ASYNC_MODULE
|
||||||
private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask
|
private static class CountTask KEY_GENERIC_TYPE extends BaseIntTask
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -618,7 +699,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
protected boolean execute() throws Exception {
|
protected boolean execute() throws Exception {
|
||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) {
|
if(filter.test(iter.NEXT())) {
|
||||||
counted++;
|
counted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -638,6 +719,8 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if OBJECT_ASYNC_MODULE
|
||||||
private static class CollectTask KSS_GENERIC_TYPE<V, T extends COLLECTION KEY_SPECIAL_GENERIC_TYPE<V>> extends BaseObjectTask<T>
|
private static class CollectTask KSS_GENERIC_TYPE<V, T extends COLLECTION KEY_SPECIAL_GENERIC_TYPE<V>> extends BaseObjectTask<T>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_SPECIAL_GENERIC_TYPE<V> iter;
|
ITERATOR KEY_SPECIAL_GENERIC_TYPE<V> iter;
|
||||||
@@ -668,6 +751,52 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class ArrayTask KEY_GENERIC_TYPE extends BaseObjectTask<KEY_TYPE[]>
|
||||||
|
{
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
IntFunction<KEY_TYPE[]> builder;
|
||||||
|
|
||||||
|
public ArrayTask(ITERABLE KEY_GENERIC_TYPE iterable, IntFunction<KEY_TYPE[]> builder) {
|
||||||
|
this.builder = builder;
|
||||||
|
#else
|
||||||
|
|
||||||
|
public ArrayTask(ITERABLE KEY_GENERIC_TYPE iterable) {
|
||||||
|
#endif
|
||||||
|
iter = iterable.iterator();
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
int size = prov == null ? -1 : prov.size();
|
||||||
|
wrapper = size < 0 ? COLLECTIONS.wrapper() : COLLECTIONS.wrapper(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean execute() throws Exception {
|
||||||
|
while(shouldRun() && iter.hasNext()) {
|
||||||
|
wrapper.add(iter.NEXT());
|
||||||
|
}
|
||||||
|
if(!iter.hasNext()) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
setResult(wrapper.TO_ARRAY(builder));
|
||||||
|
#else
|
||||||
|
setResult(wrapper.TO_ARRAY());
|
||||||
|
#endif
|
||||||
|
wrapper = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCompletion() {
|
||||||
|
super.onCompletion();
|
||||||
|
iter = null;
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
builder = null;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static class ForEachTask<T> extends BaseObjectTask<Void>
|
private static class ForEachTask<T> extends BaseObjectTask<Void>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
@@ -694,6 +823,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Base Task of the Actions that can be performed.
|
* Base Task of the Actions that can be performed.
|
||||||
* Allows to simplify the actions that get executed.
|
* Allows to simplify the actions that get executed.
|
||||||
|
|||||||
+600
-1
@@ -1,11 +1,22 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import java.util.ConcurrentModificationException;
|
||||||
|
#endif
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Objects;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if PRIMITIVES
|
#if JDK_FUNCTION && !TYPE_OBJECT
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
#if PRIMITIVES && !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -13,14 +24,26 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
import speiger.src.collections.utils.HashUtil;
|
||||||
|
#endif
|
||||||
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Collections
|
* A Helper class for Collections
|
||||||
*/
|
*/
|
||||||
@@ -75,6 +98,578 @@ public class COLLECTIONS
|
|||||||
return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex);
|
return c instanceof SynchronizedCollection ? c : new SynchronizedCollectionBRACES(c, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Singleton Collection of a given element
|
||||||
|
* @param element the element that should be converted into a singleton collection
|
||||||
|
* @Type(T)
|
||||||
|
* @return a singletoncollection of the given element
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES COLLECTION KEY_GENERIC_TYPE singleton(KEY_TYPE element) {
|
||||||
|
return new SingletonCollectionBRACES(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
||||||
|
return new CollectionWrapperBRACES();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper(int size) {
|
||||||
|
return new CollectionWrapperBRACES(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper() {
|
||||||
|
return new DistinctCollectionWrapperBRACES();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static GENERIC_KEY_BRACES DistinctCollectionWrapper KEY_GENERIC_TYPE distinctWrapper(int size) {
|
||||||
|
return new DistinctCollectionWrapperBRACES(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected static class CollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements ITrimmable {
|
||||||
|
KEY_TYPE[] elements;
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
public CollectionWrapper() {
|
||||||
|
this(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionWrapper(int size) {
|
||||||
|
if(size < 0) throw new IllegalStateException("Size has to be 0 or greater");
|
||||||
|
elements = NEW_KEY_ARRAY(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(KEY_TYPE o) {
|
||||||
|
if(size >= elements.length) elements = Arrays.copyOf(elements, (int)Math.min((long)elements.length + (elements.length >> 1), SanityChecks.MAX_ARRAY_SIZE));
|
||||||
|
elements[size++] = o;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KEY_TYPE GET_KEY(int index) {
|
||||||
|
if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||||
|
return elements[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object e) {
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
|
if(KEY_EQUALS(elements[i], e)) {
|
||||||
|
removeIndex(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public boolean REMOVE_KEY(KEY_TYPE e) {
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
|
if(KEY_EQUALS(elements[i], e)) {
|
||||||
|
removeIndex(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private void removeIndex(int index) {
|
||||||
|
if(index < 0 || index >= size) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
|
||||||
|
size--;
|
||||||
|
if(index != size) System.arraycopy(elements, index+1, elements, index, size - index);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
|
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||||
|
int index = 0;
|
||||||
|
int lastReturned = -1;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
return index < size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
int i = index++;
|
||||||
|
return elements[(lastReturned = i)];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
removeIndex(lastReturned);
|
||||||
|
index = lastReturned;
|
||||||
|
lastReturned = -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
for(int i = 0;i<size;elements[i] = null,i++);
|
||||||
|
#endif
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
public void sort(Comparator<? super CLASS_TYPE> c) {
|
||||||
|
if(c != null) ARRAYS.stableSort(elements, size, c);
|
||||||
|
else ARRAYS.stableSort(elements, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unstableSort(Comparator<? super CLASS_TYPE> c) {
|
||||||
|
if(c != null) ARRAYS.unstableSort(elements, size, c);
|
||||||
|
else ARRAYS.unstableSort(elements, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
public void sort(COMPARATOR c) {
|
||||||
|
if(c != null) ARRAYS.stableSort(elements, size, c);
|
||||||
|
else ARRAYS.stableSort(elements, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unstableSort(COMPARATOR c) {
|
||||||
|
if(c != null) ARRAYS.unstableSort(elements, size, c);
|
||||||
|
else ARRAYS.unstableSort(elements, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
action.accept(elements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
action.accept(input, elements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean trim(int size) {
|
||||||
|
if(size > size() || size() == elements.length) return false;
|
||||||
|
int value = Math.max(size, size());
|
||||||
|
elements = value == 0 ? EMPTY_KEY_ARRAY : Arrays.copyOf(elements, value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clearAndTrim(int size) {
|
||||||
|
if(elements.length <= size) {
|
||||||
|
clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elements = size == 0 ? EMPTY_KEY_ARRAY : NEW_KEY_ARRAY(size);
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Primitive
|
||||||
|
public Object[] toArray() {
|
||||||
|
Object[] obj = new Object[size];
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
obj[i] = KEY_TO_OBJ(elements[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);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
System.arraycopy(elements, 0, a, 0, size);
|
||||||
|
#else
|
||||||
|
for(int i = 0;i<size;i++)
|
||||||
|
a[i] = (E)KEY_TO_OBJ(elements[i]);
|
||||||
|
#endif
|
||||||
|
if (a.length > size) a[size] = null;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) {
|
||||||
|
if(a.length < size) a = new KEY_TYPE[size];
|
||||||
|
System.arraycopy(elements, 0, a, 0, size);
|
||||||
|
if (a.length > size) a[size] = EMPTY_KEY_VALUE;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_BOOLEAN
|
||||||
|
protected static class DistinctCollectionWrapper KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE {
|
||||||
|
KEY_TYPE[] keys;
|
||||||
|
boolean containsNull;
|
||||||
|
int minCapacity;
|
||||||
|
int nullIndex;
|
||||||
|
int maxFill;
|
||||||
|
int mask;
|
||||||
|
int size;
|
||||||
|
|
||||||
|
public DistinctCollectionWrapper() {
|
||||||
|
this(HashUtil.DEFAULT_MIN_CAPACITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DistinctCollectionWrapper(int size) {
|
||||||
|
if(minCapacity < 0) throw new IllegalStateException("Minimum Capacity is negative. This is not allowed");
|
||||||
|
minCapacity = nullIndex = HashUtil.arraySize(minCapacity, HashUtil.DEFAULT_LOAD_FACTOR);
|
||||||
|
mask = nullIndex - 1;
|
||||||
|
maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1);
|
||||||
|
keys = NEW_KEY_ARRAY(nullIndex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean add(KEY_TYPE o) {
|
||||||
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
|
if(containsNull) return false;
|
||||||
|
containsNull = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||||
|
KEY_TYPE current = keys[pos];
|
||||||
|
if(KEY_EQUALS_NOT_NULL(current)) {
|
||||||
|
if(KEY_EQUALS(current, o)) return false;
|
||||||
|
while(KEY_EQUALS_NOT_NULL((current = keys[pos = (++pos & mask)])))
|
||||||
|
if(KEY_EQUALS(current, o)) return false;
|
||||||
|
}
|
||||||
|
keys[pos] = o;
|
||||||
|
}
|
||||||
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, HashUtil.DEFAULT_LOAD_FACTOR));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(Object o) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
if(o == null) return containsNull;
|
||||||
|
#else
|
||||||
|
if(o == null) return false;
|
||||||
|
if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return containsNull;
|
||||||
|
#endif
|
||||||
|
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||||
|
KEY_TYPE current = keys[pos];
|
||||||
|
if(KEY_EQUALS_NULL(current)) return false;
|
||||||
|
if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||||
|
while(true) {
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||||
|
else if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean remove(Object o) {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
if(o == null) return (containsNull ? removeNullIndex() : false);
|
||||||
|
#else
|
||||||
|
if(o == null) return false;
|
||||||
|
if(o instanceof CLASS_TYPE && KEY_EQUALS(CLASS_TO_KEY(o), EMPTY_KEY_VALUE)) return (containsNull ? removeNullIndex() : false);
|
||||||
|
#endif
|
||||||
|
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||||
|
KEY_TYPE current = keys[pos];
|
||||||
|
if(KEY_EQUALS_NULL(current)) return false;
|
||||||
|
if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||||
|
while(true) {
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||||
|
else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE o) {
|
||||||
|
if(KEY_EQUALS_NULL(o)) return containsNull;
|
||||||
|
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||||
|
KEY_TYPE current = keys[pos];
|
||||||
|
if(KEY_EQUALS_NULL(current)) return false;
|
||||||
|
if(KEY_EQUALS(current, o)) return true;
|
||||||
|
while(true) {
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||||
|
else if(KEY_EQUALS(current, o)) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean REMOVE_KEY(KEY_TYPE o) {
|
||||||
|
if(KEY_EQUALS_NULL(o)) return containsNull ? removeNullIndex() : false;
|
||||||
|
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
||||||
|
KEY_TYPE current = keys[pos];
|
||||||
|
if(KEY_EQUALS_NULL(current)) return false;
|
||||||
|
if(KEY_EQUALS(current, o)) return removeIndex(pos);
|
||||||
|
while(true) {
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[pos = (++pos & mask)]))) return false;
|
||||||
|
else if(KEY_EQUALS(current, o)) return removeIndex(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected boolean removeIndex(int pos) {
|
||||||
|
if(pos == nullIndex) return containsNull ? removeNullIndex() : false;
|
||||||
|
keys[pos] = EMPTY_KEY_VALUE;
|
||||||
|
size--;
|
||||||
|
shiftKeys(pos);
|
||||||
|
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean removeNullIndex() {
|
||||||
|
containsNull = false;
|
||||||
|
keys[nullIndex] = EMPTY_KEY_VALUE;
|
||||||
|
size--;
|
||||||
|
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
|
return new SetIterator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
|
if(size() <= 0) return;
|
||||||
|
if(containsNull) action.accept(keys[nullIndex]);
|
||||||
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DistinctCollectionWrapper KEY_GENERIC_TYPE copy() {
|
||||||
|
DistinctCollectionWrapper KEY_GENERIC_TYPE set = new DistinctCollectionWrapperBRACES(0);
|
||||||
|
set.minCapacity = minCapacity;
|
||||||
|
set.mask = mask;
|
||||||
|
set.maxFill = maxFill;
|
||||||
|
set.nullIndex = nullIndex;
|
||||||
|
set.containsNull = containsNull;
|
||||||
|
set.size = size;
|
||||||
|
set.keys = Arrays.copyOf(keys, keys.length);
|
||||||
|
return set;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void shiftKeys(int startPos) {
|
||||||
|
int slot, last;
|
||||||
|
KEY_TYPE current;
|
||||||
|
while(true) {
|
||||||
|
startPos = ((last = startPos) + 1) & mask;
|
||||||
|
while(true){
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[startPos]))) {
|
||||||
|
keys[last] = EMPTY_KEY_VALUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
slot = HashUtil.mix(KEY_TO_HASH(current)) & mask;
|
||||||
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
|
startPos = ++startPos & mask;
|
||||||
|
}
|
||||||
|
keys[last] = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void rehash(int newSize) {
|
||||||
|
int newMask = newSize - 1;
|
||||||
|
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||||
|
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||||
|
while(true) {
|
||||||
|
if(--i < 0) throw new ConcurrentModificationException("Set was modified during rehash");
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[i])) break;
|
||||||
|
}
|
||||||
|
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
||||||
|
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
||||||
|
newKeys[pos] = keys[i];
|
||||||
|
}
|
||||||
|
nullIndex = newSize;
|
||||||
|
mask = newMask;
|
||||||
|
maxFill = Math.min((int)Math.ceil(nullIndex * HashUtil.DEFAULT_LOAD_FACTOR), nullIndex - 1);
|
||||||
|
keys = newKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
if(size == 0) return;
|
||||||
|
size = 0;
|
||||||
|
containsNull = false;
|
||||||
|
Arrays.fill(keys, EMPTY_KEY_VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SetIterator implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
int pos = nullIndex;
|
||||||
|
int returnedPos = -1;
|
||||||
|
int lastReturned = -1;
|
||||||
|
int nextIndex = Integer.MIN_VALUE;
|
||||||
|
boolean returnNull = containsNull;
|
||||||
|
KEY_TYPE[] wrapped = null;
|
||||||
|
int wrappedIndex = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() {
|
||||||
|
if(nextIndex == Integer.MIN_VALUE) {
|
||||||
|
if(returnNull) {
|
||||||
|
returnNull = false;
|
||||||
|
nextIndex = nullIndex;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(true) {
|
||||||
|
if(--pos < 0) {
|
||||||
|
if(wrapped == null || wrappedIndex <= -pos - 1) break;
|
||||||
|
nextIndex = -pos - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(KEY_EQUALS_NOT_NULL(keys[pos])){
|
||||||
|
nextIndex = pos;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nextIndex != Integer.MIN_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
returnedPos = pos;
|
||||||
|
if(nextIndex < 0){
|
||||||
|
lastReturned = Integer.MAX_VALUE;
|
||||||
|
KEY_TYPE value = wrapped[nextIndex];
|
||||||
|
nextIndex = Integer.MIN_VALUE;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
KEY_TYPE value = keys[(lastReturned = nextIndex)];
|
||||||
|
nextIndex = Integer.MIN_VALUE;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void remove() {
|
||||||
|
if(lastReturned == -1) throw new IllegalStateException();
|
||||||
|
if(lastReturned == nullIndex) {
|
||||||
|
containsNull = false;
|
||||||
|
keys[nullIndex] = EMPTY_KEY_VALUE;
|
||||||
|
}
|
||||||
|
else if(returnedPos >= 0) shiftKeys(returnedPos);
|
||||||
|
else {
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
DistinctCollectionWrapper.this.remove(wrapped[-returnedPos - 1]);
|
||||||
|
#else
|
||||||
|
DistinctCollectionWrapper.this.REMOVE_KEY(wrapped[-returnedPos - 1]);
|
||||||
|
#endif
|
||||||
|
lastReturned = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
size--;
|
||||||
|
lastReturned = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shiftKeys(int startPos) {
|
||||||
|
int slot, last;
|
||||||
|
KEY_TYPE current;
|
||||||
|
while(true) {
|
||||||
|
startPos = ((last = startPos) + 1) & mask;
|
||||||
|
while(true){
|
||||||
|
if(KEY_EQUALS_NULL((current = keys[startPos]))) {
|
||||||
|
keys[last] = EMPTY_KEY_VALUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
slot = HashUtil.mix(KEY_TO_HASH(current)) & mask;
|
||||||
|
if(last <= startPos ? (last >= slot || slot > startPos) : (last >= slot && slot > startPos)) break;
|
||||||
|
startPos = ++startPos & mask;
|
||||||
|
}
|
||||||
|
if(startPos < last) addWrapper(keys[startPos]);
|
||||||
|
keys[last] = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWrapper(KEY_TYPE value) {
|
||||||
|
if(wrapped == null) wrapped = NEW_KEY_ARRAY(2);
|
||||||
|
else if(wrappedIndex >= wrapped.length) {
|
||||||
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(wrapped.length * 2);
|
||||||
|
System.arraycopy(wrapped, 0, newArray, 0, wrapped.length);
|
||||||
|
wrapped = newArray;
|
||||||
|
}
|
||||||
|
wrapped[wrappedIndex++] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
private static class SingletonCollection KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
KEY_TYPE element;
|
||||||
|
|
||||||
|
SingletonCollection(KEY_TYPE element) {
|
||||||
|
this.element = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public boolean REMOVE_KEY(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
#endif
|
||||||
|
@Override
|
||||||
|
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
|
public ITERATOR KEY_GENERIC_TYPE iterator()
|
||||||
|
{
|
||||||
|
return new ITERATOR KEY_GENERIC_TYPE() {
|
||||||
|
boolean next = true;
|
||||||
|
@Override
|
||||||
|
public boolean hasNext() { return next; }
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
next = false;
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (o == this)
|
||||||
|
return true;
|
||||||
|
if (!(o instanceof Collection))
|
||||||
|
return false;
|
||||||
|
Collection<?> l = (Collection<?>)o;
|
||||||
|
if(l.size() != size()) return false;
|
||||||
|
Iterator<?> iter = l.iterator();
|
||||||
|
if (iter.hasNext() && !Objects.equals(element, iter.next())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !iter.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return KEY_TO_HASH(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() { return 1; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronized Collection Wrapper for the synchronizedCollection function
|
* Synchronized Collection Wrapper for the synchronizedCollection function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -183,6 +778,8 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super CLASS_TYPE> action) { synchronized(mutex) { c.forEach(action); } }
|
public void forEach(Consumer<? super CLASS_TYPE> action) { synchronized(mutex) { c.forEach(action); } }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { synchronized(mutex) { c.forEachIndexed(action); } }
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
|
public int hashCode() { synchronized(mutex) { return c.hashCode(); } }
|
||||||
@Override
|
@Override
|
||||||
@@ -308,6 +905,8 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super CLASS_TYPE> action) { c.forEach(action); }
|
public void forEach(Consumer<? super CLASS_TYPE> action) { c.forEach(action); }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) { c.forEachIndexed(action); }
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return c.hashCode(); }
|
public int hashCode() { return c.hashCode(); }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import speiger.src.collections.utils.IArray;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Type-Specific Helper class to get the underlying array of array implementations.
|
* Type-Specific Helper class to get the underlying array of array implementations.
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
* @see speiger.src.collections.PACKAGE.lists.ARRAY_LIST
|
||||||
|
#endif
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
public interface IARRAY KEY_GENERIC_TYPE extends IArray
|
||||||
|
|||||||
+120
-25
@@ -8,8 +8,12 @@ import java.util.Comparator;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@@ -17,14 +21,11 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
|
||||||
#endif
|
#endif
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Iterables
|
* A Helper class for Iterables
|
||||||
@@ -147,6 +148,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
|
||||||
@@ -225,7 +248,7 @@ public class ITERABLES
|
|||||||
return new WrappedIterableBRACES(iterable);
|
return new WrappedIterableBRACES(iterable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class WrappedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
private static class WrappedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
Iterable<? extends CLASS_TYPE> iterable;
|
Iterable<? extends CLASS_TYPE> iterable;
|
||||||
|
|
||||||
@@ -237,6 +260,12 @@ public class ITERABLES
|
|||||||
return ITERATORS.wrap(iterable.iterator());
|
return ITERATORS.wrap(iterable.iterator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
return prov == null ? -1 : prov.size();
|
||||||
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER action) {
|
public void forEach(CONSUMER action) {
|
||||||
@@ -251,7 +280,7 @@ public class ITERABLES
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>
|
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>, ISizeProvider
|
||||||
{
|
{
|
||||||
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
||||||
TO_OBJECT_FUNCTION KSS_GENERIC_TYPE<E, T> mapper;
|
TO_OBJECT_FUNCTION KSS_GENERIC_TYPE<E, T> mapper;
|
||||||
@@ -265,10 +294,16 @@ public class ITERABLES
|
|||||||
return ITERATORS.map(iterable.iterator(), mapper);
|
return ITERATORS.map(iterable.iterator(), mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
|
return prov == null ? -1 : prov.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super T> action) {
|
public void forEach(Consumer<? super T> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterable.forEach(E -> action.accept(mapper.GET_VALUE(E)));
|
iterable.forEach(E -> action.accept(mapper.apply(E)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +325,7 @@ public class ITERABLES
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super T> action) {
|
public void forEach(Consumer<? super T> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterable.forEach(E -> mapper.GET_VALUE(E).forEach(action));
|
iterable.forEach(E -> mapper.apply(E).forEach(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -314,12 +349,54 @@ public class ITERABLES
|
|||||||
public void forEach(Consumer<? super T> action) {
|
public void forEach(Consumer<? super T> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterable.forEach(E -> {
|
iterable.forEach(E -> {
|
||||||
T[] array = mapper.GET_VALUE(E);
|
T[] array = mapper.apply(E);
|
||||||
for(int i = 0,m=array.length;i<m;action.accept(array[i++]));
|
for(int i = 0,m=array.length;i<m;action.accept(array[i++]));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class RepeatingIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
return prov == null ? -1 : prov.size() * (repeats+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
@Override
|
||||||
|
public void forEach(CONSUMER action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||||
|
iterable.forEach(action.andThen(repeater::add));
|
||||||
|
for(int i = 0;i<repeats;i++)
|
||||||
|
repeater.forEach(action);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
@Override
|
||||||
|
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||||
|
iterable.forEach(T -> {action.accept(T); repeater.add(T);});
|
||||||
|
for(int i = 0;i<repeats;i++)
|
||||||
|
repeater.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;
|
||||||
@@ -339,17 +416,17 @@ public class ITERABLES
|
|||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER action) {
|
public void forEach(CONSUMER action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterable.forEach(T -> { if(!filter.TEST_VALUE(T)) action.accept(T); } );
|
iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterable.forEach(T -> { if(!filter.TEST_VALUE(T)) action.accept(T); } );
|
iterable.forEach(T -> { if(!filter.test(T)) action.accept(T); } );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class LimitedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
private static class LimitedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
ITERABLE KEY_GENERIC_TYPE iterable;
|
ITERABLE KEY_GENERIC_TYPE iterable;
|
||||||
long limit;
|
long limit;
|
||||||
@@ -364,6 +441,12 @@ public class ITERABLES
|
|||||||
return ITERATORS.limit(iterable.iterator(), limit);
|
return ITERATORS.limit(iterable.iterator(), limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
return prov == null ? -1 : (int)Math.min(prov.size(), limit);
|
||||||
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER action) {
|
public void forEach(CONSUMER action) {
|
||||||
@@ -388,7 +471,7 @@ public class ITERABLES
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SortedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
private static class SortedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
ITERABLE KEY_GENERIC_TYPE iterable;
|
ITERABLE KEY_GENERIC_TYPE iterable;
|
||||||
COMPARATOR KEY_GENERIC_TYPE sorter;
|
COMPARATOR KEY_GENERIC_TYPE sorter;
|
||||||
@@ -403,23 +486,29 @@ public class ITERABLES
|
|||||||
return ITERATORS.sorted(iterable.iterator(), sorter);
|
return ITERATORS.sorted(iterable.iterator(), sorter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
return prov == null ? -1 : prov.size();
|
||||||
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER action) {
|
public void forEach(CONSUMER action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper();
|
||||||
iterable.forEach(list::add);
|
iterable.forEach(wrapper::add);
|
||||||
list.unstableSort(sorter);
|
wrapper.unstableSort(sorter);
|
||||||
list.forEach(action);
|
wrapper.forEach(action);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE wrapper = COLLECTIONS.wrapper();
|
||||||
iterable.forEach(list::add);
|
iterable.forEach(wrapper::add);
|
||||||
list.unstableSort(sorter);
|
wrapper.unstableSort(sorter);
|
||||||
list.forEach(action);
|
wrapper.forEach(action);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -449,20 +538,20 @@ public class ITERABLES
|
|||||||
action.accept(T);
|
action.accept(T);
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||||
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
public void forEach(Consumer<? super CLASS_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||||
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
iterable.forEach(T -> { if(filtered.add(T)) action.accept(T); });
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PeekIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
private static class PeekIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE, ISizeProvider
|
||||||
{
|
{
|
||||||
ITERABLE KEY_GENERIC_TYPE iterable;
|
ITERABLE KEY_GENERIC_TYPE iterable;
|
||||||
CONSUMER KEY_GENERIC_TYPE action;
|
CONSUMER KEY_GENERIC_TYPE action;
|
||||||
@@ -477,6 +566,12 @@ public class ITERABLES
|
|||||||
return ITERATORS.peek(iterable.iterator(), action);
|
return ITERATORS.peek(iterable.iterator(), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int size() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(iterable);
|
||||||
|
return prov == null ? -1 : prov.size();
|
||||||
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER action) {
|
public void forEach(CONSUMER action) {
|
||||||
|
|||||||
+94
-38
@@ -6,6 +6,9 @@ import java.util.NoSuchElementException;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.CONSUMER;
|
import java.util.function.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -15,16 +18,21 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
#endif
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
||||||
|
#else if LINKED_LIST_FEATURE
|
||||||
|
import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.sets.HASH_SET;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Iterators
|
* A Helper class for Iterators
|
||||||
@@ -215,6 +223,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
|
||||||
@@ -446,6 +476,8 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
#if LIST_MODULE
|
||||||
|
#if ARRAY_LIST_FEATURE || LINKED_LIST_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Helper function to pours all elements of a Iterator into a List
|
* A Helper function to pours all elements of a Iterator into a List
|
||||||
* @param iter the elements that should be poured into list.
|
* @param iter the elements that should be poured into list.
|
||||||
@@ -464,12 +496,20 @@ public class ITERATORS
|
|||||||
* @return A list of all requested elements of the Iterator
|
* @return A list of all requested elements of the Iterator
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE pour(ITERATOR KEY_GENERIC_TYPE iter, int max) {
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
|
#else
|
||||||
|
LINKED_LIST KEY_GENERIC_TYPE list = new LINKED_LISTBRACES();
|
||||||
|
#endif
|
||||||
pour(iter, list, max);
|
pour(iter, list, max);
|
||||||
|
#if ARRAY_LIST_FEATURE
|
||||||
list.trim();
|
list.trim();
|
||||||
|
#endif
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function to pours all elements of a Iterator into a Collection
|
* A Helper function to pours all elements of a Iterator into a Collection
|
||||||
* @param iter the elements that should be poured into list.
|
* @param iter the elements that should be poured into list.
|
||||||
@@ -729,41 +769,21 @@ public class ITERATORS
|
|||||||
private static class EmptyIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
private static class EmptyIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() { throw new NoSuchElementException(); }
|
||||||
throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() { return false; }
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() { throw new NoSuchElementException(); }
|
||||||
throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() { return -1; }
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void remove() { throw new UnsupportedOperationException(); }
|
public void remove() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public void set(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
@@ -817,7 +837,7 @@ public class ITERATORS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T next() {
|
public T next() {
|
||||||
return mapper.GET_VALUE(iterator.NEXT());
|
return mapper.apply(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -843,7 +863,7 @@ public class ITERATORS
|
|||||||
foundNext = true;
|
foundNext = true;
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
if(last != null && last.hasNext()) return;
|
if(last != null && last.hasNext()) return;
|
||||||
last = mapper.GET_VALUE(iterator.NEXT()).iterator();
|
last = mapper.apply(iterator.NEXT()).iterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +899,7 @@ public class ITERATORS
|
|||||||
foundNext = true;
|
foundNext = true;
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
if(last != null && last.hasNext()) return;
|
if(last != null && last.hasNext()) return;
|
||||||
last = ObjectIterators.wrap(mapper.GET_VALUE(iterator.NEXT()));
|
last = ObjectIterators.wrap(mapper.apply(iterator.NEXT()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,11 +918,43 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
final int repeats;
|
||||||
|
int index = 0;
|
||||||
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
|
COLLECTION KEY_GENERIC_TYPE repeater = COLLECTIONS.wrapper();
|
||||||
|
|
||||||
|
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 = repeater.iterator();
|
||||||
|
return iter.hasNext();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE NEXT() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
KEY_TYPE value = iter.NEXT();
|
||||||
|
if(index == 0) repeater.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;
|
||||||
COMPARATOR KEY_GENERIC_TYPE sorter;
|
COMPARATOR KEY_GENERIC_TYPE sorter;
|
||||||
LIST KEY_GENERIC_TYPE sortedElements = null;
|
COLLECTIONS.CollectionWrapper KEY_GENERIC_TYPE sortedElements = null;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
public SortedIterator(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE sorter) {
|
public SortedIterator(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE sorter) {
|
||||||
@@ -914,7 +966,11 @@ public class ITERATORS
|
|||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
if(sortedElements == null) {
|
if(sortedElements == null) {
|
||||||
boolean hasNext = iterator.hasNext();
|
boolean hasNext = iterator.hasNext();
|
||||||
sortedElements = hasNext ? pour(iterator) : LISTS.empty();
|
if(hasNext) {
|
||||||
|
sortedElements = COLLECTIONS.wrapper();
|
||||||
|
pour(iterator, sortedElements);
|
||||||
|
}
|
||||||
|
else sortedElements = COLLECTIONS.wrapper();
|
||||||
if(hasNext) sortedElements.unstableSort(sorter);
|
if(hasNext) sortedElements.unstableSort(sorter);
|
||||||
}
|
}
|
||||||
return index < sortedElements.size();
|
return index < sortedElements.size();
|
||||||
@@ -933,7 +989,7 @@ public class ITERATORS
|
|||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
int filtered;
|
int filtered;
|
||||||
#else
|
#else
|
||||||
SET KEY_GENERIC_TYPE filtered = new HASH_SETBRACES();
|
COLLECTION KEY_GENERIC_TYPE filtered = COLLECTIONS.distinctWrapper();
|
||||||
#endif
|
#endif
|
||||||
KEY_TYPE lastFound;
|
KEY_TYPE lastFound;
|
||||||
boolean foundNext = false;
|
boolean foundNext = false;
|
||||||
@@ -994,7 +1050,7 @@ public class ITERATORS
|
|||||||
if(foundNext) return;
|
if(foundNext) return;
|
||||||
while(iterator.hasNext()) {
|
while(iterator.hasNext()) {
|
||||||
lastFound = iterator.NEXT();
|
lastFound = iterator.NEXT();
|
||||||
if(filter.TEST_VALUE(lastFound)) {
|
if(filter.test(lastFound)) {
|
||||||
foundNext = true;
|
foundNext = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,18 @@ package speiger.src.collections.PACKAGE.utils;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
#if IARRAY_FEATURE
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
#endif
|
||||||
|
#if JAVA_VERSION>=17
|
||||||
|
import java.util.random.RANDOM;
|
||||||
|
#else
|
||||||
|
import java.util.RANDOM;
|
||||||
|
#endif
|
||||||
import java.util.RandomAccess;
|
import java.util.RandomAccess;
|
||||||
|
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
#endif
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
#endif
|
#endif
|
||||||
@@ -17,7 +25,9 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST;
|
import speiger.src.collections.PACKAGE.lists.ABSTRACT_LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
import speiger.src.collections.PACKAGE.lists.LIST;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
|
#if IARRAY_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +70,11 @@ public class LISTS
|
|||||||
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l) {
|
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l) {
|
||||||
|
#if IARRAY_FEATURE
|
||||||
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l)));
|
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l)));
|
||||||
|
#else
|
||||||
|
return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l) : new SynchronizedListBRACES(l));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +85,11 @@ public class LISTS
|
|||||||
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
* @return a synchronized list wrapper. If the list is implementing RandomAccess or IARRAY that is also transferred. If the List already a synchronized wrapper then it just returns itself.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l, Object mutex) {
|
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE synchronize(LIST KEY_GENERIC_TYPE l, Object mutex) {
|
||||||
|
#if IARRAY_FEATURE
|
||||||
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex)));
|
return l instanceof SynchronizedList ? l : (l instanceof IARRAY ? new SynchronizedArrayListBRACES(l, mutex) : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex)));
|
||||||
|
#else
|
||||||
|
return l instanceof SynchronizedList ? l : (l instanceof RandomAccess ? new SynchronizedRandomAccessListBRACES(l, mutex) : new SynchronizedListBRACES(l, mutex));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,6 +110,7 @@ public class LISTS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE reverse(LIST KEY_GENERIC_TYPE list) {
|
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE reverse(LIST KEY_GENERIC_TYPE list) {
|
||||||
int size = list.size();
|
int size = list.size();
|
||||||
|
#if IARRAY_FEATURE
|
||||||
if(list instanceof IARRAY) {
|
if(list instanceof IARRAY) {
|
||||||
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -106,6 +125,7 @@ public class LISTS
|
|||||||
return list;
|
return list;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if(list instanceof RandomAccess) {
|
if(list instanceof RandomAccess) {
|
||||||
for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--) {
|
for (int i = 0, mid = size >> 1, j = size - 1; i < mid; i++, j--) {
|
||||||
KEY_TYPE t = list.GET_KEY(i);
|
KEY_TYPE t = list.GET_KEY(i);
|
||||||
@@ -141,8 +161,9 @@ public class LISTS
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return the input list
|
* @return the input list
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE shuffle(LIST KEY_GENERIC_TYPE list, Random random) {
|
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE shuffle(LIST KEY_GENERIC_TYPE list, RANDOM random) {
|
||||||
int size = list.size();
|
int size = list.size();
|
||||||
|
#if IARRAY_FEATURE
|
||||||
if(list instanceof IARRAY) {
|
if(list instanceof IARRAY) {
|
||||||
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
IARRAY KEY_GENERIC_TYPE array = (IARRAY KEY_GENERIC_TYPE)list;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -164,7 +185,8 @@ public class LISTS
|
|||||||
#endif
|
#endif
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
for(int i = list.size(); i-- != 0;) {
|
#endif
|
||||||
|
for(int i = size; i-- != 0;) {
|
||||||
int p = random.nextInt(i + 1);
|
int p = random.nextInt(i + 1);
|
||||||
KEY_TYPE t = list.GET_KEY(i);
|
KEY_TYPE t = list.GET_KEY(i);
|
||||||
list.set(i, list.GET_KEY(p));
|
list.set(i, list.GET_KEY(p));
|
||||||
@@ -231,6 +253,7 @@ public class LISTS
|
|||||||
public SingletonList KEY_GENERIC_TYPE copy() { return new SingletonListBRACES(element); }
|
public SingletonList KEY_GENERIC_TYPE copy() { return new SingletonListBRACES(element); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IARRAY_FEATURE
|
||||||
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
|
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
IARRAY KEY_GENERIC_TYPE l;
|
IARRAY KEY_GENERIC_TYPE l;
|
||||||
@@ -271,6 +294,7 @@ public class LISTS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
private static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess
|
private static class SynchronizedRandomAccessList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements RandomAccess
|
||||||
{
|
{
|
||||||
SynchronizedRandomAccessList(LIST KEY_GENERIC_TYPE l) {
|
SynchronizedRandomAccessList(LIST KEY_GENERIC_TYPE l) {
|
||||||
|
|||||||
+11
@@ -5,18 +5,25 @@ import java.util.Collection;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
|
#if JDK_FUNCTION
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +53,7 @@ public class PRIORITY_QUEUES
|
|||||||
return queue instanceof SynchronizedPriorityQueue ? (SynchronizedPriorityQueue KEY_GENERIC_TYPE)queue : new SynchronizedPriorityQueueBRACES(queue, mutex);
|
return queue instanceof SynchronizedPriorityQueue ? (SynchronizedPriorityQueue KEY_GENERIC_TYPE)queue : new SynchronizedPriorityQueueBRACES(queue, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
/**
|
/**
|
||||||
* Returns a synchronized PriorityDequeue instance based on the instance given.
|
* Returns a synchronized PriorityDequeue instance based on the instance given.
|
||||||
* @param dequeue that should be synchronized
|
* @param dequeue that should be synchronized
|
||||||
@@ -67,6 +75,7 @@ public class PRIORITY_QUEUES
|
|||||||
return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex);
|
return dequeue instanceof SynchronizedPriorityDequeue ? (SynchronizedPriorityDequeue KEY_GENERIC_TYPE)dequeue : new SynchronizedPriorityDequeueBRACES(dequeue, mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Wrapper class for synchronization
|
* Wrapper class for synchronization
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -134,6 +143,7 @@ public class PRIORITY_QUEUES
|
|||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEQUEUE_FEATURE
|
||||||
/**
|
/**
|
||||||
* Wrapper class for synchronization
|
* Wrapper class for synchronization
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -166,4 +176,5 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } }
|
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { synchronized(mutex) { return dequeue.copy(); } }
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,31 +2,30 @@ package speiger.src.collections.PACKAGE.utils;
|
|||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_OBJECT && SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
|
||||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
|
||||||
import speiger.src.collections.booleans.sets.BooleanSet;
|
|
||||||
import speiger.src.collections.booleans.utils.BooleanCollections.EmptyCollection;
|
|
||||||
#else
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT && SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.EmptyCollection;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.SynchronizedCollection;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
|
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.UnmodifiableCollection;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for sets
|
* A Helper class for sets
|
||||||
@@ -51,7 +50,6 @@ public class SETS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
/**
|
/**
|
||||||
* Creates a Synchronized set while preserving the ITrimmable interface
|
* Creates a Synchronized set while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @param s the set that should be synchronized
|
||||||
@@ -75,6 +73,7 @@ public class SETS
|
|||||||
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex));
|
return s instanceof SynchronizedSet ? s : (s instanceof ITrimmable ? new SynchronizedTrimSetBRACES(s, mutex) : new SynchronizedSetBRACES(s, mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
|
* Creates a Synchronized SortedSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @param s the set that should be synchronized
|
||||||
@@ -98,6 +97,8 @@ public class SETS
|
|||||||
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
|
return s instanceof SynchronizedSortedSet ? s : (s instanceof ITrimmable ? new SynchronizedSortedTrimSetBRACES(s, mutex) : new SynchronizedSortedSetBRACES(s, mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
* Creates a Synchronized OrderedSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @param s the set that should be synchronized
|
||||||
@@ -121,6 +122,8 @@ public class SETS
|
|||||||
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex));
|
return s instanceof SynchronizedOrderedSet ? s : (s instanceof ITrimmable ? new SynchronizedOrderedTrimSetBRACES(s, mutex) : new SynchronizedOrderedSetBRACES(s, mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
|
* Creates a Synchronized NavigableSet while preserving the ITrimmable interface
|
||||||
* @param s the set that should be synchronized
|
* @param s the set that should be synchronized
|
||||||
@@ -144,6 +147,7 @@ public class SETS
|
|||||||
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
|
return s instanceof SynchronizedNavigableSet ? s : (s instanceof ITrimmable ? new SynchronizedNavigableTrimSetBRACES(s, mutex) : new SynchronizedNavigableSetBRACES(s, mutex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable Set wrapper
|
* Creates Unmodifyable Set wrapper
|
||||||
* @param s set that should be made unmodifiable
|
* @param s set that should be made unmodifiable
|
||||||
@@ -154,6 +158,7 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
|
return s instanceof UnmodifiableSet ? s : new UnmodifiableSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable SortedSet wrapper
|
* Creates Unmodifyable SortedSet wrapper
|
||||||
* @param s sortedSet that should be made unmodifiable
|
* @param s sortedSet that should be made unmodifiable
|
||||||
@@ -164,6 +169,8 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
return s instanceof UnmodifiableSortedSet ? s : new UnmodifiableSortedSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable OrderedSet wrapper
|
* Creates Unmodifyable OrderedSet wrapper
|
||||||
* @param s OrderedSet that should be made unmodifiable
|
* @param s OrderedSet that should be made unmodifiable
|
||||||
@@ -174,6 +181,8 @@ public class SETS
|
|||||||
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
return s instanceof UnmodifiableOrderedSet ? s : new UnmodifiableOrderedSetBRACES(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates Unmodifyable NavigableSet wrapper
|
* Creates Unmodifyable NavigableSet wrapper
|
||||||
* @param s navigableSet that should be made unmodifiable
|
* @param s navigableSet that should be made unmodifiable
|
||||||
@@ -254,7 +263,7 @@ public class SETS
|
|||||||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if SORTED_SET_FEATURE
|
||||||
private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
|
private static class UnmodifiableNavigableSet KEY_GENERIC_TYPE extends UnmodifiableSortedSet KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
NAVIGABLE_SET KEY_GENERIC_TYPE n;
|
NAVIGABLE_SET KEY_GENERIC_TYPE n;
|
||||||
@@ -340,6 +349,8 @@ public class SETS
|
|||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE tailSet(KEY_TYPE fromElement) { return SETS.unmodifiable(n.tailSet(fromElement)); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
private static class UnmodifiableOrderedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ORDERED_SET KEY_GENERIC_TYPE s;
|
ORDERED_SET KEY_GENERIC_TYPE s;
|
||||||
@@ -373,6 +384,8 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
private static class UnmodifiableSortedSet KEY_GENERIC_TYPE extends UnmodifiableSet KEY_GENERIC_TYPE implements SORTED_SET KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
SORTED_SET KEY_GENERIC_TYPE s;
|
SORTED_SET KEY_GENERIC_TYPE s;
|
||||||
@@ -406,6 +419,7 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
|
* Unmodifyable Set wrapper that helps is used with unmodifyableSet function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -434,6 +448,7 @@ public class SETS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_SET_FEATURE
|
||||||
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
|
private static class SynchronizedNavigableTrimSet KEY_GENERIC_TYPE extends SynchronizedNavigableSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -597,6 +612,8 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_SET_FEATURE
|
||||||
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
|
private static class SynchronizedOrderedTrimSet KEY_GENERIC_TYPE extends SynchronizedOrderedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -656,6 +673,7 @@ public class SETS
|
|||||||
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable
|
private static class SynchronizedTrimSet KEY_GENERIC_TYPE extends SynchronizedSet KEY_GENERIC_TYPE implements ITrimmable
|
||||||
{
|
{
|
||||||
ITrimmable trim;
|
ITrimmable trim;
|
||||||
@@ -704,5 +722,4 @@ public class SETS
|
|||||||
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
|
* A Type Specific Strategy class that allows to give control hashcode generation and equals comparason for maps
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -19,6 +21,17 @@ public interface STRATEGY KEY_GENERIC_TYPE
|
|||||||
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
|
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE identityStrategy() { return (STRATEGY<KEY_TYPE>)IDENTITY; }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* Normal Strategy
|
||||||
|
*/
|
||||||
|
public static final STRATEGY NO_GENERIC_TYPE NORMAL = new NormalStrategyBRACES();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Type(T)
|
||||||
|
* @return a Normal Strategy that is behaving exactly like the normal Hash Strategy in the Hash Collections
|
||||||
|
*/
|
||||||
|
public static GENERIC_KEY_BRACES STRATEGY KEY_GENERIC_TYPE normalStrategy() { return (STRATEGY KEY_GENERIC_TYPE)NORMAL; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type Specific HashCode function
|
* Type Specific HashCode function
|
||||||
* @param o the element that the hashcode is requested for (if object may be null)
|
* @param o the element that the hashcode is requested for (if object may be null)
|
||||||
@@ -47,5 +60,18 @@ public interface STRATEGY KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
|
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return key == value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* A Strategy that simulates the normal Hash Collection Behavior if you want to use Hash Control Collections to replace normal ones.
|
||||||
|
* Only real reason to do that is you have to use this and want to get rid of implementations.
|
||||||
|
* @Type(T)
|
||||||
|
*/
|
||||||
|
public static class NormalStrategy KEY_GENERIC_TYPE implements STRATEGY KEY_GENERIC_TYPE
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public int hashCode(KEY_TYPE o) { return KEY_TO_HASH(o); }
|
||||||
|
@Override
|
||||||
|
public boolean equals(KEY_TYPE key, KEY_TYPE value) { return EQUALS_KEY_TYPE(key, value); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+42
-14
@@ -3,9 +3,9 @@ package speiger.src.collections.PACKAGE.utils.maps;
|
|||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT && SORTED_MAP_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#else
|
#else if !TYPE_OBJECT
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
@@ -14,31 +14,43 @@ import java.util.function.Consumer;
|
|||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
#endif
|
#endif
|
||||||
|
#if VALUE_BOOLEAN && JDK_TYPE
|
||||||
|
import java.util.function.PREDICATE;
|
||||||
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
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
|
|
||||||
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
import speiger.src.collections.objects.utils.ObjectIterators;
|
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.objects.sets.ObjectOrderedSet;
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
|
#if !VALUE_BOOLEAN || !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if !TYPE_BOOLEAN
|
#if SORTED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
|
#endif
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
||||||
|
#endif
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
import speiger.src.collections.PACKAGE.sets.SORTED_SET;
|
||||||
|
#endif
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
|
#endif
|
||||||
#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;
|
||||||
@@ -49,10 +61,6 @@ import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPER
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
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
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.utils.VALUE_SETS;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class that provides you with Singleton/Empty/Synchronized/Unmodifyable Maps
|
* A Helper class that provides you with Singleton/Empty/Synchronized/Unmodifyable Maps
|
||||||
@@ -123,8 +131,6 @@ public class MAPS
|
|||||||
else entries.forEach(action);
|
else entries.forEach(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
* @param map the map that should be synchronized
|
* @param map the map that should be synchronized
|
||||||
@@ -147,6 +153,7 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE synchronize(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedMap ? map : new SynchronizedMapKV_BRACES(map, mutex); }
|
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE synchronize(MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedMap ? map : new SynchronizedMapKV_BRACES(map, mutex); }
|
||||||
|
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function that creates a Helper wrapper to synchronize access into the SortedMap.
|
* Helper function that creates a Helper wrapper to synchronize access into the SortedMap.
|
||||||
* @param map the SortedMap that should be synchronized
|
* @param map the SortedMap that should be synchronized
|
||||||
@@ -169,6 +176,8 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); }
|
public static GENERIC_KEY_VALUE_BRACES SORTED_MAP KEY_VALUE_GENERIC_TYPE synchronize(SORTED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedSortedMap ? map : new SynchronizedSortedMapKV_BRACES(map, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function that creates a Helper wrapper to synchronize access into the OrderedMap.
|
* Helper function that creates a Helper wrapper to synchronize access into the OrderedMap.
|
||||||
* @param map the OrderedMap that should be synchronized
|
* @param map the OrderedMap that should be synchronized
|
||||||
@@ -191,6 +200,8 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); }
|
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
|
* Helper function that creates a Helper wrapper to synchronize access into the NavigableMap.
|
||||||
* @param map the NavigableMap that should be synchronized
|
* @param map the NavigableMap that should be synchronized
|
||||||
@@ -213,6 +224,7 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE synchronize(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedNavigableMap ? map : new SynchronizedNavigableMapKV_BRACES(map, mutex); }
|
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE synchronize(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedNavigableMap ? map : new SynchronizedNavigableMapKV_BRACES(map, mutex); }
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the Map
|
* A Helper function that creates a Helper wrapper to only allow Read Access into the Map
|
||||||
* @param map the map that should be made Unmodifiable
|
* @param map the map that should be made Unmodifiable
|
||||||
@@ -223,6 +235,7 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); }
|
public static GENERIC_KEY_VALUE_BRACES MAP KEY_VALUE_GENERIC_TYPE unmodifiable(MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableMap ? map : new UnmodifyableMapKV_BRACES(map); }
|
||||||
|
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap
|
* A Helper function that creates a Helper wrapper to only allow Read Access into the OrderedMap
|
||||||
* @param map the OrderedMap that should be made Unmodifiable
|
* @param map the OrderedMap that should be made Unmodifiable
|
||||||
@@ -233,6 +246,8 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); }
|
public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableOrderedMap ? map : new UnmodifyableOrderedMapKV_BRACES(map); }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap
|
* A Helper function that creates a Helper wrapper to only allow Read Access into the SortedMap
|
||||||
* @param map the SortedMap that should be made Unmodifiable
|
* @param map the SortedMap that should be made Unmodifiable
|
||||||
@@ -253,6 +268,7 @@ public class MAPS
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); }
|
public static GENERIC_KEY_VALUE_BRACES NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE unmodifiable(NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE map) { return map instanceof UnmodifyableNavigableMap ? map : new UnmodifyableNavigableMapKV_BRACES(map); }
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Helper function that creates a Unmodifyable Entry
|
* 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
|
||||||
@@ -344,7 +360,7 @@ public class MAPS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(values == null) values = VALUE_SETS.singleton(value);
|
if(values == null) values = VALUE_COLLECTIONS.singleton(value);
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@@ -425,6 +441,7 @@ public class MAPS
|
|||||||
public void set(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public void set(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Navigable Map implementation that is sued for the unmodifyableMap function
|
* The Unmodifyable Navigable Map implementation that is sued for the unmodifyableMap function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -496,6 +513,8 @@ public class MAPS
|
|||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function
|
* The Unmodifyable Ordered Map implementation that is sued for the unmodifyableMap function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -548,6 +567,8 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
|
* The Unmodifyable Sorted Map implementation that is sued for the unmodifyableMap function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -587,6 +608,7 @@ public class MAPS
|
|||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Map implementation that is sued for the unmodifyableMap function
|
* The Unmodifyable Map implementation that is sued for the unmodifyableMap function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -669,7 +691,7 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation
|
* The Unmodifyable Ordered Set implementation for the Unmodifyable Ordered Map implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -708,6 +730,7 @@ public class MAPS
|
|||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
|
* The Unmodifyable Set implementation for the Unmodifyable Map implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -741,6 +764,7 @@ public class MAPS
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Synchronized Navigable Map implementation used by the synchronizedMap helper function
|
* The Synchronized Navigable Map implementation used by the synchronizedMap helper function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -859,6 +883,8 @@ public class MAPS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if ORDERED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Synchronized Ordered Map implementation used by the synchronizedMap helper function
|
* The Synchronized Ordered Map implementation used by the synchronizedMap helper function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -916,6 +942,8 @@ public class MAPS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#if SORTED_MAP_FEATURE
|
||||||
/**
|
/**
|
||||||
* The Synchronized Sorted Map implementation used by the synchronizedMap helper function
|
* The Synchronized Sorted Map implementation used by the synchronizedMap helper function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -977,6 +1005,7 @@ public class MAPS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* The Synchronized Map implementation used by the synchronizedMap helper function
|
* The Synchronized Map implementation used by the synchronizedMap helper function
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1148,5 +1177,4 @@ public class MAPS
|
|||||||
public void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) { synchronized(mutex) { map.forEach(action); } }
|
public void forEach(BiConsumer<? super CLASS_TYPE, ? super CLASS_VALUE_TYPE> action) { synchronized(mutex) { map.forEach(action); } }
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
+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())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user