Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20927a97eb | ||
|
|
ebe75b0fea | ||
|
|
a6be24c59d | ||
|
|
afdd27648e | ||
|
|
7e475b5472 | ||
|
|
e65fde736b | ||
|
|
bf0b4172de | ||
|
|
961b47a58c | ||
|
|
330be87338 | ||
|
|
4b30ce12c9 | ||
|
|
0be7dba5d3 | ||
|
|
6eaa992f5f | ||
|
|
9b23d713ff | ||
|
|
85d230c561 |
@@ -6,6 +6,12 @@
|
|||||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="gradle_scope" value="main"/>
|
||||||
|
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
<classpathentry kind="src" output="bin/test" path="src/test/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="gradle_scope" value="test"/>
|
<attribute name="gradle_scope" value="test"/>
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ jobs:
|
|||||||
name: Code Quality Check
|
name: Code Quality Check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
- name: Set up JDK 11
|
- name: Set up JDK 11
|
||||||
uses: actions/setup-java@v5
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: 11
|
java-version: 11
|
||||||
|
|||||||
+9
-1
@@ -20,7 +20,15 @@ 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,5 +1,21 @@
|
|||||||
# 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.
|
||||||
|
|||||||
@@ -30,10 +30,13 @@ 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" is counted as "Enabled".
|
Any Setting that isn't "Present" can be defined as "Enabled" or "Disabled" using the "Default" argument.
|
||||||
|
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,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"Default": true,
|
||||||
"Async": true,
|
"Async": true,
|
||||||
"Base": true,
|
"Base": true,
|
||||||
"Collection": true,
|
"Collection": true,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||

|

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

|

|
||||||

|

