Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
867b3b4d9a |
+1
-9
@@ -20,15 +20,7 @@ gradle-app.setting
|
|||||||
/bin/
|
/bin/
|
||||||
/storage/
|
/storage/
|
||||||
#Generated Code
|
#Generated Code
|
||||||
/src/main/java/speiger/src/collections/booleans/*
|
|
||||||
/src/main/java/speiger/src/collections/bytes/*
|
|
||||||
/src/main/java/speiger/src/collections/shorts/*
|
|
||||||
/src/main/java/speiger/src/collections/chars/*
|
|
||||||
/src/main/java/speiger/src/collections/ints/*
|
|
||||||
/src/main/java/speiger/src/collections/longs/*
|
|
||||||
/src/main/java/speiger/src/collections/floats/*
|
|
||||||
/src/main/java/speiger/src/collections/doubles/*
|
|
||||||
/src/main/java/speiger/src/collections/objects/*
|
|
||||||
|
|
||||||
#Generated Tests
|
#Generated Tests
|
||||||
/src/test/java/speiger/src/testers/booleans/*
|
/src/test/java/speiger/src/testers/booleans/*
|
||||||
|
|||||||
@@ -1,35 +1,13 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
### Version 0.9.0
|
|
||||||
- Added: getFirst/getLast/removeFirst/removeLast to List.class.
|
|
||||||
- Added: Dedicated Set toArray implementations.
|
|
||||||
- Added: ToArray/pushTop functions to Stack.class.
|
|
||||||
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
|
||||||
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
|
||||||
- Added: Iterators.infinite as an option that will create a Infinite Iterator based on the inputed one.
|
|
||||||
- Added: List.indexedIterator which allows you to create a iterator with a customized iteration indecies. Useful if you want to transform lists output.
|
|
||||||
- Added: PriorityQueue.contains is now a function
|
|
||||||
- Added: Iterators/Async Builders now support MapToPrimitiveType function on the object variant. So more processing can be done. (Will be expanded upon later versions)
|
|
||||||
- Fixed: SetValue wasn't working on forEach implementations.
|
|
||||||
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
|
||||||
- Fixed: Supplier was using the wrong dataType in their function name.
|
|
||||||
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
|
||||||
- Breaking Change: Map.compute/IfAbsent/Present and Map.supplyIfAbsent if the value is a primitive it will no longer accept the defaultReturnValue() as "null" if that functionality is desired then use: computeNonDefault which contains the functionality!
|
|
||||||
|
|
||||||
### Version 0.8.1
|
### Version 0.8.1
|
||||||
- Added: getFirst/getLast/removeFirst/removeLast to List.class.
|
- Added: getFirst/getLast/removeFirst/removeLast to List.class.
|
||||||
- Added: Dedicated Set toArray implementations.
|
- Added: Dedicated Set toArray implementations.
|
||||||
- Added: ToArray/pushTop functions to Stack.class.
|
- Added: ToArray/pushTop functions to Stack.class.
|
||||||
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
- Added: ComputeNonDefault functions which will contain the current behavior of the Compute function, while the Compute will be changed to be more java compliant!
|
||||||
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
- Added: List.reversed, which returns a SubList that has all elements in reversed order and also inserts reversed.
|
||||||
- Added: Iterators.infinite as an option that will create a Infinite Iterator based on the inputed one.
|
|
||||||
- Added: List.indexedIterator which allows you to create a iterator with a customized iteration indecies. Useful if you want to transform lists output.
|
|
||||||
- Added: PriorityQueue.contains is now a function
|
|
||||||
- Added: Iterators/Async Builders now support MapToPrimitiveType function on the object variant. So more processing can be done. (Will be expanded upon later versions)
|
|
||||||
- Fixed: SetValue wasn't working on forEach implementations.
|
- Fixed: SetValue wasn't working on forEach implementations.
|
||||||
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
- Fixed: Compute functions now perform with primitives more java compliant. Meaning that getDefaultReturnValue function no longer is seen as null.
|
||||||
- Fixed: Supplier was using the wrong dataType in their function name.
|
|
||||||
- Updated: SimpleCodeGenerator 1.3.0 is now being used which allows for iterative code support.
|
|
||||||
|
|
||||||
### Version 0.8.0
|
### Version 0.8.0
|
||||||
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
- Added: getFirst/getLast/removeFirst/removeLast to Lists
|
||||||
|
|||||||
@@ -30,13 +30,10 @@ There is 3 layers of control inside of the ModuleSettings.
|
|||||||
|
|
||||||
Allowing for greater control without having to edit hundreds of lines of code.
|
Allowing for greater control without having to edit hundreds of lines of code.
|
||||||
On top of that:
|
On top of that:
|
||||||
Any Setting that isn't "Present" can be defined as "Enabled" or "Disabled" using the "Default" argument.
|
Any Setting that isn't "Present" is counted as "Enabled".
|
||||||
If "Default" is missing, then it will just default to "Enabled".
|
|
||||||
So if you want to disable just 1 thing you can keep that 1 thing and delete the rest of the Setting.
|
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.
|
It will still work as the same.
|
||||||
The default settings just come with everything so you can see what is controllable.
|
The default settings just come with everything so you can see what is controllable.
|
||||||
Note: If a global Module setting is disabled but a dependency needs said Module, it will enable only the required classes.
|
|
||||||
If a Module type (Float-Collection as example) is specifically disabled, the Dependency Resolver will throw errors telling you whats wrong.
|
|
||||||
|
|
||||||
How to compile the Code with the ModuleSettings enabled:
|
How to compile the Code with the ModuleSettings enabled:
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
"Default": true,
|
|
||||||
"Async": true,
|
"Async": true,
|
||||||
"Base": true,
|
"Base": true,
|
||||||
"Collection": true,
|
"Collection": true,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||

|

|
||||||
[](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)
|
||||||

|

|
||||||

|

|
||||||
@@ -44,21 +43,14 @@ To ensure that problems can be dealt with even if it is breaking the current API
|
|||||||
|
|
||||||
# How to install
|
# How to install
|
||||||
Using Jitpack Gradle
|
Using Jitpack Gradle
|
||||||
```groovy
|
```gradle
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = "https://jitpack.io"
|
url = "https://jitpack.io"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.Speiger:Primitive-Collections:0.9.0'
|
implementation 'com.github.Speiger:Primitive-Collections:0.7.0'
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
Using Maven Central
|
|
||||||
```groovy
|
|
||||||
dependencies {
|
|
||||||
implementation 'io.github.speiger:Primitive-Collections:0.9.0'
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
Due to how the releases work, only the latest versions will be supported.
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
If you have discovered a security vulnerability in this project, please report it privately.
|
|
||||||
**Please refrain from posting in public issues.**
|
|
||||||
This gives me time to process issues that are being found, and reduces the possiblity of abuse while patches are being created.
|
|
||||||
Please disclose it [here](https://github.com/Speiger/Primitive-Collections/security/advisories/new).
|
|
||||||
|
|
||||||
Please consider that this project is developed by a single person.
|
|
||||||
So please provide a reasonable timeframe when reporting.
|
|
||||||
+26
-86
@@ -1,7 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
id "jacoco"
|
id "jacoco"
|
||||||
// id "com.vanniktech.maven.publish" version "0.28.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
@@ -11,7 +10,6 @@ tasks.withType(JavaCompile) {
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
apply plugin: 'signing'
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -21,17 +19,12 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = RELEASE_VERSION;
|
version = '0.8.0';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
System.out.println("Java Version: "+compileJava.sourceCompatibility)
|
System.out.println("Java Version: "+compileJava.sourceCompatibility)
|
||||||
|
|
||||||
java {
|
|
||||||
withJavadocJar()
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
options.tags = [ "implSpec", "note" ]
|
options.tags = [ "implSpec", "note" ]
|
||||||
}
|
}
|
||||||
@@ -53,7 +46,7 @@ configurations {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderImplementation 'com.google.code.gson:gson:2.10'
|
builderImplementation 'com.google.code.gson:gson:2.10'
|
||||||
builderImplementation 'de.speiger:Simple-Code-Generator:1.3.0'
|
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'
|
||||||
|
|
||||||
@@ -106,12 +99,26 @@ task generateLimitSource(type: JavaExec) {
|
|||||||
args = ['silent', 'load']
|
args = ['silent', 'load']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar) {
|
||||||
|
from javadoc
|
||||||
|
archiveClassifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
task srcJar(type: Jar) {
|
||||||
|
from sourceSets.main.allSource
|
||||||
|
archiveClassifier = 'sources'
|
||||||
|
}
|
||||||
|
|
||||||
compileJava.dependsOn generateGithubSource
|
compileJava.dependsOn generateGithubSource
|
||||||
|
|
||||||
javadoc.failOnError = false
|
javadoc.failOnError = false
|
||||||
javadoc.options.memberLevel = JavadocMemberLevel.PUBLIC
|
javadoc.options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
javadoc.options.quiet()
|
javadoc.options.quiet()
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives javadocJar
|
||||||
|
archives srcJar
|
||||||
|
}
|
||||||
|
|
||||||
task testBooleans(type: Test) {
|
task testBooleans(type: Test) {
|
||||||
group 'tests'
|
group 'tests'
|
||||||
@@ -261,10 +268,13 @@ jacocoTestReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
Properties props = new Properties()
|
||||||
|
if(file("$buildDir/credentials.properties").exists()) {
|
||||||
|
props.load(new FileInputStream("$buildDir/credentials.properties"))
|
||||||
|
}
|
||||||
publications {
|
publications {
|
||||||
personal(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
pom {
|
pom {
|
||||||
name = 'Primitive Collections'
|
name = 'Primitive Collections'
|
||||||
description = 'A Primitive Collection library that reduces memory usage and improves performance'
|
description = 'A Primitive Collection library that reduces memory usage and improves performance'
|
||||||
@@ -273,6 +283,8 @@ publishing {
|
|||||||
artifactId = project.archivesBaseName.replace(" ", "-")
|
artifactId = project.archivesBaseName.replace(" ", "-")
|
||||||
groupId = 'de.speiger'
|
groupId = 'de.speiger'
|
||||||
from components.java
|
from components.java
|
||||||
|
artifact tasks.srcJar
|
||||||
|
artifact tasks.javadocJar
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name = 'The Apache License, Version 2.0'
|
name = 'The Apache License, Version 2.0'
|
||||||
@@ -297,83 +309,11 @@ publishing {
|
|||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = "Speiger_Maven"
|
|
||||||
def auth = System.getenv("Speiger_Maven_Auth")?.split(';');
|
|
||||||
url version.endsWith('SNAPSHOT') ? "https://maven.speiger.com/repository/debug" : "https://maven.speiger.com/repository/main"
|
url version.endsWith('SNAPSHOT') ? "https://maven.speiger.com/repository/debug" : "https://maven.speiger.com/repository/main"
|
||||||
credentials(PasswordCredentials) {
|
credentials(PasswordCredentials) {
|
||||||
username auth?[0]
|
username props.mavenUser
|
||||||
password auth?[1]
|
password props.mavenPassword
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(PublishToMavenRepository) {
|
|
||||||
def predicate = provider {
|
|
||||||
(repository == publishing.repositories.mavenCentral && publication == publishing.publications.maven) ||
|
|
||||||
(repository != publishing.repositories.mavenCentral && publication != publishing.publications.maven)
|
|
||||||
}
|
|
||||||
onlyIf("publishing binary to the external repository, or binary and sources to the internal one") {
|
|
||||||
predicate.get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(PublishToMavenLocal) {
|
|
||||||
def predicate = provider {
|
|
||||||
publication == publishing.publications.personal
|
|
||||||
}
|
|
||||||
onlyIf("publishing binary and sources") {
|
|
||||||
predicate.get()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Maven central Start
|
|
||||||
//Disabling due to java8 incompat, only needed to manually publishing anyways
|
|
||||||
|
|
||||||
//signing.useGpgCmd()
|
|
||||||
//
|
|
||||||
//import com.vanniktech.maven.publish.SonatypeHost
|
|
||||||
//import com.vanniktech.maven.publish.JavaLibrary
|
|
||||||
//import com.vanniktech.maven.publish.JavadocJar
|
|
||||||
//
|
|
||||||
//mavenPublishing {
|
|
||||||
// configure(new JavaLibrary(new JavadocJar.None(), true))
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//mavenPublishing {
|
|
||||||
// publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
|
|
||||||
//
|
|
||||||
// signAllPublications()
|
|
||||||
// pom {
|
|
||||||
// name = 'Primitive Collections'
|
|
||||||
// description = 'A Primitive Collection library that reduces memory usage and improves performance'
|
|
||||||
// url = 'https://github.com/Speiger/Primitive-Collections'
|
|
||||||
// version = project.version
|
|
||||||
// group = 'io.github.speiger'
|
|
||||||
// licenses {
|
|
||||||
// license {
|
|
||||||
// name = 'The Apache License, Version 2.0'
|
|
||||||
// url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// developers {
|
|
||||||
// developer {
|
|
||||||
// id = 'speiger'
|
|
||||||
// name = 'Speiger'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// scm {
|
|
||||||
// connection = 'scm:git:git://github.com/Speiger/Primitive-Collections.git'
|
|
||||||
// developerConnection = 'scm:git:ssh://github.com:Speiger/Primitive-Collections.git'
|
|
||||||
// url = 'https://github.com/Speiger/Primitive-Collections'
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// issueManagement {
|
|
||||||
// system = 'github'
|
|
||||||
// url = 'https://github.com/Speiger/Primitive-Collections/issues'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
|
||||||
maxMemory = 1024m
|
maxMemory = 1024m
|
||||||
testThreads = 4
|
testThreads = 2
|
||||||
|
|
||||||
RELEASE_VERSION = 0.9.0
|
|
||||||
@@ -45,19 +45,23 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
SettingsManager manager = new SettingsManager();
|
SettingsManager manager = new SettingsManager();
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder() {
|
public PrimitiveCollectionsBuilder()
|
||||||
|
{
|
||||||
this(false);
|
this(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess) {
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess)
|
||||||
|
{
|
||||||
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
super(silencedSuccess, Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder) {
|
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||||
|
{
|
||||||
this(false, sourceFolder, outputFolder, dataFolder);
|
this(false, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder) {
|
public PrimitiveCollectionsBuilder(boolean silencedSuccess, Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||||
|
{
|
||||||
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
super(silencedSuccess, sourceFolder, outputFolder, dataFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,24 +88,42 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isFileValid(Path fileName) { return true; }
|
protected boolean isFileValid(Path fileName)
|
||||||
@Override
|
{
|
||||||
protected boolean relativePackages() { return true; }
|
return true;
|
||||||
@Override
|
}
|
||||||
protected boolean debugUnusedMappers() { return false; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterFinish() {
|
protected boolean relativePackages()
|
||||||
if((flags & SPECIAL) == 0 && getVersion() > 8) {
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean debugUnusedMappers()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void afterFinish()
|
||||||
|
{
|
||||||
|
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")))
|
||||||
|
{
|
||||||
writer.write(getModuleInfo(basePath));
|
writer.write(getModuleInfo(basePath));
|
||||||
}
|
}
|
||||||
catch(Exception e) { e.printStackTrace(); }
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BaseModule> createModules() {
|
public List<BaseModule> createModules()
|
||||||
|
{
|
||||||
List<BaseModule> modules = new ArrayList<>();
|
List<BaseModule> modules = new ArrayList<>();
|
||||||
modules.add(JavaModule.INSTANCE);
|
modules.add(JavaModule.INSTANCE);
|
||||||
modules.add(FunctionModule.INSTANCE);
|
modules.add(FunctionModule.INSTANCE);
|
||||||
@@ -117,32 +139,38 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init()
|
||||||
|
{
|
||||||
prepPackages();
|
prepPackages();
|
||||||
//Init Modules here
|
//Init Modules here
|
||||||
addModules(createModules());
|
addModules(createModules());
|
||||||
finishPackages();
|
finishPackages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addModules(List<BaseModule> modules) {
|
public void addModules(List<BaseModule> modules)
|
||||||
|
{
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
modules.get(i).setManager(manager);
|
modules.get(i).setManager(manager);
|
||||||
}
|
}
|
||||||
manager.resolve();
|
|
||||||
for(int i = 0,m=modules.size();i<m;i++) {
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
biPackages.forEach(modules.get(i)::init);
|
biPackages.forEach(modules.get(i)::init);
|
||||||
}
|
}
|
||||||
modules.forEach(BaseModule::cleanup);
|
for(int i = 0,m=modules.size();i<m;i++) {
|
||||||
|
modules.get(i).cleanup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishPackages() {
|
private void finishPackages()
|
||||||
|
{
|
||||||
biPackages.forEach(ModulePackage::finish);
|
biPackages.forEach(ModulePackage::finish);
|
||||||
if((flags & SAVE) != 0) manager.save();
|
if((flags & SAVE) != 0) manager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepPackages() {
|
private void prepPackages()
|
||||||
|
{
|
||||||
if((flags & LOAD) != 0) manager.load();
|
if((flags & LOAD) != 0) manager.load();
|
||||||
for(ModulePackage entry : ModulePackage.createPackages(globalFlags)) {
|
for(ModulePackage entry : ModulePackage.createPackages(globalFlags))
|
||||||
|
{
|
||||||
entry.setRequirements(requirements::put);
|
entry.setRequirements(requirements::put);
|
||||||
biPackages.add(entry);
|
biPackages.add(entry);
|
||||||
if(entry.isSame()) simplePackages.add(entry);
|
if(entry.isSame()) simplePackages.add(entry);
|
||||||
@@ -151,9 +179,11 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createProcesses(String fileName, Consumer<TemplateProcess> process) {
|
public void createProcesses(String fileName, Consumer<TemplateProcess> process)
|
||||||
|
{
|
||||||
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
List<ModulePackage> packages = getPackagesByRequirement(requirements.get(fileName));
|
||||||
for(int i = 0,m=packages.size();i<m;i++) {
|
for(int i = 0,m=packages.size();i<m;i++)
|
||||||
|
{
|
||||||
packages.get(i).process(fileName, process);
|
packages.get(i).process(fileName, process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -167,7 +197,8 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
|
|
||||||
private String getModuleInfo(Path basePath) {
|
private String getModuleInfo(Path basePath) {
|
||||||
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
StringJoiner joiner = new StringJoiner("\n", "", "\n");
|
||||||
try(Stream<Path> stream = Files.walk(getOutputFolder())) {
|
try(Stream<Path> stream = Files.walk(getOutputFolder()))
|
||||||
|
{
|
||||||
stream.filter(Files::isDirectory)
|
stream.filter(Files::isDirectory)
|
||||||
.filter(this::containsFiles)
|
.filter(this::containsFiles)
|
||||||
.map(basePath::relativize)
|
.map(basePath::relativize)
|
||||||
@@ -175,7 +206,8 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
.map(this::sanitize)
|
.map(this::sanitize)
|
||||||
.forEach(T -> joiner.add("\texports "+T+";"));
|
.forEach(T -> joiner.add("\texports "+T+";"));
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -186,26 +218,34 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sanitize(String input) {
|
private String sanitize(String input)
|
||||||
|
{
|
||||||
return input.replace("\\", ".").replace("/", ".");
|
return input.replace("\\", ".").replace("/", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsFiles(Path path) {
|
private boolean containsFiles(Path path)
|
||||||
try(Stream<Path> stream = Files.walk(path, 1)) {
|
{
|
||||||
|
try(Stream<Path> stream = Files.walk(path, 1))
|
||||||
|
{
|
||||||
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
return stream.filter(Files::isRegularFile).findFirst().isPresent();
|
||||||
}
|
}
|
||||||
catch(Exception e) { e.printStackTrace(); }
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getVersion() {
|
private int getVersion()
|
||||||
|
{
|
||||||
String version = System.getProperty("java.version");
|
String version = System.getProperty("java.version");
|
||||||
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
if(version.startsWith("1.")) return Integer.parseInt(version.substring(2, 3));
|
||||||
int dot = version.indexOf(".");
|
int dot = version.indexOf(".");
|
||||||
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
return Integer.parseInt(dot != -1 ? version.substring(0, dot) : version);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String...args) {
|
public static void main(String...args)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
Set<String> flags = new HashSet<>(Arrays.asList(args));
|
||||||
|
|||||||
@@ -1,100 +1,54 @@
|
|||||||
package speiger.src.builder;
|
package speiger.src.builder;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.internal.Streams;
|
import com.google.gson.internal.Streams;
|
||||||
import com.google.gson.stream.JsonWriter;
|
import com.google.gson.stream.JsonWriter;
|
||||||
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency.LoadingState;
|
|
||||||
import speiger.src.builder.modules.BaseModule;
|
import speiger.src.builder.modules.BaseModule;
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SettingsManager
|
public class SettingsManager
|
||||||
{
|
{
|
||||||
boolean loaded;
|
boolean loaded;
|
||||||
Map<String, LoadingState> parsedData = new TreeMap<>();
|
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
Set<String> moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
Set<String> moduleNames = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
Set<IDependency> allDependencies = new LinkedHashSet<>();
|
|
||||||
|
|
||||||
public void resolve() {
|
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType) {
|
||||||
if(!loaded) return;
|
if(!loaded) return true;
|
||||||
Set<IDependency> roots = new LinkedHashSet<>();
|
if(!isEnabled(data, base.getModuleName())) return false;
|
||||||
Set<IDependency> leafs = new LinkedHashSet<>();
|
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||||
for(IDependency entry : allDependencies) {
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
if(entry.isRoot()) {
|
if(base.isBiModule()) {
|
||||||
roots.add(entry);
|
result = getObject(result, valueType.getClassPath(), false);
|
||||||
}
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
if(entry.isLeaf()) {
|
|
||||||
leafs.add(entry);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
result = getObject(result, base.getModuleName(), false);
|
||||||
* This has to be 2 iteration passes.
|
return (result.size() <= 0 || isEnabled(result, "Enabled")) && base.areDependenciesLoaded();
|
||||||
* Due to Key Value Pairs, first pass does all initials keys, and the second pass processes the values.
|
}
|
||||||
* May require more passes but extremely unlikely
|
|
||||||
*/
|
public boolean isModuleEnabled(BaseModule base, ClassType keyType, ClassType valueType, String entry)
|
||||||
for(int i = 0;i<2;i++) {
|
{
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
if(!loaded) return true;
|
||||||
for(ClassType valueType : ModulePackage.TYPE) {
|
if(!isEnabled(data, base.getModuleName())) return false;
|
||||||
for(IDependency entry : roots) {
|
JsonObject result = getObject(data, keyType.getClassPath(), false);
|
||||||
entry.resolveRequirements(keyType, valueType);
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
}
|
if(base.isBiModule()) {
|
||||||
}
|
result = getObject(result, valueType.getClassPath(), false);
|
||||||
}
|
if(!isEnabled(result, "Enabled")) return false;
|
||||||
}
|
|
||||||
|
|
||||||
List<String> errors = new ArrayList<>();
|
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
|
||||||
for(ClassType valueType : ModulePackage.TYPE) {
|
|
||||||
for(IDependency entry : leafs) {
|
|
||||||
entry.validateDependency(errors::add, keyType, valueType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(errors.size() > 0) {
|
|
||||||
throw new IllegalStateException("Issues with dependencies found: "+String.join("\n", errors));
|
|
||||||
}
|
}
|
||||||
|
result = getObject(result, base.getModuleName(), false);
|
||||||
|
return (result.size() <= 0 || (isEnabled(result, "Enabled") && isEnabled(result, entry))) && base.areDependenciesLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addModule(BaseModule module) {
|
public void addModule(BaseModule module) {
|
||||||
if(loaded) {
|
if(loaded) return;
|
||||||
if(module.isBiModule()) {
|
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
|
||||||
for(ClassType valueType : ModulePackage.TYPE) {
|
|
||||||
if(!module.isModuleValid(keyType, valueType)) continue;
|
|
||||||
for(IDependency dependency : module.getDependencies(keyType, valueType)) {
|
|
||||||
dependency.set(parsedData);
|
|
||||||
allDependencies.add(dependency);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
|
||||||
if(!module.isModuleValid(keyType, keyType)) continue;
|
|
||||||
for(IDependency dependency : module.getDependencies(keyType, keyType)) {
|
|
||||||
dependency.set(parsedData);
|
|
||||||
allDependencies.add(dependency);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String moduleName = module.getModuleName();
|
String moduleName = module.getModuleName();
|
||||||
moduleNames.add(moduleName);
|
moduleNames.add(moduleName);
|
||||||
data.addProperty(moduleName, true);
|
data.addProperty(moduleName, true);
|
||||||
@@ -103,9 +57,9 @@ public class SettingsManager
|
|||||||
for(ClassType valueType : ModulePackage.TYPE) {
|
for(ClassType valueType : ModulePackage.TYPE) {
|
||||||
if(!module.isModuleValid(keyType, valueType)) continue;
|
if(!module.isModuleValid(keyType, valueType)) continue;
|
||||||
JsonObject obj = new JsonObject();
|
JsonObject obj = new JsonObject();
|
||||||
for(IDependency dependency : module.getDependencies(keyType, valueType)) {
|
obj.addProperty("Enabled", true);
|
||||||
String key = dependency.getName();
|
for(String key : module.getModuleKeys(keyType, valueType)) {
|
||||||
if(key != null) obj.addProperty(key, true);
|
obj.addProperty(key, true);
|
||||||
}
|
}
|
||||||
addModule(keyType, valueType, true, moduleName, obj);
|
addModule(keyType, valueType, true, moduleName, obj);
|
||||||
}
|
}
|
||||||
@@ -115,61 +69,18 @@ public class SettingsManager
|
|||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
for(ClassType keyType : ModulePackage.TYPE) {
|
||||||
if(!module.isModuleValid(keyType, keyType)) continue;
|
if(!module.isModuleValid(keyType, keyType)) continue;
|
||||||
JsonObject obj = new JsonObject();
|
JsonObject obj = new JsonObject();
|
||||||
for(IDependency dependency : module.getDependencies(keyType, keyType)) {
|
obj.addProperty("Enabled", true);
|
||||||
String key = dependency.getName();
|
for(String key : module.getModuleKeys(keyType, keyType)) {
|
||||||
if(key != null) obj.addProperty(key, true);
|
obj.addProperty(key, true);
|
||||||
}
|
}
|
||||||
addModule(keyType, keyType, false, moduleName, obj);
|
addModule(keyType, keyType, false, moduleName, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printModuleSettings(List<BaseModule> modules) {
|
|
||||||
JsonObject data = new JsonObject();
|
|
||||||
for(BaseModule module : modules) {
|
|
||||||
String moduleName = module.getModuleName();
|
|
||||||
if(module.isBiModule()) {
|
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
|
||||||
for(ClassType valueType : ModulePackage.TYPE) {
|
|
||||||
if(!module.isModuleValid(keyType, valueType)) continue;
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
for(IDependency dependency : module.getDependencies(keyType, valueType)) {
|
|
||||||
String key = dependency.getName();
|
|
||||||
if(key != null) obj.addProperty(key, dependency.isLoaded(keyType, valueType).getJsonResult());
|
|
||||||
}
|
|
||||||
addModule(data, keyType, valueType, true, moduleName, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for(ClassType keyType : ModulePackage.TYPE) {
|
|
||||||
if(!module.isModuleValid(keyType, keyType)) continue;
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
for(IDependency dependency : module.getDependencies(keyType, keyType)) {
|
|
||||||
String key = dependency.getName();
|
|
||||||
if(key != null) obj.addProperty(key, dependency.isLoaded(keyType, keyType).getJsonResult());
|
|
||||||
}
|
|
||||||
addModule(data, keyType, keyType, false, moduleName, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
System.out.println();
|
|
||||||
JsonWriter writer = new JsonWriter(new OutputStreamWriter(System.out));
|
|
||||||
writer.setIndent("\t");
|
|
||||||
Streams.write(data, writer);
|
|
||||||
writer.flush();
|
|
||||||
System.out.println();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
try(BufferedReader reader = Files.newBufferedReader(Paths.get("ModulSettings.json"))) {
|
try(BufferedReader reader = Files.newBufferedReader(Paths.get("ModulSettings.json"))) {
|
||||||
data = JsonParser.parseReader(reader).getAsJsonObject();
|
data = JsonParser.parseReader(reader).getAsJsonObject();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
IDependency.flatten("", false, data, parsedData);
|
|
||||||
JsonElement element = data.get("Default");
|
|
||||||
LoadingState.setOptionalResolver(LoadingState.of(element == null ? true : element.getAsBoolean()));
|
|
||||||
}
|
}
|
||||||
catch(Exception e) { e.printStackTrace(); }
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
}
|
}
|
||||||
@@ -189,14 +100,6 @@ public class SettingsManager
|
|||||||
catch(Exception e) { e.printStackTrace(); }
|
catch(Exception e) { e.printStackTrace(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addModule(JsonObject data, 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 void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) {
|
private void addModule(ClassType keyType, ClassType valueType, boolean bi, String moduleName, JsonObject obj) {
|
||||||
JsonObject result = getObject(data, keyType.getClassPath(), true);
|
JsonObject result = getObject(data, keyType.getClassPath(), true);
|
||||||
if(bi) {
|
if(bi) {
|
||||||
@@ -214,4 +117,9 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isEnabled(JsonObject obj, String key) {
|
||||||
|
if(obj.has(key)) return obj.getAsJsonPrimitive(key).getAsBoolean();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,137 +0,0 @@
|
|||||||
package speiger.src.builder.dependencies;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
import speiger.src.builder.dependencies.Requirements.Requirement;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public abstract class BaseDependency implements IDependency {
|
|
||||||
protected static boolean FETCH_FAILURES = false;
|
|
||||||
protected static Set<String> FAILURE_KEYS = new TreeSet<>();
|
|
||||||
|
|
||||||
protected final String name;
|
|
||||||
protected final boolean biType;
|
|
||||||
protected Map<String, LoadingState> dependencies;
|
|
||||||
protected List<IDependency> children = new ArrayList<>();
|
|
||||||
protected List<Requirement> requirements = new ArrayList<>();
|
|
||||||
protected ClassType keyType;
|
|
||||||
protected ClassType valueType;
|
|
||||||
|
|
||||||
public BaseDependency(String name, boolean biType) {
|
|
||||||
this.name = name;
|
|
||||||
this.biType = biType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(Map<String, LoadingState> dependency) {
|
|
||||||
dependencies = dependency;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IDependency addDependency(Requirement require) {
|
|
||||||
requirements.add(require);
|
|
||||||
require.dependency.addChild(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addChild(IDependency child) {
|
|
||||||
children.add(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLeaf() {
|
|
||||||
return children.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRoot() {
|
|
||||||
return requirements.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LoadingState getGlobalState() {
|
|
||||||
return dependencies.getOrDefault(name, LoadingState.OPTIONAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLocalStateKey(ClassType keyType, ClassType valueType) {
|
|
||||||
return (biType ? keyType.getClassPath()+"-"+valueType.getClassPath() : keyType.getClassPath())+"-"+name;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LoadingState getLocalState(ClassType keyType, ClassType valueType) {
|
|
||||||
return dependencies.getOrDefault(getLocalStateKey(keyType, valueType), LoadingState.OPTIONAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected LoadingState getReqirementState(ClassType keyType, ClassType valueType) {
|
|
||||||
LoadingState state = requirements.isEmpty() ? LoadingState.REQUIRED : LoadingState.OPTIONAL;
|
|
||||||
for(int i = 0,m=requirements.size();i<m;i++) {
|
|
||||||
state = state.merge(requirements.get(i).test(keyType, valueType));
|
|
||||||
}
|
|
||||||
return state.resolveIfUndefined();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resolveRequirements(ClassType keyType, ClassType valueType) {
|
|
||||||
if(!children.isEmpty()) {
|
|
||||||
for(IDependency child : children) {
|
|
||||||
if(child == this) continue;
|
|
||||||
child.resolveRequirements(keyType, valueType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(getLocalState(keyType, valueType) == LoadingState.REQUIRED) {
|
|
||||||
for(Requirement req : requirements) {
|
|
||||||
dependencies.putIfAbsent(req.key(keyType, valueType), LoadingState.REQUIRED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateDependency(Consumer<String> result, ClassType keyType, ClassType valueType) {
|
|
||||||
if(getLocalState(keyType, valueType) == LoadingState.REQUIRED) {
|
|
||||||
FETCH_FAILURES = true;
|
|
||||||
for(Requirement req : requirements) {
|
|
||||||
req.test(keyType, valueType);
|
|
||||||
}
|
|
||||||
FETCH_FAILURES = false;
|
|
||||||
if(FAILURE_KEYS.size() > 0) {
|
|
||||||
int size = FAILURE_KEYS.size();
|
|
||||||
StringJoiner joiner = new StringJoiner("], [", "[", "]");
|
|
||||||
FAILURE_KEYS.forEach(joiner::add);
|
|
||||||
FAILURE_KEYS.clear();
|
|
||||||
String joins = size > 1 ? "["+joiner.toString()+"]" : joiner.toString();
|
|
||||||
|
|
||||||
result.accept("["+getLocalStateKey(keyType, valueType)+"] Requires "+joins+" but it specifically has been disabled!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(ClassType key, ClassType value) {
|
|
||||||
this.keyType = key;
|
|
||||||
this.valueType = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
if(keyType == null || keyType == null) return false;
|
|
||||||
return isLoaded(keyType, valueType).getJsonResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package speiger.src.builder.dependencies;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FunctionDependency extends BaseDependency {
|
|
||||||
ModuleDependency owner;
|
|
||||||
|
|
||||||
public FunctionDependency(ModuleDependency owner, String name) {
|
|
||||||
super(name, owner.biType);
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoadingState isLoaded(ClassType key, ClassType value) {
|
|
||||||
if(dependencies == null) return LoadingState.REQUIRED;
|
|
||||||
LoadingState result = getLocalState(key, value);
|
|
||||||
if(FETCH_FAILURES && result == LoadingState.REJECTED) {
|
|
||||||
FAILURE_KEYS.add(getLocalStateKey(key, value));
|
|
||||||
}
|
|
||||||
return result.resolveIfUndefined().merge(getReqirementState(key, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getLocalStateKey(ClassType keyType, ClassType valueType) {
|
|
||||||
return (biType ? keyType.getClassPath()+"-"+valueType.getClassPath() : keyType.getClassPath())+"-"+owner.getName()+"-"+name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
package speiger.src.builder.dependencies;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
import speiger.src.builder.dependencies.Requirements.Requirement;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public interface IDependency {
|
|
||||||
|
|
||||||
|
|
||||||
public void set(Map<String, LoadingState> dependency);
|
|
||||||
public void set(ClassType key, ClassType value);
|
|
||||||
public LoadingState isLoaded(ClassType key, ClassType value);
|
|
||||||
public String getLocalStateKey(ClassType keyType, ClassType valueType);
|
|
||||||
public boolean isEnabled();
|
|
||||||
public boolean isLeaf();
|
|
||||||
public boolean isRoot();
|
|
||||||
|
|
||||||
public String getName();
|
|
||||||
public void validateDependency(Consumer<String> result, ClassType keyType, ClassType valueType);
|
|
||||||
public void resolveRequirements(ClassType keyType, ClassType valueType);
|
|
||||||
|
|
||||||
public void addChild(IDependency child);
|
|
||||||
public <T extends IDependency> T addDependency(Requirement require);
|
|
||||||
public default <T extends IDependency> T addKeyDependency(IDependency dependency) { return addDependency(new Requirement(dependency, Requirements.KEY_TEST, Requirements.KEY_GETTER)); }
|
|
||||||
public default <T extends IDependency> T addValueDependency(IDependency dependency) { return addDependency(new Requirement(dependency, Requirements.VALUE_TEST, Requirements.VALUE_GETTER)); }
|
|
||||||
public default <T extends IDependency> T addEntryDependency(IDependency dependency) { return addDependency(new Requirement(dependency, Requirements.ENTRY_TEST, Requirements.ENTRY_GETTER)); }
|
|
||||||
public default <T extends IDependency> T addTypeDependency(IDependency dependency, ClassType type) { return addDependency(new Requirement(dependency, Requirements.typedTest(type), Requirements.typedKey(type))); }
|
|
||||||
public default <T extends IDependency> T addOptionalTypeDependency(IDependency dependency, ClassType type, boolean key) { return addDependency(new Requirement(dependency, Requirements.optionalTest(type, key), Requirements.optionalKey(type, key))); }
|
|
||||||
public default <T extends IDependency> T addOptionalTypeDependency(ClassType type, boolean key) { return addDependency(new Requirement(this, Requirements.optionalTest(type, key), Requirements.optionalKey(type, key))); }
|
|
||||||
|
|
||||||
|
|
||||||
public static void flatten(String prefix, boolean applyMiddle, JsonObject object, Map<String, LoadingState> result) {
|
|
||||||
if(applyMiddle) prefix+="-";
|
|
||||||
for(Entry<String, JsonElement> entry : object.entrySet()) {
|
|
||||||
String key = entry.getKey();
|
|
||||||
JsonElement value = entry.getValue();
|
|
||||||
if(value instanceof JsonPrimitive) {
|
|
||||||
String entryKey = prefix+key;
|
|
||||||
if("Enabled".equalsIgnoreCase(key)) {
|
|
||||||
entryKey = prefix.substring(0, prefix.length()-1);
|
|
||||||
}
|
|
||||||
result.put(entryKey, LoadingState.of(((JsonPrimitive)value).getAsBoolean()));
|
|
||||||
}
|
|
||||||
if(value instanceof JsonObject) {
|
|
||||||
flatten(prefix+key, true, (JsonObject)value, result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum LoadingState {
|
|
||||||
OPTIONAL,
|
|
||||||
REQUIRED,
|
|
||||||
REJECTED;
|
|
||||||
|
|
||||||
private static LoadingState RESOLVED = LoadingState.REQUIRED;
|
|
||||||
|
|
||||||
public static LoadingState of(boolean value) {
|
|
||||||
return value ? REQUIRED : REJECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState merge(LoadingState merge) {
|
|
||||||
return ordinal() > merge.ordinal() ? this : merge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState replaceIfUndefined(LoadingState state) {
|
|
||||||
return this == OPTIONAL ? state : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState resolveIfUndefined() {
|
|
||||||
return this == OPTIONAL ? RESOLVED : this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState mergeDown(LoadingState merge) {
|
|
||||||
if(merge == REJECTED || ordinal() > merge.ordinal()) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return merge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState mergeUp(LoadingState merge) {
|
|
||||||
if(merge == REQUIRED || ordinal() > merge.ordinal()) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
return merge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setOptionalResolver(LoadingState state) {
|
|
||||||
RESOLVED = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getJsonResult() {
|
|
||||||
LoadingState state = this == OPTIONAL ? RESOLVED : this;
|
|
||||||
return state == REQUIRED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package speiger.src.builder.dependencies;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
import speiger.src.builder.modules.BaseModule;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class ModuleDependency extends BaseDependency {
|
|
||||||
BaseModule owner;
|
|
||||||
|
|
||||||
public ModuleDependency(BaseModule owner, boolean biType) {
|
|
||||||
super(owner.getModuleName(), biType);
|
|
||||||
this.owner = owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FunctionDependency createDependency(String name) {
|
|
||||||
FunctionDependency result = new FunctionDependency(this, name);
|
|
||||||
if(biType) result.addEntryDependency(this);
|
|
||||||
else result.addKeyDependency(this);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoadingState isLoaded(ClassType key, ClassType value) {
|
|
||||||
if(dependencies == null) return LoadingState.REQUIRED;
|
|
||||||
LoadingState result = getLocalState(key, value);
|
|
||||||
if(FETCH_FAILURES && result == LoadingState.REJECTED) {
|
|
||||||
FAILURE_KEYS.add(getLocalStateKey(key, value));
|
|
||||||
}
|
|
||||||
return result.replaceIfUndefined(getGlobalState()).resolveIfUndefined().merge(getReqirementState(key, value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package speiger.src.builder.dependencies;
|
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
import speiger.src.builder.dependencies.IDependency.LoadingState;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class Requirements {
|
|
||||||
public static final RequirementTest KEY_TEST = (T, K, V) -> T.isLoaded(K, K);
|
|
||||||
public static final RequirementTest VALUE_TEST = (T, K, V) -> T.isLoaded(V, V);
|
|
||||||
public static final RequirementTest ENTRY_TEST = (T, K, V) -> T.isLoaded(K, V);
|
|
||||||
|
|
||||||
public static RequirementTest typedTest(ClassType type) {
|
|
||||||
return (T, K, V) -> T.isLoaded(type, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RequirementTest optionalTest(ClassType type, boolean key) {
|
|
||||||
return (T, K, V) -> (key ? K : V) != type ? T.isLoaded(type, type) : LoadingState.REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final RequirementKey KEY_GETTER = (T, K, V) -> T.getLocalStateKey(K, K);
|
|
||||||
public static final RequirementKey VALUE_GETTER = (T, K, V) -> T.getLocalStateKey(V, V);
|
|
||||||
public static final RequirementKey ENTRY_GETTER = (T, K, V) -> T.getLocalStateKey(K, V);
|
|
||||||
|
|
||||||
public static RequirementKey typedKey(ClassType type) {
|
|
||||||
return (T, K, V) -> T.getLocalStateKey(type, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RequirementKey optionalKey(ClassType type, boolean key) {
|
|
||||||
return (T, K, V) -> (key ? K : V) != type ? T.getLocalStateKey(type, type) : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface RequirementTest {
|
|
||||||
public LoadingState test(IDependency test, ClassType keyType, ClassType valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface RequirementKey {
|
|
||||||
public String key(IDependency test, ClassType keyType, ClassType valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static interface RequirementResolver {
|
|
||||||
public void resolve(IDependency test, Consumer<String> result, ClassType keyType, ClassType valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Requirement {
|
|
||||||
IDependency dependency;
|
|
||||||
RequirementTest test;
|
|
||||||
RequirementKey key;
|
|
||||||
|
|
||||||
public Requirement(IDependency dependency, RequirementTest test, RequirementKey key) {
|
|
||||||
this.dependency = dependency;
|
|
||||||
this.test = test;
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LoadingState test(ClassType keyType, ClassType valueType) {
|
|
||||||
return test.test(dependency, keyType, valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String key(ClassType keyType, ClassType valueType) {
|
|
||||||
return key.key(dependency, keyType, valueType);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class AsyncModule extends BaseModule
|
public class AsyncModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new AsyncModule();
|
public static final BaseModule INSTANCE = new AsyncModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(JavaModule.MODULE);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Async"; }
|
public String getModuleName() { return "Async"; }
|
||||||
@@ -24,16 +16,16 @@ public class AsyncModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
protected void loadFunctions() {}
|
protected void loadFunctions() {}
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE); }
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(CollectionModule.INSTANCE); }
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades() {
|
protected void loadBlockades() {
|
||||||
if(!MODULE.isEnabled()) {
|
if(!isModuleEnabled()) {
|
||||||
addBlockedFiles("AsyncBuilder", "Task");
|
addBlockedFiles("AsyncBuilder", "Task");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags() {
|
protected void loadFlags() {
|
||||||
if(MODULE.isEnabled()) {
|
if(isModuleEnabled()) {
|
||||||
addKeyFlag("ASYNC_MODULE");
|
addKeyFlag("ASYNC_MODULE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.ModulePackage;
|
import speiger.src.builder.ModulePackage;
|
||||||
import speiger.src.builder.RequiredType;
|
import speiger.src.builder.RequiredType;
|
||||||
import speiger.src.builder.SettingsManager;
|
import speiger.src.builder.SettingsManager;
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.mappers.ArgumentMapper;
|
import speiger.src.builder.mappers.ArgumentMapper;
|
||||||
import speiger.src.builder.mappers.InjectMapper;
|
import speiger.src.builder.mappers.InjectMapper;
|
||||||
import speiger.src.builder.mappers.LineMapper;
|
import speiger.src.builder.mappers.LineMapper;
|
||||||
@@ -32,9 +30,6 @@ public abstract class BaseModule
|
|||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
keyType = entry.getKeyType();
|
keyType = entry.getKeyType();
|
||||||
valueType = entry.getValueType();
|
valueType = entry.getValueType();
|
||||||
for(IDependency dependency : getDependencies(keyType, valueType)) {
|
|
||||||
dependency.set(keyType, valueType);
|
|
||||||
}
|
|
||||||
loadVariables();
|
loadVariables();
|
||||||
loadClasses();
|
loadClasses();
|
||||||
loadTestClasses();
|
loadTestClasses();
|
||||||
@@ -61,11 +56,28 @@ public abstract class BaseModule
|
|||||||
|
|
||||||
public abstract String getModuleName();
|
public abstract String getModuleName();
|
||||||
public boolean isBiModule() { return false; }
|
public boolean isBiModule() { return false; }
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Collections.emptyList(); }
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return Collections.emptySet(); }
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return true; }
|
||||||
|
|
||||||
public ClassType keyType() { return keyType; }
|
protected boolean isModuleEnabled() {
|
||||||
public ClassType valueType() { return valueType; }
|
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) {
|
protected void addFlag(String name) {
|
||||||
entry.addFlag(name);
|
entry.addFlag(name);
|
||||||
@@ -190,9 +202,4 @@ public abstract class BaseModule
|
|||||||
entry.addMapper(mapper);
|
entry.addMapper(mapper);
|
||||||
return mapper;
|
return mapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T make(T input, Consumer<T> processor) {
|
|
||||||
processor.accept(input);
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,59 +1,52 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class CollectionModule extends BaseModule
|
public class CollectionModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new CollectionModule();
|
public static final BaseModule INSTANCE = new CollectionModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false)
|
|
||||||
.addKeyDependency(FunctionModule.MODULE)
|
|
||||||
.addOptionalTypeDependency(FunctionModule.MODULE, ClassType.OBJECT, true)
|
|
||||||
.addOptionalTypeDependency(FunctionModule.MODULE, ClassType.INT, true)
|
|
||||||
.addOptionalTypeDependency(ClassType.OBJECT, true);
|
|
||||||
public static final FunctionDependency STREAMS = MODULE.createDependency("Streams");
|
|
||||||
public static final FunctionDependency SPLIT_ITERATORS = MODULE.createDependency("Splititerators").addKeyDependency(STREAMS);
|
|
||||||
public static final FunctionDependency IARRAY = MODULE.createDependency("IArray");
|
|
||||||
public static final FunctionDependency STRATEGY = MODULE.createDependency("Strategy");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Collection"; }
|
public String getModuleName() { return "Collection"; }
|
||||||
@Override
|
@Override
|
||||||
protected void loadVariables() {}
|
protected void loadVariables() {}
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE, STREAMS, SPLIT_ITERATORS, IARRAY, STRATEGY); }
|
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
|
@Override
|
||||||
protected void loadFlags() {
|
protected void loadFlags() {
|
||||||
if(MODULE.isEnabled()) addKeyFlag("COLLECTION_MODULE");
|
if(isModuleEnabled()) addKeyFlag("COLLECTION_MODULE");
|
||||||
if(STREAMS.isEnabled()) addKeyFlag("STREAM_FEATURE");
|
if(isModuleEnabled("Streams")) addKeyFlag("STREAM_FEATURE");
|
||||||
if(SPLIT_ITERATORS.isEnabled()) addKeyFlag("SPLIT_ITERATOR_FEATURE");
|
if(isModuleEnabled("Splititerators")) addKeyFlag("SPLIT_ITERATOR_FEATURE");
|
||||||
if(IARRAY.isEnabled()) addKeyFlag("IARRAY_FEATURE");
|
if(isModuleEnabled("IArray")) addKeyFlag("IARRAY_FEATURE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades() {
|
protected void loadBlockades() {
|
||||||
if(!MODULE.isEnabled()) {
|
if(!isModuleEnabled()) {
|
||||||
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
||||||
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
|
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
|
||||||
}
|
}
|
||||||
if(!SPLIT_ITERATORS.isEnabled()) addBlockedFiles("Splititerator", "Splititerators");
|
if(!isModuleEnabled("Splititerators")) addBlockedFiles("Splititerator", "Splititerators");
|
||||||
if(!IARRAY.isEnabled()) addBlockedFiles("IArray");
|
if(!isModuleEnabled("IArray")) addBlockedFiles("IArray");
|
||||||
if(!STRATEGY.isEnabled()) addBlockedFiles("Strategy");
|
if(!isModuleEnabled("Strategy")) addBlockedFiles("Strategy");
|
||||||
|
|
||||||
if(keyType.isObject())
|
if(keyType.isObject()) {
|
||||||
{
|
|
||||||
addBlockedFiles("Stack");
|
addBlockedFiles("Stack");
|
||||||
addBlockedFiles("CollectionStreamTester");
|
addBlockedFiles("CollectionStreamTester");
|
||||||
}
|
}
|
||||||
if(keyType == ClassType.BOOLEAN)
|
if(keyType == ClassType.BOOLEAN) {
|
||||||
{
|
|
||||||
addBlockedFiles("CollectionRemoveIfTester", "CollectionStreamTester");
|
addBlockedFiles("CollectionRemoveIfTester", "CollectionStreamTester");
|
||||||
addBlockedFilter(T -> T.endsWith("Tester") && T.startsWith("Iterable"));
|
addBlockedFilter(T -> T.endsWith("Tester") && T.startsWith("Iterable"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.RequiredType;
|
import speiger.src.builder.RequiredType;
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class FunctionModule extends BaseModule
|
public class FunctionModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new FunctionModule();
|
public static final BaseModule INSTANCE = new FunctionModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(JavaModule.MODULE);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Function"; }
|
public String getModuleName() { return "Function"; }
|
||||||
@@ -25,16 +19,10 @@ public class FunctionModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
protected void loadTestClasses() {}
|
protected void loadTestClasses() {}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
|
|
||||||
return Arrays.asList(MODULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
if(keyType.isObject()) addBlockedFiles("Consumer", "Comparator");
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Function", "UnaryOperator");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -66,8 +54,8 @@ public class FunctionModule extends BaseModule
|
|||||||
protected void loadFunctions()
|
protected void loadFunctions()
|
||||||
{
|
{
|
||||||
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
addSimpleMapper("APPLY", keyType.getApply(valueType));
|
||||||
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getNonFileType());
|
addSimpleMapper("SUPPLY_GET", keyType.isObject() ? "get" : "getAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getNonFileType());
|
addSimpleMapper("VALUE_SUPPLY_GET", valueType.isObject() ? "get" : "getAs"+valueType.getCustomJDKType().getNonFileType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class JavaModule extends BaseModule
|
public class JavaModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new JavaModule();
|
public static final BaseModule INSTANCE = new JavaModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Base"; }
|
public String getModuleName() { return "Base"; }
|
||||||
@@ -23,11 +17,6 @@ public class JavaModule extends BaseModule
|
|||||||
loadBaseVariables();
|
loadBaseVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
|
|
||||||
return Arrays.asList(MODULE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags()
|
protected void loadFlags()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,57 +1,55 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ListModule extends BaseModule
|
public class ListModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new ListModule();
|
public static final BaseModule INSTANCE = new ListModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(CollectionModule.MODULE).addKeyDependency(CollectionModule.SPLIT_ITERATORS);
|
|
||||||
public static final FunctionDependency IMPLEMENTATION = MODULE.createDependency("Implementations");
|
|
||||||
public static final FunctionDependency WRAPPERS = MODULE.createDependency("Wrappers");
|
|
||||||
public static final FunctionDependency ARRAY_LIST = MODULE.createDependency("ArrayList").addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency LINKED_LIST = MODULE.createDependency("LinkedList").addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency IMMUTABLE_LIST = MODULE.createDependency("ImmutableList").addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency COPY_ON_WRITE_LIST = MODULE.createDependency("CopyOnWriteList").addKeyDependency(IMPLEMENTATION);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "List"; }
|
public String getModuleName() { return "List"; }
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE, IMPLEMENTATION, WRAPPERS, ARRAY_LIST, LINKED_LIST, IMMUTABLE_LIST, COPY_ON_WRITE_LIST); }
|
|
||||||
@Override
|
|
||||||
protected void loadVariables() {}
|
protected void loadVariables() {}
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags() {
|
protected void loadFlags() {
|
||||||
if(MODULE.isEnabled()) addKeyFlag("LIST_MODULE");
|
if(isModuleEnabled()) addKeyFlag("LIST_MODULE");
|
||||||
if(WRAPPERS.isEnabled()) addKeyFlag("LISTS_FEATURE");
|
if(isModuleEnabled("Wrappers")) addKeyFlag("LISTS_FEATURE");
|
||||||
if(ARRAY_LIST.isEnabled()) addKeyFlag("ARRAY_LIST_FEATURE");
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
if(LINKED_LIST.isEnabled()) addKeyFlag("LINKED_LIST_FEATURE");
|
if(implementations && isModuleEnabled("ArrayList")) addKeyFlag("ARRAY_LIST_FEATURE");
|
||||||
if(IMMUTABLE_LIST.isEnabled()) addKeyFlag("IMMUTABLE_LIST_FEATURE");
|
if(implementations && isModuleEnabled("LinkedList")) addKeyFlag("LINKED_LIST_FEATURE");
|
||||||
if(COPY_ON_WRITE_LIST.isEnabled()) addKeyFlag("COPY_ON_WRITE_LIST_FEATURE");
|
if(implementations && isModuleEnabled("ImmutableList")) addKeyFlag("IMMUTABLE_LIST_FEATURE");
|
||||||
|
if(implementations && isModuleEnabled("CopyOnWriteList")) addKeyFlag("COPY_ON_WRITE_LIST_FEATURE");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(!WRAPPERS.isEnabled()) addBlockedFiles("Lists");
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Lists");
|
||||||
if(!ARRAY_LIST.isEnabled()) addBlockedFiles("ArrayList");
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
if(!LINKED_LIST.isEnabled()) addBlockedFiles("LinkedList");
|
if(implementations || !isModuleEnabled("ArrayList")) addBlockedFiles("ArrayList");
|
||||||
if(!IMMUTABLE_LIST.isEnabled()) addBlockedFiles("ImmutableList");
|
if(implementations || !isModuleEnabled("LinkedList")) addBlockedFiles("LinkedList");
|
||||||
if(!COPY_ON_WRITE_LIST.isEnabled()) addBlockedFiles("CopyOnWriteList");
|
if(implementations || !isModuleEnabled("ImmutableList")) addBlockedFiles("ImmutableList");
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("List", "AbstractList");
|
if(implementations || !isModuleEnabled("CopyOnWriteList")) addBlockedFiles("CopyOnWriteList");
|
||||||
|
if(!isModuleEnabled()) addBlockedFiles("List", "AbstractList");
|
||||||
|
|
||||||
if(keyType.isObject()) addBlockedFiles("ListFillBufferTester");
|
if(keyType.isObject()) addBlockedFiles("ListFillBufferTester");
|
||||||
if(keyType == ClassType.BOOLEAN) addBlockedFiles("ListFillBufferTester", "ListReplaceAllTester");
|
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
|
@Override
|
||||||
protected void loadRemappers()
|
protected void loadRemappers()
|
||||||
|
|||||||
@@ -1,44 +1,15 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class MapModule extends BaseModule
|
public class MapModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new MapModule();
|
public static final BaseModule INSTANCE = new MapModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, true)
|
|
||||||
.addKeyDependency(SetModule.MODULE)
|
|
||||||
.addValueDependency(CollectionModule.MODULE)
|
|
||||||
.addEntryDependency(SetModule.MODULE)
|
|
||||||
.addTypeDependency(SetModule.MODULE, ClassType.OBJECT);
|
|
||||||
public static final FunctionDependency IMPLEMENTATION = MODULE.createDependency("Implementations");
|
|
||||||
public static final FunctionDependency WRAPPERS = MODULE.createDependency("Wrappers").addKeyDependency(SetModule.WRAPPERS).addOptionalTypeDependency(SetModule.WRAPPERS, ClassType.OBJECT, true);
|
|
||||||
|
|
||||||
public static final FunctionDependency ORDERED_MAP = MODULE.createDependency("OrderedMap").addKeyDependency(SetModule.ORDERED_SET).addOptionalTypeDependency(SetModule.ORDERED_SET, ClassType.OBJECT, true);
|
|
||||||
public static final FunctionDependency SORTED_MAP = MODULE.createDependency("SortedMap").addKeyDependency(SetModule.SORTED_SET).addOptionalTypeDependency(SetModule.SORTED_SET, ClassType.OBJECT, true);
|
|
||||||
|
|
||||||
public static final FunctionDependency ARRAY_MAP = MODULE.createDependency("ArrayMap").addEntryDependency(ORDERED_MAP).addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency IMMUTABLE_MAP = MODULE.createDependency("ImmutableMap").addEntryDependency(IMPLEMENTATION);
|
|
||||||
|
|
||||||
public static final FunctionDependency HASH_MAP = MODULE.createDependency("HashMap").addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency LINKED_MAP = MODULE.createDependency("LinkedHashMap").addEntryDependency(HASH_MAP).addEntryDependency(ORDERED_MAP);
|
|
||||||
|
|
||||||
public static final FunctionDependency CUSTOM_MAP = MODULE.createDependency("CustomHashMap").addEntryDependency(IMPLEMENTATION).addKeyDependency(CollectionModule.STRATEGY);
|
|
||||||
public static final FunctionDependency LINKED_CUSTOM_MAP = MODULE.createDependency("LinkedCustomHashMap").addEntryDependency(CUSTOM_MAP).addEntryDependency(ORDERED_MAP);
|
|
||||||
|
|
||||||
public static final FunctionDependency ENUM_MAP = MODULE.createDependency("EnumMap").addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency LINKED_ENUM_MAP = MODULE.createDependency("LinkedEnumMap").addEntryDependency(ENUM_MAP).addEntryDependency(ORDERED_MAP);
|
|
||||||
|
|
||||||
public static final FunctionDependency CONCURRENT_MAP = MODULE.createDependency("ConcurrentMap").addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency AVL_TREE_MAP = MODULE.createDependency("AVLTreeMap").addEntryDependency(SORTED_MAP).addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency RB_TREE_MAP = MODULE.createDependency("RBTreeMap").addEntryDependency(SORTED_MAP).addEntryDependency(IMPLEMENTATION);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Map"; }
|
public String getModuleName() { return "Map"; }
|
||||||
@@ -49,52 +20,79 @@ public class MapModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
|
public boolean areDependenciesLoaded() { return isDependencyLoaded(SetModule.INSTANCE) && isDependencyLoaded(CollectionModule.INSTANCE, false); }
|
||||||
List<IDependency> dependencies = new ArrayList<>(Arrays.asList(MODULE, ORDERED_MAP, SORTED_MAP, IMPLEMENTATION, WRAPPERS, ARRAY_MAP, IMMUTABLE_MAP, HASH_MAP, LINKED_MAP, CUSTOM_MAP, LINKED_CUSTOM_MAP, CONCURRENT_MAP, AVL_TREE_MAP, RB_TREE_MAP));
|
|
||||||
if(keyType == ClassType.OBJECT) dependencies.addAll(Arrays.asList(ENUM_MAP, LINKED_ENUM_MAP));
|
@Override
|
||||||
return dependencies;
|
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
|
@Override
|
||||||
protected void loadFlags()
|
protected void loadFlags()
|
||||||
{
|
{
|
||||||
if(MODULE.isEnabled()) addFlag("MAP_MODULE");
|
if(isModuleEnabled()) addFlag("MAP_MODULE");
|
||||||
if(WRAPPERS.isEnabled()) addFlag("MAPS_FEATURE");
|
if(isModuleEnabled("Wrappers")) addFlag("MAPS_FEATURE");
|
||||||
if(ORDERED_MAP.isEnabled()) addFlag("ORDERED_MAP_FEATURE");
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
if(ARRAY_MAP.isEnabled()) addFlag("ARRAY_MAP_FEATURE");
|
boolean hashMap = implementations && isModuleEnabled("HashMap");
|
||||||
if(LINKED_MAP.isEnabled()) addFlag("LINKED_MAP_FEATURE");
|
boolean customHashMap = implementations && isModuleEnabled("CustomHashMap");
|
||||||
if(LINKED_CUSTOM_MAP.isEnabled()) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
boolean enumMap = implementations && isModuleEnabled("EnumMap");
|
||||||
if(LINKED_ENUM_MAP.isEnabled()) addFlag("LINKED_ENUM_MAP_FEATURE");
|
|
||||||
|
|
||||||
if(SORTED_MAP.isEnabled()) addFlag("SORTED_MAP_FEATURE");
|
if(isModuleEnabled("OrderedMap")) {
|
||||||
if(AVL_TREE_MAP.isEnabled()) addFlag("AVL_TREE_MAP_FEATURE");
|
addFlag("ORDERED_MAP_FEATURE");
|
||||||
if(RB_TREE_MAP.isEnabled()) addFlag("RB_TREE_MAP_FEATURE");
|
if(isModuleEnabled("ArrayMap")) addFlag("ARRAY_MAP_FEATURE");
|
||||||
|
if(hashMap && isModuleEnabled("LinkedHashMap")) addFlag("LINKED_MAP_FEATURE");
|
||||||
if(CONCURRENT_MAP.isEnabled()) addFlag("CONCURRENT_MAP_FEATURE");
|
if(customHashMap && isModuleEnabled("LinkedCustomHashMap")) addFlag("LINKED_CUSTOM_MAP_FEATURE");
|
||||||
if(IMMUTABLE_MAP.isEnabled()) addFlag("IMMUTABLE_MAP_FEATURE");
|
if(enumMap && isModuleEnabled("LinkedEnumMap")) addFlag("LINKED_ENUM_MAP_FEATURE");
|
||||||
if(HASH_MAP.isEnabled()) addFlag("MAP_FEATURE");
|
}
|
||||||
if(CUSTOM_MAP.isEnabled()) addFlag("CUSTOM_MAP_FEATURE");
|
if(isModuleEnabled("SortedMap")) {
|
||||||
if(ENUM_MAP.isEnabled()) addFlag("ENUM_MAP_FEATURE");
|
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
|
@Override
|
||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("Map", "AbstractMap");
|
if(!isModuleEnabled()) addBlockedFiles("Map", "AbstractMap");
|
||||||
if(!WRAPPERS.isEnabled()) addBlockedFiles("Maps");
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Maps");
|
||||||
if(!IMMUTABLE_MAP.isEnabled()) addBlockedFiles("ImmutableOpenHashMap");
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
if(!CONCURRENT_MAP.isEnabled()) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
if(implementations || !isModuleEnabled("ImmutableMap")) addBlockedFiles("ImmutableOpenHashMap");
|
||||||
if(!ORDERED_MAP.isEnabled()) addBlockedFiles("OrderedMap");
|
if(implementations || !isModuleEnabled("ConcurrentMap")) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
if(!HASH_MAP.isEnabled()) addBlockedFiles("OpenHashMap");
|
|
||||||
if(!LINKED_MAP.isEnabled()) addBlockedFiles("LinkedOpenHashMap");
|
boolean ordered = !isModuleEnabled("OrderedMap");
|
||||||
if(!CUSTOM_MAP.isEnabled()) addBlockedFiles("OpenCustomHashMap");
|
if(ordered) addBlockedFiles("OrderedMap");
|
||||||
if(!LINKED_CUSTOM_MAP.isEnabled()) addBlockedFiles("LinkedOpenCustomHashMap");
|
boolean hashMap = implementations || !isModuleEnabled("HashMap");
|
||||||
if(!ENUM_MAP.isEnabled()) addBlockedFiles("EnumMap");
|
if(hashMap) addBlockedFiles("OpenHashMap");
|
||||||
if(!LINKED_ENUM_MAP.isEnabled()) addBlockedFiles("LinkedEnumMap");
|
if(hashMap || ordered || !isModuleEnabled("LinkedHashMap")) addBlockedFiles("LinkedOpenHashMap");
|
||||||
if(!ARRAY_MAP.isEnabled()) addBlockedFiles("ArrayMap");
|
|
||||||
if(!SORTED_MAP.isEnabled()) addBlockedFiles("SortedMap", "NavigableMap");
|
boolean customHashMap = implementations || !isModuleEnabled("CustomHashMap");
|
||||||
if(!AVL_TREE_MAP.isEnabled()) addBlockedFiles("AVLTreeMap");
|
if(customHashMap) addBlockedFiles("OpenCustomHashMap");
|
||||||
if(!RB_TREE_MAP.isEnabled()) addBlockedFiles("RBTreeMap");
|
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)
|
if(keyType == ClassType.BOOLEAN)
|
||||||
{
|
{
|
||||||
@@ -110,9 +108,6 @@ public class MapModule extends BaseModule
|
|||||||
addBlockedFiles("TestOrderedMapGenerator");
|
addBlockedFiles("TestOrderedMapGenerator");
|
||||||
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
addBlockedFilter(T -> T.endsWith("Tester") && (T.startsWith("Map") || T.startsWith("OrderedMap") || T.startsWith("SortedMap") || T.startsWith("NavigableMap")));
|
||||||
}
|
}
|
||||||
if(valueType == ClassType.OBJECT) {
|
|
||||||
addBlockedFiles("MapComputeIfAbsentNonDefaultTester", "MapComputeIfPresentNonDefaultTester", "MapComputeNonDefaultTester", "MapSupplyIfAbsentNonDefaultTester");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -163,9 +158,6 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("MapComputeIfAbsentTester");
|
addBiRequirement("MapComputeIfAbsentTester");
|
||||||
addBiRequirement("MapComputeIfPresentTester");
|
addBiRequirement("MapComputeIfPresentTester");
|
||||||
addBiRequirement("MapComputeTester");
|
addBiRequirement("MapComputeTester");
|
||||||
addBiRequirement("MapComputeIfAbsentNonDefaultTester");
|
|
||||||
addBiRequirement("MapComputeIfPresentNonDefaultTester");
|
|
||||||
addBiRequirement("MapComputeNonDefaultTester");
|
|
||||||
addBiRequirement("MapCopyTester");
|
addBiRequirement("MapCopyTester");
|
||||||
addBiRequirement("MapContainsTester");
|
addBiRequirement("MapContainsTester");
|
||||||
addBiRequirement("MapContainsKeyTester");
|
addBiRequirement("MapContainsKeyTester");
|
||||||
@@ -192,7 +184,6 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("MapReplaceTester");
|
addBiRequirement("MapReplaceTester");
|
||||||
addBiRequirement("MapSizeTester");
|
addBiRequirement("MapSizeTester");
|
||||||
addBiRequirement("MapSupplyIfAbsentTester");
|
addBiRequirement("MapSupplyIfAbsentTester");
|
||||||
addBiRequirement("MapSupplyIfAbsentNonDefaultTester");
|
|
||||||
addBiRequirement("MapToStringTester");
|
addBiRequirement("MapToStringTester");
|
||||||
addBiRequirement("NavigableMapNavigationTester");
|
addBiRequirement("NavigableMapNavigationTester");
|
||||||
addBiRequirement("SortedMapNavigationTester");
|
addBiRequirement("SortedMapNavigationTester");
|
||||||
|
|||||||
@@ -1,26 +1,15 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class PairModule extends BaseModule
|
public class PairModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new PairModule();
|
public static final BaseModule INSTANCE = new PairModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, true).addKeyDependency(JavaModule.MODULE);
|
|
||||||
public static final FunctionDependency IMMUTABLE = MODULE.createDependency("Immutable");
|
|
||||||
public static final FunctionDependency MUTABLE = MODULE.createDependency("Mutable");
|
|
||||||
|
|
||||||
|
|
||||||
// public static final DependencyModule MODULE = new BiTypeModule(INSTANCE);
|
|
||||||
// public static final DependencyFunction IMMUTABLE = MODULE.createFunction("Immutable");
|
|
||||||
// public static final DependencyFunction MUTABLE = MODULE.createFunction("Mutable");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Pair"; }
|
public String getModuleName() { return "Pair"; }
|
||||||
@Override
|
@Override
|
||||||
@@ -32,20 +21,20 @@ public class PairModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
protected void loadTestClasses() {}
|
protected void loadTestClasses() {}
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE, IMMUTABLE, MUTABLE); }
|
public Set<String> getModuleKeys(ClassType keyType, ClassType valueType) { return new TreeSet<>(Arrays.asList("Mutable", "Immutable")); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadFlags() {
|
protected void loadFlags() {
|
||||||
if(MODULE.isEnabled()) addFlag("PAIR_MODULE");
|
if(isModuleEnabled()) addFlag("PAIR_MODULE");
|
||||||
if(MUTABLE.isEnabled()) addFlag("MUTABLE_PAIR");
|
if(isModuleEnabled("Mutable")) addFlag("MUTABLE_PAIR");
|
||||||
if(IMMUTABLE.isEnabled()) addFlag("IMMUTABLE_PAIR");
|
if(isModuleEnabled("Immutable")) addFlag("IMMUTABLE_PAIR");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadBlockades() {
|
protected void loadBlockades() {
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("Pair");
|
if(!isModuleEnabled()) addBlockedFiles("Pair");
|
||||||
if(!MUTABLE.isEnabled()) addBlockedFiles("MutablePair");
|
if(!isModuleEnabled("Mutable")) addBlockedFiles("MutablePair");
|
||||||
if(!IMMUTABLE.isEnabled()) addBlockedFiles("ImmutablePair");
|
if(!isModuleEnabled("Immutable")) addBlockedFiles("ImmutablePair");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,26 +1,15 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class PrioQueueModule extends BaseModule
|
public class PrioQueueModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new PrioQueueModule();
|
public static final BaseModule INSTANCE = new PrioQueueModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(CollectionModule.MODULE);
|
|
||||||
public static final FunctionDependency IMPLEMENTATION = MODULE.createDependency("Implementations");
|
|
||||||
public static final FunctionDependency WRAPPERS = MODULE.createDependency("Wrappers");
|
|
||||||
public static final FunctionDependency DEQUEUE = MODULE.createDependency("Dequeue");
|
|
||||||
|
|
||||||
public static final FunctionDependency FIFO_QUEUE = MODULE.createDependency("FiFoQueue").addKeyDependency(DEQUEUE).addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency HEAP_QUEUE = MODULE.createDependency("HeapQueue").addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency ARRAY_PRIO_QUEUE = MODULE.createDependency("ArrayPrioQueue").addKeyDependency(IMPLEMENTATION);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "PriorityQueue"; }
|
public String getModuleName() { return "PriorityQueue"; }
|
||||||
@@ -29,26 +18,36 @@ public class PrioQueueModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
protected void loadFunctions() {}
|
protected void loadFunctions() {}
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE, WRAPPERS, IMPLEMENTATION, DEQUEUE, FIFO_QUEUE, HEAP_QUEUE, ARRAY_PRIO_QUEUE); }
|
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
|
@Override
|
||||||
protected void loadFlags() {
|
protected void loadFlags() {
|
||||||
if(MODULE.isEnabled()) addFlag("QUEUE_MODULE");
|
if(isModuleEnabled()) addFlag("QUEUE_MODULE");
|
||||||
if(WRAPPERS.isEnabled()) addKeyFlag("QUEUES_FEATURE");
|
if(isModuleEnabled("Wrappers")) addKeyFlag("QUEUES_FEATURE");
|
||||||
if(DEQUEUE.isEnabled()) addKeyFlag("DEQUEUE_FEATURE");
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
if(FIFO_QUEUE.isEnabled()) addKeyFlag("FIFO_QUEUE_FEATURE");
|
if(isModuleEnabled("Dequeue")) {
|
||||||
if(HEAP_QUEUE.isEnabled()) addKeyFlag("HEAP_QUEUE_FEATURE");
|
addKeyFlag("DEQUEUE_FEATURE");
|
||||||
if(ARRAY_PRIO_QUEUE.isEnabled()) addKeyFlag("ARRAY_QUEUE_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
|
@Override
|
||||||
protected void loadBlockades() {
|
protected void loadBlockades() {
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("PriorityQueue", "AbstractPriorityQueue");
|
if(!isModuleEnabled()) addBlockedFiles("PriorityQueue", "AbstractPriorityQueue");
|
||||||
if(!WRAPPERS.isEnabled()) addBlockedFiles("PriorityQueues");
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("PriorityQueues");
|
||||||
if(!DEQUEUE.isEnabled()) addBlockedFiles("PriorityDequeue");
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
if(!FIFO_QUEUE.isEnabled()) addBlockedFiles("ArrayFIFOQueue");
|
boolean dequeue = !isModuleEnabled("Dequeue");
|
||||||
if(!HEAP_QUEUE.isEnabled()) addBlockedFiles("HeapPriorityQueue");
|
if(dequeue) addBlockedFiles("PriorityDequeue");
|
||||||
if(!ARRAY_PRIO_QUEUE.isEnabled()) addBlockedFiles("ArrayPriorityQueue");
|
if(dequeue || implementations || !isModuleEnabled("FiFoQueue")) addBlockedFiles("ArrayFIFOQueue");
|
||||||
|
if(implementations || !isModuleEnabled("HeapQueue")) addBlockedFiles("HeapPriorityQueue");
|
||||||
|
if(implementations || !isModuleEnabled("ArrayPrioQueue")) addBlockedFiles("ArrayPriorityQueue");
|
||||||
|
|
||||||
if(keyType == ClassType.BOOLEAN) {
|
if(keyType == ClassType.BOOLEAN) {
|
||||||
addBlockedFiles("QueueTests");
|
addBlockedFiles("QueueTests");
|
||||||
|
|||||||
@@ -1,30 +1,15 @@
|
|||||||
package speiger.src.builder.modules;
|
package speiger.src.builder.modules;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import speiger.src.builder.ClassType;
|
import speiger.src.builder.ClassType;
|
||||||
import speiger.src.builder.dependencies.FunctionDependency;
|
|
||||||
import speiger.src.builder.dependencies.IDependency;
|
|
||||||
import speiger.src.builder.dependencies.ModuleDependency;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class SetModule extends BaseModule
|
public class SetModule extends BaseModule
|
||||||
{
|
{
|
||||||
public static final BaseModule INSTANCE = new SetModule();
|
public static final BaseModule INSTANCE = new SetModule();
|
||||||
public static final ModuleDependency MODULE = new ModuleDependency(INSTANCE, false).addKeyDependency(CollectionModule.MODULE).addKeyDependency(CollectionModule.SPLIT_ITERATORS);
|
|
||||||
public static final FunctionDependency IMPLEMENTATION = MODULE.createDependency("Implementations");
|
|
||||||
public static final FunctionDependency WRAPPERS = MODULE.createDependency("Wrappers");
|
|
||||||
public static final FunctionDependency ORDERED_SET = MODULE.createDependency("OrderedSet");
|
|
||||||
public static final FunctionDependency SORTED_SET = MODULE.createDependency("SortedSet");
|
|
||||||
public static final FunctionDependency ARRAY_SET = MODULE.createDependency("ArraySet").addKeyDependency(ORDERED_SET).addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency IMMUTABLE_SET = MODULE.createDependency("ImmutableSet").addKeyDependency(ORDERED_SET).addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency HASH_SET = MODULE.createDependency("HashSet").addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency LINKED_SET = MODULE.createDependency("LinkedHashSet").addKeyDependency(ORDERED_SET).addKeyDependency(HASH_SET);
|
|
||||||
public static final FunctionDependency CUSTOM_SET = MODULE.createDependency("CustomHashSet").addKeyDependency(IMPLEMENTATION).addKeyDependency(CollectionModule.STRATEGY);
|
|
||||||
public static final FunctionDependency LINKED_CUSTOM_SET = MODULE.createDependency("LinkedCustomHashSet").addKeyDependency(ORDERED_SET).addKeyDependency(CUSTOM_SET);
|
|
||||||
public static final FunctionDependency AVL_TREE_SET = MODULE.createDependency("AVLTreeSet").addKeyDependency(SORTED_SET).addKeyDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency RB_TREE_SET = MODULE.createDependency("RBTreeSet").addKeyDependency(SORTED_SET).addKeyDependency(IMPLEMENTATION);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getModuleName() { return "Set"; }
|
public String getModuleName() { return "Set"; }
|
||||||
@@ -34,40 +19,68 @@ public class SetModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
public boolean isModuleValid(ClassType keyType, ClassType valueType) { return keyType != ClassType.BOOLEAN; }
|
||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) { return Arrays.asList(MODULE, WRAPPERS, ORDERED_SET, SORTED_SET, IMPLEMENTATION, ARRAY_SET, IMMUTABLE_SET, HASH_SET, LINKED_SET, CUSTOM_SET, LINKED_CUSTOM_SET, AVL_TREE_SET, RB_TREE_SET); }
|
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
|
@Override
|
||||||
protected void loadFlags()
|
protected void loadFlags()
|
||||||
{
|
{
|
||||||
if(MODULE.isEnabled()) addFlag("SET_MODULE");
|
if(isModuleEnabled()) addFlag("SET_MODULE");
|
||||||
if(WRAPPERS.isEnabled()) addFlag("SETS_FEATURE");
|
if(isModuleEnabled("Wrappers")) addFlag("SETS_FEATURE");
|
||||||
if(ORDERED_SET.isEnabled()) addFlag("ORDERED_SET_FEATURE");
|
boolean implementations = isModuleEnabled("Implementations");
|
||||||
if(SORTED_SET.isEnabled()) addFlag("SORTED_SET_FEATURE");
|
boolean hashSet = implementations && isModuleEnabled("HashSet");
|
||||||
if(IMMUTABLE_SET.isEnabled()) addFlag("IMMUTABLE_SET_FEATURE");
|
boolean customHashSet = implementations && isModuleEnabled("CustomHashSet");
|
||||||
if(ARRAY_SET.isEnabled()) addFlag("ARRAY_SET_FEATURE");
|
|
||||||
if(HASH_SET.isEnabled()) addFlag("HASH_SET_FEATURE");
|
if(isModuleEnabled("OrderedSet")) {
|
||||||
if(LINKED_SET.isEnabled()) addFlag("LINKED_SET_FEATURE");
|
addFlag("ORDERED_SET_FEATURE");
|
||||||
if(CUSTOM_SET.isEnabled()) addFlag("CUSTOM_HASH_SET_FEATURE");
|
if(implementations && isModuleEnabled("ArraySet")) addFlag("ARRAY_SET_FEATURE");
|
||||||
if(LINKED_CUSTOM_SET.isEnabled()) addFlag("LINKED_CUSTOM_SET_FEATURE");
|
if(hashSet && isModuleEnabled("LinkedHashSet")) addFlag("LINKED_SET_FEATURE");
|
||||||
if(AVL_TREE_SET.isEnabled()) addFlag("AVL_TREE_SET_FEATURE");
|
if(customHashSet && isModuleEnabled("LinkedCustomHashSet")) addFlag("LINKED_CUSTOM_SET_FEATURE");
|
||||||
if(RB_TREE_SET.isEnabled()) addFlag("RB_TREE_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
|
@Override
|
||||||
protected void loadBlockades()
|
protected void loadBlockades()
|
||||||
{
|
{
|
||||||
if(!MODULE.isEnabled()) addBlockedFiles("Set", "AbstractSet");
|
if(!isModuleEnabled()) addBlockedFiles("Set", "AbstractSet");
|
||||||
if(!WRAPPERS.isEnabled()) addBlockedFiles("Sets");
|
if(!isModuleEnabled("Wrappers")) addBlockedFiles("Sets");
|
||||||
if(!IMMUTABLE_SET.isEnabled()) addBlockedFiles("ImmutableOpenHashSet");
|
boolean implementations = !isModuleEnabled("Implementations");
|
||||||
if(!ORDERED_SET.isEnabled()) addBlockedFiles("OrderedSet");
|
if(implementations || !isModuleEnabled("ImmutableSet")) addBlockedFiles("ImmutableOpenHashSet");
|
||||||
if(!HASH_SET.isEnabled()) addBlockedFiles("OpenHashSet");
|
|
||||||
if(!LINKED_SET.isEnabled()) addBlockedFiles("LinkedOpenHashSet");
|
boolean ordered = !isModuleEnabled("OrderedSet");
|
||||||
if(!CUSTOM_SET.isEnabled()) addBlockedFiles("OpenCustomHashSet");
|
if(ordered) addBlockedFiles("OrderedSet");
|
||||||
if(!LINKED_CUSTOM_SET.isEnabled()) addBlockedFiles("LinkedOpenCustomHashSet");
|
boolean hashSet = implementations || !isModuleEnabled("HashSet");
|
||||||
if(!ARRAY_SET.isEnabled()) addBlockedFiles("ArraySet");
|
if(hashSet) addBlockedFiles("OpenHashSet");
|
||||||
if(!SORTED_SET.isEnabled()) addBlockedFiles("SortedSet", "NavigableSet");
|
if(hashSet || ordered || !isModuleEnabled("LinkedHashSet")) addBlockedFiles("LinkedOpenHashSet");
|
||||||
if(!AVL_TREE_SET.isEnabled()) addBlockedFiles("AVLTreeSet");
|
|
||||||
if(!RB_TREE_SET.isEnabled()) addBlockedFiles("RBTreeSet");
|
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)
|
if(keyType == ClassType.BOOLEAN)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-2
@@ -1,11 +1,19 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link ObjectBidirectionalIterator} to reduce (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE, ObjectBidirectionalIterator<CLASS_TYPE>
|
||||||
|
#else
|
||||||
/**
|
/**
|
||||||
* This is a basically a {@link java.util.ListIterator} without the index functions.
|
* This is a basically a {@link java.util.ListIterator} without the index functions.
|
||||||
* Allowing to have a simple Bidirectional Iterator without having to keep track of the Iteration index.
|
* Allowing to have a simple Bidirectional Iterator without having to keep track of the Iteration index.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE
|
public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns true if the Iterator has a Previous element
|
* Returns true if the Iterator has a Previous element
|
||||||
@@ -21,11 +29,11 @@ public interface BI_ITERATOR KEY_GENERIC_TYPE extends ITERATOR KEY_GENERIC_TYPE
|
|||||||
public KEY_TYPE PREVIOUS();
|
public KEY_TYPE PREVIOUS();
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
* @return the Previous element of the iterator.+
|
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default CLASS_TYPE previous() {
|
public default CLASS_TYPE previous() {
|
||||||
return KEY_TO_OBJ(PREVIOUS());
|
return KEY_TO_OBJ(PREVIOUS());
|
||||||
|
|||||||
-32
@@ -16,19 +16,6 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#if BOOLEAN_COLLECTION_MODULE
|
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterable;
|
|
||||||
#endif
|
|
||||||
#iterate
|
|
||||||
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
|
||||||
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument PACKAGE bytes shorts ints longs floats doubles
|
|
||||||
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.MAPPER;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#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.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
@@ -178,25 +165,6 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
return ITERABLES.map(this, mapper);
|
return ITERABLES.map(this, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
|
||||||
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
/**
|
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
|
||||||
* @param mapper the mapping function
|
|
||||||
* @return a new Iterable that returns the desired result
|
|
||||||
*/
|
|
||||||
default OUTPUT_ITERABLE mapToDATA_TYPE(MAPPER<T> mapper) {
|
|
||||||
return ITERABLES.mapToDATA_TYPE(this, mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
* @param mapper the flatMapping function
|
* @param mapper the flatMapping function
|
||||||
|
|||||||
+3
-171
@@ -11,15 +11,8 @@ import java.util.RandomAccess;
|
|||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#endif
|
|
||||||
#if INT_LIST_MODULE && !TYPE_INT
|
|
||||||
import speiger.src.collections.ints.lists.IntList;
|
|
||||||
#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.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -243,25 +236,13 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
||||||
return listIterator(0);
|
return listIterator(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index) {
|
||||||
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
if(index < 0 || index > size()) throw new IndexOutOfBoundsException();
|
||||||
return new LIST_ITER(index);
|
return new LIST_ITER(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
|
||||||
return new IndexedIterator(indecies);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
|
||||||
return new ListIndexedIterator(indecies);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) {
|
public void size(int size) {
|
||||||
while(size > size()) add(EMPTY_KEY_VALUE);
|
while(size > size()) add(EMPTY_KEY_VALUE);
|
||||||
@@ -536,10 +517,9 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
#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) {
|
||||||
@@ -648,155 +628,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
private class ListIndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
|
||||||
IntList indecies;
|
|
||||||
int index;
|
|
||||||
int lastReturned = -1;
|
|
||||||
|
|
||||||
ListIndexedIterator(IntList indecies) {
|
|
||||||
this.indecies = indecies;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return index < indecies.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
int i = index++;
|
|
||||||
return GET_KEY((lastReturned = indecies.getInt(i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPrevious() {
|
|
||||||
return index > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE PREVIOUS() {
|
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
|
||||||
index--;
|
|
||||||
return GET_KEY((lastReturned = indecies.getInt(index)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int nextIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int previousIndex() {
|
|
||||||
return index-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(KEY_TYPE e) {
|
|
||||||
if(lastReturned == -1) throw new IllegalStateException();
|
|
||||||
ABSTRACT_LIST.this.set(lastReturned, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int skip(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
int steps = Math.min(amount, indecies.size() - index);
|
|
||||||
index += steps;
|
|
||||||
if(steps > 0) lastReturned = Math.min(index-1, indecies.size()-1);
|
|
||||||
return steps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
int steps = Math.min(amount, index);
|
|
||||||
index -= steps;
|
|
||||||
if(steps > 0) lastReturned = Math.max(index, 0);
|
|
||||||
return steps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
private class IndexedIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
|
||||||
int[] indecies;
|
|
||||||
int index;
|
|
||||||
int lastReturned = -1;
|
|
||||||
|
|
||||||
IndexedIterator(int[] indecies) {
|
|
||||||
this.indecies = indecies;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return index < indecies.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
int i = index++;
|
|
||||||
return GET_KEY((lastReturned = indecies[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPrevious() {
|
|
||||||
return index > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE PREVIOUS() {
|
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
|
||||||
index--;
|
|
||||||
return GET_KEY((lastReturned = indecies[index]));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int nextIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int previousIndex() {
|
|
||||||
return index-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void set(KEY_TYPE e) {
|
|
||||||
if(lastReturned == -1) throw new IllegalStateException();
|
|
||||||
ABSTRACT_LIST.this.set(lastReturned, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int skip(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
int steps = Math.min(amount, indecies.length - index);
|
|
||||||
index += steps;
|
|
||||||
if(steps > 0) lastReturned = Math.min(index-1, indecies.length-1);
|
|
||||||
return steps;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
int steps = Math.min(amount, index);
|
|
||||||
index -= steps;
|
|
||||||
if(steps > 0) lastReturned = Math.max(index, 0);
|
|
||||||
return steps;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class LIST_ITER implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
@@ -874,7 +706,7 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
int steps = Math.min(amount, index);
|
int steps = Math.min(amount, index);
|
||||||
index -= steps;
|
index -= steps;
|
||||||
if(steps > 0) lastReturned = Math.max(index, 0);
|
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-9
@@ -13,13 +13,11 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
import java.util.Spliterator.JAVA_SPLIT_ITERATOR;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.IntFunction;
|
import java.util.function.IntFunction;
|
||||||
@@ -62,14 +60,12 @@ 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;
|
||||||
#endif
|
#endif
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.stream.JAVA_STREAM;
|
import java.util.stream.JAVA_STREAM;
|
||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -419,8 +415,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
if(index == 0) return new ListIter(first, index);
|
if(index == 0) return new ListIter(first, index);
|
||||||
return new ListIter(getNode(index), index);
|
return new ListIter(getNode(index), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#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.
|
||||||
@@ -441,7 +436,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return new TypeSplitIteratorBRACES(this, first, 0); }
|
public SPLIT_ITERATOR KEY_GENERIC_TYPE spliterator() { return new TypeSplitIteratorBRACES(this, first, 0); }
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1259,7 +1253,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
private static class TypeSplitIterator KEY_GENERIC_TYPE implements SPLIT_ITERATOR KEY_GENERIC_TYPE
|
private static class TypeSplitIterator KEY_GENERIC_TYPE implements SPLIT_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
static final int BATCH_UNIT = 1 << 10;
|
static final int BATCH_UNIT = 1 << 10;
|
||||||
@@ -1404,5 +1397,4 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
@@ -15,9 +15,7 @@ import java.util.function.UnaryOperator;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
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;
|
||||||
@@ -26,12 +24,7 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
|||||||
#if LISTS_FEATURE
|
#if LISTS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
import speiger.src.collections.PACKAGE.utils.LISTS;
|
||||||
#endif
|
#endif
|
||||||
#if INT_LIST_MODULE && !TYPE_INT
|
|
||||||
import speiger.src.collections.ints.lists.IntList;
|
|
||||||
#endif
|
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#endif
|
|
||||||
#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;
|
||||||
#endif
|
#endif
|
||||||
@@ -432,26 +425,6 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index);
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator(int index);
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Iterator that follows the indecies provided.<br>
|
|
||||||
* For example if the Lists Contents is:<br> -1, 0 1 <br>and the indecies are: <br>0, 1, 2, 2, 1, 0<br>
|
|
||||||
* then the iterator will return the following values: <br>-1, 0, 1, 1, 0, -1
|
|
||||||
* @param indecies that should be used for the iteration.
|
|
||||||
* @return a custom indexed iterator
|
|
||||||
*/
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies);
|
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
/**
|
|
||||||
* Creates a Iterator that follows the indecies provided.<br>
|
|
||||||
* For example if the Lists Contents is:<br> -1, 0 1 <br>and the indecies are: <br>0, 1, 2, 2, 1, 0<br>
|
|
||||||
* then the iterator will return the following values: <br>-1, 0, 1, 1, 0, -1
|
|
||||||
* @param indecies that should be used for the iteration.
|
|
||||||
* @return a custom indexed iterator
|
|
||||||
*/
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific List of subList
|
* A Type-Specific List of subList
|
||||||
* @see java.util.List#subList(int, int)
|
* @see java.util.List#subList(int, int)
|
||||||
@@ -598,12 +571,10 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#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
|
||||||
*/
|
*/
|
||||||
@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
|
|
||||||
}
|
}
|
||||||
+44
-46
@@ -218,6 +218,22 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
VALUE_TYPE value = GET_VALUE(key);
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
||||||
|
remove(key);
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
return getDefaultReturnValue();
|
||||||
|
}
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -241,6 +257,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -264,6 +294,20 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
VALUE_TYPE value;
|
||||||
|
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -287,51 +331,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
VALUE_TYPE value = GET_VALUE(key);
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
if(VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key)) {
|
|
||||||
remove(key);
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
VALUE_TYPE value;
|
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
VALUE_TYPE value;
|
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -347,7 +346,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
+91
-95
@@ -518,34 +518,19 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).compute(hash, key, mappingFunction);
|
return getSegment(hash).compute(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int hash = getHashCode(key);
|
|
||||||
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
int hash = getHashCode(key);
|
int hash = getHashCode(key);
|
||||||
return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
|
return getSegment(hash).computeNonDefault(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).computeIfAbsent(hash, key, mappingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
@@ -554,6 +539,13 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
|
return getSegment(hash).computeIfAbsentNonDefault(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).supplyIfAbsent(hash, key, valueProvider);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -561,6 +553,13 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
|
return getSegment(hash).supplyIfAbsentNonDefault(hash, key, valueProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int hash = getHashCode(key);
|
||||||
|
return getSegment(hash).computeIfPresent(hash, key, mappingFunction);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -568,7 +567,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
|
return getSegment(hash).computeIfPresentNonDefault(hash, key, mappingFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -2271,6 +2269,29 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE computeNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfAbsent(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE computeIfAbsent(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@@ -2297,7 +2318,30 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
unlockWrite(stamp);
|
unlockWrite(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE computeIfAbsentNonDefault(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE supplyIfAbsent(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
protected VALUE_TYPE supplyIfAbsent(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@@ -2324,76 +2368,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
unlockWrite(stamp);
|
unlockWrite(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfPresent(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index < 0) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VALUE_TYPE computeNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
protected VALUE_TYPE computeIfAbsentNonDefault(int hash, KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
long stamp = writeLock();
|
|
||||||
try {
|
|
||||||
int index = findIndex(hash, key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
unlockWrite(stamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VALUE_TYPE supplyIfAbsentNonDefault(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
protected VALUE_TYPE supplyIfAbsentNonDefault(int hash, KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
@@ -2418,6 +2392,29 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected VALUE_TYPE computeIfPresent(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
long stamp = writeLock();
|
||||||
|
try {
|
||||||
|
int index = findIndex(hash, key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index < 0) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
unlockWrite(stamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected VALUE_TYPE computeIfPresentNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE computeIfPresentNonDefault(int hash, KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
@@ -2436,7 +2433,6 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
protected VALUE_TYPE merge(int hash, KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
protected VALUE_TYPE merge(int hash, KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
long stamp = writeLock();
|
long stamp = writeLock();
|
||||||
try {
|
try {
|
||||||
|
|||||||
+58
-60
@@ -554,6 +554,25 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -576,7 +595,26 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
#endif
|
#endif
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -600,64 +638,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index < 0) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -677,6 +657,25 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index < 0) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -691,7 +690,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
+58
-60
@@ -513,7 +513,26 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
values[index] = newValue;
|
values[index] = newValue;
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -537,6 +556,25 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index < 0) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insert(-index-1, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -559,64 +597,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
#endif
|
#endif
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index < 0) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
@@ -637,6 +617,25 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index < 0) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index < 0 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -651,7 +650,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
+7
-8
@@ -493,22 +493,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
|||||||
+61
-63
@@ -512,6 +512,25 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index == -1) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
insertIndex(size++, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -534,68 +553,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
#endif
|
#endif
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index == -1) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
#if VALUE_OBJECT
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
#endif
|
|
||||||
insertIndex(size++, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
#if VALUE_OBJECT
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = valueProvider.VALUE_SUPPLY_GET();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(index == -1) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index == -1) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insertIndex(size++, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeIndex(index);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
@@ -616,6 +573,29 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
|
Objects.requireNonNull(valueProvider);
|
||||||
|
int index = findIndex(key);
|
||||||
|
if(index == -1) {
|
||||||
|
VALUE_TYPE newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
#endif
|
||||||
|
insertIndex(size++, key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
#if VALUE_OBJECT
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = valueProvider.VALUE_SUPPLY_GET();
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -635,6 +615,25 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
int index = findIndex(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(index == -1) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(index == -1 || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeIndex(index);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -649,7 +648,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
+59
-61
@@ -382,6 +382,26 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
if(!isSet(index)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
set(index);
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
clear(index);
|
||||||
|
values[index] = EMPTY_VALUE;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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();
|
||||||
@@ -404,7 +424,26 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
#endif
|
#endif
|
||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
if(!isSet(index)) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
set(index);
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = values[index];
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
values[index] = newValue;
|
||||||
|
}
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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();
|
||||||
@@ -428,65 +467,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(!isSet(index)) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
#else
|
|
||||||
if(!isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
clear(index);
|
|
||||||
values[index] = EMPTY_VALUE;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(!isSet(index)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
set(index);
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
clear(index);
|
|
||||||
values[index] = EMPTY_VALUE;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(T key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(!isSet(index)) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
set(index);
|
|
||||||
values[index] = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = values[index];
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
values[index] = newValue;
|
|
||||||
}
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(T key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@@ -506,6 +486,25 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
int index = key.ordinal();
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(!isSet(index)) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
#else
|
||||||
|
if(!isSet(index) || VALUE_EQUALS(values[index], getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, values[index]);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
clear(index);
|
||||||
|
values[index] = EMPTY_VALUE;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
values[index] = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(T key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@@ -520,7 +519,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(T key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(T key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
|
|||||||
+65
-73
@@ -567,6 +567,28 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -592,6 +614,27 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -617,72 +660,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(entry == null) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
#else
|
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -704,6 +681,28 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(entry == null) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
#else
|
||||||
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -721,7 +720,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -1771,7 +1769,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
#endif
|
#endif
|
||||||
if(!inRange(key)) return getDefaultReturnValue();
|
if(!inRange(key)) return getDefaultReturnValue();
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
||||||
#if VALUE_OBJECT
|
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
@@ -1780,11 +1777,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
return newValue;
|
return newValue;
|
||||||
#else
|
|
||||||
if(entry == null) return getDefaultReturnValue();
|
|
||||||
entry.value = mappingFunction.apply(key, entry.value);
|
|
||||||
return entry.value;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+65
-73
@@ -569,6 +569,28 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -594,6 +616,27 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
if(entry == null) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
put(key, newValue);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
||||||
|
entry.value = newValue;
|
||||||
|
}
|
||||||
|
return entry.value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -619,72 +662,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
if(entry == null) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
#else
|
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, getDefaultReturnValue());
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
|
||||||
removeNode(entry);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
entry.value = newValue;
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
|
||||||
Objects.requireNonNull(mappingFunction);
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
validate(key);
|
|
||||||
#endif
|
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
if(Objects.equals(entry.value, getDefaultReturnValue())) {
|
|
||||||
VALUE_TYPE newValue = mappingFunction.APPLY(key);
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
entry.value = newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
||||||
Objects.requireNonNull(valueProvider);
|
Objects.requireNonNull(valueProvider);
|
||||||
@@ -706,6 +683,28 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
#if TYPE_OBJECT
|
||||||
|
validate(key);
|
||||||
|
#endif
|
||||||
|
Node KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
|
#if !VALUE_OBJECT
|
||||||
|
if(entry == null) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
#else
|
||||||
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
|
VALUE_TYPE newValue = mappingFunction.APPLY_VALUE(key, entry.value);
|
||||||
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
|
removeNode(entry);
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
entry.value = newValue;
|
||||||
|
return newValue;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -723,7 +722,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return newValue;
|
return newValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
@@ -1837,7 +1835,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
#endif
|
#endif
|
||||||
if(!inRange(key)) return getDefaultReturnValue();
|
if(!inRange(key)) return getDefaultReturnValue();
|
||||||
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
Node KEY_VALUE_GENERIC_TYPE entry = map.findNode(key);
|
||||||
#if VALUE_OBJECT
|
|
||||||
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
if(entry == null || VALUE_EQUALS(entry.value, getDefaultReturnValue())) return getDefaultReturnValue();
|
||||||
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
VALUE_TYPE newValue = mappingFunction.apply(key, entry.value);
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) {
|
||||||
@@ -1846,11 +1843,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
entry.value = newValue;
|
entry.value = newValue;
|
||||||
return newValue;
|
return newValue;
|
||||||
#else
|
|
||||||
if(entry == null) return getDefaultReturnValue();
|
|
||||||
entry.value = mappingFunction.apply(key, entry.value);
|
|
||||||
return entry.value;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+28
-30
@@ -389,35 +389,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computation
|
* @return the result of the computation
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
|
||||||
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param mappingFunction the operator that should generate the value if not present
|
|
||||||
* @return the result of the computed value or present value
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
|
||||||
/**
|
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param valueProvider the value if not present
|
|
||||||
* @return the result of the computed value or present value
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
|
||||||
/**
|
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
|
||||||
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param mappingFunction the operator that should generate the value if present
|
|
||||||
* @return the result of the default return value or present value
|
|
||||||
* @note if not present then compute is not executed
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@@ -427,6 +398,15 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computation
|
* @return the result of the computation
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
/**
|
||||||
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
* A Type Specific computeIfAbsent method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@@ -436,6 +416,15 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
/**
|
||||||
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param valueProvider the value if not present
|
||||||
|
* @return the result of the computed value or present value
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
/**
|
/**
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@@ -445,6 +434,16 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
||||||
|
/**
|
||||||
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
* A "Null Value" will be treated as "Do not insert/remove" based on how the Java has specified it.
|
||||||
|
* @param key the key that should be computed
|
||||||
|
* @param mappingFunction the operator that should generate the value if present
|
||||||
|
* @return the result of the default return value or present value
|
||||||
|
* @note if not present then compute is not executed
|
||||||
|
*/
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
@@ -455,7 +454,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @note if not present then compute is not executed
|
* @note if not present then compute is not executed
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific merge method to reduce boxing/unboxing
|
* A Type Specific merge method to reduce boxing/unboxing
|
||||||
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
* If the generated value equals the getDefaultReturnValue it will simply not insert it since that is treated as "null".
|
||||||
|
|||||||
+458
-467
@@ -1,468 +1,459 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
* A Simple First In First Out Priority Queue that is a Good Replacement for a linked list (or ArrayDequeue)
|
||||||
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
||||||
{
|
{
|
||||||
/** Max Possible ArraySize without the JVM Crashing */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
/** The Minimum Capacity that is allowed */
|
/** The Minimum Capacity that is allowed */
|
||||||
public static final int MIN_CAPACITY = 4;
|
public static final int MIN_CAPACITY = 4;
|
||||||
/** The Backing array */
|
/** The Backing array */
|
||||||
protected transient KEY_TYPE[] array;
|
protected transient KEY_TYPE[] array;
|
||||||
/** The First Index pointer */
|
/** The First Index pointer */
|
||||||
protected int first;
|
protected int first;
|
||||||
/** The Last Index pointer */
|
/** The Last Index pointer */
|
||||||
protected int last;
|
protected int last;
|
||||||
/** The Minimum Capacity of the Queue **/
|
/** The Minimum Capacity of the Queue **/
|
||||||
protected int minCapacity;
|
protected int minCapacity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values) {
|
||||||
this(values, 0, values.length);
|
this(values, 0, values.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
* @param size the amount of elements that are in the initial array
|
* @param size the amount of elements that are in the initial array
|
||||||
* @throws IllegalStateException if values is smaller then size
|
* @throws IllegalStateException if values is smaller then size
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int size) {
|
||||||
this(values, 0, size);
|
this(values, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param values the Array that should be used
|
* @param values the Array that should be used
|
||||||
* @param offset where to begin in the initial array
|
* @param offset where to begin in the initial array
|
||||||
* @param size the amount of elements that are in the initial array
|
* @param size the amount of elements that are in the initial array
|
||||||
* @throws IllegalStateException if values is smaller then size
|
* @throws IllegalStateException if values is smaller then size
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
||||||
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
||||||
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
||||||
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
||||||
minCapacity = MIN_CAPACITY;
|
minCapacity = MIN_CAPACITY;
|
||||||
array = values;
|
array = values;
|
||||||
first = offset;
|
first = offset;
|
||||||
last = (offset + size) % array.length;
|
last = (offset + size) % array.length;
|
||||||
if(array.length == size) expand();
|
if(array.length == size) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param capacity the initial capacity of the backing array
|
* @param capacity the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(int capacity) {
|
public ARRAY_FIFO_QUEUE(int capacity) {
|
||||||
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
||||||
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity+1));
|
||||||
minCapacity = array.length;
|
minCapacity = array.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Construtor
|
* Default Construtor
|
||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE() {
|
public ARRAY_FIFO_QUEUE() {
|
||||||
this(MIN_CAPACITY);
|
this(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
final int apparentLength = last - first;
|
final int apparentLength = last - first;
|
||||||
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
return apparentLength >= 0 ? apparentLength : array.length + apparentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(first != last) {
|
if(first != last) {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
Arrays.fill(array, null);
|
Arrays.fill(array, null);
|
||||||
#endif
|
#endif
|
||||||
first = last = 0;
|
first = last = 0;
|
||||||
}
|
}
|
||||||
else if(first != 0) {
|
else if(first != 0) {
|
||||||
first = last = 0;
|
first = last = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
array[last++] = e;
|
array[last++] = e;
|
||||||
if(last == array.length) last = 0;
|
if(last == array.length) last = 0;
|
||||||
if(last == first) expand();
|
if(last == first) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueueFirst(KEY_TYPE e) {
|
public void enqueueFirst(KEY_TYPE e) {
|
||||||
if(first == 0) first = array.length;
|
if(first == 0) first = array.length;
|
||||||
array[--first] = e;
|
array[--first] = e;
|
||||||
if(first == last) expand();
|
if(first == last) expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(first == last) throw new NoSuchElementException();
|
if(first == last) throw new NoSuchElementException();
|
||||||
KEY_TYPE data = array[first];
|
KEY_TYPE data = array[first];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[first] = null;
|
array[first] = null;
|
||||||
#endif
|
#endif
|
||||||
if(++first == array.length) first = 0;
|
if(++first == array.length) first = 0;
|
||||||
reduce();
|
reduce();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeueLast() {
|
public KEY_TYPE dequeueLast() {
|
||||||
if(first == last) throw new NoSuchElementException();
|
if(first == last) throw new NoSuchElementException();
|
||||||
if(last == 0) last = array.length;
|
if(last == 0) last = array.length;
|
||||||
KEY_TYPE data = array[--last];
|
KEY_TYPE data = array[--last];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[last] = null;
|
array[last] = null;
|
||||||
#endif
|
#endif
|
||||||
reduce();
|
reduce();
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
if(first == last || index < 0 || index >= size()) throw new NoSuchElementException();
|
||||||
index += first;
|
index += first;
|
||||||
return index >= array.length ? array[index-array.length] : array[index];
|
return index >= array.length ? array[index-array.length] : array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
if(first == last) return false;
|
if(first == last) return false;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(e == array[(first + i) % array.length]) return true;
|
int index = (first + i) % array.length;
|
||||||
}
|
if(e == array[index])
|
||||||
return false;
|
return removeIndex(index);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
|
||||||
if(first == last) return false;
|
@Override
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
int index = (first + i) % array.length;
|
if(first == last) return false;
|
||||||
if(e == array[index])
|
for(int i = size()-1;i>=0;i--) {
|
||||||
return removeIndex(index);
|
int index = (first + i) % array.length;
|
||||||
}
|
if(e == array[index])
|
||||||
return false;
|
return removeIndex(index);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
|
||||||
if(first == last) return false;
|
protected boolean removeIndex(int index) {
|
||||||
for(int i = size()-1;i>=0;i--) {
|
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
||||||
int index = (first + i) % array.length;
|
if(index == first) {
|
||||||
if(e == array[index])
|
#if TYPE_OBJECT
|
||||||
return removeIndex(index);
|
array[first] = null;
|
||||||
}
|
#endif
|
||||||
return false;
|
first++;
|
||||||
}
|
}
|
||||||
|
else if(index == last) {
|
||||||
protected boolean removeIndex(int index) {
|
last--;
|
||||||
if(first >= last ? index < first && index > last : index < first || index > last) return false;
|
#if TYPE_OBJECT
|
||||||
if(index == first) {
|
array[last] = null;
|
||||||
#if TYPE_OBJECT
|
#endif
|
||||||
array[first] = null;
|
}
|
||||||
#endif
|
else if(index > last) {
|
||||||
first++;
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
}
|
#if TYPE_OBJECT
|
||||||
else if(index == last) {
|
array[first] = null;
|
||||||
last--;
|
#endif
|
||||||
#if TYPE_OBJECT
|
first = ++first % array.length;
|
||||||
array[last] = null;
|
}
|
||||||
#endif
|
else if(index < first) {
|
||||||
}
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
else if(index > last) {
|
#if TYPE_OBJECT
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
array[last] = null;
|
||||||
#if TYPE_OBJECT
|
#endif
|
||||||
array[first] = null;
|
if(--last < 0) last += array.length;
|
||||||
#endif
|
}
|
||||||
first = ++first % array.length;
|
else {
|
||||||
}
|
if(index - first < last - index) {
|
||||||
else if(index < first) {
|
System.arraycopy(array, first, array, first+1, (index - first));
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
#if TYPE_OBJECT
|
||||||
#if TYPE_OBJECT
|
array[first] = null;
|
||||||
array[last] = null;
|
#endif
|
||||||
#endif
|
first = ++first % array.length;
|
||||||
if(--last < 0) last += array.length;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
||||||
if(index - first < last - index) {
|
#if TYPE_OBJECT
|
||||||
System.arraycopy(array, first, array, first+1, (index - first));
|
array[last] = null;
|
||||||
#if TYPE_OBJECT
|
#endif
|
||||||
array[first] = null;
|
if(--last < 0) last += array.length;
|
||||||
#endif
|
}
|
||||||
first = ++first % array.length;
|
}
|
||||||
}
|
reduce();
|
||||||
else {
|
return true;
|
||||||
System.arraycopy(array, index+1, array, index, (last - index) - 1);
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
array[last] = null;
|
@Override
|
||||||
#endif
|
public void onChanged() {}
|
||||||
if(--last < 0) last += array.length;
|
|
||||||
}
|
@Override
|
||||||
}
|
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
reduce();
|
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
||||||
return true;
|
queue.first = first;
|
||||||
}
|
queue.last = last;
|
||||||
|
queue.minCapacity = minCapacity;
|
||||||
@Override
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
public void onChanged() {}
|
return queue;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
@Override
|
||||||
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
||||||
queue.first = first;
|
|
||||||
queue.last = last;
|
@Override
|
||||||
queue.minCapacity = minCapacity;
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
Objects.requireNonNull(action);
|
||||||
return queue;
|
if(first == last) return;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++)
|
||||||
|
action.accept(array[(first + i) % array.length]);
|
||||||
@Override
|
clearAndTrim(0);
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(first == last) return;
|
if(first == last) return;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
for(int i = 0,m=size();i<m;i++)
|
||||||
action.accept(array[(first + i) % array.length]);
|
action.accept(i, array[(first + i) % array.length]);
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(first == last) return;
|
if(first == last) return;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
for(int i = 0,m=size();i<m;i++)
|
||||||
action.accept(i, array[(first + i) % array.length]);
|
action.accept(input, array[(first + i) % array.length]);
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(filter);
|
||||||
if(first == last) return;
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
for(int i = 0,m=size();i<m;i++)
|
if(filter.test(array[(first + i) % array.length])) return true;
|
||||||
action.accept(input, array[(first + i) % array.length]);
|
}
|
||||||
clearAndTrim(0);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(filter.test(array[(first + i) % array.length])) return true;
|
if(filter.test(array[(first + i) % array.length])) return false;
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesNone(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(array[(first + i) % array.length])) return false;
|
if(!filter.test(array[(first + i) % array.length])) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(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=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
if(!filter.test(array[(first + i) % array.length])) return false;
|
int index = (first + i) % array.length;
|
||||||
}
|
if(filter.test(array[index])) {
|
||||||
return true;
|
KEY_TYPE data = array[index];
|
||||||
}
|
removeIndex(index);
|
||||||
|
return data;
|
||||||
@Override
|
}
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
return EMPTY_VALUE;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
}
|
||||||
int index = (first + i) % array.length;
|
|
||||||
if(filter.test(array[index])) {
|
#if !TYPE_OBJECT
|
||||||
KEY_TYPE data = array[index];
|
@Override
|
||||||
removeIndex(index);
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
return data;
|
Objects.requireNonNull(operator);
|
||||||
}
|
KEY_TYPE state = identity;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
return EMPTY_VALUE;
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
#if !TYPE_OBJECT
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
#else
|
||||||
Objects.requireNonNull(operator);
|
@Override
|
||||||
KEY_TYPE state = identity;
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
Objects.requireNonNull(operator);
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
}
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
return state;
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
}
|
}
|
||||||
|
return state;
|
||||||
#else
|
}
|
||||||
@Override
|
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
#endif
|
||||||
Objects.requireNonNull(operator);
|
@Override
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
Objects.requireNonNull(operator);
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
}
|
boolean empty = true;
|
||||||
return state;
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
}
|
if(empty) {
|
||||||
|
empty = false;
|
||||||
#endif
|
state = array[(first + i) % array.length];
|
||||||
@Override
|
continue;
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
}
|
||||||
boolean empty = true;
|
return state;
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
}
|
||||||
if(empty) {
|
|
||||||
empty = false;
|
@Override
|
||||||
state = array[(first + i) % array.length];
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
continue;
|
Objects.requireNonNull(filter);
|
||||||
}
|
int result = 0;
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
}
|
if(filter.test(array[(first + i) % array.length])) result++;
|
||||||
return state;
|
}
|
||||||
}
|
return result;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
@Override
|
||||||
Objects.requireNonNull(filter);
|
public boolean trim(int size) {
|
||||||
int result = 0;
|
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
if(newSize >= array.length) return false;
|
||||||
if(filter.test(array[(first + i) % array.length])) result++;
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
}
|
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
||||||
return result;
|
else {
|
||||||
}
|
System.arraycopy(array, first, newArray, 0, array.length - first);
|
||||||
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
@Override
|
}
|
||||||
public boolean trim(int size) {
|
first = 0;
|
||||||
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
last = size();
|
||||||
if(newSize >= array.length) return false;
|
array = newArray;
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
return true;
|
||||||
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
}
|
||||||
else {
|
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
/**
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
* Trims the collection down to the requested size and clears all elements while doing so
|
||||||
}
|
* @param size the amount of elements that should be allowed
|
||||||
first = 0;
|
* @note this will enforce minimum size of the collection itself
|
||||||
last = size();
|
*/
|
||||||
array = newArray;
|
@Override
|
||||||
return true;
|
public void clearAndTrim(int size) {
|
||||||
}
|
int newSize = Math.max(minCapacity, size);
|
||||||
|
if(array.length <= newSize) {
|
||||||
/**
|
clear();
|
||||||
* Trims the collection down to the requested size and clears all elements while doing so
|
return;
|
||||||
* @param size the amount of elements that should be allowed
|
}
|
||||||
* @note this will enforce minimum size of the collection itself
|
first = last = 0;
|
||||||
*/
|
array = NEW_KEY_ARRAY(newSize);
|
||||||
@Override
|
}
|
||||||
public void clearAndTrim(int size) {
|
|
||||||
int newSize = Math.max(minCapacity, size);
|
@Override
|
||||||
if(array.length <= newSize) {
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
clear();
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
return;
|
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
||||||
}
|
else {
|
||||||
first = last = 0;
|
System.arraycopy(array, first, input, 0, array.length - first);
|
||||||
array = NEW_KEY_ARRAY(newSize);
|
System.arraycopy(array, 0, input, array.length - first, last);
|
||||||
}
|
}
|
||||||
|
return input;
|
||||||
@Override
|
}
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
protected void reduce() {
|
||||||
if (first <= last) System.arraycopy(array, first, input, 0, last - first);
|
final int size = size();
|
||||||
else {
|
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
||||||
System.arraycopy(array, first, input, 0, array.length - first);
|
}
|
||||||
System.arraycopy(array, 0, input, array.length - first, last);
|
|
||||||
}
|
protected void expand() {
|
||||||
return input;
|
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reduce() {
|
protected final void resize(int oldSize, int newSize) {
|
||||||
final int size = size();
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
if(first >= last) {
|
||||||
}
|
if(oldSize != 0)
|
||||||
|
{
|
||||||
protected void expand() {
|
System.arraycopy(array, first, newArray, 0, array.length - first);
|
||||||
resize(array.length, (int)Math.min(MAX_ARRAY_SIZE, 2L * array.length));
|
System.arraycopy(array, 0, newArray, array.length - first, last);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
protected final void resize(int oldSize, int newSize) {
|
else System.arraycopy(array, first, newArray, 0, last-first);
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
first = 0;
|
||||||
if(first >= last) {
|
last = oldSize;
|
||||||
if(oldSize != 0)
|
array = newArray;
|
||||||
{
|
}
|
||||||
System.arraycopy(array, first, newArray, 0, array.length - first);
|
|
||||||
System.arraycopy(array, 0, newArray, array.length - first, last);
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
||||||
}
|
{
|
||||||
}
|
int index = first;
|
||||||
else System.arraycopy(array, first, newArray, 0, last-first);
|
@Override
|
||||||
first = 0;
|
public boolean hasNext()
|
||||||
last = oldSize;
|
{
|
||||||
array = newArray;
|
return index != last;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE
|
@Override
|
||||||
{
|
public KEY_TYPE NEXT() {
|
||||||
int index = first;
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
@Override
|
KEY_TYPE value = array[index];
|
||||||
public boolean hasNext()
|
removeIndex(index);
|
||||||
{
|
index = ++index % array.length;
|
||||||
return index != last;
|
return value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
KEY_TYPE value = array[index];
|
|
||||||
removeIndex(index);
|
|
||||||
index = ++index % array.length;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+439
-446
@@ -1,447 +1,440 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
* A Array Priority Queue, this is a very unoptimized implementation of the PriorityQueue for very specific usecases.
|
||||||
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
* It allows for duplicated entries and works like {@link java.util.List#indexOf(Object)} search.
|
||||||
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
/** The Amount of elements stored within the array */
|
/** The Amount of elements stored within the array */
|
||||||
protected int size;
|
protected int size;
|
||||||
/** The Last known first index pointer */
|
/** The Last known first index pointer */
|
||||||
protected int firstIndex = -1;
|
protected int firstIndex = -1;
|
||||||
/** The Sorter of the Array */
|
/** The Sorter of the Array */
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE() {
|
public ARRAY_PRIORITY_QUEUE() {
|
||||||
this(0, null);
|
this(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using custom sorter
|
* Constructor using custom sorter
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(0, comp);
|
this(0, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(int size) {
|
public ARRAY_PRIORITY_QUEUE(int size) {
|
||||||
this(size, null);
|
this(size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
if(size < 0) throw new IllegalAccessError("Size has to be 0 or positive");
|
if(size < 0) throw new IllegalAccessError("Size has to be 0 or positive");
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
this(array, array.length);
|
this(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(array, array.length, comp);
|
this(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.comparator = comp;
|
this.comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection
|
* Constructor using a Collection
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection and a custom sorter
|
* Constructor using a Collection and a custom sorter
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public ARRAY_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
return wrap(array, array.length);
|
return wrap(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
return wrap(array, array.length, comp);
|
return wrap(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a ArrayPriorityQueue containing the original input array
|
* @return a ArrayPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES(comp);
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||||
if(firstIndex != -1){
|
if(firstIndex != -1){
|
||||||
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
int compare = comparator == null ? COMPAREABLE_TO_KEY(e, array[firstIndex]) : comparator.compare(e, array[firstIndex]);
|
||||||
if(compare < 0) firstIndex = size;
|
if(compare < 0) firstIndex = size;
|
||||||
else if(compare > 0) firstIndex = -1;
|
else if(compare > 0) firstIndex = -1;
|
||||||
}
|
}
|
||||||
array[size++] = e;
|
array[size++] = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
int index = findFirstIndex();
|
int index = findFirstIndex();
|
||||||
KEY_TYPE value = array[index];
|
KEY_TYPE value = array[index];
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[size] = null;
|
array[size] = null;
|
||||||
#endif
|
#endif
|
||||||
firstIndex = -1;
|
firstIndex = -1;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE first() {
|
public KEY_TYPE first() {
|
||||||
if(isEmpty()) throw new NoSuchElementException();
|
if(isEmpty()) throw new NoSuchElementException();
|
||||||
if(firstIndex == -1) findFirstIndex();
|
if(firstIndex == -1) findFirstIndex();
|
||||||
return array[firstIndex];
|
return array[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return true;
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = size-1;i>=0;i--)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected boolean removeIndex(int index) {
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
||||||
for(int i = size-1;i>=0;i--)
|
#if TYPE_OBJECT
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
array[size] = null;
|
||||||
return false;
|
#endif
|
||||||
}
|
if(index == firstIndex) firstIndex = -1;
|
||||||
|
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
||||||
protected boolean removeIndex(int index) {
|
return true;
|
||||||
if(index != --size) System.arraycopy(array, index+1, array, index, size - index);
|
}
|
||||||
#if TYPE_OBJECT
|
|
||||||
array[size] = null;
|
@Override
|
||||||
#endif
|
public void onChanged() {
|
||||||
if(index == firstIndex) firstIndex = -1;
|
firstIndex = -1;
|
||||||
else if(firstIndex != -1 && index >= firstIndex) firstIndex--;
|
}
|
||||||
return true;
|
|
||||||
}
|
@Override
|
||||||
|
public int size() {
|
||||||
@Override
|
return size;
|
||||||
public void onChanged() {
|
}
|
||||||
firstIndex = -1;
|
|
||||||
}
|
@Override
|
||||||
|
public void clear() {
|
||||||
@Override
|
#if TYPE_OBJECT
|
||||||
public int size() {
|
Arrays.fill(array, null);
|
||||||
return size;
|
#endif
|
||||||
}
|
size = 0;
|
||||||
|
}
|
||||||
@Override
|
|
||||||
public void clear() {
|
@Override
|
||||||
#if TYPE_OBJECT
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Arrays.fill(array, null);
|
Objects.requireNonNull(action);
|
||||||
#endif
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
size = 0;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
Objects.requireNonNull(action);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
Objects.requireNonNull(action);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
Objects.requireNonNull(filter);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0;i<size;i++) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
if(filter.test(array[i])) return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
if(filter.test(array[i])) return true;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return false;
|
if(filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
if(filter.test(array[i])) return false;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return true;
|
if(!filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
#if !TYPE_OBJECT
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
if(!filter.test(array[i])) return false;
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return true;
|
KEY_TYPE state = identity;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
#if !TYPE_OBJECT
|
}
|
||||||
@Override
|
return state;
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
|
||||||
KEY_TYPE state = identity;
|
#else
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return state;
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
#else
|
}
|
||||||
@Override
|
return state;
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
#endif
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return state;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
}
|
boolean empty = true;
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
#endif
|
if(empty) {
|
||||||
@Override
|
empty = false;
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
state = array[i];
|
||||||
Objects.requireNonNull(operator);
|
continue;
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
}
|
||||||
boolean empty = true;
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(empty) {
|
return state;
|
||||||
empty = false;
|
}
|
||||||
state = array[i];
|
|
||||||
continue;
|
@Override
|
||||||
}
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return state;
|
if(filter.test(array[i])) {
|
||||||
}
|
KEY_TYPE data = array[i];
|
||||||
|
removeIndex(i);
|
||||||
@Override
|
return data;
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return EMPTY_VALUE;
|
||||||
if(filter.test(array[i])) {
|
}
|
||||||
KEY_TYPE data = array[i];
|
|
||||||
removeIndex(i);
|
@Override
|
||||||
return data;
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
}
|
int result = 0;
|
||||||
return EMPTY_VALUE;
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(filter.test(array[i])) result++;
|
||||||
|
}
|
||||||
@Override
|
return result;
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
if(filter.test(array[i])) result++;
|
return new Iter();
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
@Override
|
||||||
|
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
@Override
|
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
queue.firstIndex = firstIndex;
|
||||||
return new Iter();
|
queue.size = size;
|
||||||
}
|
queue.comparator = comparator;
|
||||||
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
@Override
|
return queue;
|
||||||
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
}
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
|
||||||
queue.firstIndex = firstIndex;
|
@Override
|
||||||
queue.size = size;
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
queue.comparator = comparator;
|
return comparator;
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
}
|
||||||
return queue;
|
|
||||||
}
|
@Override
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
@Override
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
return comparator;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected int findFirstIndex() {
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
if(firstIndex == -1) {
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
int index = size-1;
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
KEY_TYPE value = array[index];
|
||||||
return input;
|
if(comparator == null) {
|
||||||
}
|
for(int i = index;i>=0;i--) {
|
||||||
|
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
||||||
protected int findFirstIndex() {
|
value = array[index = i];
|
||||||
if(firstIndex == -1) {
|
}
|
||||||
int index = size-1;
|
}
|
||||||
KEY_TYPE value = array[index];
|
else {
|
||||||
if(comparator == null) {
|
for(int i = index;i>=0;i--) {
|
||||||
for(int i = index;i>=0;i--) {
|
if(comparator.compare(array[i], value) < 0)
|
||||||
if(COMPAREABLE_TO_KEY(array[i], value) < 0)
|
value = array[index = i];
|
||||||
value = array[index = i];
|
}
|
||||||
}
|
}
|
||||||
}
|
firstIndex = index;
|
||||||
else {
|
}
|
||||||
for(int i = index;i>=0;i--) {
|
return firstIndex;
|
||||||
if(comparator.compare(array[i], value) < 0)
|
}
|
||||||
value = array[index = i];
|
|
||||||
}
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
}
|
@Override
|
||||||
firstIndex = index;
|
public boolean hasNext() {
|
||||||
}
|
return !isEmpty();
|
||||||
return firstIndex;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
public KEY_TYPE NEXT() {
|
||||||
@Override
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
public boolean hasNext() {
|
return dequeue();
|
||||||
return !isEmpty();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
return dequeue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+407
-414
@@ -1,415 +1,408 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.BI_FROM_INT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple Heap base Priority Queue implementation
|
* A Simple Heap base Priority Queue implementation
|
||||||
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
/** The Amount of elements stored within the array */
|
/** The Amount of elements stored within the array */
|
||||||
protected int size;
|
protected int size;
|
||||||
/** The Sorter of the Array */
|
/** The Sorter of the Array */
|
||||||
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
protected COMPARATOR KEY_SUPER_GENERIC_TYPE comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE() {
|
public HEAP_PRIORITY_QUEUE() {
|
||||||
this(0, null);
|
this(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using custom sorter
|
* Constructor using custom sorter
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(0, comp);
|
this(0, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity
|
* Constructor with a Min Capacity
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(int size) {
|
public HEAP_PRIORITY_QUEUE(int size) {
|
||||||
this(size, null);
|
this(size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor with a Min Capacity and custom Sorter
|
* Constructor with a Min Capacity and custom Sorter
|
||||||
* @param size the initial capacity of the backing array
|
* @param size the initial capacity of the backing array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws IllegalStateException if the initial size is smaller 0
|
* @throws IllegalStateException if the initial size is smaller 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
if(size > 0) array = NEW_KEY_ARRAY(size);
|
if(size > 0) array = NEW_KEY_ARRAY(size);
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array) {
|
||||||
this(array, array.length);
|
this(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this(array, array.length, comp);
|
this(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array and a custom sorter
|
* Constructor using a initial array and a custom sorter
|
||||||
* @param array the Array that should be used
|
* @param array the Array that should be used
|
||||||
* @param size the amount of elements found within the array
|
* @param size the amount of elements found within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @throws NegativeArraySizeException if size is smaller then 0
|
* @throws NegativeArraySizeException if size is smaller then 0
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
this.array = Arrays.copyOf(array, size);
|
this.array = Arrays.copyOf(array, size);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection
|
* Constructor using a Collection
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a Collection and a custom sorter
|
* Constructor using a Collection and a custom sorter
|
||||||
* @param c the Collection that should be used
|
* @param c the Collection that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
*/
|
*/
|
||||||
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public HEAP_PRIORITY_QUEUE(COLLECTION KEY_GENERIC_TYPE c, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
array = CAST_KEY_ARRAY c.TO_ARRAY();
|
||||||
size = c.size();
|
size = c.size();
|
||||||
comparator = comp;
|
comparator = comp;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array) {
|
||||||
return wrap(array, array.length);
|
return wrap(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization
|
* Wrapping method to help serialization
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size) {
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
ARRAYS.heapify(array, size, null);
|
ARRAYS.heapify(array, size, null);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
return wrap(array, array.length, comp);
|
return wrap(array, array.length, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapping method to help serialization, using a custom sorter
|
* Wrapping method to help serialization, using a custom sorter
|
||||||
* @param array the array that should be used
|
* @param array the array that should be used
|
||||||
* @param size the amount of elements within the array
|
* @param size the amount of elements within the array
|
||||||
* @param comp Comparator to sort the Array. Can be null
|
* @param comp Comparator to sort the Array. Can be null
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return a HeapPriorityQueue containing the original input array
|
* @return a HeapPriorityQueue containing the original input array
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
public static GENERIC_KEY_BRACES HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE wrap(KEY_TYPE[] array, int size, COMPARATOR KEY_SUPER_GENERIC_TYPE comp) {
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES(comp);
|
||||||
queue.array = array;
|
queue.array = array;
|
||||||
queue.size = size;
|
queue.size = size;
|
||||||
ARRAYS.heapify(array, size, comp);
|
ARRAYS.heapify(array, size, comp);
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
Arrays.fill(array, null);
|
Arrays.fill(array, null);
|
||||||
#endif
|
#endif
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) {
|
public void enqueue(KEY_TYPE e) {
|
||||||
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
if(size == array.length) array = Arrays.copyOf(array, (int)Math.max(Math.min((long)array.length + (long)(array.length >> 1), (long)SanityChecks.MAX_ARRAY_SIZE), size+1));
|
||||||
array[size++] = e;
|
array[size++] = e;
|
||||||
ARRAYS.shiftUp(array, size-1, comparator);
|
ARRAYS.shiftUp(array, size-1, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() {
|
public KEY_TYPE dequeue() {
|
||||||
if(size <= 0) throw new NoSuchElementException();
|
if(size <= 0) throw new NoSuchElementException();
|
||||||
KEY_TYPE value = array[0];
|
KEY_TYPE value = array[0];
|
||||||
array[0] = array[--size];
|
array[0] = array[--size];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
array[size] = null;
|
array[size] = null;
|
||||||
#endif
|
#endif
|
||||||
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
if(size != 0) ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) {
|
public KEY_TYPE peek(int index) {
|
||||||
if(index < 0 || index >= size) throw new NoSuchElementException();
|
if(index < 0 || index >= size) throw new NoSuchElementException();
|
||||||
return array[index];
|
return array[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE e) {
|
public boolean removeFirst(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
if(KEY_EQUALS(e, array[i])) return true;
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeFirst(KEY_TYPE e) {
|
public boolean removeLast(KEY_TYPE e) {
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = size-1;i>=0;i--)
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
for(int i = size-1;i>=0;i--)
|
Objects.requireNonNull(action);
|
||||||
if(KEY_EQUALS(e, array[i])) return removeIndex(i);
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
Objects.requireNonNull(action);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(dequeue());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
||||||
public void forEachIndexed(BI_FROM_INT_CONSUMER KEY_GENERIC_TYPE action) {
|
Objects.requireNonNull(action);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(i, dequeue());
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
Objects.requireNonNull(filter);
|
||||||
Objects.requireNonNull(action);
|
for(int i = 0;i<size;i++) {
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
if(filter.test(array[i])) return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
@Override
|
}
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
if(filter.test(array[i])) return true;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return false;
|
if(filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
@Override
|
||||||
for(int i = 0;i<size;i++) {
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
if(filter.test(array[i])) return false;
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return true;
|
if(!filter.test(array[i])) return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
@Override
|
}
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
#if !TYPE_OBJECT
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
if(!filter.test(array[i])) return false;
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return true;
|
KEY_TYPE state = identity;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
#if !TYPE_OBJECT
|
}
|
||||||
@Override
|
return state;
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
|
||||||
KEY_TYPE state = identity;
|
#else
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return state;
|
KEY_SPECIAL_TYPE state = identity;
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
#else
|
}
|
||||||
@Override
|
return state;
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) {
|
}
|
||||||
Objects.requireNonNull(operator);
|
|
||||||
KEY_SPECIAL_TYPE state = identity;
|
#endif
|
||||||
for(int i = 0;i<size;i++) {
|
@Override
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
}
|
Objects.requireNonNull(operator);
|
||||||
return state;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
}
|
boolean empty = true;
|
||||||
|
for(int i = 0;i<size;i++) {
|
||||||
#endif
|
if(empty) {
|
||||||
@Override
|
empty = false;
|
||||||
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
state = array[i];
|
||||||
Objects.requireNonNull(operator);
|
continue;
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
}
|
||||||
boolean empty = true;
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
for(int i = 0;i<size;i++) {
|
}
|
||||||
if(empty) {
|
return state;
|
||||||
empty = false;
|
}
|
||||||
state = array[i];
|
|
||||||
continue;
|
@Override
|
||||||
}
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
Objects.requireNonNull(filter);
|
||||||
}
|
for(int i = 0;i<size;i++) {
|
||||||
return state;
|
if(filter.test(array[i])) {
|
||||||
}
|
KEY_TYPE data = array[i];
|
||||||
|
removeIndex(i);
|
||||||
@Override
|
return data;
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
}
|
||||||
for(int i = 0;i<size;i++) {
|
return EMPTY_VALUE;
|
||||||
if(filter.test(array[i])) {
|
}
|
||||||
KEY_TYPE data = array[i];
|
|
||||||
removeIndex(i);
|
@Override
|
||||||
return data;
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
}
|
Objects.requireNonNull(filter);
|
||||||
}
|
int result = 0;
|
||||||
return EMPTY_VALUE;
|
for(int i = 0;i<size;i++) {
|
||||||
}
|
if(filter.test(array[i])) result++;
|
||||||
|
}
|
||||||
@Override
|
return result;
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
}
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
protected boolean removeIndex(int index) {
|
||||||
for(int i = 0;i<size;i++) {
|
array[index] = array[--size];
|
||||||
if(filter.test(array[i])) result++;
|
#if TYPE_OBJECT
|
||||||
}
|
array[size] = null;
|
||||||
return result;
|
#endif
|
||||||
}
|
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
||||||
|
return true;
|
||||||
protected boolean removeIndex(int index) {
|
}
|
||||||
array[index] = array[--size];
|
|
||||||
#if TYPE_OBJECT
|
@Override
|
||||||
array[size] = null;
|
public void onChanged() {
|
||||||
#endif
|
if(size <= 0) return;
|
||||||
if(size != index) ARRAYS.shiftDown(array, size, index, comparator);
|
ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
@Override
|
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
||||||
public void onChanged() {
|
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
||||||
if(size <= 0) return;
|
queue.size = size;
|
||||||
ARRAYS.shiftDown(array, size, 0, comparator);
|
queue.comparator = comparator;
|
||||||
}
|
queue.array = Arrays.copyOf(array, array.length);
|
||||||
|
return queue;
|
||||||
@Override
|
}
|
||||||
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
@Override
|
||||||
queue.size = size;
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
queue.comparator = comparator;
|
return comparator;
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
}
|
||||||
return queue;
|
|
||||||
}
|
@Override
|
||||||
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
||||||
@Override
|
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
System.arraycopy(array, 0, input, 0, size());
|
||||||
return comparator;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) {
|
@Override
|
||||||
if(input == null || input.length < size()) input = NEW_SPECIAL_KEY_ARRAY(size());
|
public boolean hasNext() {
|
||||||
System.arraycopy(array, 0, input, 0, size());
|
return !isEmpty();
|
||||||
return input;
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
private class Iter implements ITERATOR KEY_GENERIC_TYPE {
|
public KEY_TYPE NEXT() {
|
||||||
@Override
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
public boolean hasNext() {
|
return dequeue();
|
||||||
return !isEmpty();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
return dequeue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-7
@@ -111,13 +111,6 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
*/
|
*/
|
||||||
public default KEY_TYPE first() { return peek(0); }
|
public default KEY_TYPE first() { return peek(0); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to find out if a element is part of the queue
|
|
||||||
* @param e the element that is searched for
|
|
||||||
* @return true if the element is in the queue
|
|
||||||
*/
|
|
||||||
public boolean contains(KEY_TYPE e);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the first found element in the queue
|
* Removes the first found element in the queue
|
||||||
* @param e the element that should be removed
|
* @param e the element that should be removed
|
||||||
|
|||||||
+1
-5
@@ -3,13 +3,11 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
import java.util.NavigableSet;
|
import java.util.NavigableSet;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#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;
|
|
||||||
#endif
|
|
||||||
#if SETS_FEATURE
|
#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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Navigable Set interface with a couple helper methods
|
* A Type Specific Navigable Set interface with a couple helper methods
|
||||||
@@ -147,7 +145,6 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||||||
public default NAVIGABLE_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
public default NAVIGABLE_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#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
|
||||||
@@ -155,7 +152,6 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||||||
@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
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package speiger.src.collections.PACKAGE.sets;
|
package speiger.src.collections.PACKAGE.sets;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#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;
|
|
||||||
#endif
|
|
||||||
#if SETS_FEATURE
|
#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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Special Set Interface giving Access to some really usefull functions
|
* A Special Set Interface giving Access to some really usefull functions
|
||||||
@@ -63,7 +61,6 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement);
|
||||||
|
|
||||||
#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
|
||||||
@@ -71,7 +68,6 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
|||||||
@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
|
|
||||||
/**
|
/**
|
||||||
* A method to get the first element in the set
|
* A method to get the first element in the set
|
||||||
* @return first element in the set
|
* @return first element in the set
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ 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;
|
||||||
#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;
|
|
||||||
#endif
|
|
||||||
#if SETS_FEATURE
|
#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;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -90,12 +88,10 @@ public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GE
|
|||||||
public default SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
public default SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#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
|
||||||
*/
|
*/
|
||||||
@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
|
}
|
||||||
}
|
|
||||||
@@ -3,9 +3,7 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#else
|
#else
|
||||||
@@ -14,9 +12,7 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
#if SETS_FEATURE
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
#endif
|
#endif
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific SortedSet implementation to reduce boxing/unboxing
|
* A Type Specific SortedSet implementation to reduce boxing/unboxing
|
||||||
@@ -71,7 +67,6 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
|||||||
public default SORTED_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
public default SORTED_SET KEY_GENERIC_TYPE unmodifiable() { return SETS.unmodifiable(this); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#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
|
||||||
@@ -79,7 +74,6 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
|||||||
@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
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific SubSet method to reduce boxing/unboxing
|
* A Type Specific SubSet method to reduce boxing/unboxing
|
||||||
|
|||||||
-35
@@ -16,16 +16,6 @@ import java.util.function.IntFunction;
|
|||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
#iterate
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
|
||||||
#argument PACKAGE booleans bytes shorts ints longs floats doubles
|
|
||||||
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
|
||||||
#if CHECK
|
|
||||||
import speiger.src.collections.objects.functions.function.MAPPER;
|
|
||||||
import speiger.src.collections.PACKAGE.utils.BUILDER;
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
#if OBJECT_ASYNC_MODULE
|
#if OBJECT_ASYNC_MODULE
|
||||||
@@ -33,9 +23,7 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.TASK;
|
import speiger.src.collections.PACKAGE.functions.TASK;
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
|
||||||
#if OBJECT_ASYNC_MODULE
|
#if OBJECT_ASYNC_MODULE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
#endif
|
#endif
|
||||||
@@ -71,9 +59,7 @@ import speiger.src.collections.PACKAGE.sets.ARRAY_SET;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
#if !TYPE_BOOLEAN && BOOLEAN_ASYNC_MODULE
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||||
#endif
|
|
||||||
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder.BaseBooleanTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
#if !TYPE_OBJECT && OBJECT_ASYNC_MODULE
|
||||||
@@ -81,9 +67,7 @@ import speiger.src.collections.objects.utils.ObjectAsyncBuilder;
|
|||||||
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
import speiger.src.collections.objects.utils.ObjectAsyncBuilder.BaseObjectTask;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT && INT_ASYNC_MODULE
|
#if !TYPE_INT && INT_ASYNC_MODULE
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder;
|
||||||
#endif
|
|
||||||
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
import speiger.src.collections.ints.utils.IntAsyncBuilder.BaseIntTask;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.utils.ISizeProvider;
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
@@ -203,25 +187,6 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
return new ObjectAsyncBuilder<>(ITERABLES.arrayFlatMap(iterable, mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument BUILDER BooleanAsyncBuilder ByteAsyncBuilder ShortAsyncBuilder IntAsyncBuilder LongAsyncBuilder FloatAsyncBuilder DoubleAsyncBuilder
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument TYPE Boolean Byte Short Int Long Float Double
|
|
||||||
#argument CHECK BOOLEAN_ASYNC_MODULE BYTE_ASYNC_MODULE SHORT_ASYNC_MODULE INT_ASYNC_MODULE LONG_ASYNC_MODULE FLOAT_ASYNC_MODULE DOUBLE_ASYNC_MODULE
|
|
||||||
#if CHECK
|
|
||||||
/**
|
|
||||||
* Maps the elements to something else
|
|
||||||
* @param mapper the mapping function
|
|
||||||
* @return a new Builder Object with the mapped Iterable
|
|
||||||
*/
|
|
||||||
public BUILDER mapToTYPE(MAPPER<T> mapper) {
|
|
||||||
return new BUILDER(ITERABLES.mapToTYPE(iterable, mapper));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Filters out the unwanted elements out of the Iterable
|
* Filters out the unwanted elements out of the Iterable
|
||||||
|
|||||||
@@ -19,26 +19,6 @@ 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.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
|
|
||||||
#if BOOLEAN_COLLECTION_MODULE
|
|
||||||
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterable;
|
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
|
||||||
#endif
|
|
||||||
#iterate
|
|
||||||
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#argument CONSUMER ByteConsumer ShortConsumer IntConsumer LongConsumer FloatConsumer DoubleConsumer
|
|
||||||
#argument OUTPUT_ITERABLE ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
|
||||||
#argument OUTPUT_ITERATOR ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
|
||||||
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument PACKAGE bytes shorts ints longs floats doubles
|
|
||||||
#if FILTER_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|
||||||
import speiger.src.collections.objects.functions.function.MAPPER;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERATOR;
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
@@ -76,39 +56,6 @@ public class ITERABLES
|
|||||||
return new MappedIterable<>(iterable, mapper);
|
return new MappedIterable<>(iterable, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
|
||||||
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
|
||||||
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
/**
|
|
||||||
* A Helper function that maps a Java-Iterable into a new Type.
|
|
||||||
* @param iterable the iterable that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @return a iterable that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static <T> OUTPUT_ITERABLE mapToDATA_TYPE(Iterable<? extends CLASS_TYPE> iterable, MAPPER<T> mapper) {
|
|
||||||
return new MAPPED_TYPEIterable<>(wrap(iterable), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that maps a Iterable into a new Type.
|
|
||||||
* @param iterable the iterable that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @return a iterable that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static <T> OUTPUT_ITERABLE mapToDATA_TYPE(ITERABLE KEY_GENERIC_TYPE iterable, MAPPER<T> mapper) {
|
|
||||||
return new MAPPED_TYPEIterable<>(iterable, mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
||||||
* @param iterable the iterable that should be flatMapped
|
* @param iterable the iterable that should be flatMapped
|
||||||
@@ -333,47 +280,6 @@ public class ITERABLES
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument CONSUMER BooleanConsumer ByteConsumer ShortConsumer IntConsumer LongConsumer FloatConsumer DoubleConsumer
|
|
||||||
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
|
||||||
#argument OUTPUT_ITERABLE BooleanIterable ByteIterable ShortIterable IntIterable LongIterable FloatIterable DoubleIterable
|
|
||||||
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument APPLY test applyAsByte applyAsShort applyAsInt applyAsLong applyAsFloat applyAsDouble
|
|
||||||
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
|
||||||
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
private static class MAPPED_TYPEIterable<E> implements OUTPUT_ITERABLE, ISizeProvider
|
|
||||||
{
|
|
||||||
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
|
||||||
MAPPER<E> mapper;
|
|
||||||
|
|
||||||
MAPPED_TYPEIterable(ITERABLE<E> iterable, MAPPER<E> mapper) {
|
|
||||||
this.iterable = iterable;
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OUTPUT_ITERATOR iterator() {
|
|
||||||
return ITERATORS.mapToDATA_TYPE(iterable.iterator(), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
ISizeProvider prov = ISizeProvider.of(this);
|
|
||||||
return prov == null ? -1 : prov.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void forEach(CONSUMER action) {
|
|
||||||
Objects.requireNonNull(action);
|
|
||||||
iterable.forEach(E -> action.accept(mapper.APPLY(E)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
|
||||||
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>, ISizeProvider
|
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;
|
||||||
|
|||||||
+1
-147
@@ -4,8 +4,8 @@ import java.util.Iterator;
|
|||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.function.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import java.util.function.Consumer;
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -16,23 +16,8 @@ import speiger.src.collections.objects.collections.ObjectIterator;
|
|||||||
import speiger.src.collections.objects.utils.ObjectIterators;
|
import speiger.src.collections.objects.utils.ObjectIterators;
|
||||||
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
|
|
||||||
#if BOOLEAN_COLLECTION_MODULE
|
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
|
||||||
#endif
|
|
||||||
#iterate
|
|
||||||
#argument ITERATOR ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
|
||||||
#argument PACKAGE bytes shorts ints longs floats doubles
|
|
||||||
#argument MAPPER ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument FILTER_TYPE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
import speiger.src.collections.objects.functions.function.MAPPER;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#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.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
|
||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -48,7 +33,6 @@ import speiger.src.collections.PACKAGE.lists.LINKED_LIST;
|
|||||||
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;
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS.CollectionWrapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Iterators
|
* A Helper class for Iterators
|
||||||
@@ -123,7 +107,6 @@ public class ITERATORS
|
|||||||
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if OBJECT_COLLECTION_MODULE
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that maps a Java-Iterator into a new Type.
|
* A Helper function that maps a Java-Iterator into a new Type.
|
||||||
* @param iterator that should be mapped
|
* @param iterator that should be mapped
|
||||||
@@ -148,40 +131,6 @@ public class ITERATORS
|
|||||||
return new MappedIterator<>(iterator, mapper);
|
return new MappedIterator<>(iterator, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
|
||||||
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument DATA_TYPE Boolean Byte Short Int Long Float Double
|
|
||||||
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
/**
|
|
||||||
* A Helper function that maps a Java-Iterator into a new Type.
|
|
||||||
* @param iterator that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @return a iterator that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static <T> OUTPUT_ITERATOR mapToDATA_TYPE(Iterator<? extends CLASS_TYPE> iterator, MAPPER<T> mapper) {
|
|
||||||
return new MAPPED_TYPEIterator<>(wrap(iterator), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that maps a Iterator into a new Type.
|
|
||||||
* @param iterator that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @return a iterator that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static <T> OUTPUT_ITERATOR mapToDATA_TYPE(ITERATOR KEY_GENERIC_TYPE iterator, MAPPER<T> mapper) {
|
|
||||||
return new MAPPED_TYPEIterator<>(iterator, mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
||||||
* @param iterator that should be flatMapped
|
* @param iterator that should be flatMapped
|
||||||
@@ -296,26 +245,6 @@ public class ITERATORS
|
|||||||
return new RepeatingIteratorBRACES(wrap(iterator), repeats);
|
return new RepeatingIteratorBRACES(wrap(iterator), repeats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that creates a infinitely looping iterator
|
|
||||||
* @param iterator that should be looping infinitely
|
|
||||||
* @Type(T)
|
|
||||||
* @return a infinitely looping iterator
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE infinite(ITERATOR KEY_GENERIC_TYPE iterator) {
|
|
||||||
return new InfiniteIteratorBRACES(iterator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that creates a infinitely looping iterator from a Java Iterator
|
|
||||||
* @param iterator that should be looping infinitely
|
|
||||||
* @Type(T)
|
|
||||||
* @return a infinitely looping iterator
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE infinite(Iterator<? extends CLASS_TYPE> iterator) {
|
|
||||||
return new InfiniteIteratorBRACES(wrap(iterator));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@@ -917,45 +846,6 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
#iterate
|
|
||||||
#argument MAPPED_TYPE MappedBoolean MappedByte MappedShort MappedInt MappedLong MappedFloat MappedDouble
|
|
||||||
#argument NEXT_TYPE nextBoolean nextByte nextShort nextInt nextLong nextFloat nextDouble
|
|
||||||
#argument OUTPUT_ITERATOR BooleanIterator ByteIterator ShortIterator IntIterator LongIterator FloatIterator DoubleIterator
|
|
||||||
#argument MAPPER Predicate ToByteFunction ToShortFunction ToIntFunction ToLongFunction ToFloatFunction ToDoubleFunction
|
|
||||||
#argument APPLY test applyAsByte applyAsShort applyAsInt applyAsLong applyAsFloat applyAsDouble
|
|
||||||
#argument DATA_TYPE boolean byte short int long float double
|
|
||||||
#argument FILTER_TYPE BOOLEAN_COLLECTION_MODULE BYTE_COLLECTION_MODULE SHORT_COLLECTION_MODULE INT_COLLECTION_MODULE LONG_COLLECTION_MODULE FLOAT_COLLECTION_MODULE DOUBLE_COLLECTION_MODULE
|
|
||||||
#if FILTER_TYPE
|
|
||||||
private static class MAPPED_TYPEIterator<E> implements OUTPUT_ITERATOR
|
|
||||||
{
|
|
||||||
ITERATOR<E> iterator;
|
|
||||||
MAPPER<E> mapper;
|
|
||||||
|
|
||||||
MAPPED_TYPEIterator(ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator, MAPPER<E> mapper) {
|
|
||||||
this.iterator = iterator;
|
|
||||||
this.mapper = mapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return iterator.hasNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DATA_TYPE NEXT_TYPE() {
|
|
||||||
return mapper.APPLY(iterator.NEXT());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int skip(int amount) {
|
|
||||||
return iterator.skip(amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#enditerate
|
|
||||||
#endif
|
|
||||||
private static class FlatMappedIterator KSS_GENERIC_TYPE<E, T,[SPACE]V extends Iterable<T>> implements ObjectIterator<T>
|
private static class FlatMappedIterator KSS_GENERIC_TYPE<E, T,[SPACE]V extends Iterable<T>> implements ObjectIterator<T>
|
||||||
{
|
{
|
||||||
ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator;
|
ITERATOR KEY_SPECIAL_GENERIC_TYPE<E> iterator;
|
||||||
@@ -1028,42 +918,6 @@ public class ITERATORS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InfiniteIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
|
||||||
CollectionWrapper KEY_GENERIC_TYPE looper = COLLECTIONS.wrapper();
|
|
||||||
int index = 0;
|
|
||||||
|
|
||||||
public InfiniteIterator(ITERATOR KEY_GENERIC_TYPE iter) {
|
|
||||||
this.iter = iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() {
|
|
||||||
if(iter != null) {
|
|
||||||
if(iter.hasNext()) {
|
|
||||||
KEY_TYPE value = iter.NEXT();
|
|
||||||
looper.add(value);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
else iter = null;
|
|
||||||
}
|
|
||||||
return looper.GET_KEY((index++) % looper.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
public void forEachRemaining(CONSUMER action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
|
||||||
#endif
|
|
||||||
public void forEachRemaining(Consumer<? super CLASS_TYPE> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
|
||||||
public <E> void forEachRemaining(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { throw new UnsupportedOperationException("This is a instant deadlock, so unsupported"); }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
private static class RepeatingIterator KEY_GENERIC_TYPE implements ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
final int repeats;
|
final int repeats;
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
#endif
|
#endif
|
||||||
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;
|
||||||
#if INT_LIST_MODULE && !TYPE_INT
|
|
||||||
import speiger.src.collections.ints.lists.IntList;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
@@ -411,18 +408,6 @@ public class LISTS
|
|||||||
return l.listIterator(index);
|
return l.listIterator(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
|
||||||
return l.indexedIterator(indecies);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
|
||||||
return l.indexedIterator(indecies);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
||||||
return LISTS.synchronize(l.subList(from, to));
|
return LISTS.synchronize(l.subList(from, to));
|
||||||
@@ -550,18 +535,6 @@ public class LISTS
|
|||||||
return ITERATORS.unmodifiable(l.listIterator(index));
|
return ITERATORS.unmodifiable(l.listIterator(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
|
||||||
return ITERATORS.unmodifiable(l.indexedIterator(indecies));
|
|
||||||
}
|
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
|
||||||
return ITERATORS.unmodifiable(l.indexedIterator(indecies));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) {
|
||||||
return LISTS.unmodifiable(l.subList(from, to));
|
return LISTS.unmodifiable(l.subList(from, to));
|
||||||
@@ -660,18 +633,6 @@ public class LISTS
|
|||||||
return ITERATORS.empty();
|
return ITERATORS.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(int...indecies) {
|
|
||||||
return ITERATORS.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if INT_LIST_MODULE
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE indexedIterator(IntList indecies) {
|
|
||||||
return ITERATORS.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return 1; }
|
public int hashCode() { return 1; }
|
||||||
|
|
||||||
|
|||||||
-2
@@ -116,8 +116,6 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
public KEY_TYPE peek(int index) { synchronized(mutex) { return queue.peek(index); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE e) { synchronized(mutex) { return queue.contains(e); } }
|
|
||||||
@Override
|
|
||||||
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
public boolean removeFirst(KEY_TYPE e) { synchronized(mutex) { return queue.removeFirst(e); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
public boolean removeLast(KEY_TYPE e) { synchronized(mutex) { return queue.removeLast(e); } }
|
||||||
|
|||||||
+24
-32
@@ -340,22 +340,20 @@ public class MAPS
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -412,22 +410,20 @@ public class MAPS
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -673,22 +669,20 @@ public class MAPS
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -1115,22 +1109,20 @@ public class MAPS
|
|||||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { map.REPLACE_VALUES(mappingFunction); } }
|
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { map.REPLACE_VALUES(mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE(key, mappingFunction); } }
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENT(key, mappingFunction); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENT(key, valueProvider); } }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTENonDefault(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTENonDefault(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENT(key, mappingFunction); } }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENTNonDefault(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_ABSENTNonDefault(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); } }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENTNonDefault(key, mappingFunction); } }
|
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.COMPUTE_IF_PRESENTNonDefault(key, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENT(key, valueProvider); } }
|
||||||
|
@Override
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENTNonDefault(key, valueProvider); } }
|
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { synchronized(mutex) { return map.SUPPLY_IF_ABSENTNonDefault(key, valueProvider); } }
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { synchronized(mutex) { return map.MERGE(key, value, mappingFunction); } }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-14
@@ -53,11 +53,6 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCl
|
|||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester;
|
||||||
#if !VALUE_OBJECT
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester;
|
|
||||||
#endif
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapCopyTester;
|
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_TYPEMapContainsTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsKeyTester;
|
||||||
@@ -83,9 +78,6 @@ import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapRe
|
|||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapReplaceTester;
|
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_TYPEMapSizeTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester;
|
||||||
#if !VALUE_OBJECT
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester;
|
|
||||||
#endif
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEMapToStringTester;
|
||||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
@@ -113,12 +105,6 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||||||
protected List<Class<? extends AbstractTester>> getTesters() {
|
protected List<Class<? extends AbstractTester>> getTesters() {
|
||||||
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
List<Class<? extends AbstractTester>> testers = new ArrayList<>();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapClearTester.class);
|
||||||
#if !VALUE_OBJECT
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester.class);
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester.class);
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester.class);
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester.class);
|
|
||||||
#endif
|
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester.class);
|
||||||
|
|||||||
-153
@@ -1,153 +0,0 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.maps;
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
|
||||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
|
||||||
#endignore
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
|
||||||
#endignore
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_supportedAbsent() {
|
|
||||||
#if VALUE_BOOLEAN
|
|
||||||
getMap().setDefaultReturnValue(true);
|
|
||||||
#endif
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectAdded(e3());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(ONE)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_supportedAbsentFirst() {
|
|
||||||
getMap().setDefaultReturnValue(v0());
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectContents(entry(k0(), v3()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(ONE)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
|
||||||
getMap().setDefaultReturnValue(v0());
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
return v0();
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_supportedPresent() {
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
|
||||||
throw new AssertionFailedError();
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_functionThrows() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
throw new ExpectedException();
|
|
||||||
});
|
|
||||||
fail("Expected ExpectedException");
|
|
||||||
} catch (ExpectedException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_unsupportedAbsent() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
|
||||||
// allowed to be called
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
return v3();
|
|
||||||
});
|
|
||||||
fail("COMPUTE_IF_ABSENT(notPresent, function) should throw");
|
|
||||||
} catch (UnsupportedOperationException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
|
||||||
try {
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
return v0();
|
|
||||||
}));
|
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
|
||||||
try {
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+9
-21
@@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsent() {
|
public void testComputeIfAbsent_supportedAbsent() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
@@ -40,19 +40,11 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsentFirst() {
|
public void testComputeIfAbsent_supportedAbsentFirst() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
#if VALUE_OBJECT
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
expectContents(entry(k0(), v3()));
|
expectContents(entry(k0(), v3()));
|
||||||
#else
|
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -61,7 +53,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
public void testComputeIfAbsent_supportedAbsentSameResult() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v0();
|
return v0();
|
||||||
}));
|
}));
|
||||||
@@ -74,7 +66,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_supportedPresent() {
|
public void testComputeIfAbsent_supportedPresent() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, function) should return existing value", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -84,15 +76,11 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
public void testComputeIfAbsent_functionReturnsNullNotInserted() {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
#if VALUE_OBJECT
|
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
#else
|
|
||||||
expectAdded(entry(k3(), INVALID_VALUE));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@@ -104,7 +92,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_functionThrows() {
|
public void testComputeIfAbsent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
});
|
});
|
||||||
@@ -119,7 +107,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedAbsent() {
|
public void testComputeIfAbsent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_ABSENT(k3(), k -> {
|
getMap().COMPUTE_IF_ABSENTNonDefault(k3(), k -> {
|
||||||
// allowed to be called
|
// allowed to be called
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
return v3();
|
return v3();
|
||||||
@@ -136,7 +124,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
public void testComputeIfAbsent_unsupportedPresentExistingValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v0();
|
return v0();
|
||||||
}));
|
}));
|
||||||
@@ -151,7 +139,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfAbsentTester KEY_VALUE_GEN
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
public void testComputeIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENT(k0(), k -> {
|
assertEquals("COMPUTE_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().COMPUTE_IF_ABSENTNonDefault(k0(), k -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
return v3();
|
return v3();
|
||||||
}));
|
}));
|
||||||
|
|||||||
-104
@@ -1,104 +0,0 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.maps;
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
|
||||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
|
||||||
#endignore
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_supportedAbsent() {
|
|
||||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
|
||||||
throw new AssertionFailedError();
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_supportedPresent() {
|
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectReplacement(entry(k0(), v3()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_functionReturnsNull() {
|
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
}));
|
|
||||||
expectMissing(e0());
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_functionThrows() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
throw new ExpectedException();
|
|
||||||
});
|
|
||||||
fail("Expected ExpectedException");
|
|
||||||
} catch (ExpectedException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_unsupportedAbsent() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
|
||||||
throw new AssertionFailedError();
|
|
||||||
});
|
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testComputeIfPresent_unsupportedPresent() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
|
||||||
fail("Expected UnsupportedOperationException");
|
|
||||||
} catch (UnsupportedOperationException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+6
-6
@@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_supportedAbsent() {
|
public void testComputeIfPresent_supportedAbsent() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(notPresent, function) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -32,7 +32,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_supportedPresent() {
|
public void testComputeIfPresent_supportedPresent() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(present, function) should return new value", v3(), getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return v3();
|
return v3();
|
||||||
@@ -45,7 +45,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_functionReturnsNull() {
|
public void testComputeIfPresent_functionReturnsNull() {
|
||||||
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
assertEquals("COMPUTE_IF_PRESENT(present, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
@@ -63,7 +63,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_functionThrows() {
|
public void testComputeIfPresent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> {
|
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@@ -79,7 +79,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_unsupportedAbsent() {
|
public void testComputeIfPresent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENT(k3(), (k, v) -> {
|
getMap().COMPUTE_IF_PRESENTNonDefault(k3(), (k, v) -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
});
|
});
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
@@ -93,7 +93,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeIfPresentTester KEY_VALUE_GE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testComputeIfPresent_unsupportedPresent() {
|
public void testComputeIfPresent_unsupportedPresent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE_IF_PRESENT(k0(), (k, v) -> v3());
|
getMap().COMPUTE_IF_PRESENTNonDefault(k0(), (k, v) -> v3());
|
||||||
fail("Expected UnsupportedOperationException");
|
fail("Expected UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException expected) {
|
} catch (UnsupportedOperationException expected) {
|
||||||
}
|
}
|
||||||
|
|||||||
-148
@@ -1,148 +0,0 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.maps;
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
|
||||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
|
||||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
|
|
||||||
#endignore
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
#endignore
|
|
||||||
public void testCompute_absentToPresent() {
|
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
assertEquals(INVALID_VALUE, v);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectAdded(e3());
|
|
||||||
assertEquals(getNumElements() + 1, getMap().size());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
#endignore
|
|
||||||
public void testCompute_absentToAbsent() {
|
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
assertEquals(INVALID_VALUE, v);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
assertEquals(getNumElements(), getMap().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testCompute_presentToPresent() {
|
|
||||||
#if VALUE_BOOLEAN
|
|
||||||
getMap().setDefaultReturnValue(true);
|
|
||||||
#endif
|
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
return v3();
|
|
||||||
}));
|
|
||||||
expectReplacement(entry(k0(), v3()));
|
|
||||||
assertEquals(getNumElements(), getMap().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testCompute_presentToAbsent() {
|
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
}));
|
|
||||||
expectMissing(e0());
|
|
||||||
expectMissingKeys(k0());
|
|
||||||
assertEquals(getNumElements() - 1, getMap().size());
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testCompute_presentFunctionThrows() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
|
||||||
assertEquals(k0(), k);
|
|
||||||
assertEquals(v0(), v);
|
|
||||||
throw new ExpectedException();
|
|
||||||
});
|
|
||||||
fail("Expected ExpectedException");
|
|
||||||
} catch (ExpectedException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
|
||||||
#endignore
|
|
||||||
public void testCompute_absentFunctionThrows() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
assertEquals(INVALID_VALUE, v);
|
|
||||||
throw new ExpectedException();
|
|
||||||
});
|
|
||||||
fail("Expected ExpectedException");
|
|
||||||
} catch (ExpectedException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_REMOVE)
|
|
||||||
#endignore
|
|
||||||
public void testCompute_removeAbsent() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
assertEquals(INVALID_VALUE, v);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
});
|
|
||||||
fail("Expected UnsupportedOperationException");
|
|
||||||
} catch (UnsupportedOperationException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testCompute_putAbsent() {
|
|
||||||
try {
|
|
||||||
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
|
||||||
assertEquals(k3(), k);
|
|
||||||
assertEquals(INVALID_VALUE, v);
|
|
||||||
return INVALID_VALUE;
|
|
||||||
});
|
|
||||||
fail("Expected UnsupportedOperationException");
|
|
||||||
} catch (UnsupportedOperationException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+8
-18
@@ -21,7 +21,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentToPresent() {
|
public void testCompute_absentToPresent() {
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTE(k3(), (k, v) -> {
|
assertEquals("Map.COMPUTE(absent, functionReturningValue) should return value", v3(), getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return v3();
|
return v3();
|
||||||
@@ -34,18 +34,13 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
@MapFeature.Require({ SUPPORTS_PUT, SUPPORTS_REMOVE })
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentToAbsent() {
|
public void testCompute_absentToAbsent() {
|
||||||
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k3(), (k, v) -> {
|
assertEquals("Map.COMPUTE(absent, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
#if VALUE_OBJECT
|
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
assertEquals(getNumElements(), getMap().size());
|
assertEquals(getNumElements(), getMap().size());
|
||||||
#else
|
|
||||||
expectAdded(entry(k3(), INVALID_VALUE));
|
|
||||||
assertEquals(getNumElements()+1, getMap().size());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -53,7 +48,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentToPresent() {
|
public void testCompute_presentToPresent() {
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTE(k0(), (k, v) -> {
|
assertEquals("Map.COMPUTE(present, functionReturningValue) should return new value", v3(), getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return v3();
|
return v3();
|
||||||
@@ -67,19 +62,14 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentToAbsent() {
|
public void testCompute_presentToAbsent() {
|
||||||
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTE(k0(), (k, v) -> {
|
assertEquals("Map.COMPUTE(present, functionReturningNull) should return INVALID_VALUE", INVALID_VALUE, getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
}));
|
}));
|
||||||
#if VALUE_OBJECT
|
|
||||||
expectMissing(e0());
|
expectMissing(e0());
|
||||||
expectMissingKeys(k0());
|
expectMissingKeys(k0());
|
||||||
assertEquals(getNumElements() - 1, getMap().size());
|
assertEquals(getNumElements() - 1, getMap().size());
|
||||||
#else
|
|
||||||
expectReplacement(entry(k0(), INVALID_VALUE));
|
|
||||||
assertEquals(getNumElements(), getMap().size());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@@ -92,7 +82,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_presentFunctionThrows() {
|
public void testCompute_presentFunctionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE(k0(), (k, v) -> {
|
getMap().COMPUTENonDefault(k0(), (k, v) -> {
|
||||||
assertEquals(k0(), k);
|
assertEquals(k0(), k);
|
||||||
assertEquals(v0(), v);
|
assertEquals(v0(), v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@@ -108,7 +98,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_absentFunctionThrows() {
|
public void testCompute_absentFunctionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE(k3(), (k, v) -> {
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
@@ -124,7 +114,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_removeAbsent() {
|
public void testCompute_removeAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE(k3(), (k, v) -> {
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
@@ -140,7 +130,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapComputeTester KEY_VALUE_GENERIC_TYP
|
|||||||
#endignore
|
#endignore
|
||||||
public void testCompute_putAbsent() {
|
public void testCompute_putAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().COMPUTE(k3(), (k, v) -> {
|
getMap().COMPUTENonDefault(k3(), (k, v) -> {
|
||||||
assertEquals(k3(), k);
|
assertEquals(k3(), k);
|
||||||
assertEquals(INVALID_VALUE, v);
|
assertEquals(INVALID_VALUE, v);
|
||||||
return INVALID_VALUE;
|
return INVALID_VALUE;
|
||||||
|
|||||||
-130
@@ -1,130 +0,0 @@
|
|||||||
package speiger.src.testers.PACKAGE.tests.maps;
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ZERO;
|
|
||||||
import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_PUT;
|
|
||||||
#endignore
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
import static com.google.common.collect.testing.features.CollectionSize.ONE;
|
|
||||||
#endignore
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
||||||
|
|
||||||
@Ignore
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentNonDefaultTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_supportedAbsent() {
|
|
||||||
#if VALUE_BOOLEAN
|
|
||||||
getMap().setDefaultReturnValue(true);
|
|
||||||
#endif
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
|
||||||
expectAdded(e3());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(ONE)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
|
||||||
getMap().setDefaultReturnValue(v0());
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
|
||||||
expectContents(entry(k0(), v3()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(ONE)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
|
||||||
getMap().setDefaultReturnValue(v0());
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_supportedPresent() {
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
|
||||||
throw new AssertionFailedError();
|
|
||||||
}));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_functionThrows() {
|
|
||||||
try {
|
|
||||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
|
||||||
throw new ExpectedException();
|
|
||||||
});
|
|
||||||
fail("Expected ExpectedException");
|
|
||||||
} catch (ExpectedException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_unsupportedAbsent() {
|
|
||||||
try {
|
|
||||||
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
|
||||||
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
|
||||||
} catch (UnsupportedOperationException expected) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
|
||||||
try {
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
|
||||||
try {
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
|
||||||
}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+9
-18
@@ -26,7 +26,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsent() {
|
public void testSupplyIfAbsent_supportedAbsent() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k3(), this::v3));
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3));
|
||||||
expectAdded(e3());
|
expectAdded(e3());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,13 +37,8 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
public void testSupplyIfAbsent_supportedAbsentFirst() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
#if VALUE_OBJECT
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v3(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
|
||||||
expectContents(entry(k0(), v3()));
|
expectContents(entry(k0(), v3()));
|
||||||
#else
|
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
|
||||||
expectUnchanged();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -52,7 +47,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
public void testSupplyIfAbsent_supportedAbsentSameResult() {
|
||||||
getMap().setDefaultReturnValue(v0());
|
getMap().setDefaultReturnValue(v0());
|
||||||
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
assertEquals("SUPPLY_IF_ABSENT(notPresent, function) should return new value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +57,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_supportedPresent() {
|
public void testSupplyIfAbsent_supportedPresent() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENT(k0(), () -> {
|
assertEquals("SUPPLY_IF_ABSENT(present, function) should return existing value", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), () -> {
|
||||||
throw new AssertionFailedError();
|
throw new AssertionFailedError();
|
||||||
}));
|
}));
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -72,12 +67,8 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
@MapFeature.Require(SUPPORTS_PUT)
|
@MapFeature.Require(SUPPORTS_PUT)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
public void testSupplyIfAbsent_functionReturnsNullNotInserted() {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENT(k3(), () -> INVALID_VALUE));
|
assertEquals("SUPPLY_IF_ABSENT(absent, returnsNull) should return INVALID_VALUE", INVALID_VALUE, getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> INVALID_VALUE));
|
||||||
#if VALUE_OBJECT
|
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
#else
|
|
||||||
expectAdded(entry(k3(), INVALID_VALUE));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExpectedException extends RuntimeException {
|
static class ExpectedException extends RuntimeException {
|
||||||
@@ -89,7 +80,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_functionThrows() {
|
public void testSupplyIfAbsent_functionThrows() {
|
||||||
try {
|
try {
|
||||||
getMap().SUPPLY_IF_ABSENT(k3(), () -> {
|
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), () -> {
|
||||||
throw new ExpectedException();
|
throw new ExpectedException();
|
||||||
});
|
});
|
||||||
fail("Expected ExpectedException");
|
fail("Expected ExpectedException");
|
||||||
@@ -103,7 +94,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedAbsent() {
|
public void testSupplyIfAbsent_unsupportedAbsent() {
|
||||||
try {
|
try {
|
||||||
getMap().SUPPLY_IF_ABSENT(k3(), this::v3);
|
getMap().SUPPLY_IF_ABSENTNonDefault(k3(), this::v3);
|
||||||
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
fail("SUPPLY_IF_ABSENT(notPresent, function) should throw");
|
||||||
} catch (UnsupportedOperationException expected) {
|
} catch (UnsupportedOperationException expected) {
|
||||||
}
|
}
|
||||||
@@ -116,7 +107,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
public void testSupplyIfAbsent_unsupportedPresentExistingValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v0));
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsCurrentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v0));
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -128,7 +119,7 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapSupplyIfAbsentTester KEY_VALUE_GENE
|
|||||||
#endignore
|
#endignore
|
||||||
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
public void testSupplyIfAbsent_unsupportedPresentDifferentValue() {
|
||||||
try {
|
try {
|
||||||
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENT(k0(), this::v3));
|
assertEquals("SUPPLY_IF_ABSENT(present, returnsDifferentValue) should return present or throw", v0(), getMap().SUPPLY_IF_ABSENTNonDefault(k0(), this::v3));
|
||||||
} catch (UnsupportedOperationException tolerated) {
|
} catch (UnsupportedOperationException tolerated) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
|
|||||||
+252
@@ -0,0 +1,252 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.AbstractCollection;
|
||||||
|
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanIterators;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanArrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abstract Type Specific Collection that reduces boxing/unboxing
|
||||||
|
*/
|
||||||
|
public abstract class AbstractBooleanCollection extends AbstractCollection<Boolean> implements BooleanCollection
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public abstract BooleanIterator iterator();
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean add(Boolean e) { return BooleanCollection.super.add(e); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addAll(BooleanCollection c) {
|
||||||
|
boolean modified = false;
|
||||||
|
for(BooleanIterator iter = c.iterator();iter.hasNext();modified |= add(iter.nextBoolean()));
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BooleanCollection copy() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean contains(Object e) { return BooleanCollection.super.contains(e); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of contains. This implementation iterates over the elements and returns true if the value match.
|
||||||
|
* @param e the element that should be searched for.
|
||||||
|
* @return true if the value was found.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean contains(boolean e) {
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) { if(iter.nextBoolean() == e) return true; }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean addAll(Collection<? extends Boolean> c)
|
||||||
|
{
|
||||||
|
return c instanceof BooleanCollection ? addAll((BooleanCollection)c) : super.addAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||||
|
* @param c the collection that should be checked if it contains all elements.
|
||||||
|
* @return true if all elements were found in the collection
|
||||||
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean containsAll(BooleanCollection c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) return true;
|
||||||
|
for(BooleanIterator iter = c.iterator();iter.hasNext();)
|
||||||
|
if(!contains(iter.nextBoolean()))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsAll(Collection<?> c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
return c instanceof BooleanCollection ? containsAll((BooleanCollection)c) : super.containsAll(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This implementation iterates over the elements of the collection and checks if they are stored in this collection
|
||||||
|
* @param c the elements that should be checked for
|
||||||
|
* @return true if any element is in this collection
|
||||||
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean containsAny(Collection<?> c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
for(Object e : c)
|
||||||
|
if(contains(e))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This implementation iterates over the elements of the collection and checks if they are stored in this collection.
|
||||||
|
* @param c the elements that should be checked for
|
||||||
|
* @return true if any element is in this collection
|
||||||
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean containsAny(BooleanCollection c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
for(BooleanIterator iter = c.iterator();iter.hasNext();)
|
||||||
|
if(contains(iter.nextBoolean()))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public boolean remove(Object e) { return BooleanCollection.super.remove(e); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of remove. This implementation iterates over the elements until it finds the element that is searched for or it runs out of elements.
|
||||||
|
* It stops after finding the first element
|
||||||
|
* @param e the element that is searched for
|
||||||
|
* @return true if the element was found and removed.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean remBoolean(boolean e) {
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(iter.nextBoolean() == e) {
|
||||||
|
iter.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of removeAll. This Implementation iterates over all elements and removes them as they were found in the other collection.
|
||||||
|
* @param c the elements that should be deleted
|
||||||
|
* @return true if the collection was modified.
|
||||||
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(BooleanCollection c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
boolean modified = false;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(c.contains(iter.nextBoolean())) {
|
||||||
|
iter.remove();
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removeAll(BooleanCollection c, BooleanConsumer r) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) return false;
|
||||||
|
Objects.requireNonNull(r);
|
||||||
|
boolean modified = false;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
boolean e = iter.nextBoolean();
|
||||||
|
if(c.contains(e)) {
|
||||||
|
r.accept(e);
|
||||||
|
iter.remove();
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of retainAll. This Implementation iterates over all elements and removes them as they were not found in the other collection.
|
||||||
|
* @param c the elements that should be kept
|
||||||
|
* @return true if the collection was modified.
|
||||||
|
* @throws java.lang.NullPointerException if the collection is null
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(BooleanCollection c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
boolean modified = !isEmpty();
|
||||||
|
clear();
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
boolean modified = false;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(!c.contains(iter.nextBoolean())) {
|
||||||
|
iter.remove();
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean retainAll(BooleanCollection c, BooleanConsumer r) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
Objects.requireNonNull(r);
|
||||||
|
if(c.isEmpty()) {
|
||||||
|
boolean modified = !isEmpty();
|
||||||
|
forEach(r);
|
||||||
|
clear();
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
boolean modified = false;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
boolean e = iter.nextBoolean();
|
||||||
|
if(!c.contains(e)) {
|
||||||
|
r.accept(e);
|
||||||
|
iter.remove();
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of toArray that links to {@link #toBooleanArray(boolean[])} with a newly created array.
|
||||||
|
* @return an array containing all of the elements in this collection
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean[] toBooleanArray() {
|
||||||
|
if(isEmpty()) return BooleanArrays.EMPTY_ARRAY;
|
||||||
|
return toBooleanArray(new boolean[size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific implementation of toArray. This implementation iterates over all elements and unwraps them into primitive type.
|
||||||
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
|
* @return an array containing all of the elements in this collection
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean[] toBooleanArray(boolean[] a) {
|
||||||
|
if(a == null || a.length < size()) a = new boolean[size()];
|
||||||
|
BooleanIterators.unwrap(a, iterator());
|
||||||
|
if (a.length > size()) a[size()] = false;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import speiger.src.collections.objects.collections.ObjectBidirectionalIterator;
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link ObjectBidirectionalIterator} to reduce (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanBidirectionalIterator extends BooleanIterator, ObjectBidirectionalIterator<Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns true if the Iterator has a Previous element
|
||||||
|
* @return true if the Iterator has a Previous element
|
||||||
|
*/
|
||||||
|
public boolean hasPrevious();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Previous element of the iterator.
|
||||||
|
* @return the Previous element of the iterator.
|
||||||
|
* @throws java.util.NoSuchElementException if the iteration has no more elements
|
||||||
|
*/
|
||||||
|
public boolean previousBoolean();
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default Boolean previous() {
|
||||||
|
return Boolean.valueOf(previousBoolean());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
default int skip(int amount)
|
||||||
|
{
|
||||||
|
return BooleanIterator.super.skip(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverses the Given amount of elements if possible. A Optimization function to reverse elements faster if the implementation allows it.
|
||||||
|
* @param amount the amount of elements that should be reversed
|
||||||
|
* @return the amount of elements that were reversed
|
||||||
|
*/
|
||||||
|
public default int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Can't go forward");
|
||||||
|
int i = 0;
|
||||||
|
for(;i<amount && hasPrevious();previousBoolean(),i++);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanSplititerators;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanCollections;
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanCollection extends Collection<Boolean>, BooleanIterable, ISizeProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type-Specific add function to reduce (un)boxing
|
||||||
|
* @param o the element that should be added
|
||||||
|
* @return true if the element was added to the collection
|
||||||
|
*/
|
||||||
|
public boolean add(boolean o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific addAll function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be added
|
||||||
|
* @return true if elements were added into the collection
|
||||||
|
*/
|
||||||
|
public boolean addAll(BooleanCollection c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
|
* @param e the elements that should be added
|
||||||
|
* @return if the collection was modified
|
||||||
|
*/
|
||||||
|
public default boolean addAll(boolean... e) { return addAll(e, 0, e.length); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
|
* @param e the elements that should be added
|
||||||
|
* @param length how many elements of the array should be added
|
||||||
|
* @return if the collection was modified
|
||||||
|
*/
|
||||||
|
public default boolean addAll(boolean[] e, int length) { return addAll(e, 0, length); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
||||||
|
* @param e the elements that should be added
|
||||||
|
* @param offset where to start within the array
|
||||||
|
* @param length how many elements of the array should be added
|
||||||
|
* @return if the collection was modified
|
||||||
|
*/
|
||||||
|
public default boolean addAll(boolean[] e, int offset, int length) {
|
||||||
|
if(length <= 0) return false;
|
||||||
|
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
||||||
|
boolean added = false;
|
||||||
|
for(int i = 0;i<length;i++) {
|
||||||
|
if(add(e[offset+i])) added = true;
|
||||||
|
}
|
||||||
|
return added;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific contains function to reduce (un)boxing
|
||||||
|
* @param o the element that is checked for
|
||||||
|
* @return true if the element is found in the collection
|
||||||
|
*/
|
||||||
|
public boolean contains(boolean o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific containsAll function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be tested for
|
||||||
|
* @return true if all the element is found in the collection
|
||||||
|
*/
|
||||||
|
public boolean containsAll(BooleanCollection c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific containsAny function to reduce (un)boxing
|
||||||
|
* @param c the collection of elements that should be tested for
|
||||||
|
* @return true if any element was found
|
||||||
|
*/
|
||||||
|
public boolean containsAny(BooleanCollection c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if any element of the Collection is found in the provided collection.
|
||||||
|
* A Small Optimization function to find out of any element is present when comparing collections and not all of them.
|
||||||
|
* @param c the collection of elements that should be tested for
|
||||||
|
* @return true if any element was found.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public boolean containsAny(Collection<?> c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific remove function that reduces (un)boxing.
|
||||||
|
* @param o the element that should be removed
|
||||||
|
* @return true if the element was removed
|
||||||
|
* @see Collection#remove(Object)
|
||||||
|
*/
|
||||||
|
public boolean remBoolean(boolean o);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
|
* @param c the collection of elements that should be removed
|
||||||
|
* @return true if any element was removed
|
||||||
|
* @see Collection#removeAll(Collection)
|
||||||
|
*/
|
||||||
|
public boolean removeAll(BooleanCollection c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific removeAll function that reduces (un)boxing.
|
||||||
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
|
* @param c the collection of elements that should be removed
|
||||||
|
* @param r elements that got removed
|
||||||
|
* @return true if any element was removed
|
||||||
|
* @see Collection#removeAll(Collection)
|
||||||
|
*/
|
||||||
|
public boolean removeAll(BooleanCollection c, BooleanConsumer r);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
|
* @param c the collection of elements that should be kept
|
||||||
|
* @return true if any element was removed
|
||||||
|
* @see Collection#retainAll(Collection)
|
||||||
|
*/
|
||||||
|
public boolean retainAll(BooleanCollection c);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific retainAll function that reduces (un)boxing.
|
||||||
|
* It also notifies the remover of which exact element is going to be removed.
|
||||||
|
* @param c the collection of elements that should be kept
|
||||||
|
* @param r elements that got removed
|
||||||
|
* @return true if any element was removed
|
||||||
|
* @see Collection#retainAll(Collection)
|
||||||
|
*/
|
||||||
|
public boolean retainAll(BooleanCollection c, BooleanConsumer r);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||||
|
* @param collection that the elements should be inserted to
|
||||||
|
* @param <E> the collection type
|
||||||
|
* @return the input with the desired elements
|
||||||
|
*/
|
||||||
|
default <E extends BooleanCollection> E pour(E collection) {
|
||||||
|
collection.addAll(this);
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Function that does a shallow clone of the Collection itself.
|
||||||
|
* This function is more optimized then a copy constructor since the Collection does not have to be unsorted/resorted.
|
||||||
|
* It can be compared to Cloneable but with less exception risk
|
||||||
|
* @return a Shallow Copy of the collection
|
||||||
|
* @note Wrappers and view collections will not support this feature
|
||||||
|
*/
|
||||||
|
public BooleanCollection copy();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific toArray function that delegates to {@link #toBooleanArray(boolean[])} with a newly created array.
|
||||||
|
* @return an array containing all of the elements in this collection
|
||||||
|
* @see Collection#toArray()
|
||||||
|
*/
|
||||||
|
public boolean[] toBooleanArray();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific toArray function that reduces (un)boxing.
|
||||||
|
* @param a array that the elements should be injected to. If null or to small a new array with the right size is created
|
||||||
|
* @return an array containing all of the elements in this collection
|
||||||
|
* @see Collection#toArray(Object[])
|
||||||
|
*/
|
||||||
|
public boolean[] toBooleanArray(boolean[] a);
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default boolean add(Boolean o) { return add(o.booleanValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default boolean contains(Object o) { return o != null && contains(((Boolean)o).booleanValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default boolean remove(Object o) { return o != null && remBoolean(((Boolean)o).booleanValue()); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Type-Specific Iterator to reduce (un)boxing
|
||||||
|
* @return a iterator of the collection
|
||||||
|
* @see Collection#iterator()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public BooleanIterator iterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
|
* @return a new Collection that is synchronized
|
||||||
|
* @see BooleanCollections#synchronize
|
||||||
|
*/
|
||||||
|
public default BooleanCollection synchronize() { return BooleanCollections.synchronize(this); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Wrapped Collection that is Synchronized
|
||||||
|
* @param mutex is the controller of the synchronization block
|
||||||
|
* @return a new Collection Wrapper that is synchronized
|
||||||
|
* @see BooleanCollections#synchronize
|
||||||
|
*/
|
||||||
|
public default BooleanCollection synchronize(Object mutex) { return BooleanCollections.synchronize(this, mutex); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Wrapped Collection that is unmodifiable
|
||||||
|
* @return a new Collection Wrapper that is unmodifiable
|
||||||
|
* @see BooleanCollections#unmodifiable
|
||||||
|
*/
|
||||||
|
public default BooleanCollection unmodifiable() { return BooleanCollections.unmodifiable(this); }
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
|
* @return type specific splititerator
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
default BooleanSplititerator spliterator() { return BooleanSplititerators.createSplititerator(this, 0); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,333 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanComparator;
|
||||||
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
|
import speiger.src.collections.booleans.functions.function.BooleanFunction;
|
||||||
|
import speiger.src.collections.ints.functions.consumer.IntBooleanConsumer;
|
||||||
|
import speiger.src.collections.objects.functions.consumer.ObjectBooleanConsumer;
|
||||||
|
import speiger.src.collections.booleans.functions.function.BooleanPredicate;
|
||||||
|
import speiger.src.collections.booleans.functions.function.BooleanBooleanUnaryOperator;
|
||||||
|
import speiger.src.collections.booleans.lists.BooleanList;
|
||||||
|
import speiger.src.collections.booleans.lists.BooleanArrayList;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanArrays;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanAsyncBuilder;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanSplititerators;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanIterables;
|
||||||
|
import speiger.src.collections.booleans.utils.BooleanIterators;
|
||||||
|
import speiger.src.collections.utils.ISizeProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link Iterable} that reduces (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanIterable extends Iterable<Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns an iterator over elements of type {@code T}.
|
||||||
|
*
|
||||||
|
* @return an Iterator.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
BooleanIterator iterator();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
|
*
|
||||||
|
* @implSpec
|
||||||
|
* <p>The default implementation behaves as if:
|
||||||
|
* <pre>{@code
|
||||||
|
* iterator().forEachRemaining(action);
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @param action The action to be performed for each element
|
||||||
|
* @throws NullPointerException if the specified action is null
|
||||||
|
* @see Iterable#forEach(Consumer)
|
||||||
|
*/
|
||||||
|
default void forEach(BooleanConsumer action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
iterator().forEachRemaining(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
default void forEach(Consumer<? super Boolean> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
iterator().forEachRemaining(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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(IntBooleanConsumer action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
int index = 0;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();action.accept(index++, iter.nextBoolean()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 action The action to be performed for each element
|
||||||
|
* @param <E> the generic type of the Object
|
||||||
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
*/
|
||||||
|
default <E> void forEach(E input, ObjectBooleanConsumer<E> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
iterator().forEachRemaining(input, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
|
* @return type specific splititerator
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
default BooleanSplititerator spliterator() { return BooleanSplititerators.createUnknownSplititerator(iterator(), 0); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Async Builder for moving work of the thread.
|
||||||
|
* It is not designed to split the work to multithreaded work, so using this keep it singlethreaded, but it allows to be moved to another thread.
|
||||||
|
* @see BooleanAsyncBuilder
|
||||||
|
* @return a AsyncBuilder
|
||||||
|
*/
|
||||||
|
default BooleanAsyncBuilder asAsync() {
|
||||||
|
return new BooleanAsyncBuilder(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
|
* @param mapper the mapping function
|
||||||
|
* @param <E> The return type.
|
||||||
|
* @return a new Iterable that returns the desired result
|
||||||
|
*/
|
||||||
|
default <E> ObjectIterable<E> map(BooleanFunction<E> mapper) {
|
||||||
|
return BooleanIterables.map(this, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
|
* @param mapper the flatMapping function
|
||||||
|
* @param <V> The return type supplier.
|
||||||
|
* @param <E> The return type.
|
||||||
|
* @return a new Iterable that returns the desired result
|
||||||
|
* @note does not support toBooleanArray optimizations.
|
||||||
|
*/
|
||||||
|
default <E, V extends Iterable<E>> ObjectIterable<E> flatMap(BooleanFunction<V> mapper) {
|
||||||
|
return BooleanIterables.flatMap(this, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to convert a Iterable to something else.
|
||||||
|
* @param mapper the flatMapping function
|
||||||
|
* @param <E> The return type.
|
||||||
|
* @return a new Iterable that returns the desired result
|
||||||
|
* @note does not support toBooleanArray optimizations.
|
||||||
|
*/
|
||||||
|
default <E> ObjectIterable<E> arrayflatMap(BooleanFunction<E[]> mapper) {
|
||||||
|
return BooleanIterables.arrayFlatMap(this, mapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to filter out unwanted elements
|
||||||
|
* @param filter the elements that should be kept.
|
||||||
|
* @return a Iterable that filtered out all unwanted elements
|
||||||
|
* @note does not support toBooleanArray optimizations.
|
||||||
|
*/
|
||||||
|
default BooleanIterable filter(BooleanPredicate filter) {
|
||||||
|
return BooleanIterables.filter(this, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to filter out duplicated elements
|
||||||
|
* @return a Iterable that filtered out all duplicated elements
|
||||||
|
* @note does not support toBooleanArray optimizations.
|
||||||
|
*/
|
||||||
|
default BooleanIterable distinct() {
|
||||||
|
return BooleanIterables.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 BooleanIterable repeat(int repeats) {
|
||||||
|
return BooleanIterables.repeat(this, repeats);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to limit the amount of elements
|
||||||
|
* @param limit the amount of elements it should be limited to
|
||||||
|
* @return a Iterable that is limited in length
|
||||||
|
*/
|
||||||
|
default BooleanIterable limit(long limit) {
|
||||||
|
return BooleanIterables.limit(this, limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to sort the elements
|
||||||
|
* @param sorter that sorts the elements.
|
||||||
|
* @return a Iterable that is sorted
|
||||||
|
*/
|
||||||
|
default BooleanIterable sorted(BooleanComparator sorter) {
|
||||||
|
return BooleanIterables.sorted(this, sorter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to preview elements before they are iterated through
|
||||||
|
* @param action the action that should be applied
|
||||||
|
* @return a Peeked Iterable
|
||||||
|
*/
|
||||||
|
default BooleanIterable peek(BooleanConsumer action) {
|
||||||
|
return BooleanIterables.peek(this, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function to reduce the usage of Streams and allows to collect all elements
|
||||||
|
* @param collection that the elements should be inserted to
|
||||||
|
* @param <E> the collection type
|
||||||
|
* @return the input with the desired elements
|
||||||
|
*/
|
||||||
|
default <E extends BooleanCollection> E pour(E collection) {
|
||||||
|
BooleanIterators.pour(iterator(), collection);
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a ArrayList
|
||||||
|
* @return a new ArrayList of all elements
|
||||||
|
*/
|
||||||
|
default BooleanList pourAsList() {
|
||||||
|
return pour(new BooleanArrayList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Helper function that reduces the usage of streams and allows to collect all elements as a Array
|
||||||
|
* @return a new Array of all elements
|
||||||
|
*/
|
||||||
|
default boolean[] toBooleanArray() {
|
||||||
|
ISizeProvider prov = ISizeProvider.of(this);
|
||||||
|
if(prov != null) {
|
||||||
|
int size = prov.size();
|
||||||
|
if(size >= 0) {
|
||||||
|
boolean[] array = new boolean[size];
|
||||||
|
BooleanIterators.unwrap(array, iterator());
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return BooleanArrays.pour(iterator());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for any matches.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return true if any matches were found
|
||||||
|
*/
|
||||||
|
default boolean matchesAny(BooleanPredicate filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(filter.test(iter.nextBoolean())) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for no matches.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return true if no matches were found
|
||||||
|
*/
|
||||||
|
default boolean matchesNone(BooleanPredicate filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(filter.test(iter.nextBoolean())) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for all matches.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return true if all matches.
|
||||||
|
*/
|
||||||
|
default boolean matchesAll(BooleanPredicate filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(!filter.test(iter.nextBoolean())) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to filter for the first match.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return the found value or the null equivalent variant.
|
||||||
|
*/
|
||||||
|
default boolean findFirst(BooleanPredicate filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
boolean entry = iter.nextBoolean();
|
||||||
|
if(filter.test(entry)) return entry;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
|
* elements of this Iterable
|
||||||
|
* @param operator the operation that should be applied
|
||||||
|
* @param identity the start value
|
||||||
|
* @return the reduction result, returns identity if nothing was found
|
||||||
|
*/
|
||||||
|
default boolean reduce(boolean identity, BooleanBooleanUnaryOperator operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
|
boolean state = identity;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
state = operator.applyAsBoolean(state, iter.nextBoolean());
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs a <a href="package-summary.html#Reduction">reduction</a> on the
|
||||||
|
* elements of this Iterable
|
||||||
|
* @param operator the operation that should be applied
|
||||||
|
* @return the reduction result, returns null value if nothing was found
|
||||||
|
*/
|
||||||
|
default boolean reduce(BooleanBooleanUnaryOperator operator) {
|
||||||
|
Objects.requireNonNull(operator);
|
||||||
|
boolean state = false;
|
||||||
|
boolean empty = true;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(empty) {
|
||||||
|
empty = false;
|
||||||
|
state = iter.nextBoolean();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
state = operator.applyAsBoolean(state, iter.nextBoolean());
|
||||||
|
}
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to reduce stream usage that allows to count the valid elements.
|
||||||
|
* @param filter that should be applied
|
||||||
|
* @return the amount of Valid Elements
|
||||||
|
*/
|
||||||
|
default int count(BooleanPredicate filter) {
|
||||||
|
Objects.requireNonNull(filter);
|
||||||
|
int result = 0;
|
||||||
|
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
||||||
|
if(filter.test(iter.nextBoolean())) result++;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
|
||||||
|
import speiger.src.collections.objects.functions.consumer.ObjectBooleanConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link Iterator} that reduces (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanIterator extends Iterator<Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the next element in the iteration.
|
||||||
|
*
|
||||||
|
* @return the next element in the iteration
|
||||||
|
* @throws java.util.NoSuchElementException if the iteration has no more elements
|
||||||
|
* @see Iterator#next()
|
||||||
|
*/
|
||||||
|
public boolean nextBoolean();
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default Boolean next() { return Boolean.valueOf(nextBoolean()); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the given action for each remaining element until all elements
|
||||||
|
* have been processed or the action throws an exception. Actions are
|
||||||
|
* performed in the order of iteration, if that order is specified.
|
||||||
|
* Exceptions thrown by the action are relayed to the caller.
|
||||||
|
*
|
||||||
|
* @implSpec
|
||||||
|
* <p>The default implementation behaves as if:
|
||||||
|
* <pre>{@code
|
||||||
|
* while (hasNext()) action.accept(nextBoolean());
|
||||||
|
* }</pre>
|
||||||
|
*
|
||||||
|
* @param action The action to be performed for each element
|
||||||
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
* @see Iterator#forEachRemaining(Consumer)
|
||||||
|
*/
|
||||||
|
public default void forEachRemaining(BooleanConsumer action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
while(hasNext()) { action.accept(nextBoolean()); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
default void forEachRemaining(Consumer<? super Boolean> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
forEachRemaining(action::accept);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 action The action to be performed for each element
|
||||||
|
* @param <E> the generic type of the Object
|
||||||
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
|
*/
|
||||||
|
default <E> void forEachRemaining(E input, ObjectBooleanConsumer<E> action) {
|
||||||
|
Objects.requireNonNull(action);
|
||||||
|
while(hasNext()) { action.accept(input, nextBoolean()); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skips the Given amount of elements if possible. A Optimization function to skip elements faster if the implementation allows it.
|
||||||
|
* @param amount the amount of elements that should be skipped
|
||||||
|
* @return the amount of elements that were skipped
|
||||||
|
*/
|
||||||
|
default int skip(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
|
int i = 0;
|
||||||
|
for(;i<amount && hasNext();nextBoolean(), i++);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.Spliterator.OfPrimitive;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import speiger.src.collections.booleans.functions.BooleanConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Split-Iterator that reduces boxing/unboxing
|
||||||
|
* It fills the gaps of the java and uses this collection interfaces
|
||||||
|
*/
|
||||||
|
public interface BooleanSplititerator extends OfPrimitive<Boolean, BooleanConsumer, BooleanSplititerator>, BooleanIterator
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
default void forEachRemaining(BooleanConsumer action) { BooleanIterator.super.forEachRemaining(action); }
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void forEachRemaining(Consumer<? super Boolean> action) { BooleanIterator.super.forEachRemaining(action); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
package speiger.src.collections.booleans.collections;
|
||||||
|
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
|
import speiger.src.collections.utils.Stack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type-Specific {@link Stack} that reduces (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanStack
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Inserts a given Object on top of the stack
|
||||||
|
* @param e the Object to insert
|
||||||
|
* @see Stack#push(Object)
|
||||||
|
*/
|
||||||
|
public void push(boolean e);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function that pushes the top element on top of the stack again.
|
||||||
|
* @throws NoSuchElementException if the stack is empty
|
||||||
|
*/
|
||||||
|
public default void pushTop() {
|
||||||
|
push(top());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the Object on top of the stack.
|
||||||
|
* @return the element that is on top of the stack
|
||||||
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||||
|
* @see Stack#pop()
|
||||||
|
*/
|
||||||
|
public boolean pop();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the Object on top of the stack
|
||||||
|
* @return the element that is on top of the stack
|
||||||
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||||
|
* @see Stack#top()
|
||||||
|
*/
|
||||||
|
public default boolean top() {
|
||||||
|
return peek(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the Selected Object from the stack.
|
||||||
|
* Top to bottom
|
||||||
|
* @param index of the element that should be provided
|
||||||
|
* @return the element that was requested
|
||||||
|
* @throws ArrayIndexOutOfBoundsException if the index is out of bounds
|
||||||
|
* @see Stack#peek(int)
|
||||||
|
*/
|
||||||
|
public boolean peek(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the stack
|
||||||
|
*/
|
||||||
|
public void clear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the amount of elements currently in the stack
|
||||||
|
* @return amount of elements in the list
|
||||||
|
*/
|
||||||
|
public int size();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return if the stack is empty
|
||||||
|
*/
|
||||||
|
public default boolean isEmpty() {
|
||||||
|
return size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A method to drop the contents of the Stack without clearing the stack
|
||||||
|
* @return the contents of the stack into a seperate array.
|
||||||
|
*/
|
||||||
|
public default boolean[] toBooleanArray() { return toBooleanArray(new boolean[size()]); }
|
||||||
|
/**
|
||||||
|
* A method to drop the contents of the Stack without clearing the stack
|
||||||
|
* @param input where the elements should be inserted to. If it does not fit then it creates a new appropiatly created array
|
||||||
|
* @return the contents of the stack into a seperate array.
|
||||||
|
* @note if the Type is generic then a Object Array is created instead of a Type Array
|
||||||
|
*/
|
||||||
|
public boolean[] toBooleanArray(boolean[] input);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package speiger.src.collections.booleans.functions;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type-Specific Class for Comparator to reduce (un)boxing
|
||||||
|
*/
|
||||||
|
public interface BooleanComparator extends Comparator<Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type-Specific compare function to reduce (un)boxing
|
||||||
|
* @param o1 the first object to be compared.
|
||||||
|
* @param o2 the second object to be compared.
|
||||||
|
* @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
|
||||||
|
* @see Comparator#compare(Object, Object)
|
||||||
|
*/
|
||||||
|
int compare(boolean o1, boolean o2);
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default int compare(Boolean o1, Boolean o2) {
|
||||||
|
return compare(o1.booleanValue(), o2.booleanValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Wrapper function to convert a Non-Type-Specific Comparator to a Type-Specific-Comparator
|
||||||
|
* @param c comparator to convert
|
||||||
|
* @return the wrapper of the comparator
|
||||||
|
* @throws NullPointerException if the comparator is null
|
||||||
|
*/
|
||||||
|
public static BooleanComparator of(Comparator<Boolean> c) {
|
||||||
|
Objects.requireNonNull(c);
|
||||||
|
return (K, V) -> c.compare(Boolean.valueOf(K), Boolean.valueOf(V));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default BooleanComparator reversed() {
|
||||||
|
return new Reversed(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Reversed Comparator to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
static class Reversed implements BooleanComparator
|
||||||
|
{
|
||||||
|
BooleanComparator original;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* default constructor
|
||||||
|
* @param original that is going to be reversed
|
||||||
|
*/
|
||||||
|
public Reversed(BooleanComparator original) {
|
||||||
|
this.original = original;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compare(boolean o1, boolean o2) {
|
||||||
|
return original.compare(o2, o1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BooleanComparator reversed() {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package speiger.src.collections.booleans.functions;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
/**
|
||||||
|
* Type-Specific Consumer interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface BooleanConsumer extends Consumer<Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type-Specific function to reduce (un)boxing.
|
||||||
|
* Performs this operation on the given argument.
|
||||||
|
*
|
||||||
|
* @param t the input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean t);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced consumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanConsumer andThen(BooleanConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return T -> {accept(T); after.accept(T);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean t) { accept(t.booleanValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanConsumer andThen(Consumer<? super Boolean> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return T -> {accept(T); after.accept(Boolean.valueOf(T));};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package speiger.src.collections.booleans.functions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
||||||
|
*/
|
||||||
|
public interface BooleanSupplier
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return the supplied value
|
||||||
|
*/
|
||||||
|
public boolean getAsBoolean();
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package speiger.src.collections.booleans.functions;
|
||||||
|
|
||||||
|
import java.util.concurrent.RunnableFuture;
|
||||||
|
import java.util.concurrent.CancellationException;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* A Type Specific Task interface that allows you to keep track of the task that is currently running.<br>
|
||||||
|
* It extends Runnable future and supports said functions but also provides quality of life functions like:<br>
|
||||||
|
*
|
||||||
|
* - isSuccesfull: which allows to detect if the task was completed properly and not interrupted or crashed.
|
||||||
|
* - pause/resume: which allows to pause/resume the task at any moment, making it easier to create thread-safe actions.
|
||||||
|
*/
|
||||||
|
public interface BooleanTask extends RunnableFuture<Boolean> {
|
||||||
|
/**
|
||||||
|
* Helper function to detect if the task is currently paused.
|
||||||
|
* @return true if paused
|
||||||
|
*/
|
||||||
|
public boolean isPaused();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses the task, which lets the thread finish without completing the task.
|
||||||
|
* Tasks are written in the way where they can pause without any issues.
|
||||||
|
* This won't be instant, as this function is applied asynchronous and doesn't check if the thread paused.
|
||||||
|
* So make sure it had the time to pause.
|
||||||
|
*/
|
||||||
|
public void pause();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pauses the task, which lets the thread finish without completing the task.
|
||||||
|
* Tasks are written in the way where they can pause without any issues.
|
||||||
|
* This won't be instant, as this function is applied asynchronous.
|
||||||
|
* It will await the pausing of the task.
|
||||||
|
*/
|
||||||
|
public void awaitPausing();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Continues the task if it wasn't already completed.
|
||||||
|
* This is done by resubmitting the task to the executor provided.
|
||||||
|
*/
|
||||||
|
public void resume();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quality of life function that allows to detect if no cancellation/exception was applied to this task and it completed on its own.
|
||||||
|
* @return true if it was properly completed
|
||||||
|
*/
|
||||||
|
public boolean isSuccessful();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific get method that allows to reduce (un)boxing of primtives.
|
||||||
|
*
|
||||||
|
* Waits if necessary for the computation to complete, and then
|
||||||
|
* retrieves its result.
|
||||||
|
*
|
||||||
|
* @return the computed result as primitive
|
||||||
|
* @throws CancellationException if the computation was cancelled
|
||||||
|
* @throws ExecutionException if the computation threw an exception
|
||||||
|
* @throws InterruptedException if the current thread was interrupted
|
||||||
|
* while waiting
|
||||||
|
*/
|
||||||
|
public boolean getBoolean() throws InterruptedException, ExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits if necessary for at most the given time for the computation
|
||||||
|
* to complete, and then retrieves its result, if available.
|
||||||
|
*
|
||||||
|
* @param timeout the maximum time to wait
|
||||||
|
* @param unit the time unit of the timeout argument
|
||||||
|
* @return the computed result as primitive
|
||||||
|
* @throws CancellationException if the computation was cancelled
|
||||||
|
* @throws ExecutionException if the computation threw an exception
|
||||||
|
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||||
|
* @throws TimeoutException if the wait timed out
|
||||||
|
*/
|
||||||
|
public boolean getBoolean(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default Boolean get() throws InterruptedException, ExecutionException { return Boolean.valueOf(getBoolean()); }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
public default Boolean get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return Boolean.valueOf(getBoolean(timeout, unit)); }
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanBooleanConsumer extends BiConsumer<Boolean, Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, boolean v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanBooleanConsumer andThen(BooleanBooleanConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Boolean v) { accept(k.booleanValue(), v.booleanValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanBooleanConsumer andThen(BiConsumer<? super Boolean, ? super Boolean> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Boolean.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanByteConsumer extends BiConsumer<Boolean, Byte>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, byte v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanByteConsumer andThen(BooleanByteConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Byte v) { accept(k.booleanValue(), v.byteValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanByteConsumer andThen(BiConsumer<? super Boolean, ? super Byte> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Byte.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanCharConsumer extends BiConsumer<Boolean, Character>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, char v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanCharConsumer andThen(BooleanCharConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Character v) { accept(k.booleanValue(), v.charValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanCharConsumer andThen(BiConsumer<? super Boolean, ? super Character> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Character.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanDoubleConsumer extends BiConsumer<Boolean, Double>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, double v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanDoubleConsumer andThen(BooleanDoubleConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Double v) { accept(k.booleanValue(), v.doubleValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanDoubleConsumer andThen(BiConsumer<? super Boolean, ? super Double> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Double.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanFloatConsumer extends BiConsumer<Boolean, Float>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, float v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanFloatConsumer andThen(BooleanFloatConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Float v) { accept(k.booleanValue(), v.floatValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanFloatConsumer andThen(BiConsumer<? super Boolean, ? super Float> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Float.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanIntConsumer extends BiConsumer<Boolean, Integer>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, int v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanIntConsumer andThen(BooleanIntConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Integer v) { accept(k.booleanValue(), v.intValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanIntConsumer andThen(BiConsumer<? super Boolean, ? super Integer> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Integer.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanLongConsumer extends BiConsumer<Boolean, Long>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, long v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanLongConsumer andThen(BooleanLongConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Long v) { accept(k.booleanValue(), v.longValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanLongConsumer andThen(BiConsumer<? super Boolean, ? super Long> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Long.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
* @param <V> the keyType of elements maintained by this Collection
|
||||||
|
*/
|
||||||
|
public interface BooleanObjectConsumer<V> extends BiConsumer<Boolean, V>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, V v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanObjectConsumer<V> andThen(BooleanObjectConsumer<V> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, V v) { accept(k.booleanValue(), v); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanObjectConsumer<V> andThen(BiConsumer<? super Boolean, ? super V> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), V);};
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.consumer;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific BiConsumer class to reduce boxing/unboxing and that fills the gaps that java has.
|
||||||
|
*/
|
||||||
|
public interface BooleanShortConsumer extends BiConsumer<Boolean, Short>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specific operation method to reduce boxing/unboxing
|
||||||
|
* Performs this operation on the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first input argument
|
||||||
|
* @param v the second input argument
|
||||||
|
*/
|
||||||
|
void accept(boolean k, short v);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type Specific sequencing method to reduce boxing/unboxing.
|
||||||
|
* @param after a operation that should be performed afterwards
|
||||||
|
* @return a sequenced biconsumer that does 2 operations
|
||||||
|
* @throws NullPointerException if after is null
|
||||||
|
*/
|
||||||
|
public default BooleanShortConsumer andThen(BooleanShortConsumer after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(K, V);};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default void accept(Boolean k, Short v) { accept(k.booleanValue(), v.shortValue()); }
|
||||||
|
|
||||||
|
/** {@inheritDoc}
|
||||||
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Deprecated
|
||||||
|
default BooleanShortConsumer andThen(BiConsumer<? super Boolean, ? super Short> after) {
|
||||||
|
Objects.requireNonNull(after);
|
||||||
|
return (K, V) -> {accept(K, V); after.accept(Boolean.valueOf(K), Short.valueOf(V));};
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2BooleanFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public boolean test(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2ByteFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public byte applyAsByte(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2CharFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public char applyAsChar(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2DoubleFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public double applyAsDouble(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2FloatFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public float applyAsFloat(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2IntFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public int applyAsInt(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2LongFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public long applyAsLong(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
* @param <V> the keyType of elements maintained by this Collection
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2ObjectFunction<V>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public V apply(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Boolean2ShortFunction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public short applyAsShort(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanBooleanUnaryOperator extends BiFunction<Boolean, Boolean, Boolean>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public boolean applyAsBoolean(boolean k, boolean v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Boolean apply(Boolean k, Boolean v) { return Boolean.valueOf(applyAsBoolean(k.booleanValue(), v.booleanValue())); }
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanByteUnaryOperator extends BiFunction<Boolean, Byte, Byte>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public byte applyAsByte(boolean k, byte v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Byte apply(Boolean k, Byte v) { return Byte.valueOf(applyAsByte(k.booleanValue(), v.byteValue())); }
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanCharUnaryOperator extends BiFunction<Boolean, Character, Character>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public char applyAsChar(boolean k, char v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Character apply(Boolean k, Character v) { return Character.valueOf(applyAsChar(k.booleanValue(), v.charValue())); }
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanDoubleUnaryOperator extends BiFunction<Boolean, Double, Double>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public double applyAsDouble(boolean k, double v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Double apply(Boolean k, Double v) { return Double.valueOf(applyAsDouble(k.booleanValue(), v.doubleValue())); }
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanFloatUnaryOperator extends BiFunction<Boolean, Float, Float>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public float applyAsFloat(boolean k, float v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Float apply(Boolean k, Float v) { return Float.valueOf(applyAsFloat(k.booleanValue(), v.floatValue())); }
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Function interface that reduces boxing/unboxing and fills the gaps of interfaces that are missing.
|
||||||
|
* @param <V> the keyType of elements maintained by this Collection
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface BooleanFunction<V>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Type Specific get function to reduce boxing/unboxing
|
||||||
|
* @param k the value that should be processed
|
||||||
|
* @return the result of the function
|
||||||
|
*/
|
||||||
|
public V apply(boolean k);
|
||||||
|
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanIntUnaryOperator extends BiFunction<Boolean, Integer, Integer>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public int applyAsInt(boolean k, int v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Integer apply(Boolean k, Integer v) { return Integer.valueOf(applyAsInt(k.booleanValue(), v.intValue())); }
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package speiger.src.collections.booleans.functions.function;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Type Specific Unary Operator to support Compute/Merge functions with type specific methods to reduce boxing/unboxing
|
||||||
|
*/
|
||||||
|
public interface BooleanLongUnaryOperator extends BiFunction<Boolean, Long, Long>
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A Type Specifc apply method to reduce boxing/unboxing.
|
||||||
|
* Applies this function to the given arguments.
|
||||||
|
*
|
||||||
|
* @param k the first function argument
|
||||||
|
* @param v the second function argument
|
||||||
|
* @return the function result
|
||||||
|
*/
|
||||||
|
public long applyAsLong(boolean k, long v);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public default Long apply(Boolean k, Long v) { return Long.valueOf(applyAsLong(k.booleanValue(), v.longValue())); }
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user