|
||||||
@@ -43,7 +44,7 @@ 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
|
||||||
```gradle
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
url = "https://jitpack.io"
|
url = "https://jitpack.io"
|
||||||
@@ -54,6 +55,13 @@ dependencies {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Using Maven Central
|
||||||
|
```groovy
|
||||||
|
dependencies {
|
||||||
|
implementation 'io.github.speiger:Primitive-Collections:0.9.0'
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# SourceCode
|
# SourceCode
|
||||||
The generated Sourcecode can be automatically build,
|
The generated Sourcecode can be automatically build,
|
||||||
but if you want to just browse around in it.
|
but if you want to just browse around in it.
|
||||||
|
|||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
# 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.
|
||||||
+85
-25
@@ -1,6 +1,7 @@
|
|||||||
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) {
|
||||||
@@ -10,6 +11,7 @@ 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()
|
||||||
@@ -19,12 +21,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.9.0';
|
version = RELEASE_VERSION;
|
||||||
|
|
||||||
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" ]
|
||||||
}
|
}
|
||||||
@@ -48,7 +55,7 @@ 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.3.0'
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testImplementation 'com.google.guava:guava-testlib:33.6.0-jre'
|
testImplementation 'com.google.guava:guava-testlib:31.0.1-jre'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,26 +106,12 @@ 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'
|
||||||
@@ -268,13 +261,10 @@ jacocoTestReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
Properties props = new Properties()
|
|
||||||
if(file("$buildDir/credentials.properties").exists()) {
|
|
||||||
props.load(new FileInputStream("$buildDir/credentials.properties"))
|
|
||||||
}
|
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
personal(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'
|
||||||
@@ -283,8 +273,6 @@ 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'
|
||||||
@@ -309,11 +297,83 @@ 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 props.mavenUser
|
username auth?[0]
|
||||||
password props.mavenPassword
|
password auth?[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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'
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
+3
-1
@@ -1,4 +1,6 @@
|
|||||||
org.gradle.jvmargs=-Xmx3G
|
org.gradle.jvmargs=-Xmx3G
|
||||||
|
|
||||||
maxMemory = 2048m
|
maxMemory = 1024m
|
||||||
testThreads = 4
|
testThreads = 4
|
||||||
|
|
||||||
|
RELEASE_VERSION = 0.9.0
|
||||||
@@ -41,7 +41,7 @@ public class CollectionModule extends BaseModule
|
|||||||
protected void loadBlockades() {
|
protected void loadBlockades() {
|
||||||
if(!MODULE.isEnabled()) {
|
if(!MODULE.isEnabled()) {
|
||||||
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
addBlockedFiles("Iterable", "Iterables", "Iterator", "Iterators", "BidirectionalIterator", "ListIterator");
|
||||||
addBlockedFiles("Arrays", "Collection", "OrderedCollection", "AbstractCollection", "Collections", "Stack");
|
addBlockedFiles("Arrays", "Collection", "AbstractCollection", "Collections", "Stack");
|
||||||
}
|
}
|
||||||
if(!SPLIT_ITERATORS.isEnabled()) addBlockedFiles("Splititerator", "Splititerators");
|
if(!SPLIT_ITERATORS.isEnabled()) addBlockedFiles("Splititerator", "Splititerators");
|
||||||
if(!IARRAY.isEnabled()) addBlockedFiles("IArray");
|
if(!IARRAY.isEnabled()) addBlockedFiles("IArray");
|
||||||
@@ -91,7 +91,6 @@ public class CollectionModule extends BaseModule
|
|||||||
{
|
{
|
||||||
//Abstract Classes
|
//Abstract Classes
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||||
addAbstractMapper("REVERSED_ORDERED_COLLECTION", "Reverse%sOrderedCollection");
|
|
||||||
|
|
||||||
//Helper Classes
|
//Helper Classes
|
||||||
addClassMapper("ARRAYS", "Arrays");
|
addClassMapper("ARRAYS", "Arrays");
|
||||||
@@ -102,7 +101,6 @@ public class CollectionModule extends BaseModule
|
|||||||
|
|
||||||
//Interfaces
|
//Interfaces
|
||||||
addClassMapper("COLLECTION", "Collection");
|
addClassMapper("COLLECTION", "Collection");
|
||||||
addClassMapper("ORDERED_COLLECTION", "OrderedCollection");
|
|
||||||
addClassMapper("ITERABLE", "Iterable");
|
addClassMapper("ITERABLE", "Iterable");
|
||||||
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
||||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ public class FunctionModule extends BaseModule
|
|||||||
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", "Optional", "Function", "UnaryOperator");
|
if(!MODULE.isEnabled()) addBlockedFiles("Consumer", "BiConsumer", "Comparator", "Supplier", "Function", "UnaryOperator");
|
||||||
if(!keyType.needsCustomJDKType()) addBlockedFiles("Optional");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -61,7 +60,6 @@ public class FunctionModule extends BaseModule
|
|||||||
}
|
}
|
||||||
else addBiRequirement("Function");
|
else addBiRequirement("Function");
|
||||||
addRemapper("BiConsumer", "%sConsumer");
|
addRemapper("BiConsumer", "%sConsumer");
|
||||||
addRemapper("Optional", "Optional%s");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,8 +94,6 @@ public class FunctionModule extends BaseModule
|
|||||||
|
|
||||||
addFunctionMappers("PREDICATE", "%sPredicate");
|
addFunctionMappers("PREDICATE", "%sPredicate");
|
||||||
addClassMapper("SUPPLIER", "Supplier");
|
addClassMapper("SUPPLIER", "Supplier");
|
||||||
addSimpleMapper("OPTIONAL", keyType.isObject() ? "Optional" : String.format("Optional%s", keyType.getFileType()));
|
|
||||||
addSimpleMapper("VALUE_OPTIONAL", valueType.isObject() ? "Optional" : String.format("Optional%s", valueType.getFileType()));
|
|
||||||
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
addAbstractMapper("SINGLE_UNARY_OPERATOR", "%1$s%1$sUnaryOperator");
|
||||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
||||||
if(keyType.isObject())
|
if(keyType.isObject())
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ public class JavaModule extends BaseModule
|
|||||||
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
addSimpleMapper("APPLY_KEY_VALUE", keyType.isObject() ? "apply" : "applyAs"+keyType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
addSimpleMapper("APPLY_VALUE", valueType.isObject() ? "apply" : "applyAs"+valueType.getNonFileType());
|
||||||
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
addSimpleMapper("APPLY_CAST", "applyAs"+keyType.getCustomJDKType().getNonFileType());
|
||||||
addSimpleMapper("GET_OPTIONAL", keyType.isObject() ? "ofNullable" : "of");
|
|
||||||
addSimpleMapper("GET_OPTIONAL_VALUE", valueType.isObject() ? "ofNullable" : "of");
|
|
||||||
|
|
||||||
//Shared by Maps and Pairs so moved to java.
|
//Shared by Maps and Pairs so moved to java.
|
||||||
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
addFunctionMappers("ENTRY_KEY", "get%sKey");
|
||||||
@@ -198,7 +196,6 @@ public class JavaModule extends BaseModule
|
|||||||
addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection");
|
addComment("@Type", "@param <%s> the keyType of elements maintained by this Collection");
|
||||||
addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
addValueComment("@ValueArrayType", "@param <%s> the keyType of array that the operation should be applied");
|
||||||
addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection");
|
addValueComment("@ValueType", "@param <%s> the keyType of elements maintained by this Collection");
|
||||||
addSimpleMapper("@Java21", getVersion() >= 21 ? "@Override" : "");
|
|
||||||
addAnnontion("@PrimitiveOverride", "@Override");
|
addAnnontion("@PrimitiveOverride", "@Override");
|
||||||
addSimpleMapper("@PrimitiveDoc", "");
|
addSimpleMapper("@PrimitiveDoc", "");
|
||||||
addAnnontion("@Primitive", "@Deprecated");
|
addAnnontion("@Primitive", "@Deprecated");
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ public class MapModule extends BaseModule
|
|||||||
public static final FunctionDependency ENUM_MAP = MODULE.createDependency("EnumMap").addEntryDependency(IMPLEMENTATION);
|
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 LINKED_ENUM_MAP = MODULE.createDependency("LinkedEnumMap").addEntryDependency(ENUM_MAP).addEntryDependency(ORDERED_MAP);
|
||||||
|
|
||||||
public static final FunctionDependency REF_MAP = MODULE.createDependency("ReferenceHashMap").addEntryDependency(IMPLEMENTATION);
|
|
||||||
public static final FunctionDependency LINKED_REF_MAP = MODULE.createDependency("LinkedReferenceMap").addEntryDependency(REF_MAP).addEntryDependency(ORDERED_MAP);
|
|
||||||
|
|
||||||
|
|
||||||
public static final FunctionDependency CONCURRENT_MAP = MODULE.createDependency("ConcurrentMap").addEntryDependency(IMPLEMENTATION);
|
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 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);
|
public static final FunctionDependency RB_TREE_MAP = MODULE.createDependency("RBTreeMap").addEntryDependency(SORTED_MAP).addEntryDependency(IMPLEMENTATION);
|
||||||
@@ -55,7 +51,7 @@ public class MapModule extends BaseModule
|
|||||||
@Override
|
@Override
|
||||||
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
|
public List<IDependency> getDependencies(ClassType keyType, ClassType valueType) {
|
||||||
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));
|
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, REF_MAP, LINKED_REF_MAP));
|
if(keyType == ClassType.OBJECT) dependencies.addAll(Arrays.asList(ENUM_MAP, LINKED_ENUM_MAP));
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,10 +70,6 @@ public class MapModule extends BaseModule
|
|||||||
if(AVL_TREE_MAP.isEnabled()) addFlag("AVL_TREE_MAP_FEATURE");
|
if(AVL_TREE_MAP.isEnabled()) addFlag("AVL_TREE_MAP_FEATURE");
|
||||||
if(RB_TREE_MAP.isEnabled()) addFlag("RB_TREE_MAP_FEATURE");
|
if(RB_TREE_MAP.isEnabled()) addFlag("RB_TREE_MAP_FEATURE");
|
||||||
|
|
||||||
if(REF_MAP.isEnabled()) addFlag("REF_MAP_FEATURE");
|
|
||||||
if(LINKED_REF_MAP.isEnabled()) addFlag("LINKED_REF_MAP_FEATURE");
|
|
||||||
|
|
||||||
|
|
||||||
if(CONCURRENT_MAP.isEnabled()) addFlag("CONCURRENT_MAP_FEATURE");
|
if(CONCURRENT_MAP.isEnabled()) addFlag("CONCURRENT_MAP_FEATURE");
|
||||||
if(IMMUTABLE_MAP.isEnabled()) addFlag("IMMUTABLE_MAP_FEATURE");
|
if(IMMUTABLE_MAP.isEnabled()) addFlag("IMMUTABLE_MAP_FEATURE");
|
||||||
if(HASH_MAP.isEnabled()) addFlag("MAP_FEATURE");
|
if(HASH_MAP.isEnabled()) addFlag("MAP_FEATURE");
|
||||||
@@ -93,8 +85,6 @@ public class MapModule extends BaseModule
|
|||||||
if(!IMMUTABLE_MAP.isEnabled()) addBlockedFiles("ImmutableOpenHashMap");
|
if(!IMMUTABLE_MAP.isEnabled()) addBlockedFiles("ImmutableOpenHashMap");
|
||||||
if(!CONCURRENT_MAP.isEnabled()) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
if(!CONCURRENT_MAP.isEnabled()) addBlockedFiles("ConcurrentMap", "ConcurrentOpenHashMap");
|
||||||
if(!ORDERED_MAP.isEnabled()) addBlockedFiles("OrderedMap");
|
if(!ORDERED_MAP.isEnabled()) addBlockedFiles("OrderedMap");
|
||||||
if(!REF_MAP.isEnabled()) addBlockedFiles("ReferenceHashMap");
|
|
||||||
if(!LINKED_REF_MAP.isEnabled()) addBlockedFiles("LinkedReferenceHashMap");
|
|
||||||
if(!HASH_MAP.isEnabled()) addBlockedFiles("OpenHashMap");
|
if(!HASH_MAP.isEnabled()) addBlockedFiles("OpenHashMap");
|
||||||
if(!LINKED_MAP.isEnabled()) addBlockedFiles("LinkedOpenHashMap");
|
if(!LINKED_MAP.isEnabled()) addBlockedFiles("LinkedOpenHashMap");
|
||||||
if(!CUSTOM_MAP.isEnabled()) addBlockedFiles("OpenCustomHashMap");
|
if(!CUSTOM_MAP.isEnabled()) addBlockedFiles("OpenCustomHashMap");
|
||||||
@@ -137,8 +127,6 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("AbstractMap");
|
addBiRequirement("AbstractMap");
|
||||||
addEnumRequirement("EnumMap");
|
addEnumRequirement("EnumMap");
|
||||||
addEnumRequirement("LinkedEnumMap");
|
addEnumRequirement("LinkedEnumMap");
|
||||||
addEnumRequirement("ReferenceHashMap");
|
|
||||||
addEnumRequirement("LinkedReferenceHashMap");
|
|
||||||
addBiRequirement("ConcurrentOpenHashMap");
|
addBiRequirement("ConcurrentOpenHashMap");
|
||||||
addBiRequirement("ImmutableOpenHashMap");
|
addBiRequirement("ImmutableOpenHashMap");
|
||||||
addBiRequirement("OpenHashMap");
|
addBiRequirement("OpenHashMap");
|
||||||
@@ -153,8 +141,6 @@ public class MapModule extends BaseModule
|
|||||||
addRemapper("AbstractMap", "Abstract%sMap");
|
addRemapper("AbstractMap", "Abstract%sMap");
|
||||||
addRemapper("EnumMap", "Enum2%sMap");
|
addRemapper("EnumMap", "Enum2%sMap");
|
||||||
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
addRemapper("LinkedEnumMap", "LinkedEnum2%sMap");
|
||||||
addRemapper("ReferenceHashMap", "Reference2%sHashMap");
|
|
||||||
addRemapper("LinkedReferenceHashMap", "Reference2%sLinkedHashMap");
|
|
||||||
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
addRemapper("ImmutableOpenHashMap", "Immutable%sOpenHashMap");
|
||||||
|
|
||||||
//Test Classes
|
//Test Classes
|
||||||
@@ -212,7 +198,6 @@ public class MapModule extends BaseModule
|
|||||||
addBiRequirement("SortedMapNavigationTester");
|
addBiRequirement("SortedMapNavigationTester");
|
||||||
addBiRequirement("OrderedMapNavigationTester");
|
addBiRequirement("OrderedMapNavigationTester");
|
||||||
addBiRequirement("OrderedMapMoveTester");
|
addBiRequirement("OrderedMapMoveTester");
|
||||||
addBiRequirement("OrderedMapPutTester");
|
|
||||||
addBiRequirement("MapConstructorTester");
|
addBiRequirement("MapConstructorTester");
|
||||||
|
|
||||||
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
addRemapper("TestMapGenerator", "Test%sMapGenerator");
|
||||||
@@ -263,14 +248,11 @@ public class MapModule extends BaseModule
|
|||||||
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
addBiClassMapper("RB_TREE_MAP", "RBTreeMap", "2");
|
||||||
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
addFunctionValueMappers("LINKED_ENUM_MAP", valueType.isObject() ? "LinkedEnum2ObjectMap" : "LinkedEnum2%sMap");
|
||||||
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
addFunctionValueMappers("ENUM_MAP", valueType.isObject() ? "Enum2ObjectMap" : "Enum2%sMap");
|
||||||
addFunctionValueMappers("REF_MAP", valueType.isObject() ? "Reference2ObjectHashMap" : "Reference2%sHashMap");
|
|
||||||
addFunctionValueMappers("LINKED_REF_MAP", valueType.isObject() ? "Reference2ObjectLinkedHashMap" : "Reference2%sLinkedHashMap");
|
|
||||||
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
addBiClassMapper("HASH_MAP", "OpenHashMap", "2");
|
||||||
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
addBiClassMapper("ARRAY_MAP", "ArrayMap", "2");
|
||||||
|
|
||||||
//Abstract Classes
|
//Abstract Classes
|
||||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||||
addAbstractBiMapper("REVERSED_ORDERED_MAP", "Reversed%sOrderedMap", "2");
|
|
||||||
|
|
||||||
//Helper Classes
|
//Helper Classes
|
||||||
addBiClassMapper("MAPS", "Maps", "2");
|
addBiClassMapper("MAPS", "Maps", "2");
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ public class SetModule extends BaseModule
|
|||||||
|
|
||||||
//Abstract Classes
|
//Abstract Classes
|
||||||
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
||||||
addAbstractMapper("REVERSED_ORDERED_SET", "Reversed%sOrderedSet");
|
|
||||||
|
|
||||||
//Helper Classes
|
//Helper Classes
|
||||||
addClassMapper("SETS", "Sets");
|
addClassMapper("SETS", "Sets");
|
||||||
|
|||||||
-80
@@ -1,18 +1,12 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
package speiger.src.collections.PACKAGE.collections;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
#endif
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.AbstractCollection;
|
import java.util.AbstractCollection;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
@@ -268,79 +262,5 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||||||
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
if (a.length > size()) a[size()] = EMPTY_KEY_VALUE;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
public static class REVERSED_ORDERED_COLLECTION KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements ORDERED_COLLECTION KEY_GENERIC_TYPE {
|
|
||||||
ORDERED_COLLECTION KEY_GENERIC_TYPE collection;
|
|
||||||
Supplier<ITERATOR KEY_GENERIC_TYPE> reverseIterator;
|
|
||||||
|
|
||||||
public REVERSED_ORDERED_COLLECTION(ORDERED_COLLECTION KEY_GENERIC_TYPE collection, Supplier<ITERATOR KEY_GENERIC_TYPE> reverseIterator) {
|
|
||||||
this.collection = collection;
|
|
||||||
this.reverseIterator = reverseIterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean add(KEY_TYPE o) { return collection.add(o); }
|
|
||||||
@Override
|
|
||||||
public ORDERED_COLLECTION KEY_GENERIC_TYPE reversed() { return collection; }
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE e) { collection.addLast(e); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE e) { collection.addFirst(e); }
|
|
||||||
@Override
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
public boolean contains(KEY_TYPE e) { return collection.contains(e); }
|
|
||||||
#else
|
|
||||||
public boolean contains(Object e) { return collection.contains(e); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
public boolean REMOVE_KEY(KEY_TYPE e) { return collection.REMOVE_KEY(e); }
|
|
||||||
#else
|
|
||||||
public boolean remove(Object e) { return collection.remove(e); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public void clear() { collection.clear(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_FIRST_KEY() { return collection.GET_LAST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { return collection.REMOVE_LAST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_LAST_KEY() { return collection.GET_FIRST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { return collection.REMOVE_FIRST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() { return reverseIterator.get(); }
|
|
||||||
@Override
|
|
||||||
public int size() { return collection.size(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ReverseBiIterator KEY_GENERIC_TYPE implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
|
||||||
LIST_ITERATOR KEY_GENERIC_TYPE it;
|
|
||||||
|
|
||||||
public ReverseBiIterator(LIST_ITERATOR KEY_GENERIC_TYPE it) {
|
|
||||||
this.it = it;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE NEXT() { return it.PREVIOUS(); }
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() { return it.hasPrevious(); }
|
|
||||||
@Override
|
|
||||||
public boolean hasPrevious() { return it.hasNext(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE PREVIOUS() { return it.NEXT(); }
|
|
||||||
@Override
|
|
||||||
public void remove() { it.remove(); }
|
|
||||||
@Override
|
|
||||||
public int nextIndex() { return it.previousIndex(); }
|
|
||||||
@Override
|
|
||||||
public int previousIndex() { return it.nextIndex(); }
|
|
||||||
@Override
|
|
||||||
public void set(KEY_TYPE e) { it.set(e); }
|
|
||||||
@Override
|
|
||||||
public void add(KEY_TYPE e) { it.add(e); }
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
+5
-11
@@ -5,9 +5,6 @@ import java.util.function.Consumer;
|
|||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
@@ -33,9 +30,6 @@ import speiger.src.collections.PACKAGE.collections.OUTPUT_ITERABLE;
|
|||||||
#endif
|
#endif
|
||||||
#enditerate
|
#enditerate
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
@@ -414,13 +408,13 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param filter that should be applied
|
* @param filter that should be applied
|
||||||
* @return the found value or the null equivalent variant.
|
* @return the found value or the null equivalent variant.
|
||||||
*/
|
*/
|
||||||
default OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
default KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
if(filter.test(entry)) return OPTIONAL.GET_OPTIONAL(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -465,7 +459,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param operator the operation that should be applied
|
* @param operator the operation that should be applied
|
||||||
* @return the reduction result, returns null value if nothing was found
|
* @return the reduction result, returns null value if nothing was found
|
||||||
*/
|
*/
|
||||||
default OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
default KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -477,7 +471,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, iter.NEXT());
|
state = operator.APPLY_VALUE(state, iter.NEXT());
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
-83
@@ -1,83 +0,0 @@
|
|||||||
package speiger.src.collections.PACKAGE.collections;
|
|
||||||
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
import java.util.SequencedCollection;
|
|
||||||
|
|
||||||
public interface ORDERED_COLLECTION KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, SequencedCollection<CLASS_TYPE> {
|
|
||||||
#else
|
|
||||||
public interface ORDERED_COLLECTION KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE {
|
|
||||||
#endif
|
|
||||||
@Java21
|
|
||||||
ORDERED_COLLECTION KEY_GENERIC_TYPE reversed();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the start of a collection
|
|
||||||
* @param e that should be added at the start.
|
|
||||||
*/
|
|
||||||
public void addFirst(KEY_TYPE e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the end of a collection
|
|
||||||
* @param e that should be added at the end.
|
|
||||||
*/
|
|
||||||
public void addLast(KEY_TYPE e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to get the first element in the collection
|
|
||||||
* @return first element in the collection
|
|
||||||
*/
|
|
||||||
public KEY_TYPE GET_FIRST_KEY();
|
|
||||||
/**
|
|
||||||
* A method to get and remove the first element in the collection
|
|
||||||
* @return first element in the collection
|
|
||||||
*/
|
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY();
|
|
||||||
/**
|
|
||||||
* A method to get the last element in the collection
|
|
||||||
* @return last element in the collection
|
|
||||||
*/
|
|
||||||
public KEY_TYPE GET_LAST_KEY();
|
|
||||||
/**
|
|
||||||
* A method to get and remove the last element in the collection
|
|
||||||
* @return last element in the collection
|
|
||||||
*/
|
|
||||||
public KEY_TYPE REMOVE_LAST_KEY();
|
|
||||||
|
|
||||||
#if JAVA_VERSION>=21 && !TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default void addFirst(CLASS_TYPE e) {
|
|
||||||
addFirst(OBJ_TO_KEY(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default void addLast(CLASS_TYPE e) {
|
|
||||||
addLast(OBJ_TO_KEY(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getFirst() {
|
|
||||||
return KEY_TO_OBJ(GET_FIRST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getLast() {
|
|
||||||
return KEY_TO_OBJ(GET_LAST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeFirst() {
|
|
||||||
return KEY_TO_OBJ(REMOVE_FIRST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeLast() {
|
|
||||||
return KEY_TO_OBJ(REMOVE_LAST_KEY());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
-89
@@ -1,89 +0,0 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public final class OPTIONAL KEY_GENERIC_TYPE {
|
|
||||||
private static final OPTIONAL NO_GENERIC_TYPE EMPTY = new OPTIONALBRACES();
|
|
||||||
|
|
||||||
private final boolean isPresent;
|
|
||||||
private final KEY_TYPE value;
|
|
||||||
|
|
||||||
private OPTIONAL() {
|
|
||||||
this.isPresent = false;
|
|
||||||
this.value = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OPTIONAL(KEY_TYPE value) {
|
|
||||||
this.isPresent = true;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OPTIONAL KEY_GENERIC_TYPE empty() {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OPTIONAL KEY_GENERIC_TYPE of(KEY_TYPE value) {
|
|
||||||
return new OPTIONALBRACES(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE SUPPLY_GET() {
|
|
||||||
if(!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPresent() {
|
|
||||||
return isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return !isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresent(CONSUMER KEY_GENERIC_TYPE consumer) {
|
|
||||||
if(isPresent) consumer.accept(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresentOrElse(CONSUMER KEY_GENERIC_TYPE action, Runnable emptyAction) {
|
|
||||||
if (isPresent) action.accept(value);
|
|
||||||
else emptyAction.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElse(KEY_TYPE other) {
|
|
||||||
return isPresent ? value : other;
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElseGet(SUPPLIER KEY_GENERIC_TYPE other) {
|
|
||||||
return isPresent ? value : other.SUPPLY_GET();
|
|
||||||
}
|
|
||||||
|
|
||||||
public KEY_TYPE orElseThrow() {
|
|
||||||
if (!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <X extends Throwable> KEY_TYPE orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
|
||||||
if(isPresent) return value;
|
|
||||||
else throw exceptionSupplier.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == this) return true;
|
|
||||||
if(obj instanceof OPTIONAL) {
|
|
||||||
OPTIONAL KEY_GENERIC_TYPE other = (OPTIONAL KEY_GENERIC_TYPE)obj;
|
|
||||||
return (isPresent && other.isPresent ? KEY_EQUALS(value, other.value) : isPresent == other.isPresent);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return isPresent ? KEY_TO_HASH(value) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return isPresent ? "OPTIONAL["+value+"]" : "OPTIONAL.empty";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+5
-54
@@ -7,16 +7,6 @@ import java.util.Comparator;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
#if IARRAY_FEATURE || TYPE_OBJECT
|
#if IARRAY_FEATURE || TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -43,9 +33,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.STACK;
|
import speiger.src.collections.PACKAGE.collections.STACK;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#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;
|
||||||
@@ -232,42 +219,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ArrayList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, ObjectArrayList<T>, ObjectArrayList<T>> toList() {
|
|
||||||
return Collector.of(ObjectArrayList::new, ObjectArrayList::add, ObjectArrayList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ARRAY_LIST KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
|
||||||
return stream.collect(ObjectArrayList::new, ObjectArrayList::add, ObjectArrayList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ObjectArrayList<T> merge(ObjectArrayList<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayList
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static ARRAY_LIST toList(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(ARRAY_LIST::new, ARRAY_LIST::add, ARRAY_LIST::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Appends the specified element to the end of this list.
|
* Appends the specified element to the end of this list.
|
||||||
@@ -731,12 +682,12 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -763,7 +714,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -775,7 +726,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+8
-55
@@ -8,15 +8,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
@@ -42,9 +33,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.STACK;
|
import speiger.src.collections.PACKAGE.collections.STACK;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#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;
|
||||||
@@ -178,42 +166,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a CopyOnWriteArrayList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, CopyOnWriteObjectArrayList<T>, CopyOnWriteObjectArrayList<T>> toList() {
|
|
||||||
return Collector.of(CopyOnWriteObjectArrayList::new, CopyOnWriteObjectArrayList::add, CopyOnWriteObjectArrayList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a CopyOnWriteArrayList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> CopyOnWriteObjectArrayList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
|
||||||
return stream.collect(CopyOnWriteObjectArrayList::new, CopyOnWriteObjectArrayList::add, CopyOnWriteObjectArrayList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CopyOnWriteObjectArrayList<T> merge(CopyOnWriteObjectArrayList<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a CopyOnWriteArrayList
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static COPY_ON_WRITE_LIST toList(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(COPY_ON_WRITE_LIST::new, COPY_ON_WRITE_LIST::add, COPY_ON_WRITE_LIST::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
private void setArray(KEY_TYPE[] data) {
|
private void setArray(KEY_TYPE[] data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
}
|
}
|
||||||
@@ -582,7 +535,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
* @return if the element was found.
|
* @return if the element was found.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
return indexOf(o) != -1;
|
return indexOf(o) != -1;
|
||||||
}
|
}
|
||||||
@@ -593,7 +546,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
* @return the index of the element if found. (if not found then -1)
|
* @return the index of the element if found. (if not found then -1)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Deprecated
|
||||||
public int indexOf(Object o) {
|
public int indexOf(Object o) {
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -617,7 +570,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
* @return the last index of the element if found. (if not found then -1)
|
* @return the last index of the element if found. (if not found then -1)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Deprecated
|
||||||
public int lastIndexOf(Object o) {
|
public int lastIndexOf(Object o) {
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -857,13 +810,13 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -892,7 +845,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE[] data = this.data;
|
KEY_TYPE[] data = this.data;
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
@@ -905,7 +858,7 @@ public class COPY_ON_WRITE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENER
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+9
-61
@@ -3,26 +3,10 @@ package speiger.src.collections.PACKAGE.lists;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#else if !TYPE_BOOLEAN
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
import java.util.stream.StreamSupport;
|
|
||||||
#endif
|
#endif
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if PRIMITIVES
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.utils.COLLECTIONS;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -36,7 +20,6 @@ import java.util.function.PREDICATE;
|
|||||||
#if !JDK_FUNCTION
|
#if !JDK_FUNCTION
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -44,9 +27,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
@@ -56,6 +36,10 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
|
#if PRIMITIVES && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
||||||
|
import java.util.stream.JAVA_STREAM;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
#endif
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
@@ -136,42 +120,6 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
data = Arrays.copyOfRange(a, offset, offset+length);
|
data = Arrays.copyOfRange(a, offset, offset+length);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ImmutableList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, COLLECTION<T>, ImmutableObjectList<T>> toList() {
|
|
||||||
return Collector.of(COLLECTIONS::wrapper, COLLECTION::add, ImmutableObjectList::merge, E -> new IMMUTABLE_LIST<>(E.toArray((T[])new Object[E.size()])));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ImmutableList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ImmutableObjectList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
|
||||||
return stream.collect(toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> COLLECTION<T> merge(COLLECTION<T> a, COLLECTION<T> b) {
|
|
||||||
a.addAll(b);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ImmutableList
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static IMMUTABLE_LIST toList(JAVA_STREAM stream) {
|
|
||||||
return new IMMUTABLE_LIST(stream.collect((Supplier<COLLECTION>)COLLECTIONS::wrapper, COLLECTION::add, COLLECTION::addAll).TO_ARRAY());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public boolean add(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -387,12 +335,12 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
for(int i = 0,m=data.length;i<m;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -419,7 +367,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -431,7 +379,7 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+6
-53
@@ -4,6 +4,7 @@ package speiger.src.collections.PACKAGE.lists;
|
|||||||
#if DEQUEUE_FEATURE
|
#if DEQUEUE_FEATURE
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#else if PRIMITIVES
|
#else if PRIMITIVES
|
||||||
import java.nio.JAVA_BUFFER;
|
import java.nio.JAVA_BUFFER;
|
||||||
@@ -11,15 +12,6 @@ import java.nio.JAVA_BUFFER;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import java.util.Spliterator;
|
import java.util.Spliterator;
|
||||||
@@ -42,9 +34,6 @@ import java.util.function.JAVA_PREDICATE;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -166,42 +155,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
for(int i = offset,m=offset+length;i<m;add(a[i++]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a LinkedList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, ObjectLinkedList<T>, ObjectLinkedList<T>> toList() {
|
|
||||||
return Collector.of(ObjectLinkedList::new, ObjectLinkedList::add, ObjectLinkedList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedList
|
|
||||||
* @Type(T)
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ObjectLinkedList KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
|
||||||
return stream.collect(ObjectLinkedList::new, ObjectLinkedList::add, ObjectLinkedList::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ObjectLinkedList<T> merge(ObjectLinkedList<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedList
|
|
||||||
* @return a list with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static LINKED_LIST toList(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(LINKED_LIST::new, LINKED_LIST::add, LINKED_LIST::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE e) {
|
public boolean add(KEY_TYPE e) {
|
||||||
add(size(), e);
|
add(size(), e);
|
||||||
@@ -540,12 +493,12 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
||||||
if(filter.test(entry.value)) return OPTIONAL.GET_OPTIONAL(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -572,7 +525,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -584,7 +537,7 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import java.util.function.UnaryOperator;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ORDERED_COLLECTION;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
#endif
|
#endif
|
||||||
@@ -41,7 +40,7 @@ import speiger.src.collections.utils.SanityChecks;
|
|||||||
* A Type Specific List interface that reduces boxing/unboxing and adds a couple extra quality of life features
|
* A Type Specific List interface that reduces boxing/unboxing and adds a couple extra quality of life features
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface LIST KEY_GENERIC_TYPE extends ORDERED_COLLECTION KEY_GENERIC_TYPE, List<CLASS_TYPE>
|
public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List<CLASS_TYPE>
|
||||||
{
|
{
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
@@ -106,24 +105,6 @@ public interface LIST KEY_GENERIC_TYPE extends ORDERED_COLLECTION KEY_GENERIC_TY
|
|||||||
*/
|
*/
|
||||||
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c);
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the start of a list
|
|
||||||
* @param e that should be added at the start.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public default void addFirst(KEY_TYPE e) {
|
|
||||||
add(0, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the end of a list
|
|
||||||
* @param e that should be added at the end.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public default void addLast(KEY_TYPE e) {
|
|
||||||
add(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method that returns the first element of a List.
|
* Helper method that returns the first element of a List.
|
||||||
* This function was introduced due to how annoying it is to get/remove the last element of a list.
|
* This function was introduced due to how annoying it is to get/remove the last element of a list.
|
||||||
@@ -527,56 +508,9 @@ public interface LIST KEY_GENERIC_TYPE extends ORDERED_COLLECTION KEY_GENERIC_TY
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean add(CLASS_TYPE e) {
|
public default boolean add(CLASS_TYPE e) {
|
||||||
return ORDERED_COLLECTION.super.add(e);
|
return COLLECTION.super.add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
/** {@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 addFirst(CLASS_TYPE e) {
|
|
||||||
addFirst(OBJ_TO_KEY(e));
|
|
||||||
}
|
|
||||||
/** {@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 addLast(CLASS_TYPE e) {
|
|
||||||
addLast(OBJ_TO_KEY(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getFirst() {
|
|
||||||
return KEY_TO_OBJ(GET_FIRST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getLast() {
|
|
||||||
return KEY_TO_OBJ(GET_LAST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeFirst() {
|
|
||||||
return KEY_TO_OBJ(REMOVE_FIRST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeLast() {
|
|
||||||
return KEY_TO_OBJ(REMOVE_LAST_KEY());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
* @deprecated Please use the corresponding type-specific function instead.
|
||||||
@@ -624,7 +558,7 @@ public interface LIST KEY_GENERIC_TYPE extends ORDERED_COLLECTION KEY_GENERIC_TY
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean contains(Object o) {
|
public default boolean contains(Object o) {
|
||||||
return ORDERED_COLLECTION.super.contains(o);
|
return COLLECTION.super.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
@@ -634,7 +568,7 @@ public interface LIST KEY_GENERIC_TYPE extends ORDERED_COLLECTION KEY_GENERIC_TY
|
|||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public default boolean remove(Object o) {
|
public default boolean remove(Object o) {
|
||||||
return ORDERED_COLLECTION.super.remove(o);
|
return COLLECTION.super.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
|
|||||||
+2
-137
@@ -14,15 +14,6 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
|||||||
#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.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
|
||||||
import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
#if MAPS_FEATURE
|
#if MAPS_FEATURE
|
||||||
@@ -51,7 +42,7 @@ import speiger.src.collections.utils.SanityChecks;
|
|||||||
*/
|
*/
|
||||||
public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CLASS_TYPE, CLASS_VALUE_TYPE> implements MAP KEY_VALUE_GENERIC_TYPE
|
public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CLASS_TYPE, CLASS_VALUE_TYPE> implements MAP KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
protected VALUE_TYPE defaultReturnValue = INVALID_VALUE;
|
protected VALUE_TYPE defaultReturnValue = EMPTY_VALUE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getDefaultReturnValue() {
|
public VALUE_TYPE getDefaultReturnValue() {
|
||||||
@@ -128,7 +119,7 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
public void putAll(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values, int offset, int size) {
|
public void putAll(CLASS_TYPE[] keys, CLASS_VALUE_TYPE[] values, int offset, int size) {
|
||||||
SanityChecks.checkArrayCapacity(keys.length, offset, size);
|
SanityChecks.checkArrayCapacity(keys.length, offset, size);
|
||||||
SanityChecks.checkArrayCapacity(values.length, offset, size);
|
SanityChecks.checkArrayCapacity(values.length, offset, size);
|
||||||
for(int i = 0;i<size;i++) put(OBJ_TO_KEY(keys[i]), OBJ_TO_VALUE(values[i]));
|
for(int i = 0;i<size;i++) put(keys[i], values[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -552,132 +543,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class REVERSED_ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE implements ORDERED_MAP KEY_VALUE_GENERIC_TYPE {
|
|
||||||
ORDERED_MAP KEY_VALUE_GENERIC_TYPE map;
|
|
||||||
|
|
||||||
public REVERSED_ORDERED_MAP(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map) {
|
|
||||||
this.map = map;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v) {
|
|
||||||
map.setDefaultReturnValue(v);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE getDefaultReturnValue() { return map.getDefaultReturnValue(); }
|
|
||||||
@Override
|
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE put(KEY_TYPE key, VALUE_TYPE value) { return map.put(key, value); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putIfAbsent(KEY_TYPE key, VALUE_TYPE value) { return map.putIfAbsent(key, value); }
|
|
||||||
#if VALUE_PRIMITIVES
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE addTo(KEY_TYPE key, VALUE_TYPE value) { return map.addTo(key, value); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE subFrom(KEY_TYPE key, VALUE_TYPE value) { return map.subFrom(key, value); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) { return map.REMOVE_VALUE(key); }
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public boolean remove(KEY_TYPE key, VALUE_TYPE value) { return map.remove(key, value); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE REMOVE_VALUEOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.REMOVE_VALUEOrDefault(key, defaultValue); }
|
|
||||||
@Override
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
public boolean containsKey(Object key) { return map.containsKey(key); }
|
|
||||||
#else
|
|
||||||
public boolean containsKey(KEY_TYPE key) { return map.containsKey(key); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
#if VALUE_OBJECT
|
|
||||||
public boolean containsValue(Object value) { return map.containsValue(value); }
|
|
||||||
#else
|
|
||||||
public boolean containsValue(VALUE_TYPE value) { return map.containsValue(value); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public boolean replace(KEY_TYPE key, VALUE_TYPE oldValue, VALUE_TYPE newValue) { return map.replace(key, oldValue, newValue); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE replace(KEY_TYPE key, VALUE_TYPE value) { return map.replace(key, value); }
|
|
||||||
@Override
|
|
||||||
public void REPLACE_VALUES(MAP KEY_VALUE_GENERIC_TYPE m) { map.REPLACE_VALUES(m); }
|
|
||||||
@Override
|
|
||||||
public void REPLACE_VALUES(UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { map.REPLACE_VALUES(mappingFunction); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTE(key, mappingFunction); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTE_IF_ABSENT(key, mappingFunction); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { return map.SUPPLY_IF_ABSENT(key, valueProvider); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTE_IF_PRESENT(key, mappingFunction); }
|
|
||||||
#if !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTENonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTENonDefault(key, mappingFunction); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENTNonDefault(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTE_IF_ABSENTNonDefault(key, mappingFunction); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENTNonDefault(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { return map.SUPPLY_IF_ABSENTNonDefault(key, valueProvider); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENTNonDefault(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { return map.COMPUTE_IF_PRESENTNonDefault(key, mappingFunction); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE MERGE(KEY_TYPE key, VALUE_TYPE value, VALUE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE mappingFunction) { return map.MERGE(key, value, mappingFunction); }
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE GET_VALUE(KEY_TYPE key) { return map.GET_VALUE(key); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putAndMoveToFirst(KEY_TYPE key, VALUE_TYPE value) { return map.putAndMoveToLast(key, value); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { return map.putAndMoveToFirst(key, value); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) { return map.putLast(key, value); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) { return map.putFirst(key, value); }
|
|
||||||
@Override
|
|
||||||
public boolean moveToFirst(KEY_TYPE key) { return map.moveToLast(key); }
|
|
||||||
@Override
|
|
||||||
public boolean moveToLast(KEY_TYPE key) { return map.moveToFirst(key); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) { return map.getAndMoveToLast(key); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) { return map.getAndMoveToFirst(key); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE FIRST_ENTRY_KEY() { return map.LAST_ENTRY_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE POLL_FIRST_ENTRY_KEY() { return map.POLL_LAST_ENTRY_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE LAST_ENTRY_KEY() { return map.FIRST_ENTRY_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE POLL_LAST_ENTRY_KEY() { return map.POLL_FIRST_ENTRY_KEY(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return map.lastEntry(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { return map.firstEntry(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { return map.pollLastEntry(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() { return map.pollFirstEntry(); }
|
|
||||||
@Override
|
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() { return new AbstractObjectSet.ReversedObjectOrderedSet<>(map.ENTRY_SET()); }
|
|
||||||
@Override
|
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE keySet() { return new ABSTRACT_SET.REVERSED_ORDERED_SETBRACES(map.keySet()); }
|
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() { return map.values().reversed(); }
|
|
||||||
@Override
|
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE reversed() { return map; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple Type Specific Entry class to reduce boxing/unboxing
|
* A Simple Type Specific Entry class to reduce boxing/unboxing
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
|
|||||||
+17
-24
@@ -4,18 +4,15 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.locks.StampedLock;
|
import java.util.concurrent.locks.StampedLock;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -43,12 +40,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.CONCURRENT_MAP;
|
||||||
@@ -84,7 +78,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@@ -846,7 +839,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -870,11 +863,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
@@ -884,7 +877,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index, i);
|
entry.set(index, i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -892,7 +885,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1193,7 +1186,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1217,11 +1210,11 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
@@ -1229,7 +1222,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(seg.keys[index])) return OPTIONAL.GET_OPTIONAL(seg.keys[index]);
|
if(filter.test(seg.keys[index])) return seg.keys[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1237,7 +1230,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1461,7 +1454,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1485,20 +1478,20 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
for(int i = 0,m=segments.length;i<m;i++) {
|
for(int i = 0,m=segments.length;i<m;i++) {
|
||||||
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
Segment KEY_VALUE_GENERIC_TYPE seg = segments[i];
|
||||||
long stamp = seg.readLock();
|
long stamp = seg.readLock();
|
||||||
try {
|
try {
|
||||||
int index = seg.firstIndex;
|
int index = seg.firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(seg.values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(seg.values[index]);
|
if(filter.test(seg.values[index])) return seg.values[index];
|
||||||
index = (int)seg.links[index];
|
index = (int)seg.links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1506,7 +1499,7 @@ public class CONCURRENT_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY
|
|||||||
seg.unlockRead(stamp);
|
seg.unlockRead(stamp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+85
-223
@@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@@ -30,7 +27,6 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
@@ -44,7 +40,7 @@ import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
|||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
@@ -63,7 +59,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -238,13 +233,13 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex, false);
|
moveToFirstIndex(nullIndex);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex, true);
|
moveToFirstIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@@ -252,7 +247,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos, false);
|
moveToFirstIndex(pos);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -260,7 +255,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos, true);
|
moveToFirstIndex(pos);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@@ -272,13 +267,13 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex, false);
|
moveToLastIndex(nullIndex);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex, true);
|
moveToLastIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
@@ -286,7 +281,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos, false);
|
moveToLastIndex(pos);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -294,55 +289,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos, true);
|
moveToLastIndex(pos);
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
|
||||||
if(containsNull) return values[nullIndex];
|
|
||||||
values[nullIndex] = value;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToFirstIndex(nullIndex, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
|
||||||
if(strategy.equals(keys[pos], key)) return values[pos];
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = key;
|
|
||||||
values[pos] = value;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToFirstIndex(pos, true);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
|
||||||
if(containsNull) return values[nullIndex];
|
|
||||||
values[nullIndex] = value;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToLastIndex(nullIndex, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
|
||||||
if(strategy.equals(keys[pos], key)) return values[pos];
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = key;
|
|
||||||
values[pos] = value;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToLastIndex(pos, true);
|
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@@ -353,7 +300,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(isEmpty() || strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex, false);
|
moveToFirstIndex(nullIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +308,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos, false);
|
moveToFirstIndex(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -375,7 +322,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
if(isEmpty() || strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || strategy.equals(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(key, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex, false);
|
moveToLastIndex(nullIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,7 +330,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
int pos = HashUtil.mix(strategy.hashCode(key)) & mask;
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
||||||
if(strategy.equals(keys[pos], key)) {
|
if(strategy.equals(keys[pos], key)) {
|
||||||
moveToLastIndex(pos, false);
|
moveToLastIndex(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -396,7 +343,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index, false);
|
moveToFirstIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,7 +351,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index, false);
|
moveToLastIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,52 +430,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return values[lastIndex];
|
return values[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[firstIndex], values[firstIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[lastIndex], values[lastIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = firstIndex;
|
|
||||||
onNodeRemoved(pos);
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
if(strategy.equals(result.ENTRY_KEY(), EMPTY_KEY_VALUE)) {
|
|
||||||
containsNull = false;
|
|
||||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
|
||||||
values[nullIndex] = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
else shiftKeys(pos);
|
|
||||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = lastIndex;
|
|
||||||
onNodeRemoved(pos);
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
if(strategy.equals(result.ENTRY_KEY(), EMPTY_KEY_VALUE)) {
|
|
||||||
containsNull = false;
|
|
||||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
|
||||||
values[nullIndex] = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
else shiftKeys(pos);
|
|
||||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -542,9 +443,9 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(valuesC == null) valuesC = new Values();
|
if(valuesC == null) valuesC = new Values();
|
||||||
return (VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE)valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -580,8 +481,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos, boolean adding) {
|
protected void moveToFirstIndex(int startPos) {
|
||||||
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
if(size == 1 || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@@ -598,8 +499,8 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos, boolean adding) {
|
protected void moveToLastIndex(int startPos) {
|
||||||
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
if(size == 1 || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
@@ -713,10 +614,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -733,24 +630,24 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() {
|
||||||
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() {
|
||||||
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
POLL_FIRST_ENTRY_KEY();
|
POLL_FIRST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
POLL_LAST_ENTRY_KEY();
|
POLL_LAST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
@@ -758,12 +655,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator(true);
|
return new EntryIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
|
||||||
return new EntryIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -773,7 +665,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
||||||
return new FastEntryIterator(true);
|
return new FastEntryIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -882,7 +774,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -897,21 +789,21 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.apply(state, new ValueMapEntry(index));
|
state = operator.apply(state, new ValueMapEntry(index));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index);
|
entry.set(index);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1009,12 +901,9 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -1030,12 +919,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new KeyIterator(true);
|
return new KeyIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new KeyIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1057,22 +941,22 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
return FIRST_ENTRY_KEY();
|
return FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
return POLL_FIRST_ENTRY_KEY();
|
return POLL_FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
return LAST_ENTRY_KEY();
|
return LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
return POLL_LAST_ENTRY_KEY();
|
return POLL_LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1172,7 +1056,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1187,19 +1071,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1216,47 +1100,39 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE implements VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object e) { return containsValue(e); }
|
public boolean contains(Object e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VALUE_TYPE e) { return containsValue(e); }
|
public boolean contains(VALUE_TYPE e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) {
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() { return new ValueIterator(true); }
|
|
||||||
@Override
|
|
||||||
public int size() { return LINKED_CUSTOM_HASH_MAP.this.size(); }
|
|
||||||
@Override
|
|
||||||
public void clear() { LINKED_CUSTOM_HASH_MAP.this.clear(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
|
||||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new ValueIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
@Override
|
return new ValueIterator();
|
||||||
public void addLast(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_FIRST_KEY() { return FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_FIRST_KEY() {
|
|
||||||
VALUE_TYPE result = FIRST_ENTRY_VALUE();
|
|
||||||
POLL_FIRST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_GET_LAST_KEY() { return LAST_ENTRY_VALUE(); }
|
public int size() {
|
||||||
|
return LINKED_CUSTOM_HASH_MAP.this.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_REMOVE_LAST_KEY() {
|
public void clear() {
|
||||||
VALUE_TYPE result = LAST_ENTRY_VALUE();
|
LINKED_CUSTOM_HASH_MAP.this.clear();
|
||||||
POLL_LAST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1355,7 +1231,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1370,19 +1246,19 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1402,7 +1278,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
|
|
||||||
public FastEntryIterator(boolean start) { super(start); }
|
public FastEntryIterator() {}
|
||||||
public FastEntryIterator(KEY_TYPE from) {
|
public FastEntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1429,7 +1305,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry;
|
MapEntry entry;
|
||||||
|
|
||||||
public EntryIterator(boolean start) { super(start); }
|
public EntryIterator() {}
|
||||||
public EntryIterator(KEY_TYPE from) {
|
public EntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1459,7 +1335,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
public KeyIterator(boolean start) { super(start); }
|
public KeyIterator() {}
|
||||||
public KeyIterator(KEY_TYPE from) {
|
public KeyIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1481,7 +1357,7 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public ValueIterator(boolean start) { super(start); }
|
public ValueIterator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
@@ -1502,20 +1378,16 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapIterator {
|
private class MapIterator {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
MapIterator(boolean start) {
|
MapIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
this.forward = true;
|
|
||||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
@@ -1543,11 +1415,11 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
@@ -1607,30 +1479,20 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
|
next = current;
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextEntry() {
|
public int nextEntry() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
next = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = next;
|
current = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
previous = current;
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+22
-29
@@ -5,17 +5,14 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -81,7 +75,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@@ -1097,7 +1090,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1114,25 +1107,25 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(nullIndex);
|
entry.set(nullIndex);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1338,7 +1331,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1355,18 +1348,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1504,7 +1497,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1521,18 +1514,18 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(values[nullIndex])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[nullIndex]);
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+84
-225
@@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@@ -30,7 +27,6 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
@@ -43,7 +39,7 @@ import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
@@ -62,7 +58,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -215,13 +210,13 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToFirstIndex(nullIndex, false);
|
moveToFirstIndex(nullIndex);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToFirstIndex(nullIndex, true);
|
moveToFirstIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@@ -229,7 +224,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToFirstIndex(pos, false);
|
moveToFirstIndex(pos);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -237,7 +232,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToFirstIndex(pos, true);
|
moveToFirstIndex(pos);
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@@ -249,13 +244,13 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
VALUE_TYPE lastValue = values[nullIndex];
|
VALUE_TYPE lastValue = values[nullIndex];
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
moveToLastIndex(nullIndex, false);
|
moveToLastIndex(nullIndex);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
values[nullIndex] = value;
|
values[nullIndex] = value;
|
||||||
containsNull = true;
|
containsNull = true;
|
||||||
onNodeAdded(nullIndex);
|
onNodeAdded(nullIndex);
|
||||||
moveToLastIndex(nullIndex, true);
|
moveToLastIndex(nullIndex);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
@@ -263,7 +258,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
VALUE_TYPE lastValue = values[pos];
|
VALUE_TYPE lastValue = values[pos];
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
moveToLastIndex(pos, false);
|
moveToLastIndex(pos);
|
||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -271,55 +266,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
keys[pos] = key;
|
keys[pos] = key;
|
||||||
values[pos] = value;
|
values[pos] = value;
|
||||||
onNodeAdded(pos);
|
onNodeAdded(pos);
|
||||||
moveToLastIndex(pos, true);
|
moveToLastIndex(pos);
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
|
||||||
if(containsNull) return values[nullIndex];
|
|
||||||
values[nullIndex] = value;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToFirstIndex(nullIndex, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
|
||||||
if(KEY_EQUALS(keys[pos], key)) return values[pos];
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = key;
|
|
||||||
values[pos] = value;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToFirstIndex(pos, true);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
|
||||||
if(containsNull) return values[nullIndex];
|
|
||||||
values[nullIndex] = value;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToLastIndex(nullIndex, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
|
||||||
if(KEY_EQUALS(keys[pos], key)) return values[pos];
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = key;
|
|
||||||
values[pos] = value;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToLastIndex(pos, true);
|
|
||||||
}
|
}
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
@@ -330,7 +277,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(isEmpty() || KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(FIRST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex, false);
|
moveToFirstIndex(nullIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -338,7 +285,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
moveToFirstIndex(pos, false);
|
moveToFirstIndex(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -352,7 +299,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
if(isEmpty() || KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
if(isEmpty() || KEY_EQUALS(LAST_ENTRY_KEY(), key)) return false;
|
||||||
if(KEY_EQUALS_NULL(key)) {
|
if(KEY_EQUALS_NULL(key)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex, false);
|
moveToLastIndex(nullIndex);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +307,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
int pos = HashUtil.mix(KEY_TO_HASH(key)) & mask;
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
||||||
if(KEY_EQUALS(keys[pos], key)) {
|
if(KEY_EQUALS(keys[pos], key)) {
|
||||||
moveToLastIndex(pos, false);
|
moveToLastIndex(pos);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pos = ++pos & mask;
|
pos = ++pos & mask;
|
||||||
@@ -373,7 +320,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToFirstIndex(index, false);
|
moveToFirstIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +328,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
public VALUE_TYPE getAndMoveToLast(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
if(index < 0) return getDefaultReturnValue();
|
if(index < 0) return getDefaultReturnValue();
|
||||||
moveToLastIndex(index, false);
|
moveToLastIndex(index);
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,52 +434,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return values[lastIndex];
|
return values[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[firstIndex], values[firstIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[lastIndex], values[lastIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = firstIndex;
|
|
||||||
onNodeRemoved(pos);
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
if(KEY_EQUALS_NULL(result.ENTRY_KEY())) {
|
|
||||||
containsNull = false;
|
|
||||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
|
||||||
values[nullIndex] = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
else shiftKeys(pos);
|
|
||||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = lastIndex;
|
|
||||||
onNodeRemoved(pos);
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
if(KEY_EQUALS_NULL(result.ENTRY_KEY())) {
|
|
||||||
containsNull = false;
|
|
||||||
keys[nullIndex] = EMPTY_KEY_VALUE;
|
|
||||||
values[nullIndex] = EMPTY_VALUE;
|
|
||||||
}
|
|
||||||
else shiftKeys(pos);
|
|
||||||
if(nullIndex > minCapacity && size < maxFill / 4 && nullIndex > HashUtil.DEFAULT_MIN_CAPACITY) rehash(nullIndex / 2);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -546,9 +447,9 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(valuesC == null) valuesC = new Values();
|
if(valuesC == null) valuesC = new Values();
|
||||||
return (VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE)valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -584,8 +485,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
containsNull = false;
|
containsNull = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToFirstIndex(int startPos, boolean adding) {
|
protected void moveToFirstIndex(int startPos) {
|
||||||
if(size == (adding ? 0 : 1) || firstIndex == startPos) return;
|
if(size == 1 || firstIndex == startPos) return;
|
||||||
if(lastIndex == startPos) {
|
if(lastIndex == startPos) {
|
||||||
lastIndex = (int)(links[startPos] >>> 32);
|
lastIndex = (int)(links[startPos] >>> 32);
|
||||||
links[lastIndex] |= 0xFFFFFFFFL;
|
links[lastIndex] |= 0xFFFFFFFFL;
|
||||||
@@ -602,8 +503,8 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
firstIndex = startPos;
|
firstIndex = startPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void moveToLastIndex(int startPos, boolean adding) {
|
protected void moveToLastIndex(int startPos) {
|
||||||
if(size == (adding ? 0 : 1) || lastIndex == startPos) return;
|
if(size == 1 || lastIndex == startPos) return;
|
||||||
if(firstIndex == startPos) {
|
if(firstIndex == startPos) {
|
||||||
firstIndex = (int)links[startPos];
|
firstIndex = (int)links[startPos];
|
||||||
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
links[lastIndex] |= 0xFFFFFFFF00000000L;
|
||||||
@@ -717,10 +618,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -737,24 +634,24 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() {
|
||||||
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() {
|
||||||
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
POLL_FIRST_ENTRY_KEY();
|
POLL_FIRST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
POLL_LAST_ENTRY_KEY();
|
POLL_LAST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
@@ -762,12 +659,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator(true);
|
return new EntryIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
|
||||||
return new EntryIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -777,7 +669,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
||||||
return new FastEntryIterator(true);
|
return new FastEntryIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -886,7 +778,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -901,21 +793,21 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.apply(state, new ValueMapEntry(index));
|
state = operator.apply(state, new ValueMapEntry(index));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(index);
|
entry.set(index);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1008,12 +900,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -1032,12 +918,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new KeyIterator(true);
|
return new KeyIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new KeyIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1059,22 +940,22 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
return FIRST_ENTRY_KEY();
|
return FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
return POLL_FIRST_ENTRY_KEY();
|
return POLL_FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
return LAST_ENTRY_KEY();
|
return LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
return POLL_LAST_ENTRY_KEY();
|
return POLL_LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1174,7 +1055,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1189,19 +1070,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1218,50 +1099,41 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE implements VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object e) { return containsValue(e); }
|
public boolean contains(Object e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VALUE_TYPE e) { return containsValue(e); }
|
public boolean contains(VALUE_TYPE e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) {
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() { return new ValueIterator(true); }
|
|
||||||
@Override
|
|
||||||
public int size() { return LINKED_HASH_MAP.this.size(); }
|
|
||||||
@Override
|
|
||||||
public void clear() { LINKED_HASH_MAP.this.clear(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
|
||||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new ValueIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
@Override
|
return new ValueIterator();
|
||||||
public void addLast(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_FIRST_KEY() { return FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_FIRST_KEY() {
|
|
||||||
VALUE_TYPE result = FIRST_ENTRY_VALUE();
|
|
||||||
POLL_FIRST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_GET_LAST_KEY() { return LAST_ENTRY_VALUE(); }
|
public int size() {
|
||||||
@Override
|
return LINKED_HASH_MAP.this.size();
|
||||||
public VALUE_TYPE VALUE_REMOVE_LAST_KEY() {
|
|
||||||
VALUE_TYPE result = LAST_ENTRY_VALUE();
|
|
||||||
POLL_LAST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
LINKED_HASH_MAP.this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1359,7 +1231,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1374,19 +1246,19 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1406,7 +1278,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
|
|
||||||
public FastEntryIterator(boolean start) { super(start); }
|
public FastEntryIterator() {}
|
||||||
public FastEntryIterator(KEY_TYPE from) {
|
public FastEntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1433,7 +1305,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry;
|
MapEntry entry;
|
||||||
|
|
||||||
public EntryIterator(boolean start) { super(start); }
|
public EntryIterator() {}
|
||||||
public EntryIterator(KEY_TYPE from) {
|
public EntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1463,7 +1335,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
public KeyIterator(boolean start) { super(start); }
|
public KeyIterator() {}
|
||||||
public KeyIterator(KEY_TYPE from) {
|
public KeyIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1485,7 +1357,7 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public ValueIterator(boolean start) { super(start); }
|
public ValueIterator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
@@ -1505,16 +1377,13 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapIterator {
|
private class MapIterator {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
MapIterator(boolean start) {
|
MapIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
@@ -1545,11 +1414,11 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
@@ -1609,30 +1478,20 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
|
next = current;
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextEntry() {
|
public int nextEntry() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
next = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = next;
|
current = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
previous = current;
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+22
-29
@@ -5,17 +5,14 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -79,7 +73,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
|
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@@ -1056,7 +1049,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1073,25 +1066,25 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
entry.set(nullIndex);
|
entry.set(nullIndex);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1293,7 +1286,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1310,18 +1303,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1459,7 +1452,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1476,18 +1469,18 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(values[nullIndex])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[nullIndex]);
|
if(containsNull && filter.test(values[nullIndex])) return values[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+66
-130
@@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -29,12 +26,9 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
#if !SAME_TYPE && !TYPE_INT
|
#if !SAME_TYPE && !TYPE_INT
|
||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if !VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
@@ -65,14 +59,13 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
@@ -126,7 +119,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
/** KeySet cache */
|
/** KeySet cache */
|
||||||
protected transient ORDERED_SET KEY_GENERIC_TYPE keySet;
|
protected transient ORDERED_SET KEY_GENERIC_TYPE keySet;
|
||||||
/** Values cache */
|
/** Values cache */
|
||||||
protected transient VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
protected transient VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||||
|
|
||||||
/** Amount of Elements stored in the HashMap */
|
/** Amount of Elements stored in the HashMap */
|
||||||
protected int size;
|
protected int size;
|
||||||
@@ -327,10 +320,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@@ -454,23 +443,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
return values[lastIndex];
|
return values[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[firstIndex], values[firstIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[lastIndex], values[lastIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -484,7 +456,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(valuesC == null) valuesC = new Values();
|
if(valuesC == null) valuesC = new Values();
|
||||||
return valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
@@ -637,10 +609,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -653,29 +621,24 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
public boolean moveToLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean moveToLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() {
|
||||||
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() {
|
||||||
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() { throw new UnsupportedOperationException(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() { throw new UnsupportedOperationException(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator(true);
|
return new EntryIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
|
||||||
return new EntryIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -685,7 +648,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
||||||
return new FastEntryIterator(true);
|
return new FastEntryIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -794,7 +757,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -809,21 +772,21 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
state = operator.apply(state, new BasicEntryKV_BRACES(keys[index], values[index]));
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -898,12 +861,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -918,12 +875,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new KeyIterator(true);
|
return new KeyIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new KeyIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -943,20 +895,20 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
public void clear() { throw new UnsupportedOperationException(); }
|
public void clear() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
return FIRST_ENTRY_KEY();
|
return FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
return LAST_ENTRY_KEY();
|
return LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
@@ -1054,7 +1006,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1069,19 +1021,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
state = operator.APPLY_KEY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_KEY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1098,42 +1050,39 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE implements VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object e) { return containsValue(e); }
|
public boolean contains(Object e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VALUE_TYPE e) { return containsValue(e); }
|
public boolean contains(VALUE_TYPE e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() { return new ValueIterator(true); }
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
|
return new ValueIterator();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() { return IMMUTABLE_HASH_MAP.this.size(); }
|
public int size() {
|
||||||
|
return IMMUTABLE_HASH_MAP.this.size();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() { throw new UnsupportedOperationException(); }
|
public void clear() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
|
||||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new ValueIterator(false);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_FIRST_KEY() { return FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_LAST_KEY() { return LAST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
@@ -1230,7 +1179,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1245,19 +1194,19 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
state = operator.APPLY_VALUE(state, values[index]);
|
state = operator.APPLY_VALUE(state, values[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return VALUE_OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
if(filter.test(values[index])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[index]);
|
if(filter.test(values[index])) return values[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1277,7 +1226,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
|
|
||||||
public FastEntryIterator(boolean start) { super(start); }
|
public FastEntryIterator() {}
|
||||||
public FastEntryIterator(KEY_TYPE from) {
|
public FastEntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1303,7 +1252,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
|
||||||
public EntryIterator(boolean start) { super(start); }
|
public EntryIterator() {}
|
||||||
public EntryIterator(KEY_TYPE from) {
|
public EntryIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1330,7 +1279,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
public KeyIterator(boolean start) { super(start); }
|
public KeyIterator() {}
|
||||||
public KeyIterator(KEY_TYPE from) {
|
public KeyIterator(KEY_TYPE from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -1352,7 +1301,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public ValueIterator(boolean start) { super(start); }
|
public ValueIterator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
@@ -1373,16 +1322,13 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapIterator {
|
private class MapIterator {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
MapIterator(boolean start) {
|
MapIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapIterator(KEY_TYPE from) {
|
MapIterator(KEY_TYPE from) {
|
||||||
@@ -1413,11 +1359,11 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
@@ -1434,30 +1380,20 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
|
next = current;
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextEntry() {
|
public int nextEntry() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
next = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = next;
|
current = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
previous = current;
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+78
-183
@@ -4,17 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@@ -29,12 +26,9 @@ import speiger.src.collections.ints.functions.consumer.IntObjectConsumer;
|
|||||||
#if !SAME_TYPE && !TYPE_INT
|
#if !SAME_TYPE && !TYPE_INT
|
||||||
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
import speiger.src.collections.ints.functions.consumer.VALUE_BI_FROM_INT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
@@ -52,7 +46,7 @@ import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
@@ -72,7 +66,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@@ -112,7 +105,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
/** KeySet cache */
|
/** KeySet cache */
|
||||||
protected ORDERED_SET KEY_GENERIC_TYPE keySet;
|
protected ORDERED_SET KEY_GENERIC_TYPE keySet;
|
||||||
/** Values cache */
|
/** Values cache */
|
||||||
protected VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
protected VALUE_COLLECTION VALUE_GENERIC_TYPE valuesC;
|
||||||
/** EntrySet cache */
|
/** EntrySet cache */
|
||||||
protected FastOrderedSet KEY_VALUE_GENERIC_TYPE entrySet;
|
protected FastOrderedSet KEY_VALUE_GENERIC_TYPE entrySet;
|
||||||
|
|
||||||
@@ -282,27 +275,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return lastValue;
|
return lastValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
insertIndex(0, key, value);
|
|
||||||
size++;
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) {
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
insertIndex(size++, key, value);
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE key) {
|
public boolean moveToFirst(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
@@ -430,34 +402,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[0], values[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[size-1], values[size-1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[0], values[0]);
|
|
||||||
removeIndex(0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[size-1], values[size-1]);
|
|
||||||
removeIndex(size-1);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
|
public VALUE_TYPE REMOVE_VALUE(KEY_TYPE key) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
@@ -517,7 +461,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(valuesC == null) valuesC = new Values();
|
if(valuesC == null) valuesC = new Values();
|
||||||
return valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
@@ -868,10 +812,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -888,24 +828,24 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() {
|
||||||
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() {
|
||||||
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
POLL_FIRST_ENTRY_KEY();
|
POLL_FIRST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
POLL_LAST_ENTRY_KEY();
|
POLL_LAST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
@@ -913,12 +853,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator(true);
|
return new EntryIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
|
||||||
return new EntryIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -928,7 +863,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
||||||
return new FastEntryIterator(true);
|
return new FastEntryIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1020,7 +955,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1032,19 +967,19 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new ValueMapEntry(i));
|
state = operator.apply(state, new ValueMapEntry(i));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
entry.set(i);
|
entry.set(i);
|
||||||
if(filter.test(entry)) return Optional.ofNullable(entry);
|
if(filter.test(entry)) return entry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1130,10 +1065,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@@ -1142,9 +1073,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE o) { return ARRAY_MAP.this.moveToLast(o); }
|
public boolean moveToLast(KEY_TYPE o) { return ARRAY_MAP.this.moveToLast(o); }
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() { return new KeyIterator(true); }
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() { return new KeyIterator(); }
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() { return new KeyIterator(false); }
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return new KeyIterator(fromElement); }
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return new KeyIterator(fromElement); }
|
||||||
@Override
|
@Override
|
||||||
@@ -1152,13 +1081,13 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public void clear() { ARRAY_MAP.this.clear(); }
|
public void clear() { ARRAY_MAP.this.clear(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() { return FIRST_ENTRY_KEY(); }
|
public KEY_TYPE FIRST_KEY() { return FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { return POLL_FIRST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_FIRST_KEY() { return POLL_FIRST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() { return LAST_ENTRY_KEY(); }
|
public KEY_TYPE LAST_KEY() { return LAST_ENTRY_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
public KeySet copy() { throw new UnsupportedOperationException(); }
|
||||||
@@ -1233,7 +1162,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1245,16 +1174,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
state = operator.APPLY_KEY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1268,49 +1197,40 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE implements VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) { return containsValue(e); }
|
public boolean contains(Object e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VALUE_TYPE e) { return containsValue(e); }
|
public boolean contains(VALUE_TYPE e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) {
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() { return new ValueIterator(true); }
|
|
||||||
@Override
|
|
||||||
public int size() { return ARRAY_MAP.this.size(); }
|
|
||||||
@Override
|
|
||||||
public void clear() { ARRAY_MAP.this.clear(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
|
||||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new ValueIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
@Override
|
return new ValueIterator();
|
||||||
public void addLast(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_FIRST_KEY() { return FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_FIRST_KEY() {
|
|
||||||
VALUE_TYPE result = FIRST_ENTRY_VALUE();
|
|
||||||
POLL_FIRST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_GET_LAST_KEY() { return LAST_ENTRY_VALUE(); }
|
public int size() {
|
||||||
@Override
|
return ARRAY_MAP.this.size();
|
||||||
public VALUE_TYPE VALUE_REMOVE_LAST_KEY() {
|
|
||||||
VALUE_TYPE result = LAST_ENTRY_VALUE();
|
|
||||||
POLL_LAST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
ARRAY_MAP.this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
public void forEach(VALUE_CONSUMER VALUE_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1374,7 +1294,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1386,16 +1306,16 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, values[i]);
|
state = operator.APPLY_VALUE(state, values[i]);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(values[i])) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(values[i]);
|
if(filter.test(values[i])) return values[i];
|
||||||
}
|
}
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1412,8 +1332,10 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
|
|
||||||
public FastEntryIterator(boolean start) { super(start); }
|
public FastEntryIterator() {}
|
||||||
public FastEntryIterator(KEY_TYPE element) { super(element); }
|
public FastEntryIterator(KEY_TYPE from) {
|
||||||
|
index = findIndex(from);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
@@ -1436,8 +1358,11 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = null;
|
MapEntry entry = null;
|
||||||
|
|
||||||
public EntryIterator(boolean start) { super(start); }
|
public EntryIterator() {}
|
||||||
public EntryIterator(KEY_TYPE element) { super(element); }
|
public EntryIterator(KEY_TYPE from) {
|
||||||
|
index = findIndex(from);
|
||||||
|
if(index == -1) throw new NoSuchElementException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE next() {
|
||||||
@@ -1464,8 +1389,11 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
public KeyIterator(boolean start) { super(start); }
|
public KeyIterator() {}
|
||||||
public KeyIterator(KEY_TYPE element) { super(element); }
|
public KeyIterator(KEY_TYPE element) {
|
||||||
|
index = findIndex(element);
|
||||||
|
if(index == -1) throw new NoSuchElementException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
@@ -1485,9 +1413,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public ValueIterator(boolean start) { super(start); }
|
|
||||||
public ValueIterator(KEY_TYPE element) { super(element); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
return values[previousEntry()];
|
return values[previousEntry()];
|
||||||
@@ -1506,37 +1431,23 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapIterator {
|
private class MapIterator {
|
||||||
boolean forward;
|
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
|
|
||||||
MapIterator(boolean start) {
|
|
||||||
this.forward = start;
|
|
||||||
this.index = start ? 0 : size;
|
|
||||||
}
|
|
||||||
|
|
||||||
MapIterator(KEY_TYPE element) {
|
|
||||||
this.forward = true;
|
|
||||||
index = findIndex(element);
|
|
||||||
if(index == -1) throw new NoSuchElementException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return forward ? index < size : index > 0;
|
return index < size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return forward ? index > 0 : index < size;
|
return index > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
if(forward) return index;
|
return index;
|
||||||
return size - index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
if(forward) return index-1;
|
return index-1;
|
||||||
return (size - index)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove() {
|
public void remove() {
|
||||||
@@ -1549,42 +1460,26 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) {
|
|
||||||
index--;
|
|
||||||
return (lastReturned = index);
|
|
||||||
}
|
|
||||||
lastReturned = index;
|
|
||||||
return index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int nextEntry() {
|
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
|
||||||
if(forward) {
|
|
||||||
lastReturned = index;
|
|
||||||
return index++;
|
|
||||||
}
|
|
||||||
index--;
|
index--;
|
||||||
return (lastReturned = index);
|
return (lastReturned = index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int nextEntry() {
|
||||||
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
|
lastReturned = index;
|
||||||
|
return index++;
|
||||||
|
}
|
||||||
|
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
return forward ? moveForward(amount) : moveBackwards(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int back(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
return forward ? moveBackwards(amount) : moveForward(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int moveForward(int amount) {
|
|
||||||
int steps = Math.min(amount, size() - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int moveBackwards(int amount) {
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
int steps = Math.min(amount, index);
|
int steps = Math.min(amount, index);
|
||||||
index -= steps;
|
index -= steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
||||||
|
|||||||
+49
-147
@@ -18,7 +18,7 @@ import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET;
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
#if !VALUE_OBJECT && !SAME_TYPE
|
#if !VALUE_OBJECT && !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||||
@@ -216,28 +216,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
return getDefaultReturnValue();
|
return getDefaultReturnValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putFirst(T key, VALUE_TYPE value) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(isSet(index)) return values[index];
|
|
||||||
set(index);
|
|
||||||
values[index] = value;
|
|
||||||
onNodeAdded(index);
|
|
||||||
moveToFirstIndex(index);
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(T key, VALUE_TYPE value) {
|
|
||||||
int index = key.ordinal();
|
|
||||||
if(isSet(index)) return values[index];
|
|
||||||
set(index);
|
|
||||||
values[index] = value;
|
|
||||||
onNodeAdded(index);
|
|
||||||
moveToLastIndex(index);
|
|
||||||
return getDefaultReturnValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(T key) {
|
public boolean moveToFirst(T key) {
|
||||||
int index = key.ordinal();
|
int index = key.ordinal();
|
||||||
@@ -334,42 +312,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
return values[lastIndex];
|
return values[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[firstIndex], values[firstIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
return new BasicEntryKV_BRACES(keys[lastIndex], values[lastIndex]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = firstIndex;
|
|
||||||
firstIndex = (int)links[pos];
|
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
values[result.ENTRY_KEY().ordinal()] = EMPTY_VALUE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() {
|
|
||||||
if(size == 0) throw new NoSuchElementException();
|
|
||||||
int pos = lastIndex;
|
|
||||||
firstIndex = (int)links[pos];
|
|
||||||
if(0 <= firstIndex) links[firstIndex] |= 0xFFFFFFFF00000000L;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE result = new BasicEntryKV_BRACES(keys[pos], values[pos]);
|
|
||||||
size--;
|
|
||||||
values[result.ENTRY_KEY().ordinal()] = EMPTY_VALUE;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -383,9 +325,9 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() {
|
||||||
if(valuesC == null) valuesC = new Values();
|
if(valuesC == null) valuesC = new Values();
|
||||||
return (VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE)valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -473,10 +415,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
private class MapEntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> implements ORDERED_MAP.FastOrderedSet KEY_VALUE_GENERIC_TYPE {
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -493,24 +431,24 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() {
|
||||||
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() {
|
||||||
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
return new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(FIRST_ENTRY_KEY(), FIRST_ENTRY_VALUE());
|
||||||
POLL_FIRST_ENTRY_KEY();
|
POLL_FIRST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() {
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES(LAST_ENTRY_KEY(), LAST_ENTRY_VALUE());
|
||||||
POLL_LAST_ENTRY_KEY();
|
POLL_LAST_ENTRY_KEY();
|
||||||
return entry;
|
return entry;
|
||||||
@@ -518,12 +456,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() {
|
||||||
return new EntryIterator(true);
|
return new EntryIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() {
|
|
||||||
return new EntryIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -533,7 +466,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> fastIterator() {
|
||||||
return new FastEntryIterator(true);
|
return new FastEntryIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -641,10 +574,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
public boolean add(T o) {
|
public boolean add(T o) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public void addFirst(T o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(T o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(T o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(T o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -663,12 +593,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new KeyIterator(true);
|
return new KeyIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new KeyIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -689,22 +614,22 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T GET_FIRST_KEY() {
|
public T FIRST_KEY() {
|
||||||
return FIRST_ENTRY_KEY();
|
return FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T REMOVE_FIRST_KEY() {
|
public T POLL_FIRST_KEY() {
|
||||||
return POLL_FIRST_ENTRY_KEY();
|
return POLL_FIRST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T GET_LAST_KEY() {
|
public T LAST_KEY() {
|
||||||
return LAST_ENTRY_KEY();
|
return LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T REMOVE_LAST_KEY() {
|
public T POLL_LAST_KEY() {
|
||||||
return POLL_LAST_ENTRY_KEY();
|
return POLL_LAST_ENTRY_KEY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,50 +656,41 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE implements VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object e) { return containsValue(e); }
|
public boolean contains(Object e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(VALUE_TYPE e) { return containsValue(e); }
|
public boolean contains(VALUE_TYPE e) {
|
||||||
|
return containsValue(e);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(VALUE_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean add(VALUE_TYPE o) {
|
||||||
@Override
|
throw new UnsupportedOperationException();
|
||||||
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() { return new ValueIterator(true); }
|
|
||||||
@Override
|
|
||||||
public int size() { return LINKED_ENUM_MAP.this.size(); }
|
|
||||||
@Override
|
|
||||||
public void clear() { LINKED_ENUM_MAP.this.clear(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE reversed() { return new VALUE_ABSTRACT_COLLECTION.VALUE_REVERSED_ORDERED_COLLECTIONVALUE_BRACES(this, this::reverseIterator); }
|
|
||||||
private VALUE_ITERATOR VALUE_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new ValueIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
public VALUE_ITERATOR VALUE_GENERIC_TYPE iterator() {
|
||||||
@Override
|
return new ValueIterator();
|
||||||
public void addLast(VALUE_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_GET_FIRST_KEY() { return FIRST_ENTRY_VALUE(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE VALUE_REMOVE_FIRST_KEY() {
|
|
||||||
VALUE_TYPE result = FIRST_ENTRY_VALUE();
|
|
||||||
POLL_FIRST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_GET_LAST_KEY() { return LAST_ENTRY_VALUE(); }
|
public int size() {
|
||||||
@Override
|
return LINKED_ENUM_MAP.this.size();
|
||||||
public VALUE_TYPE VALUE_REMOVE_LAST_KEY() {
|
|
||||||
VALUE_TYPE result = LAST_ENTRY_VALUE();
|
|
||||||
POLL_LAST_ENTRY_KEY();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
LINKED_ENUM_MAP.this.clear();
|
||||||
|
}
|
||||||
|
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer VALUE_SUPER_GENERIC_TYPE action) {
|
public void forEach(Consumer VALUE_SUPER_GENERIC_TYPE action) {
|
||||||
@@ -799,7 +715,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry = new MapEntry();
|
MapEntry entry = new MapEntry();
|
||||||
|
|
||||||
public FastEntryIterator(boolean start) { super(start); }
|
public FastEntryIterator() {}
|
||||||
public FastEntryIterator(T from) {
|
public FastEntryIterator(T from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -826,7 +742,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class EntryIterator extends MapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
MapEntry entry;
|
MapEntry entry;
|
||||||
|
|
||||||
public EntryIterator(boolean start) { super(start); }
|
public EntryIterator() {}
|
||||||
public EntryIterator(T from) {
|
public EntryIterator(T from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -856,7 +772,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
|
|
||||||
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class KeyIterator extends MapIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
|
|
||||||
public KeyIterator(boolean start) { super(start); }
|
public KeyIterator() {}
|
||||||
public KeyIterator(T from) {
|
public KeyIterator(T from) {
|
||||||
super(from);
|
super(from);
|
||||||
}
|
}
|
||||||
@@ -878,7 +794,7 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
private class ValueIterator extends MapIterator implements VALUE_LIST_ITERATOR VALUE_GENERIC_TYPE {
|
||||||
public ValueIterator(boolean start) { super(start); }
|
public ValueIterator() {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE VALUE_PREVIOUS() {
|
public VALUE_TYPE VALUE_PREVIOUS() {
|
||||||
@@ -899,20 +815,16 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class MapIterator {
|
private class MapIterator {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
MapIterator(boolean start) {
|
MapIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapIterator(T from) {
|
MapIterator(T from) {
|
||||||
this.forward = true;
|
|
||||||
previous = from.ordinal() - 1;
|
previous = from.ordinal() - 1;
|
||||||
index = from.ordinal();
|
index = from.ordinal();
|
||||||
next = from.ordinal();
|
next = from.ordinal();
|
||||||
@@ -920,11 +832,11 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
@@ -959,30 +871,20 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
|
|
||||||
public int previousEntry() {
|
public int previousEntry() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
|
next = current;
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int nextEntry() {
|
public int nextEntry() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
next = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = next;
|
current = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
previous = current;
|
previous = current;
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
-1581
File diff suppressed because it is too large
Load Diff
-1572
File diff suppressed because it is too large
Load Diff
+28
-35
@@ -6,18 +6,15 @@ import java.util.Map;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -40,12 +37,9 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
|||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -79,7 +73,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@@ -1330,7 +1323,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1342,15 +1335,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2033,7 +2026,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2045,19 +2038,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2172,7 +2165,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2184,15 +2177,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2528,7 +2521,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2540,15 +2533,15 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2694,7 +2687,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2706,19 +2699,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+28
-35
@@ -6,18 +6,15 @@ import java.util.Map;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
#if !TYPE_OBJECT && JDK_TYPE
|
#if !TYPE_OBJECT && JDK_TYPE
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
#if !SAME_TYPE && JDK_VALUE && !VALUE_OBJECT
|
||||||
import java.util.function.VALUE_PREDICATE;
|
import java.util.function.VALUE_PREDICATE;
|
||||||
import java.util.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
@@ -39,12 +36,9 @@ import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
|||||||
#if !TYPE_INT || !SAME_TYPE
|
#if !TYPE_INT || !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !JDK_TYPE
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN && !JDK_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#if!VALUE_BOOLEAN
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.SINGLE_UNARY_OPERATOR;
|
||||||
@@ -78,7 +72,6 @@ import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_C
|
|||||||
#endif
|
#endif
|
||||||
#if !JDK_VALUE
|
#if !JDK_VALUE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@@ -1386,7 +1379,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(SINGLE_UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_KEY_VALUE;
|
KEY_TYPE state = EMPTY_KEY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1398,15 +1391,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
state = operator.APPLY_KEY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
return OPTIONAL.empty();
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2099,7 +2092,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2111,19 +2104,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2238,7 +2231,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2250,15 +2243,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(Node KEY_VALUE_GENERIC_TYPE entry = subLowest(), last = subHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2594,7 +2587,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
public VALUE_TYPE reduce(VALUE_SINGLE_UNARY_OPERATOR VALUE_VALUE_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
VALUE_TYPE state = EMPTY_VALUE;
|
VALUE_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2606,15 +2599,15 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.value);
|
state = operator.APPLY_VALUE(state, entry.value);
|
||||||
}
|
}
|
||||||
return empty ? VALUE_OPTIONAL.empty() : VALUE_OPTIONAL.GET_OPTIONAL_VALUE(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_OPTIONAL VALUE_GENERIC_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
public VALUE_TYPE findFirst(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
if(filter.test(entry.value)) return VALUE_OPTIONAL.GET_OPTIONAL_VALUE(entry.value);
|
if(filter.test(entry.value)) return entry.value;
|
||||||
return VALUE_OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2760,7 +2753,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE reduce(ObjectObjectUnaryOperator<MAP.Entry KEY_VALUE_GENERIC_TYPE, MAP.Entry KEY_VALUE_GENERIC_TYPE> operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
MAP.Entry KEY_VALUE_GENERIC_TYPE state = null;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -2772,19 +2765,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
state = operator.apply(state, new BasicEntryKV_BRACES(entry.key, entry.value));
|
||||||
}
|
}
|
||||||
return empty ? Optional.empty() : Optional.ofNullable(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<MAP.Entry KEY_VALUE_GENERIC_TYPE> findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE findFirst(Predicate<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return Optional.empty();
|
if(size() <= 0) return null;
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
||||||
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Node KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
subEntry.set(entry.key, entry.value);
|
subEntry.set(entry.key, entry.value);
|
||||||
if(filter.test(subEntry)) return Optional.ofNullable(subEntry);
|
if(filter.test(subEntry)) return subEntry;
|
||||||
}
|
}
|
||||||
return Optional.empty();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -154,7 +154,7 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the last present value or default return value.
|
* @return the last present value or default return value.
|
||||||
*/
|
*/
|
||||||
public default CLASS_VALUE_TYPE put(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) {
|
public default CLASS_VALUE_TYPE put(Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE> entry) {
|
||||||
return put(OBJ_TO_KEY(entry.getKey()), OBJ_TO_VALUE(entry.getValue()));
|
return put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
-68
@@ -1,15 +1,8 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.interfaces;
|
package speiger.src.collections.PACKAGE.maps.interfaces;
|
||||||
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.SequencedMap;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if MAPS_FEATURE
|
#if MAPS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
||||||
#endif
|
#endif
|
||||||
@@ -24,11 +17,7 @@ import speiger.src.collections.objects.sets.ObjectOrderedSet;
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @ValueType(V)
|
* @ValueType(V)
|
||||||
*/
|
*/
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERIC_TYPE, SequencedMap<CLASS_TYPE, CLASS_VALUE_TYPE>
|
|
||||||
#else
|
|
||||||
public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERIC_TYPE
|
public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERIC_TYPE
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A customized put method that allows you to insert into the first index.
|
* A customized put method that allows you to insert into the first index.
|
||||||
@@ -48,26 +37,6 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
*/
|
*/
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value);
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value);
|
||||||
|
|
||||||
/**
|
|
||||||
* A alternative to putAndMoveToFirst.
|
|
||||||
* This method simply puts an entry at the first spot of the Map but only if the entry is missing.
|
|
||||||
* @param key the key that should be inserted
|
|
||||||
* @param value the value that should be inserted
|
|
||||||
* @return the previous present or default return value
|
|
||||||
* @see java.util.Map#put(Object, Object)
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A alternative to putAndMoveToLast.
|
|
||||||
* This method simply puts an entry at the last spot of the Map but only if the entry is missing.
|
|
||||||
* @param key the key that should be inserted
|
|
||||||
* @param value the value that should be inserted
|
|
||||||
* @return the previous present or default return value
|
|
||||||
* @see java.util.Map#put(Object, Object)
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specific move method to move a given key/value to the first index.
|
* A specific move method to move a given key/value to the first index.
|
||||||
* @param key that should be moved to the first index
|
* @param key that should be moved to the first index
|
||||||
@@ -128,34 +97,13 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
*/
|
*/
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE();
|
public VALUE_TYPE LAST_ENTRY_VALUE();
|
||||||
|
|
||||||
@Java21
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry();
|
|
||||||
@Java21
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry();
|
|
||||||
@Java21
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry();
|
|
||||||
@Java21
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry();
|
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE keySet();
|
public ORDERED_SET KEY_GENERIC_TYPE keySet();
|
||||||
@Override
|
@Override
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values();
|
|
||||||
@Override
|
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET();
|
||||||
@Java21
|
|
||||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE reversed() { return new ABSTRACT_MAP.REVERSED_ORDERED_MAPKV_BRACES(this); }
|
|
||||||
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
@Override
|
|
||||||
default ORDERED_SET KEY_GENERIC_TYPE sequencedKeySet() { return keySet(); }
|
|
||||||
@Override
|
|
||||||
default VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE sequencedValues() { return values(); }
|
|
||||||
@Override
|
|
||||||
default ObjectOrderedSet<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>> sequencedEntrySet() { return (ObjectOrderedSet<Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>)(Object)ENTRY_SET(); }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if MAPS_FEATURE
|
#if MAPS_FEATURE
|
||||||
/**
|
/**
|
||||||
* Creates a Wrapped SortedMap that is Synchronized
|
* Creates a Wrapped SortedMap that is Synchronized
|
||||||
@@ -182,22 +130,6 @@ public interface ORDERED_MAP KEY_VALUE_GENERIC_TYPE extends MAP KEY_VALUE_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
public default ORDERED_MAP KEY_VALUE_GENERIC_TYPE unmodifiable() { return MAPS.unmodifiable(this); }
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
#if !SAME_TYPE || !TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public default CLASS_VALUE_TYPE putFirst(CLASS_TYPE k, CLASS_VALUE_TYPE v) {
|
|
||||||
return putFirst(OBJ_TO_KEY(k), OBJ_TO_VALUE(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public default CLASS_VALUE_TYPE putLast(CLASS_TYPE k, CLASS_VALUE_TYPE v) {
|
|
||||||
return putLast(OBJ_TO_KEY(k), OBJ_TO_VALUE(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
* Fast Ordered Entry Set that allows for a faster Entry Iterator by recycling the Entry Object and just exchanging 1 internal value
|
||||||
|
|||||||
+5
-60
@@ -7,26 +7,12 @@ 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_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
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 !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#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;
|
||||||
@@ -113,47 +99,6 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
this(MIN_CAPACITY);
|
this(MIN_CAPACITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ArrayFIFOQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, ARRAY_FIFO_QUEUE<T>, ARRAY_FIFO_QUEUE<T>> toQueue() {
|
|
||||||
return Collector.of(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayFIFOQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
|
||||||
return stream.collect(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ARRAY_FIFO_QUEUE<T> merge(ARRAY_FIFO_QUEUE<T> a) {
|
|
||||||
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayFIFOQueue
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static ARRAY_FIFO_QUEUE toQueue(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(ARRAY_FIFO_QUEUE::new, ARRAY_FIFO_QUEUE::enqueue, ARRAY_FIFO_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ARRAY_FIFO_QUEUE merge(ARRAY_FIFO_QUEUE a) {
|
|
||||||
enqueueAll(a.TO_ARRAY());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
@@ -373,17 +318,17 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
for(int i = 0,m=size();i<m;i++) {
|
||||||
int index = (first + i) % array.length;
|
int index = (first + i) % array.length;
|
||||||
if(filter.test(array[index])) {
|
if(filter.test(array[index])) {
|
||||||
KEY_TYPE data = array[index];
|
KEY_TYPE data = array[index];
|
||||||
removeIndex(index);
|
removeIndex(index);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -410,7 +355,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -422,7 +367,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
state = operator.APPLY_VALUE(state, array[(first + i) % array.length]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-59
@@ -8,26 +8,12 @@ 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_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#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 !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#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;
|
||||||
@@ -204,47 +190,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
queue.size = size;
|
queue.size = size;
|
||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ArrayPriorityQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, ARRAY_PRIORITY_QUEUE<T>, ARRAY_PRIORITY_QUEUE<T>> toQueue() {
|
|
||||||
return Collector.of(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayPriorityQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
|
||||||
return stream.collect(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ARRAY_PRIORITY_QUEUE<T> merge(ARRAY_PRIORITY_QUEUE<T> a) {
|
|
||||||
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayPriorityQueue
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static ARRAY_PRIORITY_QUEUE toQueue(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(ARRAY_PRIORITY_QUEUE::new, ARRAY_PRIORITY_QUEUE::enqueue, ARRAY_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ARRAY_PRIORITY_QUEUE merge(ARRAY_PRIORITY_QUEUE a) {
|
|
||||||
enqueueAll(a.TO_ARRAY());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@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));
|
||||||
@@ -400,7 +346,7 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -412,20 +358,20 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-60
@@ -8,26 +8,12 @@ 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_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#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 !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#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;
|
||||||
@@ -207,47 +193,6 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ArrayFIFOQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, HEAP_PRIORITY_QUEUE<T>, HEAP_PRIORITY_QUEUE<T>> toQueue() {
|
|
||||||
return Collector.of(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayFIFOQueue
|
|
||||||
* @Type(T)
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE toQueue(Stream<T> stream) {
|
|
||||||
return stream.collect(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HEAP_PRIORITY_QUEUE<T> merge(HEAP_PRIORITY_QUEUE<T> a) {
|
|
||||||
enqueueAll(a.toArray((T[])new Object[a.size()]));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArrayFIFOQueue
|
|
||||||
* @return a queue with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static HEAP_PRIORITY_QUEUE toQueue(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(HEAP_PRIORITY_QUEUE::new, HEAP_PRIORITY_QUEUE::enqueue, HEAP_PRIORITY_QUEUE::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HEAP_PRIORITY_QUEUE merge(HEAP_PRIORITY_QUEUE a) {
|
|
||||||
enqueueAll(a.TO_ARRAY());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return size;
|
return size;
|
||||||
@@ -381,7 +326,7 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -393,20 +338,20 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, array[i]);
|
state = operator.APPLY_VALUE(state, array[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(array[i])) {
|
if(filter.test(array[i])) {
|
||||||
KEY_TYPE data = array[i];
|
KEY_TYPE data = array[i];
|
||||||
removeIndex(i);
|
removeIndex(i);
|
||||||
return OPTIONAL.GET_OPTIONAL(data);
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+10
-58
@@ -10,15 +10,6 @@ import java.util.function.BiFunction;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -28,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -220,42 +208,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a AVLTreeSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, AVL_TREE_SET<T>, AVL_TREE_SET<T>> toSet() {
|
|
||||||
return Collector.of(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a AVLTreeSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> AVL_TREE_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
|
||||||
return stream.collect(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private AVL_TREE_SET<T> merge(AVL_TREE_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a AVLTreeSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static AVL_TREE_SET toSet(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(AVL_TREE_SET::new, AVL_TREE_SET::add, AVL_TREE_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||||
@@ -453,12 +405,12 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -485,7 +437,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -497,7 +449,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1362,7 +1314,7 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1374,16 +1326,16 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import java.util.Objects;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,105 +47,4 @@ public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ORDERED_SET_FEATURE
|
|
||||||
public static class REVERSED_ORDERED_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements ORDERED_SET KEY_GENERIC_TYPE {
|
|
||||||
protected ORDERED_SET KEY_GENERIC_TYPE set;
|
|
||||||
|
|
||||||
public REVERSED_ORDERED_SET(ORDERED_SET KEY_GENERIC_TYPE set) {
|
|
||||||
this.set = set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public REVERSED_ORDERED_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) {
|
|
||||||
return set.iterator(fromElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
|
||||||
return set.reverseIterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return set.iterator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) {
|
|
||||||
set.addLast(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) {
|
|
||||||
set.addFirst(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
public boolean remove(KEY_TYPE o) {
|
|
||||||
#else
|
|
||||||
public boolean remove(Object o) {
|
|
||||||
#endif
|
|
||||||
return set.remove(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean add(KEY_TYPE o) {
|
|
||||||
return set.add(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
|
||||||
return set.addAndMoveToLast(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAndMoveToLast(KEY_TYPE o) {
|
|
||||||
return set.addAndMoveToFirst(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean moveToFirst(KEY_TYPE o) {
|
|
||||||
return set.moveToLast(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean moveToLast(KEY_TYPE o) {
|
|
||||||
return set.moveToFirst(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
|
||||||
return set.GET_LAST_KEY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
|
||||||
return set.REMOVE_LAST_KEY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
|
||||||
return set.GET_FIRST_KEY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
|
||||||
return set.REMOVE_FIRST_KEY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE reversed() {
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return set.size();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-135
@@ -8,15 +8,6 @@ import java.util.function.BiFunction;
|
|||||||
#endif
|
#endif
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
@@ -27,9 +18,7 @@ import java.util.function.JAVA_PREDICATE;
|
|||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -80,7 +69,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
* @param array the array that should be used for set.
|
* @param array the array that should be used for set.
|
||||||
*/
|
*/
|
||||||
public ARRAY_SET(KEY_TYPE[] array) {
|
public ARRAY_SET(KEY_TYPE[] array) {
|
||||||
this(array, 0, array.length);
|
this(array, array.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -94,18 +83,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
addAll(array, length);
|
addAll(array, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructur using initial Array
|
|
||||||
* @param array the array that should be used for set.
|
|
||||||
* @param offset the starting offset of where the array should be copied from
|
|
||||||
* @param length the amount of elements present within the array
|
|
||||||
* @throws NegativeArraySizeException if the length is negative
|
|
||||||
*/
|
|
||||||
public ARRAY_SET(KEY_TYPE[] array, int offset, int length) {
|
|
||||||
this(length);
|
|
||||||
addAll(array, offset, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
* A Helper constructor that allows to create a Set with exactly the same values as the provided collection.
|
||||||
* @param c the elements that should be added to the set.
|
* @param c the elements that should be added to the set.
|
||||||
@@ -149,42 +126,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
for(ITERATOR KEY_GENERIC_TYPE iter = s.iterator();iter.hasNext();data[size++] = iter.NEXT());
|
for(ITERATOR KEY_GENERIC_TYPE iter = s.iterator();iter.hasNext();data[size++] = iter.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a ArraySet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, ARRAY_SET<T>, ARRAY_SET<T>> toList() {
|
|
||||||
return Collector.of(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArraySet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> ARRAY_SET KEY_GENERIC_TYPE toList(Stream<T> stream) {
|
|
||||||
return stream.collect(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ARRAY_SET<T> merge(ARRAY_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a ArraySet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static ARRAY_SET toList(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(ARRAY_SET::new, ARRAY_SET::add, ARRAY_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) {
|
public boolean add(KEY_TYPE o) {
|
||||||
int index = findIndex(o);
|
int index = findIndex(o);
|
||||||
@@ -207,25 +148,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) {
|
|
||||||
int index = findIndex(o);
|
|
||||||
if(index == -1) {
|
|
||||||
if(data.length == size) data = Arrays.copyOf(data, size == 0 ? 2 : size * 2);
|
|
||||||
System.arraycopy(data, 0, data, 1, size++);
|
|
||||||
data[0] = o;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) {
|
|
||||||
int index = findIndex(o);
|
|
||||||
if(index == -1) {
|
|
||||||
if(data.length == size) data = Arrays.copyOf(data, size == 0 ? 2 : size * 2);
|
|
||||||
data[size++] = o;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
||||||
int index = findIndex(o);
|
int index = findIndex(o);
|
||||||
@@ -297,13 +219,13 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return data[size - 1];
|
return data[size - 1];
|
||||||
}
|
}
|
||||||
@@ -432,7 +354,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
KEY_TYPE result = data[0];
|
KEY_TYPE result = data[0];
|
||||||
System.arraycopy(data, 1, data, 0, --size);
|
System.arraycopy(data, 1, data, 0, --size);
|
||||||
@@ -443,7 +365,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
size--;
|
size--;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -516,12 +438,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
if(filter.test(data[i])) return OPTIONAL.GET_OPTIONAL(data[i]);
|
if(filter.test(data[i])) return data[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -548,7 +470,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -560,7 +482,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, data[i]);
|
state = operator.APPLY_VALUE(state, data[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -589,18 +511,13 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator(true, 0);
|
return new SetIterator(0);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new SetIterator(false, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) {
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) {
|
||||||
int index = findIndex(fromElement);
|
int index = findIndex(fromElement);
|
||||||
if(index != -1) return new SetIterator(true, index);
|
if(index != -1) return new SetIterator(index);
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,57 +570,45 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
boolean forward;
|
|
||||||
int index;
|
int index;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
|
|
||||||
public SetIterator(boolean forward, int index) {
|
public SetIterator(int index) {
|
||||||
this.forward = forward;
|
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return forward ? index < size() : index > 0;
|
return index < size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) {
|
|
||||||
lastReturned = index;
|
|
||||||
return data[index++];
|
|
||||||
}
|
|
||||||
index--;
|
|
||||||
return data[(lastReturned = index)];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPrevious() {
|
|
||||||
return forward ? index > 0 : index < size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE PREVIOUS() {
|
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
|
||||||
if(forward) {
|
|
||||||
index--;
|
|
||||||
return data[(lastReturned = index)];
|
|
||||||
}
|
|
||||||
lastReturned = index;
|
lastReturned = index;
|
||||||
return data[index++];
|
return data[index++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPrevious() {
|
||||||
|
return index > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public KEY_TYPE PREVIOUS() {
|
||||||
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
|
--index;
|
||||||
|
return data[(lastReturned = index)];
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
if(forward) return index;
|
return index;
|
||||||
return size - index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
if(forward) return index-1;
|
return index-1;
|
||||||
return (size - index)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -732,23 +637,15 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
return forward ? moveForward(amount) : moveBackwards(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
|
||||||
return forward ? moveBackwards(amount) : moveForward(amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int moveForward(int amount) {
|
|
||||||
int steps = Math.min(amount, size() - index);
|
int steps = Math.min(amount, size() - index);
|
||||||
index += steps;
|
index += steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
if(steps > 0) lastReturned = Math.min(index-1, size()-1);
|
||||||
return steps;
|
return steps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int moveBackwards(int amount) {
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
|
if(amount < 0) throw new IllegalStateException("Negative Numbers are not allowed");
|
||||||
int steps = Math.min(amount, index);
|
int steps = Math.min(amount, index);
|
||||||
index -= steps;
|
index -= steps;
|
||||||
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
if(steps > 0) lastReturned = Math.min(index, size()-1);
|
||||||
|
|||||||
+25
-66
@@ -9,9 +9,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -22,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -264,10 +258,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) { throw new UnsupportedOperationException(); }
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@@ -295,22 +285,22 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[firstIndex];
|
return keys[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[lastIndex];
|
return keys[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
|
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -424,7 +414,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -437,18 +427,18 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -465,12 +455,7 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator(true);
|
return new SetIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new SetIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -536,20 +521,16 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = -1;
|
int index = 0;
|
||||||
|
|
||||||
SetIterator(boolean start) {
|
SetIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
this.forward = true;
|
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
@@ -578,60 +559,48 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
int result = forward ? moveForward(amount) : moveBackwards(amount);
|
|
||||||
if(index >= 0) index+=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
int result = forward ? moveBackwards(amount) : moveForward(amount);
|
|
||||||
if(index >= 0) index-=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int moveForward(int amount) {
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(next != -1 && result != amount) {
|
while(next != -1 && result != amount) {
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int moveBackwards(int amount) {
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(previous != -1 && result != amount) {
|
while(previous != -1 && result != amount) {
|
||||||
current = next = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index;
|
return index;
|
||||||
return size - index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index-1;
|
return index - 1;
|
||||||
return (size - index)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -640,8 +609,8 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = next = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -649,20 +618,10 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return keys[current];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = next = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+27
-146
@@ -9,15 +9,6 @@ import java.util.Objects;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -27,9 +18,6 @@ import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
@@ -247,82 +235,6 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a LinkedCustomHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, LINKED_CUSTOM_HASH_SET<T>, LINKED_CUSTOM_HASH_SET<T>> toLinkedSet(STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return Collector.of(() -> new LINKED_CUSTOM_HASH_SET<>(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedCustomHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE toLinkedSet(Stream<T> stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return stream.collect(() -> new LINKED_CUSTOM_HASH_SET<>(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LINKED_CUSTOM_HASH_SET<T> merge(LINKED_CUSTOM_HASH_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedCustomHashSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static LINKED_CUSTOM_HASH_SET toList(JAVA_STREAM stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return stream.collect(() -> new LINKED_CUSTOM_HASH_SET(strategy), LINKED_CUSTOM_HASH_SET::add, LINKED_CUSTOM_HASH_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) {
|
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
|
||||||
if(containsNull) return;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToFirstIndex(nullIndex);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(strategy.hashCode(o)) & mask;
|
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
|
||||||
if(strategy.equals(keys[pos], o)) return;
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = o;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToFirstIndex(pos);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) {
|
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
|
||||||
if(containsNull) return;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(strategy.hashCode(o)) & mask;
|
|
||||||
while(!strategy.equals(keys[pos], EMPTY_KEY_VALUE)) {
|
|
||||||
if(strategy.equals(keys[pos], o)) return;
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = o;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
||||||
@@ -379,7 +291,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE o) {
|
public boolean moveToFirst(KEY_TYPE o) {
|
||||||
if(isEmpty() || strategy.equals(GET_FIRST_KEY(), o)) return false;
|
if(isEmpty() || strategy.equals(FIRST_KEY(), o)) return false;
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -401,7 +313,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE o) {
|
public boolean moveToLast(KEY_TYPE o) {
|
||||||
if(isEmpty() || strategy.equals(GET_LAST_KEY(), o)) return false;
|
if(isEmpty() || strategy.equals(LAST_KEY(), o)) return false;
|
||||||
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(o, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -458,13 +370,13 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[firstIndex];
|
return keys[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
onNodeRemoved(pos);
|
onNodeRemoved(pos);
|
||||||
@@ -480,13 +392,13 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[lastIndex];
|
return keys[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
onNodeRemoved(pos);
|
onNodeRemoved(pos);
|
||||||
@@ -744,7 +656,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -757,18 +669,18 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -785,12 +697,7 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator(true);
|
return new SetIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new SetIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -815,20 +722,16 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = -1;
|
int index = 0;
|
||||||
|
|
||||||
SetIterator(boolean start) {
|
SetIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
this.forward = true;
|
|
||||||
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
if(strategy.equals(from, EMPTY_KEY_VALUE)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
@@ -857,60 +760,48 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
int result = forward ? moveForward(amount) : moveBackwards(amount);
|
|
||||||
if(index >= 0) index+=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
int result = forward ? moveBackwards(amount) : moveForward(amount);
|
|
||||||
if(index >= 0) index-=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int moveForward(int amount) {
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(next != -1 && result != amount) {
|
while(next != -1 && result != amount) {
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int moveBackwards(int amount) {
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(previous != -1 && result != amount) {
|
while(previous != -1 && result != amount) {
|
||||||
current = next = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index;
|
return index;
|
||||||
return size - index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index-1;
|
return index - 1;
|
||||||
return (size - index)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -959,8 +850,8 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = next = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -968,20 +859,10 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return keys[current];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = next = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+27
-146
@@ -5,15 +5,6 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@@ -30,9 +21,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -218,82 +206,6 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a LinkedHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, LINKED_HASH_SET<T>, LINKED_HASH_SET<T>> toLinkedSet() {
|
|
||||||
return Collector.of(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> LINKED_HASH_SET KEY_GENERIC_TYPE toLinkedSet(Stream<T> stream) {
|
|
||||||
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private LINKED_HASH_SET<T> merge(LINKED_HASH_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a LinkedHashSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static LINKED_HASH_SET toLinkedSet(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(LINKED_HASH_SET::new, LINKED_HASH_SET::add, LINKED_HASH_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) {
|
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
|
||||||
if(containsNull) return;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
moveToFirstIndex(nullIndex);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
|
||||||
if(KEY_EQUALS(keys[pos], o)) return;
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = o;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
moveToFirstIndex(pos);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) {
|
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
|
||||||
if(containsNull) return;
|
|
||||||
containsNull = true;
|
|
||||||
onNodeAdded(nullIndex);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int pos = HashUtil.mix(KEY_TO_HASH(o)) & mask;
|
|
||||||
while(KEY_EQUALS_NOT_NULL(keys[pos])) {
|
|
||||||
if(KEY_EQUALS(keys[pos], o)) return;
|
|
||||||
pos = ++pos & mask;
|
|
||||||
}
|
|
||||||
keys[pos] = o;
|
|
||||||
onNodeAdded(pos);
|
|
||||||
}
|
|
||||||
if(size++ >= maxFill) rehash(HashUtil.arraySize(size+1, loadFactor));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
public boolean addAndMoveToFirst(KEY_TYPE o) {
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
@@ -350,7 +262,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToFirst(KEY_TYPE o) {
|
public boolean moveToFirst(KEY_TYPE o) {
|
||||||
if(isEmpty() || KEY_EQUALS(GET_FIRST_KEY(), o)) return false;
|
if(isEmpty() || KEY_EQUALS(FIRST_KEY(), o)) return false;
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToFirstIndex(nullIndex);
|
moveToFirstIndex(nullIndex);
|
||||||
@@ -372,7 +284,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE o) {
|
public boolean moveToLast(KEY_TYPE o) {
|
||||||
if(isEmpty() || KEY_EQUALS(GET_LAST_KEY(), o)) return false;
|
if(isEmpty() || KEY_EQUALS(LAST_KEY(), o)) return false;
|
||||||
if(KEY_EQUALS_NULL(o)) {
|
if(KEY_EQUALS_NULL(o)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
moveToLastIndex(nullIndex);
|
moveToLastIndex(nullIndex);
|
||||||
@@ -429,13 +341,13 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[firstIndex];
|
return keys[firstIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = firstIndex;
|
int pos = firstIndex;
|
||||||
onNodeRemoved(pos);
|
onNodeRemoved(pos);
|
||||||
@@ -451,13 +363,13 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() {
|
public KEY_TYPE LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
return keys[lastIndex];
|
return keys[lastIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() {
|
public KEY_TYPE POLL_LAST_KEY() {
|
||||||
if(size == 0) throw new NoSuchElementException();
|
if(size == 0) throw new NoSuchElementException();
|
||||||
int pos = lastIndex;
|
int pos = lastIndex;
|
||||||
onNodeRemoved(pos);
|
onNodeRemoved(pos);
|
||||||
@@ -599,7 +511,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -612,18 +524,18 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
else state = operator.APPLY_VALUE(state, keys[index]);
|
else state = operator.APPLY_VALUE(state, keys[index]);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.test(keys[index])) return OPTIONAL.GET_OPTIONAL(keys[index]);
|
if(filter.test(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -756,12 +668,7 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator(true);
|
return new SetIterator();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE reverseIterator() {
|
|
||||||
return new SetIterator(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -786,20 +693,16 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE {
|
||||||
boolean forward;
|
|
||||||
int previous = -1;
|
int previous = -1;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
int current = -1;
|
int current = -1;
|
||||||
int index = -1;
|
int index = 0;
|
||||||
|
|
||||||
SetIterator(boolean start) {
|
SetIterator() {
|
||||||
this.forward = start;
|
next = firstIndex;
|
||||||
if(start) next = firstIndex;
|
|
||||||
else previous = lastIndex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetIterator(KEY_TYPE from) {
|
SetIterator(KEY_TYPE from) {
|
||||||
this.forward = true;
|
|
||||||
if(KEY_EQUALS_NULL(from)) {
|
if(KEY_EQUALS_NULL(from)) {
|
||||||
if(containsNull) {
|
if(containsNull) {
|
||||||
next = (int) links[nullIndex];
|
next = (int) links[nullIndex];
|
||||||
@@ -828,60 +731,48 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int skip(int amount) {
|
public int skip(int amount) {
|
||||||
int result = forward ? moveForward(amount) : moveBackwards(amount);
|
|
||||||
if(index >= 0) index+=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int back(int amount) {
|
|
||||||
int result = forward ? moveBackwards(amount) : moveForward(amount);
|
|
||||||
if(index >= 0) index-=result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int moveForward(int amount) {
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(next != -1 && result != amount) {
|
while(next != -1 && result != amount) {
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index+=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int moveBackwards(int amount) {
|
@Override
|
||||||
|
public int back(int amount) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
while(previous != -1 && result != amount) {
|
while(previous != -1 && result != amount) {
|
||||||
current = next = previous;
|
current = next = previous;
|
||||||
previous = (int)(links[current] >> 32);
|
previous = (int)(links[current] >> 32);
|
||||||
result++;
|
result++;
|
||||||
}
|
}
|
||||||
|
if(index >= 0) index-=result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return (forward ? next : previous) != -1;
|
return next != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPrevious() {
|
public boolean hasPrevious() {
|
||||||
return (forward ? previous : next) != -1;
|
return previous != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int nextIndex() {
|
public int nextIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index;
|
return index;
|
||||||
return size - index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
ensureIndexKnown();
|
ensureIndexKnown();
|
||||||
if(forward) return index-1;
|
return index - 1;
|
||||||
return (size - index)-1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -930,8 +821,8 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE PREVIOUS() {
|
public KEY_TYPE PREVIOUS() {
|
||||||
if(!hasPrevious()) throw new NoSuchElementException();
|
if(!hasPrevious()) throw new NoSuchElementException();
|
||||||
if(forward) moveBackwards();
|
current = next = previous;
|
||||||
else moveForwards();
|
previous = (int)(links[current] >> 32);
|
||||||
if(index >= 0) index--;
|
if(index >= 0) index--;
|
||||||
return keys[current];
|
return keys[current];
|
||||||
}
|
}
|
||||||
@@ -939,20 +830,10 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE NEXT() {
|
public KEY_TYPE NEXT() {
|
||||||
if(!hasNext()) throw new NoSuchElementException();
|
if(!hasNext()) throw new NoSuchElementException();
|
||||||
if(forward) moveForwards();
|
|
||||||
else moveBackwards();
|
|
||||||
if(index >= 0) index++;
|
|
||||||
return keys[current];
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveBackwards() {
|
|
||||||
current = next = previous;
|
|
||||||
previous = (int)(links[current] >> 32);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveForwards() {
|
|
||||||
current = previous = next;
|
current = previous = next;
|
||||||
next = (int)(links[current]);
|
next = (int)(links[current]);
|
||||||
|
if(index >= 0) index++;
|
||||||
|
return keys[current];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ensureIndexKnown() {
|
private void ensureIndexKnown() {
|
||||||
|
|||||||
+7
-55
@@ -6,15 +6,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@@ -25,9 +16,6 @@ import java.util.function.PREDICATE;
|
|||||||
|
|
||||||
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 !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -263,42 +251,6 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a CustomHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, CUSTOM_HASH_SET<T>, CUSTOM_HASH_SET<T>> toSet(STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return Collector.of(() -> new CUSTOM_HASH_SET<>(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a CustomHashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> CUSTOM_HASH_SET KEY_GENERIC_TYPE toSet(Stream<T> stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return stream.collect(() -> new CUSTOM_HASH_SET<>(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CUSTOM_HASH_SET<T> merge(CUSTOM_HASH_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a CustomHashSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static CUSTOM_HASH_SET toSet(JAVA_STREAM stream, STRATEGY KEY_SUPER_GENERIC_TYPE strategy) {
|
|
||||||
return stream.collect(() -> new CUSTOM_HASH_SET(strategy), CUSTOM_HASH_SET::add, CUSTOM_HASH_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
/**
|
/**
|
||||||
* Helper getter function to get the current strategy
|
* Helper getter function to get the current strategy
|
||||||
@@ -683,7 +635,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -700,18 +652,18 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, keys[i]);
|
state = operator.APPLY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+7
-55
@@ -6,15 +6,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@@ -29,9 +20,6 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -230,42 +218,6 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a HashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, HASH_SET<T>, HASH_SET<T>> toSet() {
|
|
||||||
return Collector.of(HASH_SET::new, HASH_SET::add, HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a HashSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> HASH_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
|
||||||
return stream.collect(HASH_SET::new, HASH_SET::add, HASH_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HASH_SET<T> merge(HASH_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a HashSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static HASH_SET toSet(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(HASH_SET::new, HASH_SET::add, HASH_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean add(KEY_TYPE o) {
|
public boolean add(KEY_TYPE o) {
|
||||||
@@ -546,7 +498,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -563,18 +515,18 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, keys[i]);
|
state = operator.APPLY_VALUE(state, keys[i]);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
if(size() <= 0) return OPTIONAL.empty();
|
if(size() <= 0) return EMPTY_VALUE;
|
||||||
if(containsNull && filter.test(keys[nullIndex])) return OPTIONAL.GET_OPTIONAL(keys[nullIndex]);
|
if(containsNull && filter.test(keys[nullIndex])) return keys[nullIndex];
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return OPTIONAL.GET_OPTIONAL(keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.test(keys[i])) return keys[i];
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-69
@@ -1,16 +1,10 @@
|
|||||||
package speiger.src.collections.PACKAGE.sets;
|
package speiger.src.collections.PACKAGE.sets;
|
||||||
|
|
||||||
#if JAVA_VERSION>=21
|
|
||||||
import java.util.SequencedSet;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.ORDERED_COLLECTION;
|
|
||||||
#if SPLIT_ITERATOR_FEATURE
|
#if SPLIT_ITERATOR_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.SPLIT_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.sets.ABSTRACT_SET.REVERSED_ORDERED_SET;
|
|
||||||
#if SETS_FEATURE
|
#if SETS_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
#endif
|
#endif
|
||||||
@@ -23,11 +17,7 @@ import speiger.src.collections.PACKAGE.utils.SETS;
|
|||||||
*
|
*
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
#if JAVA_VERSION>=21
|
public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE
|
||||||
public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, ORDERED_COLLECTION KEY_GENERIC_TYPE, SequencedSet<CLASS_TYPE>
|
|
||||||
#else
|
|
||||||
public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, ORDERED_COLLECTION KEY_GENERIC_TYPE
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* A customized add method that allows you to insert into the first index.
|
* A customized add method that allows you to insert into the first index.
|
||||||
@@ -64,7 +54,6 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, ORDE
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE reverseIterator();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A type Specific Iterator starting from a given key
|
* A type Specific Iterator starting from a given key
|
||||||
@@ -87,75 +76,22 @@ public interface ORDERED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, ORDE
|
|||||||
* 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
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_FIRST_KEY();
|
public KEY_TYPE FIRST_KEY();
|
||||||
/**
|
/**
|
||||||
* A method to get and remove the first element in the set
|
* A method to get and remove the first element in the set
|
||||||
* @return first element in the set
|
* @return first element in the set
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY();
|
public KEY_TYPE POLL_FIRST_KEY();
|
||||||
/**
|
/**
|
||||||
* A method to get the last element in the set
|
* A method to get the last element in the set
|
||||||
* @return last element in the set
|
* @return last element in the set
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE GET_LAST_KEY();
|
public KEY_TYPE LAST_KEY();
|
||||||
/**
|
/**
|
||||||
* A method to get and remove the last element in the set
|
* A method to get and remove the last element in the set
|
||||||
* @return last element in the set
|
* @return last element in the set
|
||||||
*/
|
*/
|
||||||
public KEY_TYPE REMOVE_LAST_KEY();
|
public KEY_TYPE POLL_LAST_KEY();
|
||||||
|
|
||||||
#if JAVA_VERSION>=21 && !TYPE_OBJECT
|
|
||||||
/** {@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 addFirst(CLASS_TYPE e) { addAndMoveToFirst(OBJ_TO_KEY(e)); }
|
|
||||||
|
|
||||||
/** {@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 addLast(CLASS_TYPE e) { addAndMoveToLast(OBJ_TO_KEY(e)); }
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getFirst() { return GET_FIRST_KEY(); }
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE getLast() { return GET_LAST_KEY(); }
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeFirst() { return REMOVE_FIRST_KEY(); }
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
default CLASS_TYPE removeLast() { return REMOVE_LAST_KEY(); }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Java21
|
|
||||||
public default ORDERED_SET KEY_GENERIC_TYPE reversed() { return new REVERSED_ORDERED_SETBRACES(this); }
|
|
||||||
|
|
||||||
#if SETS_FEATURE
|
#if SETS_FEATURE
|
||||||
/**
|
/**
|
||||||
|
|||||||
+10
-58
@@ -2,15 +2,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import java.util.stream.JAVA_STREAM;
|
|
||||||
#else
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collector;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -28,9 +19,6 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#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
|
||||||
@@ -220,42 +208,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
while(iterator.hasNext()) add(iterator.NEXT());
|
while(iterator.hasNext()) add(iterator.NEXT());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if JDK_TYPE && SPLIT_ITERATOR_FEATURE && STREAM_FEATURE
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Creates a Collector for a RBTreeSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a collector
|
|
||||||
*/
|
|
||||||
public static <T> Collector<T, RB_TREE_SET<T>, RB_TREE_SET<T>> toSet() {
|
|
||||||
return Collector.of(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a RBTreeSet
|
|
||||||
* @Type(T)
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static <T> RB_TREE_SET KEY_GENERIC_TYPE toSet(Stream<T> stream) {
|
|
||||||
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RB_TREE_SET<T> merge(RB_TREE_SET<T> a) {
|
|
||||||
addAll(a);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/**
|
|
||||||
* Collects a Stream to a RBTreeSet
|
|
||||||
* @return a set with the contents of the Stream
|
|
||||||
*/
|
|
||||||
public static RB_TREE_SET toSet(JAVA_STREAM stream) {
|
|
||||||
return stream.collect(RB_TREE_SET::new, RB_TREE_SET::add, RB_TREE_SET::addAll);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||||
@@ -475,7 +427,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -487,16 +439,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1422,7 +1374,7 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
Objects.requireNonNull(operator);
|
Objects.requireNonNull(operator);
|
||||||
KEY_TYPE state = EMPTY_VALUE;
|
KEY_TYPE state = EMPTY_VALUE;
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
@@ -1434,16 +1386,16 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
state = operator.APPLY_VALUE(state, entry.key);
|
state = operator.APPLY_VALUE(state, entry.key);
|
||||||
}
|
}
|
||||||
return empty ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(state);
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
Objects.requireNonNull(filter);
|
Objects.requireNonNull(filter);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
||||||
if(filter.test(entry.key)) return OPTIONAL.GET_OPTIONAL(entry.key);
|
if(filter.test(entry.key)) return entry.key;
|
||||||
}
|
}
|
||||||
return OPTIONAL.empty();
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import java.util.function.IntFunction;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
import speiger.src.collections.utils.Swapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Arrays
|
* A Helper class for Arrays
|
||||||
@@ -338,69 +337,6 @@ public class ARRAYS
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Shuffle method for Arrays.
|
|
||||||
* With a Callback for indirect shuffling
|
|
||||||
* @param array the elements that should be shuffled
|
|
||||||
* @param swapper the callback on the swaps
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @note This uses the SanityChecks#getRandom
|
|
||||||
* @return the provided sorted array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectShuffle(KEY_TYPE[] array, Swapper swapper) {
|
|
||||||
return indirectShuffle(array, SanityChecks.getRandom(), swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Shuffle method for Arrays.
|
|
||||||
* With a Callback for indirect shuffling
|
|
||||||
* @param array the elements that should be shuffled
|
|
||||||
* @param random the Random Number Generator that should be used for the shuffling
|
|
||||||
* @param swapper the callback on the swaps
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return the provided sorted array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectShuffle(KEY_TYPE[] array, RANDOM random, Swapper swapper) {
|
|
||||||
return indirectShuffle(array, 0, array.length, random, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Shuffle method for Arrays.
|
|
||||||
* With a Callback for indirect shuffling
|
|
||||||
* @param array the elements that should be shuffled
|
|
||||||
* @param length the length of the array
|
|
||||||
* @param random the Random Number Generator that should be used for the shuffling
|
|
||||||
* @param swapper the callback on the swaps
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return the provided sorted array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectShuffle(KEY_TYPE[] array, int length, RANDOM random, Swapper swapper) {
|
|
||||||
return indirectShuffle(array, 0, length, random, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple Shuffle method for Arrays.
|
|
||||||
* With a Callback for indirect shuffling
|
|
||||||
* @param array the elements that should be shuffled
|
|
||||||
* @param offset the start array
|
|
||||||
* @param length the length of the array
|
|
||||||
* @param random the Random Number Generator that should be used for the shuffling
|
|
||||||
* @param swapper the callback on the swaps
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return the provided sorted array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectShuffle(KEY_TYPE[] array, int offset, int length, RANDOM random, Swapper swapper) {
|
|
||||||
for(int i = length-1; i>=0;i--) {
|
|
||||||
int j = offset + i;
|
|
||||||
int p = offset + random.nextInt(i + 1);
|
|
||||||
swapper.swap(j, p);
|
|
||||||
KEY_TYPE t = array[j];
|
|
||||||
array[j] = array[p];
|
|
||||||
array[p] = t;
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple Array Reversal method
|
* Simple Array Reversal method
|
||||||
* @param array the Array that should flip
|
* @param array the Array that should flip
|
||||||
@@ -639,55 +575,6 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Insertion Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return input array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectInsertionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectInsertionSort(array, 0, array.length, comp, swapper);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Insertion Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectInsertionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectInsertionSort(array, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Insertion Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectInsertionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
for (int i = from+1;i<to; i++) {
|
|
||||||
KEY_TYPE current = array[i];
|
|
||||||
int j = i - 1;
|
|
||||||
while(j >= from && comp.compare(current, array[j]) < 0) {
|
|
||||||
swapper.swap(j+1, j);
|
|
||||||
array[j+1] = array[j--];
|
|
||||||
}
|
|
||||||
array[j+1] = current;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using InsertionSort,
|
* Sorts an array according to the natural ascending order using InsertionSort,
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
@@ -774,60 +661,6 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Selection Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return input array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectSelectionSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectSelectionSort(array, 0, array.length, comp, swapper);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Selection Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectSelectionSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectSelectionSort(array, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Selection Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectSelectionSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
for (int i = from; i < to; i++) {
|
|
||||||
KEY_TYPE min = array[i];
|
|
||||||
int minId = i;
|
|
||||||
for(int j = i+1; j < to; j++) {
|
|
||||||
if(comp.compare(array[j], min) < 0) {
|
|
||||||
min = array[j];
|
|
||||||
minId = j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
swapper.swap(i, minId);
|
|
||||||
KEY_TYPE temp = array[i];
|
|
||||||
array[i] = min;
|
|
||||||
array[minId] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using Selection Sort,
|
* Sorts an array according to the natural ascending order using Selection Sort,
|
||||||
* @param array the array that needs to be sorted
|
* @param array the array that needs to be sorted
|
||||||
@@ -927,72 +760,6 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return input array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectMergeSort(array, null, 0, array.length, comp, swapper);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectMergeSort(array, null, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param supp the auxillary array that is used to simplify the sorting
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
if(to - from < BASE_THRESHOLD) {
|
|
||||||
indirectInsertionSort(array, from, to, comp, swapper);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
|
||||||
int mid = (from + to) >>> 1;
|
|
||||||
indirectMergeSort(supp, array, from, mid, comp, swapper);
|
|
||||||
indirectMergeSort(supp, array, mid, to, comp, swapper);
|
|
||||||
if(comp.compare(supp[mid - 1], supp[mid]) <= 0)
|
|
||||||
{
|
|
||||||
System.arraycopy(supp, from, array, from, to - from);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(int p = from, q = mid;from < to;from++) {
|
|
||||||
if(q >= to || p < mid && comp.compare(supp[p], supp[q]) < 0) {
|
|
||||||
swapper.swap(from, p);
|
|
||||||
array[from] = supp[p++];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
swapper.swap(from, q);
|
|
||||||
array[from] = supp[q++];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using Merge Sort,
|
* Sorts an array according to the natural ascending order using Merge Sort,
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
||||||
@@ -1089,56 +856,6 @@ public class ARRAYS
|
|||||||
mergeSort(array, supp, from, to, comp);
|
mergeSort(array, supp, from, to, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using a Parallel Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelMergeSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectParallelMergeSort(array, null, 0, array.length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Parallel Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelMergeSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectParallelMergeSort(array, null, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Parallel Merge Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param supp the auxillary array that is used to simplify the sorting
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelMergeSort(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) {
|
|
||||||
SanityChecks.invokeTask(new MergeSortActionCompSwapBRACES(array, supp, from, to, comp, swapper));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
indirectMergeSort(array, supp, from, to, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using Parallel Merge Sort,
|
* Sorts an array according to the natural ascending order using Parallel Merge Sort,
|
||||||
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
* This implementation was copied from <a href="https://github.com/vigna/fastutil">FastUtil</a> with a couple custom optimizations
|
||||||
@@ -1492,73 +1209,6 @@ public class ARRAYS
|
|||||||
if((length = d - c) > 1) quickSort(array, to - length, to, comp);
|
if((length = d - c) > 1) quickSort(array, to - length, to, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @return input array
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES KEY_TYPE[] indirectQuickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectQuickSort(array, 0, array.length, comp, swapper);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectQuickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectQuickSort(array, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectQuickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
int length = to - from;
|
|
||||||
if(length <= 0) return;
|
|
||||||
if(length < BASE_THRESHOLD) {
|
|
||||||
indirectSelectionSort(array, from, to, comp, swapper);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
KEY_TYPE pivot = array[length > 128 ? subMedium(array, from, from + (length / 2), to - 1, length / 8, comp) : medium(array, from, from + (length / 2), to - 1, comp)];
|
|
||||||
int a = from, b = a, c = to - 1, d = c;
|
|
||||||
for(int compare;;swap(array, b++, c--, swapper)) {
|
|
||||||
for(;b<=c && (compare = comp.compare(array[b], pivot)) <= 0;b++) {
|
|
||||||
if(compare == 0) swap(array, a++, b, swapper);
|
|
||||||
}
|
|
||||||
for(;c>=b && (compare = comp.compare(array[c], pivot)) >= 0;c--) {
|
|
||||||
if(compare == 0) swap(array, c, d--, swapper);
|
|
||||||
}
|
|
||||||
if(b>c) break;
|
|
||||||
}
|
|
||||||
swap(array, from, b, Math.min(a - from, b - a), swapper);
|
|
||||||
swap(array, b, to, Math.min(d - c, to - d - 1), swapper);
|
|
||||||
if((length = b - a) > 1) indirectQuickSort(array, from, from + length, comp, swapper);
|
|
||||||
if((length = d - c) > 1) indirectQuickSort(array, to - length, to, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using Quick Sort,
|
* Sorts an array according to the natural ascending order using Quick Sort,
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
||||||
@@ -1663,58 +1313,6 @@ public class ARRAYS
|
|||||||
quickSort(array, from, to, comp);
|
quickSort(array, from, to, comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Parallel Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelQuickSort(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectParallelQuickSort(array, 0, array.length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Parallel Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param length the maxmium size of the array to be sorted
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelQuickSort(KEY_TYPE[] array, int length, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
indirectParallelQuickSort(array, 0, length, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sorts the specified range of elements according to the order induced by the specified comparator using Parallel Quick Sort,
|
|
||||||
* On top of that allows to sort other things along with it.
|
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
|
||||||
* and that sorting Algorithm is based on the tuned quicksort adapted from Jon L. Bentley and M. DouglasMcIlroy, "Engineering a Sort Function", Software: Practice and Experience, 23(11), pages1249−1265, 1993.
|
|
||||||
* @param array the array that needs to be sorted
|
|
||||||
* @param from where the array should be sorted from
|
|
||||||
* @param to where the array should be sorted to
|
|
||||||
* @param comp the Comparator that decides the sorting order
|
|
||||||
* @param swapper the callback which elements were swapped
|
|
||||||
* @ArrayType(T)
|
|
||||||
* @note This parallelization is invoked through {@link SanityChecks#invokeTask} which the threadpool can be changed as needed
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES void indirectParallelQuickSort(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
if(SanityChecks.canParallelTask() && to - from >= PARALLEL_THRESHOLD) {
|
|
||||||
SanityChecks.invokeTask(new QuickSortActionCompSwapBRACES(array, from, to, comp, swapper));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
indirectQuickSort(array, from, to, comp, swapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts an array according to the natural ascending order using Parallel Quick Sort,
|
* Sorts an array according to the natural ascending order using Parallel Quick Sort,
|
||||||
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
* This implementation is a custom of <a href="https://github.com/vigna/fastutil">FastUtil</a> quicksort but with a different code structure,
|
||||||
@@ -1769,18 +1367,6 @@ public class ARRAYS
|
|||||||
for(int i = 0;i<length;i++,swap(a, from++, to++));
|
for(int i = 0;i<length;i++,swap(a, from++, to++));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GENERIC_KEY_BRACES void swap(KEY_TYPE[] a, int from, int to, Swapper swapper) {
|
|
||||||
swapper.swap(from, to);
|
|
||||||
KEY_TYPE t = a[from];
|
|
||||||
a[from] = a[to];
|
|
||||||
a[to] = t;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GENERIC_KEY_BRACES void swap(KEY_TYPE[] a, int from, int to, int length, Swapper swapper) {
|
|
||||||
to -= length;
|
|
||||||
for(int i = 0;i<length;i++,swap(a, from++, to++, swapper));
|
|
||||||
}
|
|
||||||
|
|
||||||
static GENERIC_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length, COMPARATOR KEY_GENERIC_TYPE comp) {
|
static GENERIC_KEY_BRACES int subMedium(KEY_TYPE[] data, int a, int b, int c, int length, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||||
return medium(data, medium(data, a, a + length, a + (length * 2), comp), medium(data, b - length, b, b + length, comp), medium(data, c - (length * 2), c - length, c, comp), comp);
|
return medium(data, medium(data, a, a + length, a + (length * 2), comp), medium(data, b - length, b, b + length, comp), medium(data, c - (length * 2), c - length, c, comp), comp);
|
||||||
}
|
}
|
||||||
@@ -1803,14 +1389,16 @@ public class ARRAYS
|
|||||||
int from;
|
int from;
|
||||||
int to;
|
int to;
|
||||||
|
|
||||||
QuickSortAction(KEY_TYPE[] array, int from, int to) {
|
QuickSortAction(KEY_TYPE[] array, int from, int to)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
if(length < BASE_THRESHOLD) {
|
if(length < BASE_THRESHOLD) {
|
||||||
@@ -1843,7 +1431,8 @@ public class ARRAYS
|
|||||||
int to;
|
int to;
|
||||||
COMPARATOR KEY_GENERIC_TYPE comp;
|
COMPARATOR KEY_GENERIC_TYPE comp;
|
||||||
|
|
||||||
QuickSortActionComp(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) {
|
QuickSortActionComp(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
@@ -1851,7 +1440,8 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
int length = to - from;
|
int length = to - from;
|
||||||
if(length <= 0) return;
|
if(length <= 0) return;
|
||||||
if(length < BASE_THRESHOLD) {
|
if(length < BASE_THRESHOLD) {
|
||||||
@@ -1877,49 +1467,6 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class QuickSortActionCompSwap KEY_GENERIC_TYPE extends RecursiveAction {
|
|
||||||
private static final long serialVersionUID = 0L;
|
|
||||||
KEY_TYPE[] array;
|
|
||||||
int from;
|
|
||||||
int to;
|
|
||||||
COMPARATOR KEY_GENERIC_TYPE comp;
|
|
||||||
Swapper swapper;
|
|
||||||
|
|
||||||
QuickSortActionCompSwap(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
this.array = array;
|
|
||||||
this.from = from;
|
|
||||||
this.to = to;
|
|
||||||
this.comp = comp;
|
|
||||||
this.swapper = swapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void compute() {
|
|
||||||
int length = to - from;
|
|
||||||
if(length <= 0) return;
|
|
||||||
if(length < BASE_THRESHOLD) {
|
|
||||||
indirectSelectionSort(array, from, to, comp, swapper);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
KEY_TYPE pivot = array[length > 128 ? subMedium(array, from, from + (length / 2), to - 1, length / 8, comp) : medium(array, from, from + (length / 2), to - 1, comp)];
|
|
||||||
int a = from, b = a, c = to - 1, d = c;
|
|
||||||
for(int compare;;swap(array, b++, c--, swapper)) {
|
|
||||||
for(;b<=c && (compare = comp.compare(array[b], pivot)) <= 0;b++) {
|
|
||||||
if(compare == 0) swap(array, a++, b, swapper);
|
|
||||||
}
|
|
||||||
for(;c>=b && (compare = comp.compare(array[c], pivot)) >= 0;c--) {
|
|
||||||
if(compare == 0) swap(array, c, d--, swapper);
|
|
||||||
}
|
|
||||||
if(b>c) break;
|
|
||||||
}
|
|
||||||
swap(array, from, b, Math.min(a - from, b - a), swapper);
|
|
||||||
swap(array, b, to, Math.min(d - c, to - d - 1), swapper);
|
|
||||||
if(b - a > 1 && d - c > 1) invokeAll(new QuickSortActionCompSwapBRACES(array, from, from + (b - a), comp, swapper), new QuickSortActionCompSwapBRACES(array, to - (d - c), to, comp, swapper));
|
|
||||||
else if(b - a > 1) new QuickSortActionCompSwapBRACES(array, from, from + (b - a), comp, swapper).invoke();
|
|
||||||
else if(d - c > 1) new QuickSortActionCompSwapBRACES(array, to - (d - c), to, comp, swapper).invoke();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class MergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
static class MergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
||||||
private static final long serialVersionUID = 0L;
|
private static final long serialVersionUID = 0L;
|
||||||
KEY_TYPE[] array;
|
KEY_TYPE[] array;
|
||||||
@@ -1927,7 +1474,8 @@ public class ARRAYS
|
|||||||
int from;
|
int from;
|
||||||
int to;
|
int to;
|
||||||
|
|
||||||
MergeSortAction(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to) {
|
MergeSortAction(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.supp = supp;
|
this.supp = supp;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
@@ -1935,7 +1483,8 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
if(to - from < BASE_THRESHOLD) {
|
if(to - from < BASE_THRESHOLD) {
|
||||||
insertionSort(array, from, to);
|
insertionSort(array, from, to);
|
||||||
return;
|
return;
|
||||||
@@ -1963,7 +1512,8 @@ public class ARRAYS
|
|||||||
int to;
|
int to;
|
||||||
COMPARATOR KEY_GENERIC_TYPE comp;
|
COMPARATOR KEY_GENERIC_TYPE comp;
|
||||||
|
|
||||||
MergeSortActionComp(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) {
|
MergeSortActionComp(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.supp = supp;
|
this.supp = supp;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
@@ -1972,7 +1522,8 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
if(to - from < BASE_THRESHOLD) {
|
if(to - from < BASE_THRESHOLD) {
|
||||||
insertionSort(array, from, to, comp);
|
insertionSort(array, from, to, comp);
|
||||||
return;
|
return;
|
||||||
@@ -1992,64 +1543,22 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MergeSortActionCompSwap KEY_GENERIC_TYPE extends RecursiveAction {
|
|
||||||
private static final long serialVersionUID = 0L;
|
|
||||||
KEY_TYPE[] array;
|
|
||||||
KEY_TYPE[] supp;
|
|
||||||
int from;
|
|
||||||
int to;
|
|
||||||
COMPARATOR KEY_GENERIC_TYPE comp;
|
|
||||||
Swapper swapper;
|
|
||||||
|
|
||||||
MergeSortActionCompSwap(KEY_TYPE[] array, KEY_TYPE[] supp, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp, Swapper swapper) {
|
|
||||||
this.array = array;
|
|
||||||
this.supp = supp;
|
|
||||||
this.from = from;
|
|
||||||
this.to = to;
|
|
||||||
this.comp = comp;
|
|
||||||
this.swapper = swapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void compute() {
|
|
||||||
if(to - from < BASE_THRESHOLD) {
|
|
||||||
indirectInsertionSort(array, from, to, comp, swapper);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(supp == null) supp = Arrays.copyOf(array, to);
|
|
||||||
int mid = (from + to) >>> 1;
|
|
||||||
invokeAll(new MergeSortActionCompSwapBRACES(supp, array, from, mid, comp, swapper), new MergeSortActionCompSwapBRACES(supp, array, mid, to, comp, swapper));
|
|
||||||
if(comp.compare(supp[mid - 1], supp[mid]) <= 0)
|
|
||||||
{
|
|
||||||
System.arraycopy(supp, from, array, from, to - from);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(int p = from, q = mid;from < to;from++) {
|
|
||||||
if(q >= to || p < mid && comp.compare(supp[p], supp[q]) < 0) {
|
|
||||||
swapper.swap(from, p);
|
|
||||||
array[from] = supp[p++];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
swapper.swap(from, q);
|
|
||||||
array[from] = supp[q++];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class MemFreeMergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
static class MemFreeMergeSortAction KEY_GENERIC_TYPE extends RecursiveAction {
|
||||||
private static final long serialVersionUID = 0L;
|
private static final long serialVersionUID = 0L;
|
||||||
KEY_TYPE[] array;
|
KEY_TYPE[] array;
|
||||||
int from;
|
int from;
|
||||||
int to;
|
int to;
|
||||||
|
|
||||||
MemFreeMergeSortAction(KEY_TYPE[] array, int from, int to) {
|
MemFreeMergeSortAction(KEY_TYPE[] array, int from, int to)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
if(to - from < BASE_THRESHOLD) {
|
if(to - from < BASE_THRESHOLD) {
|
||||||
insertionSort(array, from, to);
|
insertionSort(array, from, to);
|
||||||
return;
|
return;
|
||||||
@@ -2095,7 +1604,8 @@ public class ARRAYS
|
|||||||
int to;
|
int to;
|
||||||
COMPARATOR KEY_GENERIC_TYPE comp;
|
COMPARATOR KEY_GENERIC_TYPE comp;
|
||||||
|
|
||||||
MemFreeMergeSortActionComp(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp) {
|
MemFreeMergeSortActionComp(KEY_TYPE[] array, int from, int to, COMPARATOR KEY_GENERIC_TYPE comp)
|
||||||
|
{
|
||||||
this.array = array;
|
this.array = array;
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
@@ -2103,7 +1613,8 @@ public class ARRAYS
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void compute() {
|
protected void compute()
|
||||||
|
{
|
||||||
if(to - from < BASE_THRESHOLD) {
|
if(to - from < BASE_THRESHOLD) {
|
||||||
insertionSort(array, from, to, comp);
|
insertionSort(array, from, to, comp);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+10
-15
@@ -7,11 +7,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
import java.util.concurrent.locks.LockSupport;
|
import java.util.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -304,8 +299,9 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
* @param operator that reduces the elements.
|
* @param operator that reduces the elements.
|
||||||
* @return self with the reduce action applied
|
* @return self with the reduce action applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<OPTIONAL KEY_GENERIC_TYPE> reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public ASYNC_BUILDER KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
return new ObjectAsyncBuilder<>(new SimpleReduceTaskBRACES(iterable.iterator(), operator));
|
task = new SimpleReduceTaskBRACES(iterable.iterator(), operator);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -439,8 +435,9 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
* @param filter that decides the desired elements
|
* @param filter that decides the desired elements
|
||||||
* @return self with the findFirst function applied
|
* @return self with the findFirst function applied
|
||||||
*/
|
*/
|
||||||
public ObjectAsyncBuilder<OPTIONAL KEY_GENERIC_TYPE> findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
public ASYNC_BUILDER KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
return new ObjectAsyncBuilder<>(new FindFirstTaskBRACES(iterable.iterator(), filter));
|
task = new FindFirstTaskBRACES(iterable.iterator(), filter);
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if INT_ASYNC_MODULE
|
#if INT_ASYNC_MODULE
|
||||||
@@ -593,7 +590,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private static class SimpleReduceTask KEY_GENERIC_TYPE extends BaseObjectTask<OPTIONAL KEY_GENERIC_TYPE>
|
private static class SimpleReduceTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator;
|
UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator;
|
||||||
@@ -603,7 +600,6 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
public SimpleReduceTask(ITERATOR KEY_GENERIC_TYPE iter, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
public SimpleReduceTask(ITERATOR KEY_GENERIC_TYPE iter, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
this.setResult(OPTIONAL.empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -618,7 +614,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!iter.hasNext()) {
|
if(!iter.hasNext()) {
|
||||||
setResult(OPTIONAL.GET_OPTIONAL(value));
|
setResult(value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -693,7 +689,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
private static class FindFirstTask KEY_GENERIC_TYPE extends BaseObjectTask<OPTIONAL KEY_GENERIC_TYPE>
|
private static class FindFirstTask KEY_GENERIC_TYPE extends BASE_TASK KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
ITERATOR KEY_GENERIC_TYPE iter;
|
ITERATOR KEY_GENERIC_TYPE iter;
|
||||||
PREDICATE KEY_GENERIC_TYPE filter;
|
PREDICATE KEY_GENERIC_TYPE filter;
|
||||||
@@ -701,7 +697,6 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
public FindFirstTask(ITERATOR KEY_GENERIC_TYPE iter, PREDICATE KEY_GENERIC_TYPE filter) {
|
public FindFirstTask(ITERATOR KEY_GENERIC_TYPE iter, PREDICATE KEY_GENERIC_TYPE filter) {
|
||||||
this.iter = iter;
|
this.iter = iter;
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.setResult(OPTIONAL.empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -709,7 +704,7 @@ public class ASYNC_BUILDER KEY_GENERIC_TYPE
|
|||||||
while(shouldRun() && iter.hasNext()) {
|
while(shouldRun() && iter.hasNext()) {
|
||||||
KEY_TYPE entry = iter.NEXT();
|
KEY_TYPE entry = iter.NEXT();
|
||||||
if(filter.test(iter.NEXT())) {
|
if(filter.test(iter.NEXT())) {
|
||||||
setResult(OPTIONAL.GET_OPTIONAL(entry));
|
setResult(entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-108
@@ -8,9 +8,6 @@ import java.util.ConcurrentModificationException;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@@ -26,16 +23,10 @@ import java.util.function.Consumer;
|
|||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ORDERED_COLLECTION;
|
|
||||||
#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;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.utils.ObjectArrays;
|
import speiger.src.collections.objects.utils.ObjectArrays;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
@@ -85,37 +76,6 @@ public class COLLECTIONS
|
|||||||
return c instanceof UnmodifiableCollection ? c : new UnmodifiableCollectionBRACES(c);
|
return c instanceof UnmodifiableCollection ? c : new UnmodifiableCollectionBRACES(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a Immutable Ordered Collection instance based on the instance given.
|
|
||||||
* @param c that should be made immutable/unmodifiable
|
|
||||||
* @Type(T)
|
|
||||||
* @return a unmodifiable Ordered collection wrapper. If the Collection already a unmodifiable wrapper then it just returns itself.
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE unmodifiable(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
return c instanceof UnmodifiableOrderedCollection ? c : new UnmodifiableOrderedCollectionBRACES(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a synchronized ordered Collection instance based on the instance given.
|
|
||||||
* @param c that should be synchronized
|
|
||||||
* @Type(T)
|
|
||||||
* @return a synchronized ordered collection wrapper. If the Collection already a synchronized wrapper then it just returns itself.
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE synchronize(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
return c instanceof SynchronizedOrderedCollection ? c : new SynchronizedOrderedCollectionBRACES(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a synchronized ordered Collection instance based on the instance given.
|
|
||||||
* @param c that should be synchronized
|
|
||||||
* @param mutex is the controller of the synchronization block.
|
|
||||||
* @Type(T)
|
|
||||||
* @return a synchronized ordered collection wrapper. If the Collection already a synchronized wrapper then it just returns itself.
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ORDERED_COLLECTION KEY_GENERIC_TYPE synchronize(ORDERED_COLLECTION KEY_GENERIC_TYPE c, Object mutex) {
|
|
||||||
return c instanceof SynchronizedOrderedCollection ? c : new SynchronizedOrderedCollectionBRACES(c, mutex);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a synchronized Collection instance based on the instance given.
|
* Returns a synchronized Collection instance based on the instance given.
|
||||||
* @param c that should be synchronized
|
* @param c that should be synchronized
|
||||||
@@ -147,10 +107,7 @@ public class COLLECTIONS
|
|||||||
return new SingletonCollectionBRACES(element);
|
return new SingletonCollectionBRACES(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
||||||
* Internal Use mainly. Its a collection wrapper with 0 dependencies for those actions where a collector is needed.
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES CollectionWrapper KEY_GENERIC_TYPE wrapper() {
|
|
||||||
return new CollectionWrapperBRACES();
|
return new CollectionWrapperBRACES();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -711,38 +668,6 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
|
public SingletonCollection KEY_GENERIC_TYPE copy() { return new SingletonCollectionBRACES(element); }
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Synchronized Ordered Collection Wrapper for the synchronizedCollection function
|
|
||||||
* @Type(T)
|
|
||||||
*/
|
|
||||||
public static class SynchronizedOrderedCollection KEY_GENERIC_TYPE extends SynchronizedCollection KEY_GENERIC_TYPE implements ORDERED_COLLECTION KEY_GENERIC_TYPE {
|
|
||||||
ORDERED_COLLECTION KEY_GENERIC_TYPE c;
|
|
||||||
|
|
||||||
SynchronizedOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c, Object mutex) {
|
|
||||||
super(c, mutex);
|
|
||||||
this.c = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
SynchronizedOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
super(c);
|
|
||||||
this.c = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ORDERED_COLLECTION KEY_GENERIC_TYPE reversed() { return COLLECTIONS.synchronize(c.reversed(), mutex); }
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE e) { synchronized(mutex) { this.c.addFirst(e); } }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE e) { synchronized(mutex) { this.c.addLast(e); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_FIRST_KEY() { synchronized(mutex) { return this.c.GET_FIRST_KEY(); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { synchronized(mutex) { return this.c.REMOVE_FIRST_KEY(); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_LAST_KEY() { synchronized(mutex) { return this.c.GET_LAST_KEY(); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { synchronized(mutex) { return this.c.REMOVE_LAST_KEY(); } }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronized Collection Wrapper for the synchronizedCollection function
|
* Synchronized Collection Wrapper for the synchronizedCollection function
|
||||||
@@ -878,41 +803,13 @@ public class COLLECTIONS
|
|||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(identity, operator); } }
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(identity, operator); } }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(operator); } }
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return c.reduce(operator); } }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.findFirst(filter); } }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.findFirst(filter); } }
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unmodifyable Ordered Collection Wrapper for the unmodifyableCollection method
|
|
||||||
* @Type(T)
|
|
||||||
*/
|
|
||||||
public static class UnmodifiableOrderedCollection KEY_GENERIC_TYPE extends UnmodifiableCollection KEY_GENERIC_TYPE implements ORDERED_COLLECTION KEY_GENERIC_TYPE {
|
|
||||||
ORDERED_COLLECTION KEY_GENERIC_TYPE c;
|
|
||||||
|
|
||||||
UnmodifiableOrderedCollection(ORDERED_COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
super(c);
|
|
||||||
this.c = c;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ORDERED_COLLECTION KEY_GENERIC_TYPE reversed() { return COLLECTIONS.unmodifiable(c.reversed()); }
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_FIRST_KEY() { return c.GET_FIRST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE GET_LAST_KEY() { return c.GET_LAST_KEY(); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmodifyable Collection Wrapper for the unmodifyableCollection method
|
* Unmodifyable Collection Wrapper for the unmodifyableCollection method
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -1030,9 +927,9 @@ public class COLLECTIONS
|
|||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(identity, operator); }
|
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(identity, operator); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(operator); }
|
public KEY_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { return c.reduce(operator); }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { return c.findFirst(filter); }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { return c.findFirst(filter); }
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { return c.count(filter); }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { return c.count(filter); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class ITERATORS
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return an empty iterator
|
* @return an empty iterator
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST_ITERATOR KEY_GENERIC_TYPE empty() {
|
public static GENERIC_KEY_BRACES EmptyIterator KEY_GENERIC_TYPE empty() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
return (EmptyIterator<KEY_TYPE>)EMPTY;
|
return (EmptyIterator<KEY_TYPE>)EMPTY;
|
||||||
#else
|
#else
|
||||||
@@ -400,7 +400,7 @@ public class ITERATORS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return a Iterator that is wrapping a array.
|
* @return a Iterator that is wrapping a array.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE wrap(KEY_TYPE... a) {
|
public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE... a) {
|
||||||
return wrap(a, 0, a.length);
|
return wrap(a, 0, a.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ public class ITERATORS
|
|||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return a Iterator that is wrapping a array.
|
* @return a Iterator that is wrapping a array.
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int start, int end) {
|
public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a, int start, int end) {
|
||||||
return new ArrayIteratorBRACES(a, start, end);
|
return new ArrayIteratorBRACES(a, start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class LISTS
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
* @return an empty list
|
* @return an empty list
|
||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES LIST KEY_GENERIC_TYPE empty() {
|
public static GENERIC_KEY_BRACES EmptyList KEY_GENERIC_TYPE empty() {
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
return (EmptyList<KEY_TYPE>)EMPTY;
|
return (EmptyList<KEY_TYPE>)EMPTY;
|
||||||
#else
|
#else
|
||||||
|
|||||||
+2
-17
@@ -4,22 +4,16 @@ package speiger.src.collections.PACKAGE.utils;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.BiFunction;
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_FUNCTION
|
#if JDK_FUNCTION
|
||||||
import java.util.function.PREDICATE;
|
import java.util.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
#if !JDK_TYPE
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
#if DEQUEUE_FEATURE
|
#if DEQUEUE_FEATURE
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
#endif
|
#endif
|
||||||
@@ -30,7 +24,6 @@ import speiger.src.collections.PACKAGE.functions.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.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,15 +140,7 @@ public class PRIORITY_QUEUES
|
|||||||
@Override
|
@Override
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAll(filter); } }
|
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAll(filter); } }
|
||||||
@Override
|
@Override
|
||||||
public OPTIONAL KEY_GENERIC_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.findFirst(filter); } }
|
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.findFirst(filter); } }
|
||||||
#if TYPE_OBJECT
|
|
||||||
public <KEY_SPECIAL_TYPE> KEY_SPECIAL_TYPE reduce(KEY_SPECIAL_TYPE identity, BiFunction<KEY_SPECIAL_TYPE, KEY_TYPE, KEY_SPECIAL_TYPE> operator) { synchronized(mutex) { return queue.reduce(identity, operator); } }
|
|
||||||
#else
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE reduce(KEY_TYPE identity, UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return queue.reduce(identity, operator); } }
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public OPTIONAL KEY_GENERIC_TYPE reduce(UNARY_OPERATOR KEY_KEY_GENERIC_TYPE operator) { synchronized(mutex) { return queue.reduce(operator); } }
|
|
||||||
@Override
|
@Override
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,10 +360,6 @@ public class SETS
|
|||||||
s = c;
|
s = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -375,19 +371,17 @@ public class SETS
|
|||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(s.iterator()); }
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(s.iterator()); }
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE reverseIterator() { return ITERATORS.unmodifiable(s.reverseIterator()); }
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return ITERATORS.unmodifiable(s.iterator(fromElement)); }
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { return ITERATORS.unmodifiable(s.iterator(fromElement)); }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE copy() { return s.copy(); }
|
public ORDERED_SET KEY_GENERIC_TYPE copy() { return s.copy(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() { return s.GET_FIRST_KEY(); }
|
public KEY_TYPE FIRST_KEY() { return s.FIRST_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_FIRST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() { return s.GET_LAST_KEY(); }
|
public KEY_TYPE LAST_KEY() { return s.LAST_KEY(); }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { throw new UnsupportedOperationException(); }
|
public KEY_TYPE POLL_LAST_KEY() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -655,10 +649,6 @@ public class SETS
|
|||||||
s = c;
|
s = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(KEY_TYPE o) { synchronized(mutex) { s.addFirst(o); } }
|
|
||||||
@Override
|
|
||||||
public void addLast(KEY_TYPE o) { synchronized(mutex) { s.addLast(o); } }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToFirst(o); } }
|
public boolean addAndMoveToFirst(KEY_TYPE o) { synchronized(mutex) { return s.addAndMoveToFirst(o); } }
|
||||||
@Override
|
@Override
|
||||||
@@ -670,19 +660,17 @@ public class SETS
|
|||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { synchronized(mutex) { return s.iterator(); } }
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator() { synchronized(mutex) { return s.iterator(); } }
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE reverseIterator() { synchronized(mutex) { return s.reverseIterator(); } }
|
|
||||||
@Override
|
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { synchronized(mutex) { return s.iterator(fromElement); } }
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator(KEY_TYPE fromElement) { synchronized(mutex) { return s.iterator(fromElement); } }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE copy() { synchronized(mutex) { return s.copy(); } }
|
public ORDERED_SET KEY_GENERIC_TYPE copy() { synchronized(mutex) { return s.copy(); } }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_FIRST_KEY() { synchronized(mutex) { return s.GET_FIRST_KEY(); } }
|
public KEY_TYPE FIRST_KEY() { synchronized(mutex) { return s.FIRST_KEY(); } }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_FIRST_KEY() { synchronized(mutex) { return s.REMOVE_FIRST_KEY(); } }
|
public KEY_TYPE POLL_FIRST_KEY() { synchronized(mutex) { return s.POLL_FIRST_KEY(); } }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE GET_LAST_KEY() { synchronized(mutex) { return s.GET_LAST_KEY(); } }
|
public KEY_TYPE LAST_KEY() { synchronized(mutex) { return s.LAST_KEY(); } }
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE REMOVE_LAST_KEY() { synchronized(mutex) { return s.REMOVE_LAST_KEY(); } }
|
public KEY_TYPE POLL_LAST_KEY() { synchronized(mutex) { return s.POLL_LAST_KEY(); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+6
-47
@@ -56,9 +56,6 @@ import speiger.src.collections.PACKAGE.sets.SET;
|
|||||||
import speiger.src.collections.PACKAGE.utils.SETS;
|
import speiger.src.collections.PACKAGE.utils.SETS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
#if ORDERED_MAP_FEATURE
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ORDERED_COLLECTION;
|
|
||||||
#endif
|
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
@@ -556,10 +553,6 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToFirst(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
public boolean moveToLast(KEY_TYPE key) { throw new UnsupportedOperationException(); }
|
||||||
@@ -580,25 +573,13 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { return map.firstEntry(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { return map.lastEntry(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { return map.copy(); }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keys == null) keys = SETS.unmodifiable(map.keySet());
|
if(keys == null) keys = SETS.unmodifiable(map.keySet());
|
||||||
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
|
||||||
if(values == null) values = VALUE_COLLECTIONS.unmodifiable(map.values());
|
|
||||||
return (VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE)values;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new UnmodifyableOrderedEntrySetKV_BRACES(map.ENTRY_SET());
|
if(entrySet == null) entrySet = new UnmodifyableOrderedEntrySetKV_BRACES(map.ENTRY_SET());
|
||||||
@@ -755,10 +736,6 @@ public class MAPS
|
|||||||
set = c;
|
set = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addLast(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean addAndMoveToFirst(MAP.Entry KEY_VALUE_GENERIC_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -772,17 +749,15 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() { return ObjectIterators.unmodifiable(set.iterator()); }
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator() { return ObjectIterators.unmodifiable(set.iterator()); }
|
||||||
@Override
|
@Override
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> reverseIterator() { return ObjectIterators.unmodifiable(set.reverseIterator()); }
|
|
||||||
@Override
|
|
||||||
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator(MAP.Entry KEY_VALUE_GENERIC_TYPE fromElement) { return ObjectIterators.unmodifiable(set.iterator(fromElement)); }
|
public ObjectBidirectionalIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> iterator(MAP.Entry KEY_VALUE_GENERIC_TYPE fromElement) { return ObjectIterators.unmodifiable(set.iterator(fromElement)); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getFirst() { return set.getFirst(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE first() { return set.first(); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeFirst() { throw new UnsupportedOperationException(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirst() { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE getLast() { return set.getLast(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE last() { return set.last(); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE removeLast() { throw new UnsupportedOperationException(); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLast() { throw new UnsupportedOperationException(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -963,10 +938,6 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToLast(key, value); } }
|
public VALUE_TYPE putAndMoveToLast(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putAndMoveToLast(key, value); } }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE putFirst(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putFirst(key, value); } }
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE putLast(KEY_TYPE key, VALUE_TYPE value) { synchronized(mutex) { return map.putLast(key, value); } }
|
|
||||||
@Override
|
|
||||||
public boolean moveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.moveToFirst(key); } }
|
public boolean moveToFirst(KEY_TYPE key) { synchronized(mutex) { return map.moveToFirst(key); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean moveToLast(KEY_TYPE key) { synchronized(mutex) { return map.moveToLast(key); } }
|
public boolean moveToLast(KEY_TYPE key) { synchronized(mutex) { return map.moveToLast(key); } }
|
||||||
@@ -987,25 +958,13 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { synchronized(mutex) { return map.LAST_ENTRY_VALUE(); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE firstEntry() { synchronized(mutex) { return map.firstEntry(); } }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE lastEntry() { synchronized(mutex) { return map.lastEntry(); } }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollFirstEntry() { synchronized(mutex) { return map.pollFirstEntry(); } }
|
|
||||||
@Override
|
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE pollLastEntry() { synchronized(mutex) { return map.pollLastEntry(); } }
|
|
||||||
@Override
|
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE copy() { synchronized(mutex) { return map.copy(); } }
|
||||||
@Override
|
@Override
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
public ORDERED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
||||||
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
return (ORDERED_SET KEY_GENERIC_TYPE)keys;
|
||||||
}
|
}
|
||||||
@Override
|
|
||||||
public VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE values() {
|
|
||||||
if(values == null) values = VALUE_COLLECTIONS.synchronize(map.values(), mutex);
|
|
||||||
return (VALUE_ORDERED_COLLECTION VALUE_GENERIC_TYPE)values;
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectOrderedSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = ObjectSets.synchronize(map.ENTRY_SET(), mutex);
|
if(entrySet == null) entrySet = ObjectSets.synchronize(map.ENTRY_SET(), mutex);
|
||||||
|
|||||||
-77
@@ -1,29 +1,16 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder;
|
package speiger.src.testers.PACKAGE.builder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
|
||||||
import com.google.common.collect.testing.Helpers;
|
import com.google.common.collect.testing.Helpers;
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
|
||||||
import com.google.common.collect.testing.SampleElements;
|
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.ARRAY_LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST;
|
|
||||||
import speiger.src.collections.PACKAGE.sets.ORDERED_SET;
|
|
||||||
import speiger.src.collections.PACKAGE.utils.LISTS;
|
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetMoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetIterationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.set.FILE_KEY_TYPEOrderedSetNavigationTester;
|
||||||
import speiger.src.testers.PACKAGE.utils.SAMPLE_ELEMENTS;
|
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER KEY_GENERIC_TYPE {
|
||||||
@@ -48,68 +35,4 @@ public class ORDERED_SET_TEST_BUILDER KEY_GENERIC_TYPE extends SET_TEST_BUILDER
|
|||||||
#endignore
|
#endignore
|
||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<TestSuite> createDerivedSuites(
|
|
||||||
FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
|
||||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
|
||||||
|
|
||||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.REVERSE)) {
|
|
||||||
derivedSuites.add(createReverseSuite(parentBuilder));
|
|
||||||
}
|
|
||||||
|
|
||||||
return derivedSuites;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TestSuite createReverseSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Collection<CLASS_TYPE>, CLASS_TYPE>> parentBuilder) {
|
|
||||||
TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE delegate = (TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
|
||||||
|
|
||||||
List<Feature<?>> features = new ArrayList<>();
|
|
||||||
features.add(SpecialFeature.REVERSE);
|
|
||||||
features.addAll(parentBuilder.getFeatures());
|
|
||||||
features.remove(SpecialFeature.COPYING);
|
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
|
||||||
|
|
||||||
return ORDERED_SET_TEST_BUILDER.using(new TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE() {
|
|
||||||
@Override
|
|
||||||
public SampleElements<CLASS_TYPE> samples() {
|
|
||||||
return delegate.samples();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SAMPLE_ELEMENTS KEY_GENERIC_TYPE getSamples() {
|
|
||||||
return delegate.getSamples();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ITERABLE KEY_GENERIC_TYPE order(LIST KEY_GENERIC_TYPE insertionOrder) {
|
|
||||||
return insertionOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<CLASS_TYPE> order(List<CLASS_TYPE> insertionOrder) {
|
|
||||||
return insertionOrder;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE create(KEY_TYPE... elements) {
|
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES(elements);
|
|
||||||
LISTS.reverse(list);
|
|
||||||
return delegate.create(list.TO_ARRAY()).reversed();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
|
||||||
public ORDERED_SET KEY_GENERIC_TYPE create(Object... elements) {
|
|
||||||
LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
|
||||||
for (Object e : elements) {
|
|
||||||
list.add(CLASS_TO_KEY(e));
|
|
||||||
}
|
|
||||||
LISTS.reverse(list);
|
|
||||||
return delegate.create(list.toArray()).reversed();
|
|
||||||
}
|
|
||||||
}).named(parentBuilder.getName() + " reversing").withFeatures(features)
|
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+44
-31
@@ -238,17 +238,21 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||||||
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
private static Set<Feature<?>> computeEntrySetFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
Set<Feature<?>> entrySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
#ignore
|
#ignore
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_ENTRY_QUERIES)) {
|
||||||
|
entrySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) entrySetFeatures.add(SpecialFeature.COPYING);
|
}
|
||||||
else entrySetFeatures.remove(SpecialFeature.COPYING);
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
|
entrySetFeatures.add(SpecialFeature.COPYING);
|
||||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
}
|
||||||
else entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
else {
|
||||||
|
entrySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
if(mapFeatures.contains(SpecialFeature.REVERSE)) entrySetFeatures.add(SpecialFeature.REVERSE);
|
}
|
||||||
else entrySetFeatures.remove(SpecialFeature.REVERSE);
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
|
entrySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entrySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
entrySetFeatures.add(SpecialFeature.MAP_ENTRY);
|
||||||
#endignore
|
#endignore
|
||||||
return entrySetFeatures;
|
return entrySetFeatures;
|
||||||
@@ -258,17 +262,23 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||||||
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
Set<Feature<?>> keySetFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
#ignore
|
#ignore
|
||||||
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
keySetFeatures.add(CollectionFeature.SUBSET_VIEW);
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEYS)) {
|
||||||
else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
|
} else if (mapFeatures.contains(MapFeature.ALLOWS_NULL_KEY_QUERIES)) {
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) keySetFeatures.add(SpecialFeature.COPYING);
|
keySetFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
else keySetFeatures.remove(SpecialFeature.COPYING);
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
keySetFeatures.add(SpecialFeature.COPYING);
|
||||||
else keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
}
|
||||||
|
else {
|
||||||
if(mapFeatures.contains(SpecialFeature.REVERSE)) keySetFeatures.add(SpecialFeature.REVERSE);
|
keySetFeatures.remove(SpecialFeature.COPYING);
|
||||||
else keySetFeatures.remove(SpecialFeature.REVERSE);
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.MODIFIABLE)) {
|
||||||
|
keySetFeatures.add(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
keySetFeatures.remove(SpecialFeature.MODIFIABLE);
|
||||||
|
}
|
||||||
#endignore
|
#endignore
|
||||||
return keySetFeatures;
|
return keySetFeatures;
|
||||||
}
|
}
|
||||||
@@ -277,15 +287,18 @@ public class MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MapTestSuiteBuilder
|
|||||||
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
private static Set<Feature<?>> computeValuesCollectionFeatures(Set<Feature<?>> mapFeatures) {
|
||||||
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
Set<Feature<?>> valuesCollectionFeatures = MapTestSuiteBuilder.computeCommonDerivedCollectionFeatures(mapFeatures);
|
||||||
#ignore
|
#ignore
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUE_QUERIES)) {
|
||||||
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_QUERIES);
|
||||||
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
}
|
||||||
|
if (mapFeatures.contains(MapFeature.ALLOWS_NULL_VALUES)) {
|
||||||
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
valuesCollectionFeatures.add(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
else valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
}
|
||||||
|
if(mapFeatures.contains(SpecialFeature.CHILDREN_COPY)) {
|
||||||
if(mapFeatures.contains(SpecialFeature.REVERSE)) valuesCollectionFeatures.add(SpecialFeature.REVERSE);
|
valuesCollectionFeatures.add(SpecialFeature.COPYING);
|
||||||
else valuesCollectionFeatures.remove(SpecialFeature.REVERSE);
|
}
|
||||||
|
else {
|
||||||
|
valuesCollectionFeatures.remove(SpecialFeature.COPYING);
|
||||||
|
}
|
||||||
#endignore
|
#endignore
|
||||||
return valuesCollectionFeatures;
|
return valuesCollectionFeatures;
|
||||||
}
|
}
|
||||||
|
|||||||
-31
@@ -1,14 +1,9 @@
|
|||||||
package speiger.src.testers.PACKAGE.builder.maps;
|
package speiger.src.testers.PACKAGE.builder.maps;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.AbstractTester;
|
import com.google.common.collect.testing.AbstractTester;
|
||||||
import com.google.common.collect.testing.FeatureSpecificTestSuiteBuilder;
|
|
||||||
import com.google.common.collect.testing.OneSizeTestContainerGenerator;
|
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
|
||||||
|
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
@@ -17,17 +12,14 @@ import speiger.src.testers.PACKAGE.builder.SET_TEST_BUILDER;
|
|||||||
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_ORDERED_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.TEST_SET_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
import speiger.src.testers.PACKAGE.generators.maps.TEST_ORDERED_MAP_GENERATOR;
|
||||||
import speiger.src.testers.PACKAGE.impl.maps.DERIVED_MAP_GENERATORS;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester;
|
||||||
import speiger.src.testers.PACKAGE.tests.maps.FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester;
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectSetGenerator;
|
||||||
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
import speiger.src.testers.objects.builder.ObjectOrderedSetTestSuiteBuilder;
|
||||||
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
import speiger.src.testers.objects.generators.TestObjectOrderedSetGenerator;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.testers.utils.SpecialFeature;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE
|
||||||
@@ -42,7 +34,6 @@ public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BU
|
|||||||
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
List<Class<? extends AbstractTester>> testers = super.getTesters();
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapMoveTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapNavigationTester.class);
|
||||||
testers.add(FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester.class);
|
|
||||||
return testers;
|
return testers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,15 +45,6 @@ public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BU
|
|||||||
return super.createTestSuite();
|
return super.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<TestSuite> createDerivedSuites(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
|
||||||
List<TestSuite> derivedSuites = super.createDerivedSuites(parentBuilder);
|
|
||||||
if (!parentBuilder.getFeatures().contains(SpecialFeature.REVERSE)) {
|
|
||||||
derivedSuites.add(createReverseSuite(parentBuilder));
|
|
||||||
}
|
|
||||||
return derivedSuites;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
protected ObjectSetTestSuiteBuilder<MAP.Entry KEY_VALUE_GENERIC_TYPE> createDerivedEntrySetSuite(TestObjectSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE> entrySetGenerator) {
|
||||||
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
return ObjectOrderedSetTestSuiteBuilder.using((TestObjectOrderedSetGenerator<MAP.Entry KEY_VALUE_GENERIC_TYPE>)entrySetGenerator);
|
||||||
}
|
}
|
||||||
@@ -70,17 +52,4 @@ public class ORDERED_MAP_TEST_BUILDER KEY_VALUE_GENERIC_TYPE extends MAP_TEST_BU
|
|||||||
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
protected SET_TEST_BUILDER KEY_GENERIC_TYPE createDerivedKeySetSuite(TEST_SET_GENERATOR KEY_GENERIC_TYPE generator) {
|
||||||
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
return ORDERED_SET_TEST_BUILDER.using((TEST_ORDERED_SET_GENERATOR KEY_GENERIC_TYPE)generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestSuite createReverseSuite(FeatureSpecificTestSuiteBuilder<?, ? extends OneSizeTestContainerGenerator<Map<CLASS_TYPE, CLASS_VALUE_TYPE>, Map.Entry<CLASS_TYPE, CLASS_VALUE_TYPE>>> parentBuilder) {
|
|
||||||
TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE delegate = (TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE) parentBuilder.getSubjectGenerator().getInnerGenerator();
|
|
||||||
|
|
||||||
List<Feature<?>> features = new ArrayList<>();
|
|
||||||
features.add(SpecialFeature.REVERSE);
|
|
||||||
features.addAll(parentBuilder.getFeatures());
|
|
||||||
features.remove(SpecialFeature.COPYING);
|
|
||||||
features.remove(SpecialFeature.CHILDREN_COPY);
|
|
||||||
return ORDERED_MAP_TEST_BUILDER.using(new DERIVED_MAP_GENERATORS.ReverseTestOrderedMapGeneratorKV_BRACES(delegate))
|
|
||||||
.named(parentBuilder.getName() + " reversed").withFeatures(features)
|
|
||||||
.suppressing(parentBuilder.getSuppressedTests()).createTestSuite();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-17
@@ -20,7 +20,6 @@ import speiger.src.collections.PACKAGE.maps.abstracts.ABSTRACT_MAP;
|
|||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
import speiger.src.collections.PACKAGE.maps.interfaces.MAP.Entry;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.NAVIGABLE_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
import speiger.src.collections.PACKAGE.maps.interfaces.SORTED_MAP;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.sets.SET;
|
import speiger.src.collections.PACKAGE.sets.SET;
|
||||||
@@ -207,22 +206,6 @@ public class DERIVED_MAP_GENERATORS {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ReverseTestOrderedMapGenerator KEY_VALUE_GENERIC_TYPE extends MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE {
|
|
||||||
TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
|
||||||
|
|
||||||
public ReverseTestOrderedMapGenerator(TEST_ORDERED_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent) {
|
|
||||||
super(parent);
|
|
||||||
this.parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ORDERED_MAP KEY_VALUE_GENERIC_TYPE create(Entry KEY_VALUE_GENERIC_TYPE... elements) {
|
|
||||||
ObjectList<Entry KEY_VALUE_GENERIC_TYPE> entries = new ObjectArrayList<Entry KEY_VALUE_GENERIC_TYPE>(elements);
|
|
||||||
ObjectLists.reverse(entries);
|
|
||||||
return ((ORDERED_MAP KEY_VALUE_GENERIC_TYPE)parent.create(entries.toArray(Entry[]::new))).reversed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
public static class MapGenerator KEY_VALUE_GENERIC_TYPE implements TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
TEST_MAP_GENERATOR KEY_VALUE_GENERIC_TYPE parent;
|
||||||
|
|||||||
-93
@@ -27,8 +27,6 @@ import speiger.src.collections.PACKAGE.maps.impl.concurrent.CONCURRENT_HASH_MAP;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.reference.REF_MAP;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.reference.LINKED_REF_MAP;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||||
@@ -136,97 +134,6 @@ public class MAP_CONSTRUCTOR_TESTS
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
public static class RefMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
public RefMap() {
|
|
||||||
setSimpleConstructor(REF_MAP::new);
|
|
||||||
setSizeConstructor(REF_MAP::new);
|
|
||||||
setPArrayConstructor(REF_MAP::new);
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
|
||||||
setArrayConstructor(REF_MAP::new);
|
|
||||||
#endif
|
|
||||||
setPMapConstructor(REF_MAP::new);
|
|
||||||
setMapConstructor(REF_MAP::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWrongLoadFactorSize() {
|
|
||||||
setSizeConstructor(T -> new REF_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F));
|
|
||||||
try {
|
|
||||||
testSizeConstructor_smallSize();
|
|
||||||
fail("A Constructor using a 0 LoadFactor should error");
|
|
||||||
} catch(IllegalStateException e) {}
|
|
||||||
|
|
||||||
setSizeConstructor(T -> new REF_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F));
|
|
||||||
try {
|
|
||||||
testSizeConstructor_smallSize();
|
|
||||||
fail("A Constructor using a 1 LoadFactor should error");
|
|
||||||
} catch(IllegalStateException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
protected String[] createKeyElements() {
|
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
protected String[] createValueElements() {
|
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LinkedRefMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester KEY_VALUE_STRING_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
public LinkedRefMap() {
|
|
||||||
setSimpleConstructor(LINKED_REF_MAP::new);
|
|
||||||
setSizeConstructor(LINKED_REF_MAP::new);
|
|
||||||
setPArrayConstructor(LINKED_REF_MAP::new);
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
|
||||||
setArrayConstructor(LINKED_REF_MAP::new);
|
|
||||||
#endif
|
|
||||||
setPMapConstructor(LINKED_REF_MAP::new);
|
|
||||||
setMapConstructor(LINKED_REF_MAP::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testWrongLoadFactorSize() {
|
|
||||||
setSizeConstructor(T -> new LINKED_REF_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 0F));
|
|
||||||
try {
|
|
||||||
testSizeConstructor_smallSize();
|
|
||||||
fail("A Constructor using a 0 LoadFactor should error");
|
|
||||||
} catch(IllegalStateException e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
setSizeConstructor(T -> new LINKED_REF_MAP KEY_VALUE_STRING_GENERIC_TYPE(T, 1F));
|
|
||||||
try {
|
|
||||||
testSizeConstructor_smallSize();
|
|
||||||
fail("A Constructor using a 1 LoadFactor should error");
|
|
||||||
} catch(IllegalStateException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
protected String[] createKeyElements() {
|
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#if VALUE_OBJECT
|
|
||||||
@Override
|
|
||||||
protected String[] createValueElements() {
|
|
||||||
return Arrays.copyOfRange(StringSortTest.NAMES, 100, 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
public static class EnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum, String>
|
public static class EnumMap extends FILE_KEY_TYPE2FILE_VALUE_TYPEMapConstructorTester<AnEnum, String>
|
||||||
#else
|
#else
|
||||||
|
|||||||
-18
@@ -26,15 +26,6 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
|
||||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
|
||||||
public void testIndexedForEachUnknownOrder() {
|
|
||||||
#endignore
|
|
||||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
|
||||||
collection.forEachIndexed((K, V) -> elements.add(V));
|
|
||||||
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
@CollectionFeature.Require(absent = KNOWN_ORDER)
|
||||||
public void testForEachExtraUnknownOrder() {
|
public void testForEachExtraUnknownOrder() {
|
||||||
@@ -53,15 +44,6 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
|
||||||
@CollectionFeature.Require(KNOWN_ORDER)
|
|
||||||
public void testIndexedForEachKnownOrder() {
|
|
||||||
#endignore
|
|
||||||
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
|
|
||||||
collection.forEachIndexed((K, V) -> elements.add(V));
|
|
||||||
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionFeature.Require(KNOWN_ORDER)
|
@CollectionFeature.Require(KNOWN_ORDER)
|
||||||
public void testForEachExtraKnownOrder() {
|
public void testForEachExtraKnownOrder() {
|
||||||
|
|||||||
+3
-9
@@ -4,12 +4,6 @@ package speiger.src.testers.PACKAGE.tests.iterable;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
import com.google.common.collect.testing.features.CollectionSize;
|
||||||
@@ -33,17 +27,17 @@ public class FILE_KEY_TYPEIterableFindFirstTester KEY_GENERIC_TYPE extends ABSTR
|
|||||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testIterableFindFirst_FindFirstElements() {
|
public void testIterableFindFirst_FindFirstElements() {
|
||||||
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())).SUPPLY_GET());
|
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableFindFirst_FindNothing() {
|
public void testIterableFindFirst_FindNothing() {
|
||||||
assertEquals("No element should be found", OPTIONAL.empty(), container.findFirst(T -> KEY_EQUALS(T, e4())));
|
assertEquals("No element should be found", EMPTY_KEY_VALUE, container.findFirst(T -> KEY_EQUALS(T, e4())));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testIterableFindFirst_FindLastElement() {
|
public void testIterableFindFirst_FindLastElement() {
|
||||||
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())).SUPPLY_GET());
|
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-8
@@ -3,16 +3,9 @@ package speiger.src.testers.PACKAGE.tests.iterable;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@@ -36,7 +29,7 @@ public class FILE_KEY_TYPEIterableReduceTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableReduce() {
|
public void testIterableReduce() {
|
||||||
assertEquals("The sum of the collection should match", size == CollectionSize.ZERO ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(getSum()), collection.reduce(this::sum));
|
assertEquals("The sum of the collection should match", getSum(), collection.reduce(this::sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterableExtraReduce() {
|
public void testIterableExtraReduce() {
|
||||||
|
|||||||
-2
@@ -27,7 +27,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester KEY_VALUE_GENERIC_TY
|
|||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(absent = ZERO)
|
@CollectionSize.Require(absent = ZERO)
|
||||||
@SuppressWarnings("unlikely-arg-type")
|
|
||||||
#endignore
|
#endignore
|
||||||
public void testContainsObject_yes() {
|
public void testContainsObject_yes() {
|
||||||
assertTrue("contains(present) should return true", getMap().ENTRY_SET().contains(new AbstractMap.SimpleEntry<>(e0())));
|
assertTrue("contains(present) should return true", getMap().ENTRY_SET().contains(new AbstractMap.SimpleEntry<>(e0())));
|
||||||
@@ -37,7 +36,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapContainsTester KEY_VALUE_GENERIC_TY
|
|||||||
assertFalse("contains(notPresent) should return false", getMap().ENTRY_SET().contains(e3()));
|
assertFalse("contains(notPresent) should return false", getMap().ENTRY_SET().contains(e3()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unlikely-arg-type")
|
|
||||||
public void testContainsObject_no() {
|
public void testContainsObject_no() {
|
||||||
assertFalse("contains(notPresent) should return false", getMap().ENTRY_SET().contains(new AbstractMap.SimpleEntry<>(e3())));
|
assertFalse("contains(notPresent) should return false", getMap().ENTRY_SET().contains(new AbstractMap.SimpleEntry<>(e3())));
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -136,7 +136,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester KEY_VALUE_GENERIC
|
|||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
@MapFeature.Require(SUPPORTS_REMOVE)
|
@MapFeature.Require(SUPPORTS_REMOVE)
|
||||||
@SuppressWarnings("unlikely-arg-type")
|
|
||||||
#endignore
|
#endignore
|
||||||
public void testRemove_supportedObjectEntryPresent() {
|
public void testRemove_supportedObjectEntryPresent() {
|
||||||
assertTrue(getMap().ENTRY_SET().remove(new AbstractMap.SimpleEntry<>(e0())));
|
assertTrue(getMap().ENTRY_SET().remove(new AbstractMap.SimpleEntry<>(e0())));
|
||||||
@@ -155,7 +154,6 @@ public class FILE_KEY_TYPE2FILE_VALUE_TYPEMapRemoveEntryTester KEY_VALUE_GENERIC
|
|||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
@MapFeature.Require(SUPPORTS_REMOVE)
|
@MapFeature.Require(SUPPORTS_REMOVE)
|
||||||
@SuppressWarnings("unlikely-arg-type")
|
|
||||||
#endignore
|
#endignore
|
||||||
public void testRemove_supportedObjectEntryMissing() {
|
public void testRemove_supportedObjectEntryMissing() {
|
||||||
assertFalse(getMap().ENTRY_SET().remove(new AbstractMap.SimpleEntry<>(e3())));
|
assertFalse(getMap().ENTRY_SET().remove(new AbstractMap.SimpleEntry<>(e3())));
|
||||||
|
|||||||
-118
@@ -1,118 +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;
|
|
||||||
import static org.junit.Assert.assertNotEquals;
|
|
||||||
#endignore
|
|
||||||
|
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
import com.google.common.collect.testing.features.MapFeature;
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.MAP;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.interfaces.ORDERED_MAP;
|
|
||||||
import speiger.src.collections.objects.lists.ObjectList;
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.maps.ABSTRACT_MAP_TESTER;
|
|
||||||
import speiger.src.testers.objects.utils.ObjectHelpers;
|
|
||||||
|
|
||||||
@SuppressWarnings("javadoc")
|
|
||||||
public class FILE_KEY_TYPE2FILE_VALUE_TYPEOrderedMapPutTester KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP_TESTER KEY_VALUE_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
private ORDERED_MAP KEY_VALUE_GENERIC_TYPE orderedMap;
|
|
||||||
private ObjectList<MAP.Entry KEY_VALUE_GENERIC_TYPE> values;
|
|
||||||
private KEY_TYPE a;
|
|
||||||
private VALUE_TYPE aValue;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
orderedMap = (ORDERED_MAP KEY_VALUE_GENERIC_TYPE)getMap();
|
|
||||||
values = ObjectHelpers.copyToList(getSampleElements(getSubjectGenerator().getCollectionSize().getNumElements()));
|
|
||||||
if (values.size() >= 1) {
|
|
||||||
a = values.get(0).ENTRY_KEY();
|
|
||||||
aValue = values.get(0).ENTRY_VALUE();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testPutFirst() {
|
|
||||||
assertEquals(aValue, orderedMap.putFirst(a, v3()));
|
|
||||||
assertNotEquals(v3(), orderedMap.FIRST_ENTRY_VALUE());
|
|
||||||
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putFirst(k4(), v4()));
|
|
||||||
assertEquals(v4(), orderedMap.FIRST_ENTRY_VALUE());
|
|
||||||
assertEquals(e4(), orderedMap.firstEntry());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_PUT)
|
|
||||||
@CollectionSize.Require(absent = ZERO)
|
|
||||||
#endignore
|
|
||||||
public void testPutLast() {
|
|
||||||
assertEquals(aValue, orderedMap.putLast(a, v3()));
|
|
||||||
assertNotEquals(v3(), orderedMap.LAST_ENTRY_VALUE());
|
|
||||||
assertEquals(orderedMap.getDefaultReturnValue(), orderedMap.putLast(k4(), v4()));
|
|
||||||
assertEquals(v4(), orderedMap.LAST_ENTRY_VALUE());
|
|
||||||
assertEquals(e4(), orderedMap.lastEntry());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_REMOVE)
|
|
||||||
@CollectionSize.Require(CollectionSize.ONE)
|
|
||||||
#endignore
|
|
||||||
public void testPollFirst() {
|
|
||||||
assertFalse(orderedMap.isEmpty());
|
|
||||||
assertEquals(e0(), orderedMap.pollFirstEntry());
|
|
||||||
assertTrue(orderedMap.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(SUPPORTS_REMOVE)
|
|
||||||
@CollectionSize.Require(CollectionSize.ONE)
|
|
||||||
#endignore
|
|
||||||
public void testPollLast() {
|
|
||||||
assertFalse(orderedMap.isEmpty());
|
|
||||||
assertEquals(e0(), orderedMap.pollLastEntry());
|
|
||||||
assertTrue(orderedMap.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testUnsupportedPutFirst() {
|
|
||||||
try { orderedMap.putFirst(a, aValue); }
|
|
||||||
catch (UnsupportedOperationException tolerated) {}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_PUT)
|
|
||||||
#endignore
|
|
||||||
public void testUnsupportedPutLast() {
|
|
||||||
try { orderedMap.putLast(a, aValue); }
|
|
||||||
catch (UnsupportedOperationException tolerated) {}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_REMOVE)
|
|
||||||
#endignore
|
|
||||||
public void testUnsupportedPollFirst() {
|
|
||||||
try { orderedMap.pollFirstEntry(); }
|
|
||||||
catch (UnsupportedOperationException tolerated) {}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ignore
|
|
||||||
@MapFeature.Require(absent = SUPPORTS_REMOVE)
|
|
||||||
#endignore
|
|
||||||
public void testUnsupportedPollLast() {
|
|
||||||
try { orderedMap.pollFirstEntry(); }
|
|
||||||
catch (UnsupportedOperationException tolerated) {}
|
|
||||||
expectUnchanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-8
@@ -2,11 +2,6 @@ package speiger.src.testers.PACKAGE.tests.queue.iterators;
|
|||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
@@ -32,17 +27,17 @@ public class FILE_KEY_TYPEQueueFindFirstTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
@CollectionSize.Require(absent = CollectionSize.ZERO)
|
||||||
#endignore
|
#endignore
|
||||||
public void testQueueFindFirst_FindFirstElements() {
|
public void testQueueFindFirst_FindFirstElements() {
|
||||||
assertEquals("First Element should be found", e0(), queue.findFirst(T -> KEY_EQUALS(T, e0())).SUPPLY_GET());
|
assertEquals("First Element should be found", e0(), queue.findFirst(T -> KEY_EQUALS(T, e0())));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQueueFindFirst_FindNothing() {
|
public void testQueueFindFirst_FindNothing() {
|
||||||
assertEquals("No element should be found", OPTIONAL.empty(), queue.findFirst(T -> KEY_EQUALS(T, e4())));
|
assertEquals("No element should be found", EMPTY_KEY_VALUE, queue.findFirst(T -> KEY_EQUALS(T, e4())));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(CollectionSize.SEVERAL)
|
@CollectionSize.Require(CollectionSize.SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testQueueFindFirst_FindLastElement() {
|
public void testQueueFindFirst_FindLastElement() {
|
||||||
assertEquals("Last Element should be found", e2(), queue.findFirst(T -> KEY_EQUALS(T, e2())).SUPPLY_GET());
|
assertEquals("Last Element should be found", e2(), queue.findFirst(T -> KEY_EQUALS(T, e2())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-7
@@ -3,16 +3,10 @@ package speiger.src.testers.PACKAGE.tests.queue.iterators;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
#endif
|
|
||||||
#if JDK_TYPE
|
|
||||||
import java.util.OPTIONAL;
|
|
||||||
#else
|
|
||||||
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
|
|
||||||
#endif
|
#endif
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
|
||||||
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_QUEUE_TESTER;
|
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_QUEUE_TESTER;
|
||||||
import com.google.common.collect.testing.features.CollectionSize;
|
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@SuppressWarnings("javadoc")
|
@SuppressWarnings("javadoc")
|
||||||
@@ -35,7 +29,7 @@ public class FILE_KEY_TYPEQueueReduceTester KEY_GENERIC_TYPE extends ABSTRACT_QU
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testQueueReduce() {
|
public void testQueueReduce() {
|
||||||
assertEquals("The sum of the queue should match", size == CollectionSize.ZERO ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(getSum()), queue.reduce(this::sum));
|
assertEquals("The sum of the queue should match", getSum(), queue.reduce(this::sum));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testQueueExtraReduce() {
|
public void testQueueExtraReduce() {
|
||||||
|
|||||||
+48
-48
@@ -45,10 +45,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testaddMoveToFirstMissing()
|
public void testaddMoveToFirstMissing()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(true, orderedSet.addAndMoveToFirst(e4()));
|
assertEquals(true, orderedSet.addAndMoveToFirst(e4()));
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(e4(), orderedSet.GET_FIRST_KEY());
|
assertEquals(e4(), orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -57,10 +57,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testaddMoveToFirstPreset()
|
public void testaddMoveToFirstPreset()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(false, orderedSet.addAndMoveToFirst(c));
|
assertEquals(false, orderedSet.addAndMoveToFirst(c));
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(c, orderedSet.GET_FIRST_KEY());
|
assertEquals(c, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -69,10 +69,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testaddMoveToLastMissing()
|
public void testaddMoveToLastMissing()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(true, orderedSet.addAndMoveToLast(e4()));
|
assertEquals(true, orderedSet.addAndMoveToLast(e4()));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(e4(), orderedSet.GET_LAST_KEY());
|
assertEquals(e4(), orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -81,10 +81,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testaddMoveToLastPreset()
|
public void testaddMoveToLastPreset()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(false, orderedSet.addAndMoveToLast(a));
|
assertEquals(false, orderedSet.addAndMoveToLast(a));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(a, orderedSet.GET_LAST_KEY());
|
assertEquals(a, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -93,9 +93,9 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveToFirstMissing()
|
public void testMoveToFirstMissing()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(false, orderedSet.moveToFirst(e4()));
|
assertEquals(false, orderedSet.moveToFirst(e4()));
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -104,10 +104,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveToFirstPreset()
|
public void testMoveToFirstPreset()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(true, orderedSet.moveToFirst(c));
|
assertEquals(true, orderedSet.moveToFirst(c));
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(c, orderedSet.GET_FIRST_KEY());
|
assertEquals(c, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -116,9 +116,9 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveToLastMissing()
|
public void testMoveToLastMissing()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(false, orderedSet.moveToLast(e4()));
|
assertEquals(false, orderedSet.moveToLast(e4()));
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -127,10 +127,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveToLastPreset()
|
public void testMoveToLastPreset()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(true, orderedSet.moveToLast(a));
|
assertEquals(true, orderedSet.moveToLast(a));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(a, orderedSet.GET_LAST_KEY());
|
assertEquals(a, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -139,10 +139,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveCenterToLast()
|
public void testMoveCenterToLast()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertTrue(orderedSet.moveToLast(e1()));
|
assertTrue(orderedSet.moveToLast(e1()));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(e1(), orderedSet.GET_LAST_KEY());
|
assertEquals(e1(), orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -151,10 +151,10 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveCenterToFirst()
|
public void testMoveCenterToFirst()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertTrue(orderedSet.moveToFirst(e1()));
|
assertTrue(orderedSet.moveToFirst(e1()));
|
||||||
assertNotEquals(c, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(c, orderedSet.FIRST_KEY());
|
||||||
assertEquals(e1(), orderedSet.GET_FIRST_KEY());
|
assertEquals(e1(), orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -163,13 +163,13 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveForthAndBack()
|
public void testMoveForthAndBack()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertTrue(orderedSet.moveToLast(e0()));
|
assertTrue(orderedSet.moveToLast(e0()));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(a, orderedSet.GET_LAST_KEY());
|
assertEquals(a, orderedSet.LAST_KEY());
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertTrue(orderedSet.moveToFirst(e0()));
|
assertTrue(orderedSet.moveToFirst(e0()));
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -178,13 +178,13 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testMoveBackAndForth()
|
public void testMoveBackAndForth()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertTrue(orderedSet.moveToFirst(e2()));
|
assertTrue(orderedSet.moveToFirst(e2()));
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(c, orderedSet.GET_FIRST_KEY());
|
assertEquals(c, orderedSet.FIRST_KEY());
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertTrue(orderedSet.moveToLast(e2()));
|
assertTrue(orderedSet.moveToLast(e2()));
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -193,13 +193,13 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testAddForthAndBack()
|
public void testAddForthAndBack()
|
||||||
{
|
{
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
assertFalse(orderedSet.addAndMoveToLast(e0()));
|
assertFalse(orderedSet.addAndMoveToLast(e0()));
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertEquals(a, orderedSet.GET_LAST_KEY());
|
assertEquals(a, orderedSet.LAST_KEY());
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertFalse(orderedSet.addAndMoveToFirst(e0()));
|
assertFalse(orderedSet.addAndMoveToFirst(e0()));
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@@ -208,13 +208,13 @@ public class FILE_KEY_TYPEOrderedSetMoveTester KEY_GENERIC_TYPE extends ABSTRACT
|
|||||||
#endignore
|
#endignore
|
||||||
public void testAddBackAndForth()
|
public void testAddBackAndForth()
|
||||||
{
|
{
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertFalse(orderedSet.addAndMoveToFirst(e2()));
|
assertFalse(orderedSet.addAndMoveToFirst(e2()));
|
||||||
assertNotEquals(a, orderedSet.GET_FIRST_KEY());
|
assertNotEquals(a, orderedSet.FIRST_KEY());
|
||||||
assertEquals(c, orderedSet.GET_FIRST_KEY());
|
assertEquals(c, orderedSet.FIRST_KEY());
|
||||||
assertNotEquals(c, orderedSet.GET_LAST_KEY());
|
assertNotEquals(c, orderedSet.LAST_KEY());
|
||||||
assertFalse(orderedSet.addAndMoveToLast(e2()));
|
assertFalse(orderedSet.addAndMoveToLast(e2()));
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
|
|||||||
+22
-22
@@ -68,7 +68,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
int polled = 0;
|
int polled = 0;
|
||||||
int expectedPolls = orderedSet.size();
|
int expectedPolls = orderedSet.size();
|
||||||
while(polled < expectedPolls) {
|
while(polled < expectedPolls) {
|
||||||
orderedSet.REMOVE_FIRST_KEY();
|
orderedSet.POLL_FIRST_KEY();
|
||||||
polled++;
|
polled++;
|
||||||
}
|
}
|
||||||
assertTrue("Map should be empty", orderedSet.isEmpty());
|
assertTrue("Map should be empty", orderedSet.isEmpty());
|
||||||
@@ -82,7 +82,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
int polled = 0;
|
int polled = 0;
|
||||||
int expectedPolls = orderedSet.size();
|
int expectedPolls = orderedSet.size();
|
||||||
while(polled < expectedPolls) {
|
while(polled < expectedPolls) {
|
||||||
orderedSet.REMOVE_LAST_KEY();
|
orderedSet.POLL_LAST_KEY();
|
||||||
polled++;
|
polled++;
|
||||||
}
|
}
|
||||||
assertTrue("Map should be empty", orderedSet.isEmpty());
|
assertTrue("Map should be empty", orderedSet.isEmpty());
|
||||||
@@ -94,8 +94,8 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testEmptySetPollFirst() {
|
public void testEmptySetPollFirst() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_FIRST_KEY();
|
orderedSet.POLL_FIRST_KEY();
|
||||||
fail("OrderedSet.REMOVE_FIRST_KEY should throw NoSuchElementException");
|
fail("OrderedSet.POLL_FIRST_KEY should throw NoSuchElementException");
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -107,8 +107,8 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testEmptySetPollLast() {
|
public void testEmptySetPollLast() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_LAST_KEY();
|
orderedSet.POLL_LAST_KEY();
|
||||||
fail("OrderedSet.REMOVE_LAST_KEY should throw NoSuchElementException");
|
fail("OrderedSet.POLL_LAST_KEY should throw NoSuchElementException");
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -119,8 +119,8 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testUnsupportedSetPollFirst() {
|
public void testUnsupportedSetPollFirst() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_FIRST_KEY();
|
orderedSet.POLL_FIRST_KEY();
|
||||||
fail("OrderedSet.REMOVE_FIRST_KEY should throw UnsupportedOperationException");
|
fail("OrderedSet.POLL_FIRST_KEY should throw UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -131,8 +131,8 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testUnsupportedSetPollLast() {
|
public void testUnsupportedSetPollLast() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_LAST_KEY();
|
orderedSet.POLL_LAST_KEY();
|
||||||
fail("OrderedSet.REMOVE_LAST_KEY should throw UnsupportedOperationException");
|
fail("OrderedSet.POLL_LAST_KEY should throw UnsupportedOperationException");
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
expectUnchanged();
|
expectUnchanged();
|
||||||
@@ -143,7 +143,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSingletonSetPollFirst() {
|
public void testSingletonSetPollFirst() {
|
||||||
assertEquals(a, orderedSet.REMOVE_FIRST_KEY());
|
assertEquals(a, orderedSet.POLL_FIRST_KEY());
|
||||||
assertTrue(orderedSet.isEmpty());
|
assertTrue(orderedSet.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSingletonSetPollLast() {
|
public void testSingletonSetPollLast() {
|
||||||
assertEquals(a, orderedSet.REMOVE_LAST_KEY());
|
assertEquals(a, orderedSet.POLL_LAST_KEY());
|
||||||
assertTrue(orderedSet.isEmpty());
|
assertTrue(orderedSet.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
@CollectionSize.Require(SEVERAL)
|
@CollectionSize.Require(SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testPollFirst() {
|
public void testPollFirst() {
|
||||||
assertEquals(a, orderedSet.REMOVE_FIRST_KEY());
|
assertEquals(a, orderedSet.POLL_FIRST_KEY());
|
||||||
assertEquals(values.subList(1, values.size()), HELPERS.copyToList(orderedSet));
|
assertEquals(values.subList(1, values.size()), HELPERS.copyToList(orderedSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
@CollectionSize.Require(SEVERAL)
|
@CollectionSize.Require(SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testPollLast() {
|
public void testPollLast() {
|
||||||
assertEquals(c, orderedSet.REMOVE_LAST_KEY());
|
assertEquals(c, orderedSet.POLL_LAST_KEY());
|
||||||
assertEquals(values.subList(0, values.size()-1), HELPERS.copyToList(orderedSet));
|
assertEquals(values.subList(0, values.size()-1), HELPERS.copyToList(orderedSet));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testPollFirstUnsupported() {
|
public void testPollFirstUnsupported() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_FIRST_KEY();
|
orderedSet.POLL_FIRST_KEY();
|
||||||
fail();
|
fail();
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
@@ -190,7 +190,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testPollLastUnsupported() {
|
public void testPollLastUnsupported() {
|
||||||
try {
|
try {
|
||||||
orderedSet.REMOVE_LAST_KEY();
|
orderedSet.POLL_LAST_KEY();
|
||||||
fail();
|
fail();
|
||||||
} catch (UnsupportedOperationException e) {
|
} catch (UnsupportedOperationException e) {
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testEmptySetFirst() {
|
public void testEmptySetFirst() {
|
||||||
try {
|
try {
|
||||||
orderedSet.GET_FIRST_KEY();
|
orderedSet.FIRST_KEY();
|
||||||
fail();
|
fail();
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
}
|
}
|
||||||
@@ -212,7 +212,7 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
#endignore
|
#endignore
|
||||||
public void testEmptySetLast() {
|
public void testEmptySetLast() {
|
||||||
try {
|
try {
|
||||||
orderedSet.GET_LAST_KEY();
|
orderedSet.LAST_KEY();
|
||||||
fail();
|
fail();
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
}
|
}
|
||||||
@@ -222,27 +222,27 @@ public class FILE_KEY_TYPEOrderedSetNavigationTester KEY_GENERIC_TYPE extends AB
|
|||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSingletonSetFirst() {
|
public void testSingletonSetFirst() {
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(ONE)
|
@CollectionSize.Require(ONE)
|
||||||
#endignore
|
#endignore
|
||||||
public void testSingletonSetLast() {
|
public void testSingletonSetLast() {
|
||||||
assertEquals(a, orderedSet.GET_LAST_KEY());
|
assertEquals(a, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(SEVERAL)
|
@CollectionSize.Require(SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testFirst() {
|
public void testFirst() {
|
||||||
assertEquals(a, orderedSet.GET_FIRST_KEY());
|
assertEquals(a, orderedSet.FIRST_KEY());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ignore
|
#ignore
|
||||||
@CollectionSize.Require(SEVERAL)
|
@CollectionSize.Require(SEVERAL)
|
||||||
#endignore
|
#endignore
|
||||||
public void testLast() {
|
public void testLast() {
|
||||||
assertEquals(c, orderedSet.GET_LAST_KEY());
|
assertEquals(c, orderedSet.LAST_KEY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,9 +12,6 @@ import com.google.common.collect.testing.features.CollectionSize;
|
|||||||
import com.google.common.collect.testing.features.SetFeature;
|
import com.google.common.collect.testing.features.SetFeature;
|
||||||
import com.google.common.collect.testing.features.Feature;
|
import com.google.common.collect.testing.features.Feature;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import com.google.common.collect.testing.testers.CollectionAddTester;
|
|
||||||
import com.google.common.collect.testing.testers.CollectionAddAllTester;
|
|
||||||
import com.google.common.collect.testing.testers.CollectionCreationTester;
|
|
||||||
import com.google.common.collect.testing.features.CollectionFeature;
|
import com.google.common.collect.testing.features.CollectionFeature;
|
||||||
#endif
|
#endif
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
@@ -125,9 +122,6 @@ public class SET_TESTS extends TestCase
|
|||||||
#ignore
|
#ignore
|
||||||
.withFeatures(getSizes(size)).withFeatures(features);
|
.withFeatures(getSizes(size)).withFeatures(features);
|
||||||
if(nullValues) builder.withFeatures(CollectionFeature.ALLOWS_NULL_VALUES);
|
if(nullValues) builder.withFeatures(CollectionFeature.ALLOWS_NULL_VALUES);
|
||||||
builder.suppressing(CollectionAddTester.getAddNullUnsupportedMethod(), CollectionAddTester.getAddNullSupportedMethod());
|
|
||||||
builder.suppressing(CollectionAddAllTester.getAddAllNullUnsupportedMethod());
|
|
||||||
builder.suppressing(CollectionCreationTester.getCreateWithNullUnsupportedMethod());
|
|
||||||
#endignore
|
#endignore
|
||||||
return builder.createTestSuite();
|
return builder.createTestSuite();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ import speiger.src.collections.PACKAGE.maps.impl.misc.ARRAY_MAP;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.ENUM_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.misc.LINKED_ENUM_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.reference.REF_MAP;
|
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.reference.LINKED_REF_MAP;
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.AVL_TREE_MAP;
|
||||||
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
import speiger.src.collections.PACKAGE.maps.impl.tree.RB_TREE_MAP;
|
||||||
@@ -106,7 +104,6 @@ public class MAP_TESTS extends TestCase
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.EnumMap.class));
|
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.EnumMap.class));
|
||||||
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.LinkedEnumMap.class));
|
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.LinkedEnumMap.class));
|
||||||
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.RefMap.class));
|
|
||||||
#endif
|
#endif
|
||||||
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.CustomHashMap.class));
|
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.CustomHashMap.class));
|
||||||
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.LinkedCustomHashMap.class));
|
constructors.addTest(new TestSuite(MAP_CONSTRUCTOR_TESTS.LinkedCustomHashMap.class));
|
||||||
@@ -133,29 +130,27 @@ public class MAP_TESTS extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void suite(TestSuite suite) {
|
public static void suite(TestSuite suite) {
|
||||||
suite.addTest(mapSuite("HASH_MAP", HASH_MAP::new, getFeatures(), -1, true, true));
|
suite.addTest(mapSuite("HASH_MAP", HASH_MAP::new, getFeatures(), -1, true));
|
||||||
suite.addTest(orderedMapSuite("LINKED_HASH_MAP", LINKED_HASH_MAP::new, getFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("LINKED_HASH_MAP", LINKED_HASH_MAP::new, getFeatures(), -1));
|
||||||
suite.addTest(orderedMapSuite("IMMUTABLE_HASH_MAP", IMMUTABLE_HASH_MAP::new, getImmutableFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("IMMUTABLE_HASH_MAP", IMMUTABLE_HASH_MAP::new, getImmutableFeatures(), -1));
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
suite.addTest(enumMapSuite("ENUM_MAP", ENUM_MAP::new, getFeatures(), 5));
|
suite.addTest(enumMapSuite("ENUM_MAP", ENUM_MAP::new, getFeatures(), 5));
|
||||||
suite.addTest(enumOrderedMapSuite("LINKED_ENUM_MAP", (K, V) -> K.length <= 0 ? new LINKED_ENUM_MAP<>(AnEnum.class) : new LINKED_ENUM_MAP<>(K, V), getFeatures(), 5));
|
suite.addTest(enumOrderedMapSuite("LINKED_ENUM_MAP", (K, V) -> K.length <= 0 ? new LINKED_ENUM_MAP<>(AnEnum.class) : new LINKED_ENUM_MAP<>(K, V), getFeatures(), 5));
|
||||||
suite.addTest(mapSuite("REF_MAP", REF_MAP::new, getFeatures(), - 1, true, false));
|
|
||||||
suite.addTest(orderedMapSuite("LINKED_REF_MAP", LINKED_REF_MAP::new, getFeatures(), - 1, false));
|
|
||||||
#endif
|
#endif
|
||||||
suite.addTest(mapSuite("CUSTOM_HASH_MAP", (K, V) -> new CUSTOM_HASH_MAPKV_BRACES(K, V, HashStrategy.INSTANCE), getFeatures(), -1, true, true));
|
suite.addTest(mapSuite("CUSTOM_HASH_MAP", (K, V) -> new CUSTOM_HASH_MAPKV_BRACES(K, V, HashStrategy.INSTANCE), getFeatures(), -1, true));
|
||||||
suite.addTest(orderedMapSuite("LINKED_CUSTOM_HASH_MAP", (K, V) -> new LINKED_CUSTOM_HASH_MAPKV_BRACES(K, V, HashStrategy.INSTANCE), getFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("LINKED_CUSTOM_HASH_MAP", (K, V) -> new LINKED_CUSTOM_HASH_MAPKV_BRACES(K, V, HashStrategy.INSTANCE), getFeatures(), -1));
|
||||||
suite.addTest(orderedMapSuite("ARRAY_MAP", ARRAY_MAP::new, getFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("ARRAY_MAP", ARRAY_MAP::new, getFeatures(), -1));
|
||||||
suite.addTest(concurrentMapSuite("CONCURRENT_HASH_MAP", CONCURRENT_HASH_MAP::new, getFeatures(), 2));
|
suite.addTest(concurrentMapSuite("CONCURRENT_HASH_MAP", CONCURRENT_HASH_MAP::new, getFeatures(), 2));
|
||||||
suite.addTest(concurrentMapSuite("CONCURRENT_HASH_MAP", CONCURRENT_HASH_MAP::new, getFeatures(), 3));
|
suite.addTest(concurrentMapSuite("CONCURRENT_HASH_MAP", CONCURRENT_HASH_MAP::new, getFeatures(), 3));
|
||||||
suite.addTest(navigableMapSuite("RB_TREE_MAP", RB_TREE_MAP::new, getFeatures(), -1));
|
suite.addTest(navigableMapSuite("RB_TREE_MAP", RB_TREE_MAP::new, getFeatures(), -1));
|
||||||
suite.addTest(navigableMapSuite("AVL_TREE_MAP", AVL_TREE_MAP::new, getFeatures(), -1));
|
suite.addTest(navigableMapSuite("AVL_TREE_MAP", AVL_TREE_MAP::new, getFeatures(), -1));
|
||||||
suite.addTest(navigableMapSuite("SynchronizedRB_TREE_MAP", (K, V) -> new RB_TREE_MAPKV_BRACES(K, V).synchronize(), getLimitedFeatures(), -1));
|
suite.addTest(navigableMapSuite("SynchronizedRB_TREE_MAP", (K, V) -> new RB_TREE_MAPKV_BRACES(K, V).synchronize(), getLimitedFeatures(), -1));
|
||||||
suite.addTest(navigableMapSuite("UnmodifiableRB_TREE_MAP", (K, V) -> new RB_TREE_MAPKV_BRACES(K, V).unmodifiable(), getLimitedImmutableFeatures(), -1));
|
suite.addTest(navigableMapSuite("UnmodifiableRB_TREE_MAP", (K, V) -> new RB_TREE_MAPKV_BRACES(K, V).unmodifiable(), getLimitedImmutableFeatures(), -1));
|
||||||
suite.addTest(orderedMapSuite("SynchronizedORDERED_MAP", (K, V) -> new LINKED_HASH_MAPKV_BRACES(K, V).synchronize(), getFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("SynchronizedORDERED_MAP", (K, V) -> new LINKED_HASH_MAPKV_BRACES(K, V).synchronize(), getFeatures(), -1));
|
||||||
suite.addTest(orderedMapSuite("UnmodifiableORDERED_MAP", (K, V) -> new LINKED_HASH_MAPKV_BRACES(K, V).unmodifiable(), getImmutableFeatures(), -1, true));
|
suite.addTest(orderedMapSuite("UnmodifiableORDERED_MAP", (K, V) -> new LINKED_HASH_MAPKV_BRACES(K, V).unmodifiable(), getImmutableFeatures(), -1));
|
||||||
suite.addTest(mapSuite("EmptyMAP", (K, V) -> MAPS.empty(), getEmptyFeatures(), 0, false, true));
|
suite.addTest(mapSuite("EmptyMAP", (K, V) -> MAPS.empty(), getEmptyFeatures(), 0, false));
|
||||||
suite.addTest(mapSuite("SingletonMAP", (K, V) -> MAPS.singleton(K[0], V[0]), getEmptyFeatures(), 1, false, true));
|
suite.addTest(mapSuite("SingletonMAP", (K, V) -> MAPS.singleton(K[0], V[0]), getEmptyFeatures(), 1, false));
|
||||||
suite.addTest(mapSuite("AbstractMap", SIMPLE_TEST_MAP::new, getTestFeatures(), -1, false, true));
|
suite.addTest(mapSuite("AbstractMap", SIMPLE_TEST_MAP::new, getTestFeatures(), -1, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -214,14 +209,14 @@ public class MAP_TESTS extends TestCase
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private static Test mapSuite(String name, BiFunction<KEY_STRING_TYPE[], VALUE_STRING_TYPE[], MAP KEY_VALUE_STRING_GENERIC_TYPE> factory, Collection<Feature<?>> features, int size, boolean sorted, boolean allowNullKeys) {
|
private static Test mapSuite(String name, BiFunction<KEY_STRING_TYPE[], VALUE_STRING_TYPE[], MAP KEY_VALUE_STRING_GENERIC_TYPE> factory, Collection<Feature<?>> features, int size, boolean sorted) {
|
||||||
SIMPLE_MAP_TEST_GENERATOR.Maps KEY_VALUE_STRING_GENERIC_TYPE generator = new SIMPLE_MAP_TEST_GENERATOR.Maps KEY_VALUE_STRING_GENERIC_TYPE(factory);
|
SIMPLE_MAP_TEST_GENERATOR.Maps KEY_VALUE_STRING_GENERIC_TYPE generator = new SIMPLE_MAP_TEST_GENERATOR.Maps KEY_VALUE_STRING_GENERIC_TYPE(factory);
|
||||||
MAP_TEST_BUILDER KEY_VALUE_STRING_GENERIC_TYPE builder = MAP_TEST_BUILDER.using(generator);
|
MAP_TEST_BUILDER KEY_VALUE_STRING_GENERIC_TYPE builder = MAP_TEST_BUILDER.using(generator);
|
||||||
builder.shouldBlockKeys(sorted);
|
builder.shouldBlockKeys(sorted);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
generator.setKeys(createKeys());
|
generator.setKeys(createKeys());
|
||||||
#ignore
|
#ignore
|
||||||
if(allowNullKeys) builder.withFeatures(MapFeature.ALLOWS_NULL_KEYS);
|
builder.withFeatures(MapFeature.ALLOWS_NULL_KEYS);
|
||||||
#endignore
|
#endignore
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
@@ -270,13 +265,13 @@ public class MAP_TESTS extends TestCase
|
|||||||
return builder.named(name).createTestSuite();
|
return builder.named(name).createTestSuite();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Test orderedMapSuite(String name, BiFunction<KEY_STRING_TYPE[], VALUE_STRING_TYPE[], ORDERED_MAP KEY_VALUE_STRING_GENERIC_TYPE> factory, Collection<Feature<?>> features, int size, boolean allowNullKeys) {
|
private static Test orderedMapSuite(String name, BiFunction<KEY_STRING_TYPE[], VALUE_STRING_TYPE[], ORDERED_MAP KEY_VALUE_STRING_GENERIC_TYPE> factory, Collection<Feature<?>> features, int size) {
|
||||||
SIMPLE_MAP_TEST_GENERATOR.OrderedMaps KEY_VALUE_STRING_GENERIC_TYPE generator = new SIMPLE_MAP_TEST_GENERATOR.OrderedMaps KEY_VALUE_STRING_GENERIC_TYPE(factory);
|
SIMPLE_MAP_TEST_GENERATOR.OrderedMaps KEY_VALUE_STRING_GENERIC_TYPE generator = new SIMPLE_MAP_TEST_GENERATOR.OrderedMaps KEY_VALUE_STRING_GENERIC_TYPE(factory);
|
||||||
ORDERED_MAP_TEST_BUILDER KEY_VALUE_STRING_GENERIC_TYPE builder = ORDERED_MAP_TEST_BUILDER.using(generator);
|
ORDERED_MAP_TEST_BUILDER KEY_VALUE_STRING_GENERIC_TYPE builder = ORDERED_MAP_TEST_BUILDER.using(generator);
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
generator.setKeys(createKeys());
|
generator.setKeys(createKeys());
|
||||||
#ignore
|
#ignore
|
||||||
if(allowNullKeys) builder.withFeatures(MapFeature.ALLOWS_NULL_KEYS);
|
builder.withFeatures(MapFeature.ALLOWS_NULL_KEYS);
|
||||||
#endignore
|
#endignore
|
||||||
#endif
|
#endif
|
||||||
#if VALUE_OBJECT
|
#if VALUE_OBJECT
|
||||||
|
|||||||
-318
@@ -1,318 +0,0 @@
|
|||||||
package speiger.src.collections.booleans.collections;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.AbstractCollection;
|
|
||||||
|
|
||||||
import speiger.src.collections.booleans.lists.BooleanListIterator;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ReverseBooleanOrderedCollection extends AbstractBooleanCollection implements BooleanOrderedCollection {
|
|
||||||
BooleanOrderedCollection collection;
|
|
||||||
Supplier<BooleanIterator> reverseIterator;
|
|
||||||
|
|
||||||
public ReverseBooleanOrderedCollection(BooleanOrderedCollection collection, Supplier<BooleanIterator> reverseIterator) {
|
|
||||||
this.collection = collection;
|
|
||||||
this.reverseIterator = reverseIterator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean add(boolean o) { return collection.add(o); }
|
|
||||||
@Override
|
|
||||||
public BooleanOrderedCollection reversed() { return collection; }
|
|
||||||
@Override
|
|
||||||
public void addFirst(boolean e) { collection.addLast(e); }
|
|
||||||
@Override
|
|
||||||
public void addLast(boolean e) { collection.addFirst(e); }
|
|
||||||
@Override
|
|
||||||
public boolean contains(boolean e) { return collection.contains(e); }
|
|
||||||
@Override
|
|
||||||
public boolean remBoolean(boolean e) { return collection.remBoolean(e); }
|
|
||||||
@Override
|
|
||||||
public void clear() { collection.clear(); }
|
|
||||||
@Override
|
|
||||||
public boolean getFirstBoolean() { return collection.getLastBoolean(); }
|
|
||||||
@Override
|
|
||||||
public boolean removeFirstBoolean() { return collection.removeLastBoolean(); }
|
|
||||||
@Override
|
|
||||||
public boolean getLastBoolean() { return collection.getFirstBoolean(); }
|
|
||||||
@Override
|
|
||||||
public boolean removeLastBoolean() { return collection.removeFirstBoolean(); }
|
|
||||||
@Override
|
|
||||||
public BooleanIterator iterator() { return reverseIterator.get(); }
|
|
||||||
@Override
|
|
||||||
public int size() { return collection.size(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ReverseBiIterator implements BooleanListIterator {
|
|
||||||
BooleanListIterator it;
|
|
||||||
|
|
||||||
public ReverseBiIterator(BooleanListIterator it) {
|
|
||||||
this.it = it;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nextBoolean() { return it.previousBoolean(); }
|
|
||||||
@Override
|
|
||||||
public boolean hasNext() { return it.hasPrevious(); }
|
|
||||||
@Override
|
|
||||||
public boolean hasPrevious() { return it.hasNext(); }
|
|
||||||
@Override
|
|
||||||
public boolean previousBoolean() { return it.nextBoolean(); }
|
|
||||||
@Override
|
|
||||||
public void remove() { it.remove(); }
|
|
||||||
@Override
|
|
||||||
public int nextIndex() { return it.previousIndex(); }
|
|
||||||
@Override
|
|
||||||
public int previousIndex() { return it.nextIndex(); }
|
|
||||||
@Override
|
|
||||||
public void set(boolean e) { it.set(e); }
|
|
||||||
@Override
|
|
||||||
public void add(boolean e) { it.add(e); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-52
@@ -1,52 +0,0 @@
|
|||||||
package speiger.src.collections.booleans.collections;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
public interface BooleanBidirectionalIterator extends BooleanIterator
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
* @return the Previous element of the iterator.+
|
|
||||||
*/
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
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); }
|
|
||||||
}
|
|
||||||
@@ -1,334 +0,0 @@
|
|||||||
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.OptionalBoolean;
|
|
||||||
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 OptionalBoolean findFirst(BooleanPredicate filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
for(BooleanIterator iter = iterator();iter.hasNext();) {
|
|
||||||
boolean entry = iter.nextBoolean();
|
|
||||||
if(filter.test(entry)) return OptionalBoolean.of(entry);
|
|
||||||
}
|
|
||||||
return OptionalBoolean.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 OptionalBoolean 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 empty ? OptionalBoolean.empty() : OptionalBoolean.of(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,88 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package speiger.src.collections.booleans.collections;
|
|
||||||
|
|
||||||
public interface BooleanOrderedCollection extends BooleanCollection {
|
|
||||||
|
|
||||||
BooleanOrderedCollection reversed();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the start of a collection
|
|
||||||
* @param e that should be added at the start.
|
|
||||||
*/
|
|
||||||
public void addFirst(boolean e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to add an element to the end of a collection
|
|
||||||
* @param e that should be added at the end.
|
|
||||||
*/
|
|
||||||
public void addLast(boolean e);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to get the first element in the collection
|
|
||||||
* @return first element in the collection
|
|
||||||
*/
|
|
||||||
public boolean getFirstBoolean();
|
|
||||||
/**
|
|
||||||
* A method to get and remove the first element in the collection
|
|
||||||
* @return first element in the collection
|
|
||||||
*/
|
|
||||||
public boolean removeFirstBoolean();
|
|
||||||
/**
|
|
||||||
* A method to get the last element in the collection
|
|
||||||
* @return last element in the collection
|
|
||||||
*/
|
|
||||||
public boolean getLastBoolean();
|
|
||||||
/**
|
|
||||||
* A method to get and remove the last element in the collection
|
|
||||||
* @return last element in the collection
|
|
||||||
*/
|
|
||||||
public boolean removeLastBoolean();
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
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); }
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
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));};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
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)); }
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
package speiger.src.collections.booleans.functions;
|
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public final class OptionalBoolean {
|
|
||||||
private static final OptionalBoolean EMPTY = new OptionalBoolean();
|
|
||||||
|
|
||||||
private final boolean isPresent;
|
|
||||||
private final boolean value;
|
|
||||||
|
|
||||||
private OptionalBoolean() {
|
|
||||||
this.isPresent = false;
|
|
||||||
this.value = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private OptionalBoolean(boolean value) {
|
|
||||||
this.isPresent = true;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OptionalBoolean empty() {
|
|
||||||
return EMPTY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static OptionalBoolean of(boolean value) {
|
|
||||||
return new OptionalBoolean(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getAsBoolean() {
|
|
||||||
if(!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPresent() {
|
|
||||||
return isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty() {
|
|
||||||
return !isPresent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresent(BooleanConsumer consumer) {
|
|
||||||
if(isPresent) consumer.accept(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ifPresentOrElse(BooleanConsumer action, Runnable emptyAction) {
|
|
||||||
if (isPresent) action.accept(value);
|
|
||||||
else emptyAction.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean orElse(boolean other) {
|
|
||||||
return isPresent ? value : other;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean orElseGet(BooleanSupplier other) {
|
|
||||||
return isPresent ? value : other.getAsBoolean();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean orElseThrow() {
|
|
||||||
if (!isPresent) throw new NoSuchElementException("No value present");
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <X extends Throwable> boolean orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
|
|
||||||
if(isPresent) return value;
|
|
||||||
else throw exceptionSupplier.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj == this) return true;
|
|
||||||
if(obj instanceof OptionalBoolean) {
|
|
||||||
OptionalBoolean other = (OptionalBoolean)obj;
|
|
||||||
return (isPresent && other.isPresent ? value == other.value : isPresent == other.isPresent);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return isPresent ? Boolean.hashCode(value) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return isPresent ? "OptionalBoolean["+value+"]" : "OptionalBoolean.empty";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,50 +0,0 @@
|
|||||||
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
@@ -1,49 +0,0 @@
|
|||||||
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
@@ -1,17 +0,0 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user