Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f6ffea14e | ||
|
|
9c09f2ee70 | ||
|
|
3fc6bed79a |
+1
-1
@@ -38,7 +38,7 @@
|
|||||||
<attribute name="gradle_used_by_scope" value="builder"/>
|
<attribute name="gradle_used_by_scope" value="builder"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||||
<classpathentry kind="output" path="bin/default"/>
|
<classpathentry kind="output" path="bin/default"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
+11
-3
@@ -11,15 +11,23 @@ gradle-app.setting
|
|||||||
|
|
||||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||||
# gradle/wrapper/gradle-wrapper.properties
|
# gradle/wrapper/gradle-wrapper.properties
|
||||||
|
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
|
|
||||||
---> Custom
|
# IntelliJ
|
||||||
|
|
||||||
|
.idea/
|
||||||
|
out/
|
||||||
|
*.iws
|
||||||
|
*.ipr
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
# ---> Custom
|
||||||
!/libs/
|
!/libs/
|
||||||
/.settings/
|
/.settings/
|
||||||
/bin/
|
/bin/
|
||||||
/storage/
|
/storage/
|
||||||
|
|
||||||
#Generated Code
|
#Generated Code
|
||||||
/src/main/java/speiger/src/collections/booleans/*
|
/src/main/java/speiger/src/collections/booleans/*
|
||||||
/src/main/java/speiger/src/collections/bytes/*
|
/src/main/java/speiger/src/collections/bytes/*
|
||||||
@@ -32,4 +40,4 @@ gradle-app.setting
|
|||||||
/src/main/java/speiger/src/collections/objects/*
|
/src/main/java/speiger/src/collections/objects/*
|
||||||
|
|
||||||
#Cache result
|
#Cache result
|
||||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
/src/builder/resources/speiger/assets/collections/cache.bin
|
||||||
|
|||||||
@@ -1,28 +1,5 @@
|
|||||||
# Changelog of versions
|
# Changelog of versions
|
||||||
|
|
||||||
### Version 0.4.4
|
|
||||||
- Fixed: ObjectArrayList.of was causing crashes because of a Poor implementation.
|
|
||||||
- Added: Unsorted HashMaps/Sets now throw Concurrent exceptions if they were modified during a rehash.
|
|
||||||
- Added: Array/Collection version of enqueue and enqueueFirst to PriorityQueues.
|
|
||||||
- Added: fillBuffer function into PrimitiveLists which allow to optimize JavaNio buffers if needed.
|
|
||||||
|
|
||||||
### Version 0.4.3
|
|
||||||
- Added: Wrapper now support the Optimized Lambda replacer functions to improve performance.
|
|
||||||
- Added: FIFO Queue has now a minimum capacity and that is now checked more consistently.
|
|
||||||
|
|
||||||
### Version 0.4.2
|
|
||||||
- Added: Lists/Sets/Maps/PriorityQueues are now copy-able. with the new copy() function.
|
|
||||||
Note: subLists/subMaps/subSets or synchronize/unmodifyable wrappers do not support that function.
|
|
||||||
- Fixed: PriorityQueues didn't implement: hashCode/equals/toString
|
|
||||||
|
|
||||||
### Version 0.4.1
|
|
||||||
- Changed: ForEach with input now provides input, value instead of value, input, this improves the usage of method references greatly
|
|
||||||
- Added: addAll with Array-types in collections.
|
|
||||||
- Added: Java Iterator/Iterable support for Stream replacing methods
|
|
||||||
- Added: Suppliers.
|
|
||||||
- Added: SupplyIfAbsent. It is ComputeIfAbsent but using suppliers
|
|
||||||
- Added: Count feature into Iterable
|
|
||||||
- Fixed: A couple bugs with the new StreamReplacing functions in LinkedCollections Iterating to Infinity
|
|
||||||
|
|
||||||
### Version 0.4.0
|
### Version 0.4.0
|
||||||
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
- Changed: Iterable specific helper functions were moved out of Iterators and moved into Iterables
|
||||||
|
|||||||
@@ -15,25 +15,19 @@ But its focus is a different one.
|
|||||||
- SplitIterators
|
- SplitIterators
|
||||||
- Iterators
|
- Iterators
|
||||||
- Pairs
|
- Pairs
|
||||||
- Unary/Functions
|
|
||||||
- Suppliers
|
|
||||||
- Bi/Consumers
|
|
||||||
|
|
||||||
## Specialized Functions
|
## Specialized Functions
|
||||||
New Specialized functions that were added to increase performance or reduce allocations or Quality Of life.
|
New Specialized functions that were added to increase performance or reduce allocations or Quality Of life.
|
||||||
To highlight things that may be wanted.
|
To highlight things that may be wanted.
|
||||||
- Iterable:
|
- Iterable:
|
||||||
- map/flatMap/arrayFlatMap: A Light weight version of Stream.map().
|
- map/flatMap/arrayFlatMap: A Light weight version of Stream.map()
|
||||||
- findFirst: Allows to find the first element of a Predicated Iterable.
|
- findFirst: Allows to find the first element of a Predicated Iterable.
|
||||||
- filter: Allows to filter unwanted elements for wrapped Iterable
|
- filter: Allows to filter unwanted elements for wrapped Iterable
|
||||||
- matchAny/matchNone/matchAll: Allows to find elements in a collection.
|
- matchAny/matchNone/matchAll: Allows to find elements in a collection.
|
||||||
- count: counts all valid elements in a collection.
|
|
||||||
- forEach: Allows to input a second element into a forEach move allowing for more flexibility for Method References
|
- forEach: Allows to input a second element into a forEach move allowing for more flexibility for Method References
|
||||||
- Collection:
|
- Collection:
|
||||||
- containsAny: Allows to test if another collection contains an of the elements of the tested collection.
|
- containsAny: Allows to test if another collection contains an of the elements of the tested collection.
|
||||||
- primitiveStream: Provides access to the closest Java Stream Type.
|
- primitiveStream: Provides access to the closest Java Stream Type.
|
||||||
- copy: shallowCopies the collection, used instead of clone because this is better to use.
|
|
||||||
(subCollections/synchronized/unmodifiable not supported for obvious reasons)
|
|
||||||
- List:
|
- List:
|
||||||
- add/get/removeElements (From FastUtil): Allows to add/get/remove an Array into/from a list. Just with less overhead
|
- add/get/removeElements (From FastUtil): Allows to add/get/remove an Array into/from a list. Just with less overhead
|
||||||
- extractElements: Allows to remove a Range of elements from the List and get what was removed.
|
- extractElements: Allows to remove a Range of elements from the List and get what was removed.
|
||||||
@@ -49,7 +43,6 @@ To highlight things that may be wanted.
|
|||||||
- addToAll: Same as addTo but bulkVersion.
|
- addToAll: Same as addTo but bulkVersion.
|
||||||
- removeOrDefault: removes a Element and if not present returns the default value instead of the present value.
|
- removeOrDefault: removes a Element and if not present returns the default value instead of the present value.
|
||||||
- mergeAll: BulkVersion of Merge function.
|
- mergeAll: BulkVersion of Merge function.
|
||||||
- supplyIfAbsent: A Supplier based computeIfAbsent
|
|
||||||
- Sorted Map:
|
- Sorted Map:
|
||||||
- addAndMoveToFirst/Last (From FastUtil but moved to Interface): Allows to add a element to the first/last position of a sorted Map.
|
- addAndMoveToFirst/Last (From FastUtil but moved to Interface): Allows to add a element to the first/last position of a sorted Map.
|
||||||
- moveToFirst/Last: Moves the desired element at the first/last position of the Map.
|
- moveToFirst/Last: Moves the desired element at the first/last position of the Map.
|
||||||
@@ -72,17 +65,13 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'de.speiger:Primitive-Collections:0.4.4'
|
compile 'de.speiger:Primitive-Collections:0.4.0'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
Direct:
|
Direct:
|
||||||
|
|
||||||
| Version | Jar | Sources | Java Doc |
|
| Version | Jar | Sources | Java Doc |
|
||||||
|--------- |------------------------------------------------------------------------------------------------------------------------------ |-------------------------------------------------------------------------------------------------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------- |
|
|--------- |------------------------------------------------------------------------------------------------------------------------------ |-------------------------------------------------------------------------------------------------------------------------------------- |-------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| 0.4.4 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.4/Primitive-Collections-0.4.4-javadoc.jar) |
|
|
||||||
| 0.4.3 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.3/Primitive-Collections-0.4.3-javadoc.jar) |
|
|
||||||
| 0.4.2 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.2/Primitive-Collections-0.4.2-javadoc.jar) |
|
|
||||||
| 0.4.1 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.1/Primitive-Collections-0.4.1-javadoc.jar) |
|
|
||||||
| 0.4.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-javadoc.jar) |
|
| 0.4.0 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.4.0/Primitive-Collections-0.4.0-javadoc.jar) |
|
||||||
| 0.3.6 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-javadoc.jar) |
|
| 0.3.6 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.6/Primitive-Collections-0.3.6-javadoc.jar) |
|
||||||
| 0.3.5 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5-javadoc.jar) |
|
| 0.3.5 | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5-sources.jar) | [Download](https://maven.speiger.com/repository/main/de/speiger/Primitive-Collections/0.3.5/Primitive-Collections-0.3.5-javadoc.jar) |
|
||||||
|
|||||||
+41
-19
@@ -1,9 +1,7 @@
|
|||||||
plugins {
|
buildscript {
|
||||||
id 'java-library'
|
def config = new Properties()
|
||||||
}
|
file('build.properties').withInputStream(config.&load)
|
||||||
|
project.ext.config = config
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.encoding = 'UTF-8'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
@@ -12,27 +10,52 @@ apply plugin: 'maven'
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
google()
|
||||||
|
|
||||||
maven {
|
maven {
|
||||||
url = "https://maven.speiger.com/repository/main"
|
url = "https://maven.speiger.com/repository/main"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = config.project_name
|
||||||
version = '0.4.4';
|
version = config.project_version
|
||||||
|
group = config.project_group
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
sourceCompatibility = config.java_source_version
|
||||||
|
targetCompatibility = config.java_target_version
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
options.tags = [ "implSpec", "note" ]
|
options.tags = [ "implSpec", "note" ]
|
||||||
|
failOnError = false
|
||||||
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
|
options.quiet()
|
||||||
}
|
}
|
||||||
|
|
||||||
eclipse {
|
eclipse {
|
||||||
classpath {
|
classpath {
|
||||||
downloadJavadoc = true
|
downloadJavadoc = true
|
||||||
downloadSources = true
|
downloadSources = true
|
||||||
|
|
||||||
|
file {
|
||||||
|
whenMerged {
|
||||||
|
//Enforce a custom container and allowing access to the sun.misc package which is nessesary for EnumMaps
|
||||||
|
entries.find{ it.kind == 'con' && it.path.startsWith('org.eclipse.jdt')}.path = 'org.eclipse.jdt.launching.JRE_CONTAINER';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
sourceCompatibility = config.java_source_version
|
||||||
|
targetCompatibility = config.java_target_version
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.compilerArgs << '-XDignore.symbol.file'
|
||||||
|
options.fork = true
|
||||||
|
options.forkOptions.executable = 'javac' // may not needed on 1.8
|
||||||
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
builder
|
builder
|
||||||
}
|
}
|
||||||
@@ -42,8 +65,11 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
builderCompile 'de.speiger:Simple-Code-Generator:1.0.5'
|
implementation group: 'org.jetbrains', name: 'annotations', version: config.annotations_version
|
||||||
runtimeOnly 'de.speiger:Simple-Code-Generator:1.0.5'
|
|
||||||
|
builderCompile group: 'de.speiger', name: 'Simple-Code-Generator', version: config.scg_version
|
||||||
|
runtimeOnly group: 'de.speiger', name: 'Simple-Code-Generator', version: config.scg_version
|
||||||
|
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,10 +98,6 @@ task srcJar(type: Jar) {
|
|||||||
classifier = 'sources'
|
classifier = 'sources'
|
||||||
}
|
}
|
||||||
|
|
||||||
javadoc.failOnError = false
|
|
||||||
javadoc.options.memberLevel = JavadocMemberLevel.PUBLIC
|
|
||||||
javadoc.options.quiet()
|
|
||||||
|
|
||||||
artifacts {
|
artifacts {
|
||||||
archives javadocJar
|
archives javadocJar
|
||||||
archives srcJar
|
archives srcJar
|
||||||
@@ -95,8 +117,8 @@ uploadArchives {
|
|||||||
}
|
}
|
||||||
pom {
|
pom {
|
||||||
version = project.version
|
version = project.version
|
||||||
artifactId = project.archivesBaseName.replace(" ", "-")
|
artifactId = config.artifact_id
|
||||||
groupId = 'de.speiger'
|
groupId = config.artifact_group
|
||||||
project {
|
project {
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
project_name=PrimitiveCollections
|
||||||
|
project_id=primitivecollections
|
||||||
|
project_group=speiger.src.collections
|
||||||
|
project_version=0.4.0
|
||||||
|
|
||||||
|
artifact_group=de.speiger
|
||||||
|
artifact_id=Primitive-Collections
|
||||||
|
|
||||||
|
java_source_version=11
|
||||||
|
java_target_version=8
|
||||||
|
annotations_version=22.0.0
|
||||||
|
|
||||||
|
scg_version=1.0.4
|
||||||
@@ -147,13 +147,11 @@ public class GlobalVariables
|
|||||||
{
|
{
|
||||||
addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate");
|
addSimpleMapper("JAVA_PREDICATE", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Predicate");
|
||||||
addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer");
|
addSimpleMapper("JAVA_CONSUMER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Consumer");
|
||||||
addSimpleMapper("JAVA_SUPPLIER", type.isPrimitiveBlocking() ? "" : "java.util.function."+type.getCustomJDKType().getFileType()+"Supplier");
|
|
||||||
addSimpleMapper("JAVA_FUNCTION", type.getFunctionClass(valueType));
|
addSimpleMapper("JAVA_FUNCTION", type.getFunctionClass(valueType));
|
||||||
addSimpleMapper("JAVA_BINARY_OPERATOR", type == ClassType.BOOLEAN ? "" : (type.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+type.getCustomJDKType().getFileType()+"BinaryOperator"));
|
addSimpleMapper("JAVA_BINARY_OPERATOR", type == ClassType.BOOLEAN ? "" : (type.isObject() ? "java.util.function.BinaryOperator" : "java.util.function."+type.getCustomJDKType().getFileType()+"BinaryOperator"));
|
||||||
addSimpleMapper("JAVA_UNARY_OPERATOR", type.isObject() ? "BinaryOperator" : type == ClassType.BOOLEAN ? "" : type.getCustomJDKType().getFileType()+"UnaryOperator");
|
addSimpleMapper("JAVA_UNARY_OPERATOR", type.isObject() ? "BinaryOperator" : type == ClassType.BOOLEAN ? "" : type.getCustomJDKType().getFileType()+"UnaryOperator");
|
||||||
addSimpleMapper("JAVA_SPLIT_ITERATOR", type.isPrimitiveBlocking() ? "Spliterator" : "Of"+type.getCustomJDKType().getFileType());
|
addSimpleMapper("JAVA_SPLIT_ITERATOR", type.isPrimitiveBlocking() ? "Spliterator" : "Of"+type.getCustomJDKType().getFileType());
|
||||||
addSimpleMapper("JAVA_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Stream");
|
addSimpleMapper("JAVA_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getFileType()+"Stream");
|
||||||
addSimpleMapper("JAVA_BUFFER", type.getFileType()+"Buffer");
|
|
||||||
|
|
||||||
//Final Classes
|
//Final Classes
|
||||||
addClassMapper("ARRAY_LIST", "ArrayList");
|
addClassMapper("ARRAY_LIST", "ArrayList");
|
||||||
@@ -185,7 +183,6 @@ public class GlobalVariables
|
|||||||
|
|
||||||
//Abstract Classes
|
//Abstract Classes
|
||||||
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
addAbstractMapper("ABSTRACT_COLLECTION", "Abstract%sCollection");
|
||||||
addAbstractMapper("ABSTRACT_PRIORITY_QUEUE", "Abstract%sPriorityQueue");
|
|
||||||
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
addAbstractMapper("ABSTRACT_SET", "Abstract%sSet");
|
||||||
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
addAbstractMapper("ABSTRACT_LIST", "Abstract%sList");
|
||||||
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
addAbstractBiMapper("ABSTRACT_MAP", "Abstract%sMap", "2");
|
||||||
@@ -206,8 +203,7 @@ public class GlobalVariables
|
|||||||
addClassMapper("LIST_ITERATOR", "ListIterator");
|
addClassMapper("LIST_ITERATOR", "ListIterator");
|
||||||
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
addClassMapper("BI_ITERATOR", "BidirectionalIterator");
|
||||||
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
addBiClassMapper("BI_CONSUMER", "Consumer", "");
|
||||||
addClassMapper("BI_TO_OBJECT_CONSUMER", "ObjectConsumer");
|
addClassMapper("BI_OBJECT_CONSUMER", "ObjectConsumer");
|
||||||
addAbstractMapper("BI_FROM_OBJECT_CONSUMER", "Object%sConsumer");
|
|
||||||
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
addClassMapper("SPLIT_ITERATOR", "Splititerator");
|
||||||
addClassMapper("ITERATOR", "Iterator");
|
addClassMapper("ITERATOR", "Iterator");
|
||||||
addClassMapper("ITERABLE", "Iterable");
|
addClassMapper("ITERABLE", "Iterable");
|
||||||
@@ -228,7 +224,6 @@ public class GlobalVariables
|
|||||||
addClassMapper("SET", "Set");
|
addClassMapper("SET", "Set");
|
||||||
addClassMapper("STRATEGY", "Strategy");
|
addClassMapper("STRATEGY", "Strategy");
|
||||||
addClassMapper("STACK", "Stack");
|
addClassMapper("STACK", "Stack");
|
||||||
addClassMapper("SUPPLIER", "Supplier");
|
|
||||||
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
addBiClassMapper("UNARY_OPERATOR", "UnaryOperator", "");
|
||||||
if(type.isObject())
|
if(type.isObject())
|
||||||
{
|
{
|
||||||
@@ -279,7 +274,6 @@ public class GlobalVariables
|
|||||||
addFunctionMapper("GET_KEY", "get");
|
addFunctionMapper("GET_KEY", "get");
|
||||||
if(type.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
if(type.isObject()) addFunctionValueMapper("GET_VALUE", valueType.isObject() ? "getObject" : "get");
|
||||||
else addSimpleMapper("GET_VALUE", "get");
|
else addSimpleMapper("GET_VALUE", "get");
|
||||||
addSimpleMapper("GET_JAVA", type.isObject() ? "get" : "getAs"+type.getCustomJDKType().getNonFileType());
|
|
||||||
addFunctionMapper("LAST_KEY", "last");
|
addFunctionMapper("LAST_KEY", "last");
|
||||||
addFunctionValueMapper("MERGE", "merge");
|
addFunctionValueMapper("MERGE", "merge");
|
||||||
addFunctionMapper("NEXT", "next");
|
addFunctionMapper("NEXT", "next");
|
||||||
@@ -292,7 +286,6 @@ public class GlobalVariables
|
|||||||
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
addFunctionValueMappers("REPLACE_VALUES", valueType.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
addFunctionMappers("REPLACE", type.isObject() ? "replaceObjects" : "replace%ss");
|
addFunctionMappers("REPLACE", type.isObject() ? "replaceObjects" : "replace%ss");
|
||||||
addFunctionMappers("SORT", "sort%ss");
|
addFunctionMappers("SORT", "sort%ss");
|
||||||
addFunctionValueMappers("SUPPLY_IF_ABSENT", "supply%sIfAbsent");
|
|
||||||
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
addSimpleMapper("VALUE_TEST_VALUE", valueType.isObject() ? "getBoolean" : "get");
|
||||||
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
addSimpleMapper("TEST_VALUE", type.isObject() ? "getBoolean" : "get");
|
||||||
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
addSimpleMapper("NEW_STREAM", type.isPrimitiveBlocking() ? "" : type.getCustomJDKType().getKeyType()+"Stream");
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
|||||||
nameRemapper.put("IArray", "I%sArray");
|
nameRemapper.put("IArray", "I%sArray");
|
||||||
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
nameRemapper.put("AbstractMap", "Abstract%sMap");
|
||||||
nameRemapper.put("AbstractCollection", "Abstract%sCollection");
|
nameRemapper.put("AbstractCollection", "Abstract%sCollection");
|
||||||
nameRemapper.put("AbstractPriorityQueue", "Abstract%sPriorityQueue");
|
|
||||||
nameRemapper.put("AbstractSet", "Abstract%sSet");
|
nameRemapper.put("AbstractSet", "Abstract%sSet");
|
||||||
nameRemapper.put("AbstractList", "Abstract%sList");
|
nameRemapper.put("AbstractList", "Abstract%sList");
|
||||||
nameRemapper.put("EnumMap", "Enum2%sMap");
|
nameRemapper.put("EnumMap", "Enum2%sMap");
|
||||||
|
|||||||
-3
@@ -35,9 +35,6 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
|||||||
+3
-41
@@ -9,8 +9,11 @@ import java.util.stream.JAVA_STREAM;
|
|||||||
import java.util.stream.StreamSupport;
|
import java.util.stream.StreamSupport;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
||||||
|
|
||||||
|
#if TYPE_BYTE || TYPE_SHORT || TYPE_CHAR || TYPE_FLOAT
|
||||||
import speiger.src.collections.utils.SanityChecks;
|
import speiger.src.collections.utils.SanityChecks;
|
||||||
|
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* A Type-Specific {@link Collection} that reduces (un)boxing
|
* A Type-Specific {@link Collection} that reduces (un)boxing
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -33,38 +36,6 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||||||
*/
|
*/
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
|
||||||
* @param e the elements that should be added
|
|
||||||
* @return if the collection was modified
|
|
||||||
*/
|
|
||||||
public default boolean addAll(KEY_TYPE... e) { return addAll(e, 0, e.length); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A Type-Specific Array based addAll method to reduce the amount of Wrapping
|
|
||||||
* @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(KEY_TYPE[] 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(KEY_TYPE[] 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific contains function to reduce (un)boxing
|
* A Type-Specific contains function to reduce (un)boxing
|
||||||
@@ -123,15 +94,6 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
|||||||
*/
|
*/
|
||||||
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
public boolean retainAll(COLLECTION KEY_GENERIC_TYPE c);
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 COLLECTION KEY_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
* A Type-Specific toArray function that delegates to {@link #TO_ARRAY(KEY_TYPE[])} with a newly created array.
|
||||||
|
|||||||
+2
-16
@@ -8,7 +8,7 @@ import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|||||||
import speiger.src.collections.objects.collections.ObjectIterable;
|
import speiger.src.collections.objects.collections.ObjectIterable;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.TO_OBJECT_FUNCTION;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
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;
|
||||||
@@ -66,7 +66,7 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
* @param <E> the generic type of the Object
|
* @param <E> the generic type of the Object
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
*/
|
*/
|
||||||
default <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
default <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
iterator().forEachRemaining(input, action);
|
iterator().forEachRemaining(input, action);
|
||||||
}
|
}
|
||||||
@@ -170,18 +170,4 @@ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable<CLASS_TYPE>
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function to reduce stream usage that allows to count the valid elements.
|
|
||||||
* @param filter that should be applied
|
|
||||||
* @return the amount of Valid Elements
|
|
||||||
*/
|
|
||||||
default int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = iterator();iter.hasNext();) {
|
|
||||||
if(filter.TEST_VALUE(iter.NEXT())) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -8,7 +8,7 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific {@link Iterator} that reduces (un)boxing
|
* A Type-Specific {@link Iterator} that reduces (un)boxing
|
||||||
@@ -74,9 +74,9 @@ public interface ITERATOR KEY_GENERIC_TYPE extends Iterator<CLASS_TYPE>
|
|||||||
* @param <E> the generic type of the Object
|
* @param <E> the generic type of the Object
|
||||||
* @throws java.lang.NullPointerException if the specified action is null
|
* @throws java.lang.NullPointerException if the specified action is null
|
||||||
*/
|
*/
|
||||||
default <E> void forEachRemaining(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
default <E> void forEachRemaining(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
while(hasNext()) { action.accept(input, NEXT()); }
|
while(hasNext()) { action.accept(NEXT(), input); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
package speiger.src.collections.PACKAGE.functions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type-Specific Supplier interface that reduces (un)boxing and allows to merge other consumer types into this interface
|
|
||||||
* @Type(T)
|
|
||||||
*/
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE extends java.util.function.Supplier<KEY_TYPE>
|
|
||||||
#else if JDK_TYPE && !TYPE_BOOLEAN
|
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE extends JAVA_SUPPLIER
|
|
||||||
#else
|
|
||||||
public interface SUPPLIER KEY_GENERIC_TYPE
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @return the supplied value
|
|
||||||
*/
|
|
||||||
public KEY_TYPE GET_KEY();
|
|
||||||
#if JDK_TYPE && PRIMITIVE
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public default KEY_TYPE GET_JAVA() {
|
|
||||||
return GET_KEY();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
-10
@@ -229,8 +229,6 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
while(size < size()) REMOVE(size() - 1);
|
while(size < size()) REMOVE(size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ABSTRACT_LIST KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
private class SUB_LIST extends ABSTRACT_LIST KEY_GENERIC_TYPE {
|
private class SUB_LIST extends ABSTRACT_LIST KEY_GENERIC_TYPE {
|
||||||
ABSTRACT_LIST KEY_GENERIC_TYPE l;
|
ABSTRACT_LIST KEY_GENERIC_TYPE l;
|
||||||
int offset;
|
int offset;
|
||||||
@@ -282,14 +280,6 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
|
||||||
if(length <= 0) return false;
|
|
||||||
l.addElements(this.offset, e, offset, length);
|
|
||||||
offset += length;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
checkRange(from);
|
checkRange(from);
|
||||||
|
|||||||
+5
-40
@@ -15,7 +15,6 @@ import java.util.function.UnaryOperator;
|
|||||||
#if PRIMITIVES
|
#if PRIMITIVES
|
||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
import java.nio.JAVA_BUFFER;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
@@ -27,7 +26,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
@@ -182,7 +181,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
*/
|
*/
|
||||||
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
public static GENERIC_KEY_BRACES ARRAY_LIST KEY_GENERIC_TYPE of(Class<KEY_TYPE> c) {
|
||||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
||||||
list.data = (KEY_TYPE[])ObjectArrays.newArray(c, 0);
|
list.data = (KEY_TYPE[])ObjectArrays.newArray(c.getClass().getComponentType(), 0);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,16 +282,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
|
||||||
if(length <= 0) return false;
|
|
||||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
|
||||||
grow(size + length);
|
|
||||||
System.arraycopy(e, offset, data, size, length);
|
|
||||||
size+=length;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appends the specified array elements to the index of the list.
|
* Appends the specified array elements to the index of the list.
|
||||||
* @param from the index where to append the elements to
|
* @param from the index where to append the elements to
|
||||||
@@ -389,15 +378,9 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
size -= length;
|
size -= length;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if PRIMITIVES
|
|
||||||
@Override
|
|
||||||
public void fillBuffer(JAVA_BUFFER buffer) {
|
|
||||||
buffer.put(data, 0, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function to find if the Element is present in this list.
|
* A function to find if the Element is present in this list.
|
||||||
* @param o the element that is searched for
|
* @param o the element that is searched for
|
||||||
@@ -608,10 +591,10 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
action.accept(input, data[i]);
|
action.accept(data[i], input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -650,16 +633,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific set function to reduce (un)boxing
|
* A Type-Specific set function to reduce (un)boxing
|
||||||
* @param index the index of the element to set
|
* @param index the index of the element to set
|
||||||
@@ -1022,14 +995,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
grow(size);
|
grow(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ARRAY_LIST KEY_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_LIST KEY_GENERIC_TYPE list = new ARRAY_LISTBRACES();
|
|
||||||
list.data = Arrays.copyOf(data, data.length);
|
|
||||||
list.size = size;
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void grow(int capacity) {
|
protected void grow(int capacity) {
|
||||||
if(capacity < data.length) return;
|
if(capacity < data.length) return;
|
||||||
data = Arrays.copyOf(data, data == ARRAYS.EMPTY_ARRAY ? Math.max(DEFAULT_ARRAY_SIZE, capacity) : (int)Math.max(Math.min((long)data.length + (data.length >> 1), SanityChecks.MAX_ARRAY_SIZE), capacity));
|
data = Arrays.copyOf(data, data == ARRAYS.EMPTY_ARRAY ? Math.max(DEFAULT_ARRAY_SIZE, capacity) : (int)Math.max(Math.min((long)data.length + (data.length >> 1), SanityChecks.MAX_ARRAY_SIZE), capacity));
|
||||||
|
|||||||
+3
-20
@@ -22,7 +22,7 @@ import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.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.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
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;
|
||||||
@@ -120,8 +120,6 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
@Override
|
@Override
|
||||||
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) { throw new UnsupportedOperationException(); }
|
public boolean addAll(int index, LIST KEY_GENERIC_TYPE c) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) { throw new UnsupportedOperationException(); }
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -261,11 +259,6 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
return data[index];
|
return data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMMUTABLE_LIST KEY_GENERIC_TYPE copy() {
|
|
||||||
return new IMMUTABLE_LISTBRACES(Arrays.copyOf(data, data.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific foreach function that reduces (un)boxing
|
* A Type Specific foreach function that reduces (un)boxing
|
||||||
*
|
*
|
||||||
@@ -288,10 +281,10 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0,m=data.length;i<m;i++)
|
for(int i = 0,m=data.length;i<m;i++)
|
||||||
action.accept(input, data[i]);
|
action.accept(data[i], input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -330,16 +323,6 @@ public class IMMUTABLE_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_T
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0,m=data.length;i<m;i++) {
|
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE set(int index, KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
public KEY_TYPE set(int index, KEY_TYPE e) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+3
-48
@@ -2,8 +2,6 @@ package speiger.src.collections.PACKAGE.lists;
|
|||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#else if PRIMITIVES
|
|
||||||
import java.nio.JAVA_BUFFER;
|
|
||||||
#endif
|
#endif
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -19,7 +17,7 @@ import java.util.function.UnaryOperator;
|
|||||||
import java.util.function.JAVA_PREDICATE;
|
import java.util.function.JAVA_PREDICATE;
|
||||||
import java.util.function.JAVA_UNARY_OPERATOR;
|
import java.util.function.JAVA_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -243,14 +241,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
add(e);
|
add(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) {
|
|
||||||
if(length <= 0) return false;
|
|
||||||
SanityChecks.checkArrayCapacity(e.length, offset, length);
|
|
||||||
for(int i = 0;i<length;i++) linkLast(e[offset+i]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length) {
|
||||||
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
SanityChecks.checkArrayCapacity(a.length, offset, length);
|
||||||
@@ -412,10 +402,10 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next)
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next)
|
||||||
action.accept(input, entry.value);
|
action.accept(entry.value, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -454,16 +444,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next) {
|
|
||||||
if(filter.TEST_VALUE(entry.value)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE set(int index, KEY_TYPE e) {
|
public KEY_TYPE set(int index, KEY_TYPE e) {
|
||||||
checkRange(index);
|
checkRange(index);
|
||||||
@@ -639,14 +619,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
#if PRIMITIVES
|
|
||||||
@Override
|
|
||||||
public void fillBuffer(JAVA_BUFFER buffer) {
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next)
|
|
||||||
buffer.put(entry.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
@@ -830,23 +802,6 @@ public class LINKED_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
|||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_LIST KEY_GENERIC_TYPE copy() {
|
|
||||||
LINKED_LIST KEY_GENERIC_TYPE list = new LINKED_LISTBRACES();
|
|
||||||
list.size = size;
|
|
||||||
if(first != null) {
|
|
||||||
list.first = new EntryBRACES(first.value, null, null);
|
|
||||||
Entry KEY_GENERIC_TYPE lastReturned = list.first;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first.next;entry != null;entry = entry.next) {
|
|
||||||
Entry KEY_GENERIC_TYPE next = new EntryBRACES(entry.value, lastReturned, null);
|
|
||||||
lastReturned.next = next;
|
|
||||||
lastReturned = next;
|
|
||||||
}
|
|
||||||
list.last = lastReturned;
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Entry KEY_GENERIC_TYPE getNode(int index) {
|
protected Entry KEY_GENERIC_TYPE getNode(int index) {
|
||||||
if(index < size >> 2) {
|
if(index < size >> 2) {
|
||||||
Entry KEY_GENERIC_TYPE x = first;
|
Entry KEY_GENERIC_TYPE x = first;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package speiger.src.collections.PACKAGE.lists;
|
package speiger.src.collections.PACKAGE.lists;
|
||||||
|
|
||||||
#if PRIMITIVES
|
|
||||||
import java.nio.JAVA_BUFFER;
|
|
||||||
#endif
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
#if !TYPE_OBJECT && !TYPE_BOOLEAN
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -172,6 +169,7 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
* @param offset the start index of the array should be read from
|
* @param offset the start index of the array should be read from
|
||||||
* @param length how many elements should be read from
|
* @param length how many elements should be read from
|
||||||
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
* @throws IndexOutOfBoundsException if from is outside of the lists range
|
||||||
|
* @throws IllegalStateException if offset or length are smaller then 0 or exceed the array length
|
||||||
*/
|
*/
|
||||||
public void addElements(int from, KEY_TYPE[] a, int offset, int length);
|
public void addElements(int from, KEY_TYPE[] a, int offset, int length);
|
||||||
|
|
||||||
@@ -258,14 +256,6 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
*/
|
*/
|
||||||
public KEY_TYPE[] extractElements(int from, int to);
|
public KEY_TYPE[] extractElements(int from, int to);
|
||||||
|
|
||||||
#if PRIMITIVES
|
|
||||||
/**
|
|
||||||
* Helper function that allows to fastFill a buffer reducing the duplication requirement
|
|
||||||
* @param buffer where the data should be stored in.
|
|
||||||
*/
|
|
||||||
public default void fillBuffer(JAVA_BUFFER buffer) { buffer.put(TO_ARRAY()); }
|
|
||||||
|
|
||||||
#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.
|
||||||
@@ -350,8 +340,6 @@ public interface LIST KEY_GENERIC_TYPE extends COLLECTION KEY_GENERIC_TYPE, List
|
|||||||
*/
|
*/
|
||||||
public void size(int size);
|
public void size(int size);
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST KEY_GENERIC_TYPE copy();
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
|
|||||||
-20
@@ -18,7 +18,6 @@ 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.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#endif
|
#endif
|
||||||
@@ -47,11 +46,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -195,20 +189,6 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Objects.requireNonNull(valueProvider);
|
|
||||||
VALUE_TYPE value;
|
|
||||||
if((value = GET_VALUE(key)) == getDefaultReturnValue() || !containsKey(key)) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS_NOT(newValue, getDefaultReturnValue())) {
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Objects.requireNonNull(mappingFunction);
|
Objects.requireNonNull(mappingFunction);
|
||||||
|
|||||||
+10
-76
@@ -1,6 +1,5 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -11,7 +10,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -40,10 +41,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -337,23 +335,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_CUSTOM_HASH_MAPKV_BRACES(0, loadFactor, strategy);
|
|
||||||
map.minCapacity = minCapacity;
|
|
||||||
map.mask = mask;
|
|
||||||
map.maxFill = maxFill;
|
|
||||||
map.nullIndex = nullIndex;
|
|
||||||
map.containsNull = containsNull;
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, values.length);
|
|
||||||
map.links = Arrays.copyOf(links, links.length);
|
|
||||||
map.firstIndex = firstIndex;
|
|
||||||
map.lastIndex = lastIndex;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -671,9 +652,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return new FastEntryIterator(fromElement);
|
return new FastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
@@ -695,12 +673,12 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, new BasicEntryKV_BRACES(keys[index], values[index]));
|
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]), input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -761,21 +739,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
entry.set(keys[index], values[index]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
@@ -882,9 +845,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return new KeyIterator(fromElement);
|
return new KeyIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return LINKED_CUSTOM_HASH_MAP.this.size();
|
return LINKED_CUSTOM_HASH_MAP.this.size();
|
||||||
@@ -925,12 +885,12 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -983,19 +943,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
@@ -1054,12 +1001,12 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, values[index]);
|
action.accept(values[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1111,19 +1058,6 @@ public class LINKED_CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends CUSTOM_HASH_M
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
|
|||||||
+14
-92
@@ -1,7 +1,6 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
package speiger.src.collections.PACKAGE.maps.impl.customHash;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
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;
|
||||||
@@ -10,11 +9,13 @@ import java.util.function.Consumer;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -30,7 +31,6 @@ import speiger.src.collections.PACKAGE.sets.SET;
|
|||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@@ -47,10 +47,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@@ -424,20 +421,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new CUSTOM_HASH_MAPKV_BRACES(0, loadFactor, strategy);
|
|
||||||
map.minCapacity = minCapacity;
|
|
||||||
map.mask = mask;
|
|
||||||
map.maxFill = maxFill;
|
|
||||||
map.nullIndex = nullIndex;
|
|
||||||
map.containsNull = containsNull;
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, values.length);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -511,18 +494,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
@@ -668,10 +639,7 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||||
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
||||||
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||||
while(true) {
|
while(strategy.equals(keys[--i], EMPTY_KEY_VALUE));
|
||||||
if(--i < 0) throw new ConcurrentModificationException("Map was modified during rehash");
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) break;
|
|
||||||
}
|
|
||||||
if(!strategy.equals(newKeys[pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask], EMPTY_KEY_VALUE))
|
if(!strategy.equals(newKeys[pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask], EMPTY_KEY_VALUE))
|
||||||
while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_KEY_VALUE));
|
while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_KEY_VALUE));
|
||||||
newKeys[pos] = keys[i];
|
newKeys[pos] = keys[i];
|
||||||
@@ -811,12 +779,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
if(containsNull) action.accept(new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]), input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(new BasicEntryKV_BRACES(keys[i], values[i]), input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -892,25 +860,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull) {
|
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) {
|
|
||||||
entry.set(keys[i], values[i]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return CUSTOM_HASH_MAP.this.size();
|
return CUSTOM_HASH_MAP.this.size();
|
||||||
@@ -982,9 +931,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
return new KeyIterator();
|
return new KeyIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return CUSTOM_HASH_MAP.this.size();
|
return CUSTOM_HASH_MAP.this.size();
|
||||||
@@ -1003,12 +949,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1055,18 +1001,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -1111,12 +1045,12 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, values[nullIndex]);
|
if(containsNull) action.accept(values[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, values[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(values[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1163,18 +1097,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
|||||||
+10
-76
@@ -1,6 +1,5 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -11,7 +10,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
#if !TYPE_OBJECT || VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -39,10 +40,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -314,23 +312,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_HASH_MAPKV_BRACES(0, loadFactor);
|
|
||||||
map.minCapacity = minCapacity;
|
|
||||||
map.mask = mask;
|
|
||||||
map.maxFill = maxFill;
|
|
||||||
map.nullIndex = nullIndex;
|
|
||||||
map.containsNull = containsNull;
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, values.length);
|
|
||||||
map.links = Arrays.copyOf(links, links.length);
|
|
||||||
map.firstIndex = firstIndex;
|
|
||||||
map.lastIndex = lastIndex;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -648,9 +629,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return new FastEntryIterator(fromElement);
|
return new FastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
@@ -672,12 +650,12 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, new BasicEntryKV_BRACES(keys[index], values[index]));
|
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]), input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -738,21 +716,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
entry.set(keys[index], values[index]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
@@ -859,9 +822,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return new KeyIterator(fromElement);
|
return new KeyIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return LINKED_HASH_MAP.this.size();
|
return LINKED_HASH_MAP.this.size();
|
||||||
@@ -902,12 +862,12 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -960,19 +920,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.TEST_VALUE(keys[index])) return result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
@@ -1032,12 +979,12 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, values[index]);
|
action.accept(values[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1089,19 +1036,6 @@ public class LINKED_HASH_MAP KEY_VALUE_GENERIC_TYPE extends HASH_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
|
|||||||
+16
-94
@@ -1,7 +1,6 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
package speiger.src.collections.PACKAGE.maps.impl.hash;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
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;
|
||||||
@@ -10,11 +9,13 @@ import java.util.function.Consumer;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
import speiger.src.collections.PACKAGE.functions.function.FUNCTION;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
import speiger.src.collections.PACKAGE.functions.function.UNARY_OPERATOR;
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
@@ -29,10 +30,8 @@ import speiger.src.collections.PACKAGE.sets.SET;
|
|||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
|
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_CONSUMER;
|
||||||
@@ -47,9 +46,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
@@ -384,21 +381,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return slot < 0 ? defaultValue : values[slot];
|
return slot < 0 ? defaultValue : values[slot];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
HASH_MAP KEY_VALUE_GENERIC_TYPE map = new HASH_MAPKV_BRACES(0, loadFactor);
|
|
||||||
map.minCapacity = minCapacity;
|
|
||||||
map.mask = mask;
|
|
||||||
map.maxFill = maxFill;
|
|
||||||
map.nullIndex = nullIndex;
|
|
||||||
map.containsNull = containsNull;
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, values.length);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new MapEntrySet();
|
if(entrySet == null) entrySet = new MapEntrySet();
|
||||||
@@ -472,19 +455,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index < 0) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insert(-index-1, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
@@ -628,10 +599,7 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||||
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
VALUE_TYPE[] newValues = NEW_VALUE_ARRAY(newSize + 1);
|
||||||
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||||
while(true) {
|
while(KEY_EQUALS_NULL(keys[--i]));
|
||||||
if(--i < 0) throw new ConcurrentModificationException("Map was modified during rehash");
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) break;
|
|
||||||
}
|
|
||||||
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
||||||
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
||||||
newKeys[pos] = keys[i];
|
newKeys[pos] = keys[i];
|
||||||
@@ -771,12 +739,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]));
|
if(containsNull) action.accept(new BasicEntryKV_BRACES(keys[nullIndex], values[nullIndex]), input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(new BasicEntryKV_BRACES(keys[i], values[i]), input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,25 +820,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull) {
|
|
||||||
entry.set(keys[nullIndex], values[nullIndex]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) {
|
|
||||||
entry.set(keys[i], values[i]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return HASH_MAP.this.size();
|
return HASH_MAP.this.size();
|
||||||
@@ -952,9 +901,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
HASH_MAP.this.clear();
|
HASH_MAP.this.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
if(containsNull) action.accept(keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex]);
|
||||||
@@ -963,12 +909,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1015,18 +961,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
private class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -1071,12 +1005,12 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, values[nullIndex]);
|
if(containsNull) action.accept(values[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, values[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(values[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1123,18 +1057,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.VALUE_TEST_VALUE(values[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.VALUE_TEST_VALUE(values[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class FastEntryIterator extends MapIterator implements ObjectIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
|
|||||||
+12
-88
@@ -1,8 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.maps.impl.immutable;
|
package speiger.src.collections.PACKAGE.maps.impl.immutable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@@ -11,7 +10,9 @@ import java.util.function.Consumer;
|
|||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -37,10 +38,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -50,7 +48,6 @@ import speiger.src.collections.PACKAGE.sets.SET;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@@ -104,10 +101,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
/** Amount of Elements stored in the HashMap */
|
/** Amount of Elements stored in the HashMap */
|
||||||
protected int size;
|
protected int size;
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper constructor for copying the Map
|
|
||||||
*/
|
|
||||||
protected IMMUTABLE_HASH_MAP() {}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT || !VALUE_OBJECT
|
#if !TYPE_OBJECT || !VALUE_OBJECT
|
||||||
/**
|
/**
|
||||||
@@ -417,21 +410,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
return valuesC;
|
return valuesC;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE map = new IMMUTABLE_HASH_MAPKV_BRACES();
|
|
||||||
map.mask = mask;
|
|
||||||
map.nullIndex = nullIndex;
|
|
||||||
map.containsNull = containsNull;
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, values.length);
|
|
||||||
map.links = Arrays.copyOf(links, links.length);
|
|
||||||
map.firstIndex = firstIndex;
|
|
||||||
map.lastIndex = lastIndex;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
@Override
|
@Override
|
||||||
@@ -461,10 +439,7 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@@ -609,9 +584,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
return new FastEntryIterator(fromElement);
|
return new FastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
@@ -633,12 +605,12 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, new BasicEntryKV_BRACES(keys[index], values[index]));
|
action.accept(new BasicEntryKV_BRACES(keys[index], values[index]), input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -652,7 +624,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return true;
|
if(filter.getBoolean(entry)) return true;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -666,7 +637,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return false;
|
if(filter.getBoolean(entry)) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -680,7 +650,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(!filter.getBoolean(entry)) return false;
|
if(!filter.getBoolean(entry)) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -694,26 +663,10 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
entry.set(keys[index], values[index]);
|
entry.set(keys[index], values[index]);
|
||||||
if(filter.getBoolean(entry)) return entry;
|
if(filter.getBoolean(entry)) return entry;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
entry.set(keys[index], values[index]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
@@ -796,9 +749,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
return new KeyIterator(fromElement);
|
return new KeyIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return IMMUTABLE_HASH_MAP.this.size();
|
return IMMUTABLE_HASH_MAP.this.size();
|
||||||
@@ -833,12 +783,12 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -891,19 +841,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
int result = 0;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
@@ -960,12 +897,12 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1){
|
while(index != -1){
|
||||||
action.accept(input, values[index]);
|
action.accept(values[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1017,19 +954,6 @@ public class IMMUTABLE_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1){
|
|
||||||
if(filter.VALUE_TEST_VALUE(values[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
|
|||||||
+15
-121
@@ -11,7 +11,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -30,7 +32,6 @@ import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@@ -47,10 +48,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !VALUE_OBJECT
|
#if !VALUE_OBJECT
|
||||||
@@ -487,19 +485,7 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
int index = findIndex(key);
|
|
||||||
if(index == -1) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
insertIndex(size++, key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
return values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
int index = findIndex(key);
|
int index = findIndex(key);
|
||||||
@@ -554,14 +540,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ARRAY_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_MAP KEY_VALUE_GENERIC_TYPE map = new ARRAY_MAPKV_BRACES();
|
|
||||||
map.size = size;
|
|
||||||
map.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
map.values = Arrays.copyOf(values, keys.length);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -989,11 +967,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return entrySet;
|
return entrySet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMap copy() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -1146,9 +1119,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return new SubFastEntryIterator(fromElement);
|
return new SubFastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1168,10 +1138,10 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<length;i++)
|
for(int i = 0;i<length;i++)
|
||||||
action.accept(input, new BasicEntryKV_BRACES(keys[offset+i], values[offset+i]));
|
action.accept(new BasicEntryKV_BRACES(keys[offset+i], values[offset+i]), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1222,19 +1192,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
for(int i = 0;i<length;i++) {
|
|
||||||
entry.set(keys[offset+i], values[offset+i]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
@@ -1332,9 +1289,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubKeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1342,10 +1296,10 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
for(int i = 0;i<length;action.accept(input, keys[offset+i]));
|
for(int i = 0;i<length;action.accept(keys[offset+i], input));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1389,17 +1343,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<length;i++) {
|
|
||||||
if(filter.TEST_VALUE(keys[i+offset])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
@Override
|
@Override
|
||||||
@@ -1451,9 +1394,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<length;action.accept(input, values[offset+i]));
|
for(int i = 0;i<length;action.accept(values[offset+i], input));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1492,16 +1435,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<length;i++) {
|
|
||||||
if(filter.VALUE_TEST_VALUE(values[offset+i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SubFastEntryIterator extends SubMapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
private class SubFastEntryIterator extends SubMapIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
@@ -1717,9 +1650,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return new FastEntryIterator(fromElement);
|
return new FastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1739,10 +1669,10 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
action.accept(input, new BasicEntryKV_BRACES(keys[i], values[i]));
|
action.accept(new BasicEntryKV_BRACES(keys[i], values[i]), input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1794,19 +1724,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE entry = new BasicEntryKV_BRACES();
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
entry.set(keys[i], values[i]);
|
|
||||||
if(filter.getBoolean(entry)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
@@ -1904,9 +1821,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
public KEY_TYPE POLL_LAST_KEY() { return POLL_LAST_ENTRY_KEY(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1914,9 +1828,9 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<size;action.accept(input, keys[i++]));
|
for(int i = 0;i<size;action.accept(keys[i++], input));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1957,16 +1871,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(keys[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
@Override
|
@Override
|
||||||
@@ -2052,16 +1956,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.VALUE_TEST_VALUE(values[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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> {
|
||||||
|
|||||||
-9
@@ -176,15 +176,6 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public ENUM_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
ENUM_MAP KEY_VALUE_GENERIC_TYPE map = new ENUM_MAPKV_BRACES(keyType);
|
|
||||||
map.size = size;
|
|
||||||
System.arraycopy(present, 0, map.present, 0, Math.min(present.length, map.present.length));
|
|
||||||
System.arraycopy(values, 0, map.values, 0, Math.min(values.length, map.values.length));
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||||
if(entrySet == null) entrySet = new EntrySet();
|
if(entrySet == null) entrySet = new EntrySet();
|
||||||
|
|||||||
-16
@@ -127,18 +127,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
return values[index];
|
return values[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
LINKED_ENUM_MAP KEY_VALUE_GENERIC_TYPE map = new LINKED_ENUM_MAPKV_BRACES(keyType);
|
|
||||||
map.size = size;
|
|
||||||
System.arraycopy(present, 0, map.present, 0, Math.min(present.length, map.present.length));
|
|
||||||
System.arraycopy(values, 0, map.values, 0, Math.min(values.length, map.values.length));
|
|
||||||
System.arraycopy(links, 0, map.links, 0, Math.min(links.length, map.links.length));
|
|
||||||
map.firstIndex = firstIndex;
|
|
||||||
map.lastIndex = lastIndex;
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -363,8 +351,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
return new FastEntryIterator(fromElement);
|
return new FastEntryIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapEntrySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public void forEach(Consumer<? super MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
@@ -491,8 +477,6 @@ public class LINKED_ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ENUM_MAP KEY_VA
|
|||||||
return new KeyIterator(fromElement);
|
return new KeyIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeySet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int size() {
|
public int size() {
|
||||||
return LINKED_ENUM_MAP.this.size();
|
return LINKED_ENUM_MAP.this.size();
|
||||||
|
|||||||
+15
-104
@@ -12,7 +12,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -33,7 +35,6 @@ import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
||||||
@@ -51,10 +52,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@@ -530,18 +528,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
@@ -610,21 +596,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
return new KeyIterator(findNode(key));
|
return new KeyIterator(findNode(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE set = new AVL_TREE_MAPKV_BRACES();
|
|
||||||
set.size = size;
|
|
||||||
if(tree != null) {
|
|
||||||
set.tree = tree.copy();
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE lastFound = null;
|
|
||||||
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
|
||||||
set.first = lastFound;
|
|
||||||
lastFound = null;
|
|
||||||
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
|
||||||
set.last = lastFound;
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
@@ -1148,8 +1119,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
@Override
|
|
||||||
public NavigableSubMap KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
@Override
|
@Override
|
||||||
@@ -1517,10 +1487,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1570,19 +1540,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
|
||||||
subEntry.set(entry.key, entry.value);
|
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -1623,10 +1580,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
action.accept(input, entry.value);
|
action.accept(entry.value, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1660,15 +1617,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
@@ -1851,10 +1799,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1968,9 +1916,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public KeySet KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
||||||
return new KeySetKV_BRACES(m.subMap(fromElement, fromInclusive, toElement, toInclusive));
|
return new KeySetKV_BRACES(m.subMap(fromElement, fromInclusive, toElement, toInclusive));
|
||||||
@@ -2047,10 +1992,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2084,15 +2029,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -2134,10 +2070,10 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, entry.value);
|
action.accept(entry.value, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2171,15 +2107,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(AVL_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
@@ -2339,22 +2266,6 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = new EntryKV_BRACES(key, value, null);
|
|
||||||
entry.state = state;
|
|
||||||
if(left != null) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE newLeft = left.copy();
|
|
||||||
entry.left = newLeft;
|
|
||||||
newLeft.parent = entry;
|
|
||||||
}
|
|
||||||
if(right != null) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE newRight = right.copy();
|
|
||||||
entry.right = newRight;
|
|
||||||
newRight.parent = entry;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ENTRY_KEY() {
|
public KEY_TYPE ENTRY_KEY() {
|
||||||
return key;
|
return key;
|
||||||
|
|||||||
+14
-117
@@ -12,7 +12,9 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
#endif
|
||||||
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
#if !TYPE_OBJECT && !VALUE_BOOLEAN
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
@@ -33,7 +35,6 @@ import speiger.src.collections.PACKAGE.utils.maps.MAPS;
|
|||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ABSTRACT_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_COLLECTION;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.collections.VALUE_ITERATOR;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
#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;
|
||||||
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.lists.VALUE_LIST_ITERATOR;
|
||||||
@@ -51,10 +52,7 @@ import speiger.src.collections.objects.functions.function.Object2BooleanFunction
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
#if !TYPE_OBJECT
|
import speiger.src.collections.VALUE_PACKAGE.functions.consumer.VALUE_BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.objects.functions.consumer.VALUE_BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_PREDICATE;
|
||||||
#endif
|
#endif
|
||||||
#if !TYPE_OBJECT && !VALUE_OBJECT
|
#if !TYPE_OBJECT && !VALUE_OBJECT
|
||||||
@@ -529,18 +527,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return entry.value;
|
return entry.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
|
||||||
if(entry == null) {
|
|
||||||
VALUE_TYPE newValue = valueProvider.VALUE_GET_KEY();
|
|
||||||
if(VALUE_EQUALS(newValue, getDefaultReturnValue())) return newValue;
|
|
||||||
put(key, newValue);
|
|
||||||
return newValue;
|
|
||||||
}
|
|
||||||
return entry.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
public VALUE_TYPE COMPUTE_IF_PRESENT(KEY_TYPE key, UNARY_OPERATOR KEY_VALUE_GENERIC_TYPE mappingFunction) {
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
Entry KEY_VALUE_GENERIC_TYPE entry = findNode(key);
|
||||||
@@ -609,21 +595,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
return new KeyIterator(findNode(key));
|
return new KeyIterator(findNode(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public RB_TREE_MAP KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
RB_TREE_MAP KEY_VALUE_GENERIC_TYPE set = new RB_TREE_MAPKV_BRACES();
|
|
||||||
set.size = size;
|
|
||||||
if(tree != null) {
|
|
||||||
set.tree = tree.copy();
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE lastFound = null;
|
|
||||||
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
|
||||||
set.first = lastFound;
|
|
||||||
lastFound = null;
|
|
||||||
for(Entry KEY_VALUE_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
|
||||||
set.last = lastFound;
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
public SORTED_SET KEY_GENERIC_TYPE keySet() {
|
||||||
return navigableKeySet();
|
return navigableKeySet();
|
||||||
@@ -1202,8 +1173,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE next(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
abstract RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE previous(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry);
|
||||||
|
|
||||||
@Override
|
|
||||||
public NavigableSubMap KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
@Override
|
||||||
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public abstract NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
@Override
|
@Override
|
||||||
@@ -1571,10 +1540,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1624,19 +1593,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry)) {
|
|
||||||
subEntry.set(entry.key, entry.value);
|
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
final class SubMapValues extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -1677,10 +1633,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
||||||
action.accept(input, entry.value);
|
action.accept(entry.value, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1714,15 +1670,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = findLowest(), last = findHighest();entry != null && (last == null || last != previous(entry));entry = next(entry))
|
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
final class SubMapEntrySetIterator extends SubMapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
@@ -1905,10 +1852,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, ObjectObjectConsumer<E, MAP.Entry KEY_VALUE_GENERIC_TYPE> action) {
|
public <E> void forEach(E input, ObjectObjectConsumer<MAP.Entry KEY_VALUE_GENERIC_TYPE, E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, new BasicEntryKV_BRACES(entry.key, entry.value));
|
action.accept(new BasicEntryKV_BRACES(entry.key, entry.value), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1958,19 +1905,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(Object2BooleanFunction<MAP.Entry KEY_VALUE_GENERIC_TYPE> filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
BasicEntry KEY_VALUE_GENERIC_TYPE subEntry = new BasicEntryKV_BRACES();
|
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
|
||||||
subEntry.set(entry.key, entry.value);
|
|
||||||
if(filter.getBoolean(subEntry)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static final class KeySet KEY_VALUE_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE {
|
static final class KeySet KEY_VALUE_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE implements NAVIGABLE_SET KEY_GENERIC_TYPE {
|
||||||
@@ -2035,9 +1969,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public KeySet KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) {
|
||||||
return new KeySetKV_BRACES(m.subMap(fromElement, fromInclusive, toElement, toInclusive));
|
return new KeySetKV_BRACES(m.subMap(fromElement, fromInclusive, toElement, toInclusive));
|
||||||
@@ -2114,10 +2045,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2151,15 +2082,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
if(filter.TEST_VALUE(entry.key)) return entry.key;
|
||||||
return EMPTY_KEY_VALUE;
|
return EMPTY_KEY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = start(), end = end();entry != null && (end == null || (end != previous(entry)));entry = next(entry))
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
final class Values extends VALUE_ABSTRACT_COLLECTION VALUE_GENERIC_TYPE {
|
||||||
@@ -2201,10 +2123,10 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, VALUE_BI_FROM_OBJECT_CONSUMER VSV_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, VALUE_BI_OBJECT_CONSUMER VVS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, entry.value);
|
action.accept(entry.value, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -2238,15 +2160,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
if(filter.VALUE_TEST_VALUE(entry.value)) return entry.value;
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(VALUE_PREDICATE VALUE_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(RB_TREE_MAP.Entry KEY_VALUE_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
|
||||||
if(filter.VALUE_TEST_VALUE(entry.value)) result++;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
final class EntryIterator extends MapEntryIterator implements ObjectListIterator<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||||
@@ -2408,22 +2321,6 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE copy() {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE entry = new EntryKV_BRACES(key, value, null);
|
|
||||||
entry.state = state;
|
|
||||||
if(left != null) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE newLeft = left.copy();
|
|
||||||
entry.left = newLeft;
|
|
||||||
newLeft.parent = entry;
|
|
||||||
}
|
|
||||||
if(right != null) {
|
|
||||||
Entry KEY_VALUE_GENERIC_TYPE newRight = right.copy();
|
|
||||||
entry.right = newRight;
|
|
||||||
newRight.parent = entry;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE ENTRY_KEY() {
|
public KEY_TYPE ENTRY_KEY() {
|
||||||
return key;
|
return key;
|
||||||
|
|||||||
-18
@@ -33,7 +33,6 @@ import speiger.src.collections.PACKAGE.sets.SET;
|
|||||||
#if !SAME_TYPE
|
#if !SAME_TYPE
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
import speiger.src.collections.VALUE_PACKAGE.functions.function.VALUE_UNARY_OPERATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.VALUE_PACKAGE.functions.VALUE_SUPPLIER;
|
|
||||||
import speiger.src.collections.objects.collections.ObjectIterator;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.objects.sets.ObjectSet;
|
import speiger.src.collections.objects.sets.ObjectSet;
|
||||||
@@ -59,15 +58,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
*/
|
*/
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v);
|
public MAP KEY_VALUE_GENERIC_TYPE setDefaultReturnValue(VALUE_TYPE v);
|
||||||
|
|
||||||
/**
|
|
||||||
* A Function that does a shallow clone of the Map itself.
|
|
||||||
* This function is more optimized then a copy constructor since the Map does not have to be unsorted/resorted.
|
|
||||||
* It can be compared to Cloneable but with less exception risk
|
|
||||||
* @return a Shallow Copy of the Map
|
|
||||||
* @note Wrappers and view Maps will not support this feature
|
|
||||||
*/
|
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type Specific method to reduce boxing/unboxing of values
|
* Type Specific method to reduce boxing/unboxing of values
|
||||||
* @param key the key that should be inserted,
|
* @param key the key that should be inserted,
|
||||||
@@ -277,14 +267,6 @@ public interface MAP KEY_VALUE_GENERIC_TYPE extends Map<CLASS_TYPE, CLASS_VALUE_
|
|||||||
* @return the result of the computed value or present value
|
* @return the result of the computed value or present value
|
||||||
*/
|
*/
|
||||||
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
public VALUE_TYPE COMPUTE_IF_ABSENT(KEY_TYPE key, FUNCTION KEY_VALUE_GENERIC_TYPE mappingFunction);
|
||||||
|
|
||||||
/**
|
|
||||||
* A Supplier based computeIfAbsent function to fill the most used usecase of this function
|
|
||||||
* @param key the key that should be computed
|
|
||||||
* @param valueProvider the value if not present
|
|
||||||
* @return the result of the computed value or present value
|
|
||||||
*/
|
|
||||||
public VALUE_TYPE SUPPLY_IF_ABSENT(KEY_TYPE key, VALUE_SUPPLIER VALUE_GENERIC_TYPE valueProvider);
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific compute method to reduce boxing/unboxing
|
* A Type Specific compute method to reduce boxing/unboxing
|
||||||
* @param key the key that should be computed
|
* @param key the key that should be computed
|
||||||
|
|||||||
-2
@@ -10,8 +10,6 @@ import speiger.src.collections.PACKAGE.sets.NAVIGABLE_SET;
|
|||||||
*/
|
*/
|
||||||
public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VALUE_GENERIC_TYPE, NavigableMap<CLASS_TYPE, CLASS_VALUE_TYPE>
|
public interface NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE extends SORTED_MAP KEY_VALUE_GENERIC_TYPE, NavigableMap<CLASS_TYPE, CLASS_VALUE_TYPE>
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy();
|
|
||||||
/** @return a Type Specific desendingMap */
|
/** @return a Type Specific desendingMap */
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE descendingMap();
|
||||||
|
|||||||
-3
@@ -75,9 +75,6 @@ public interface SORTED_MAP KEY_VALUE_GENERIC_TYPE extends SortedMap<CLASS_TYPE,
|
|||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
||||||
|
|
||||||
@Override
|
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet();
|
public SET KEY_GENERIC_TYPE keySet();
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-46
@@ -1,46 +0,0 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.Objects;
|
|
||||||
#endif
|
|
||||||
import java.util.StringJoiner;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper class that implements all the essential methods for the PriorityQueues
|
|
||||||
* @Type(T)
|
|
||||||
*/
|
|
||||||
public abstract class ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj instanceof PRIORITY_QUEUE) {
|
|
||||||
PRIORITY_QUEUE KEY_GENERIC_TYPE queue = (PRIORITY_QUEUE KEY_GENERIC_TYPE)obj;
|
|
||||||
if(queue.size() != size()) return false;
|
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
|
||||||
if(KEY_EQUALS_NOT(queue.peek(i), peek(i))) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = 1;
|
|
||||||
for (int i = 0,m=size();i<m;i++) {
|
|
||||||
result = 31 * result + KEY_TO_HASH(peek(i));
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
if(isEmpty()) return "[]";
|
|
||||||
StringJoiner joiner = new StringJoiner(", ", "[", "]");
|
|
||||||
for (int i = 0,m=size();i<m;i++) {
|
|
||||||
joiner.add(KEY_TO_STRING(peek(i)));
|
|
||||||
}
|
|
||||||
return joiner.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+10
-35
@@ -1,7 +1,7 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
@@ -13,7 +13,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import speiger.src.collections.utils.ITrimmable;
|
|||||||
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
* Its specific implementation uses a backing array that grows and shrinks as it is needed.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE implements PRIORITY_DEQUEUE KEY_GENERIC_TYPE, ITrimmable
|
||||||
{
|
{
|
||||||
/** Max Possible ArraySize without the JVM Crashing */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
@@ -34,8 +34,6 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
protected int first;
|
protected int first;
|
||||||
/** The Last Index pointer */
|
/** The Last Index pointer */
|
||||||
protected int last;
|
protected int last;
|
||||||
/** The Minimum Capacity of the Queue **/
|
|
||||||
protected int minCapacity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor using a initial array
|
* Constructor using a initial array
|
||||||
@@ -64,9 +62,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
public ARRAY_FIFO_QUEUE(KEY_TYPE[] values, int offset, int size) {
|
||||||
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
if (values.length < size) throw new IllegalArgumentException("Initial array (" + values.length + ") is smaller then the expected size (" + size + ")");
|
||||||
if(values.length <= 0) values = NEW_KEY_ARRAY(MIN_CAPACITY);
|
if(values.length <= 0) values = NEW_KEY_ARRAY(1);
|
||||||
else if(values.length < MIN_CAPACITY) values = Arrays.copyOf(values, MIN_CAPACITY);
|
|
||||||
minCapacity = MIN_CAPACITY;
|
|
||||||
array = values;
|
array = values;
|
||||||
first = offset;
|
first = offset;
|
||||||
last = (offset + size) % array.length;
|
last = (offset + size) % array.length;
|
||||||
@@ -80,8 +76,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
*/
|
*/
|
||||||
public ARRAY_FIFO_QUEUE(int capacity) {
|
public ARRAY_FIFO_QUEUE(int capacity) {
|
||||||
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative");
|
||||||
array = NEW_KEY_ARRAY(Math.max(MIN_CAPACITY, capacity));
|
array = NEW_KEY_ARRAY(Math.max(1, capacity));
|
||||||
minCapacity = array.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,16 +222,6 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
@Override
|
@Override
|
||||||
public void onChanged() {}
|
public void onChanged() {}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_FIFO_QUEUEBRACES();
|
|
||||||
queue.first = first;
|
|
||||||
queue.last = last;
|
|
||||||
queue.minCapacity = minCapacity;
|
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
@@ -250,11 +235,11 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(first == last) return;
|
if(first == last) return;
|
||||||
for(int i = 0,m=size();i<m;i++)
|
for(int i = 0,m=size();i<m;i++)
|
||||||
action.accept(input, array[(first + i) % array.length]);
|
action.accept(array[(first + i) % array.length], input);
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,19 +284,9 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0,m=size();i<m;i++) {
|
|
||||||
if(filter.TEST_VALUE(array[(first + i) % array.length])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trim(int size) {
|
public boolean trim(int size) {
|
||||||
int newSize = Math.max(Math.max(size, size()), minCapacity);
|
int newSize = Math.max(size, size());
|
||||||
if(newSize >= array.length) return false;
|
if(newSize >= array.length) return false;
|
||||||
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
KEY_TYPE[] newArray = NEW_KEY_ARRAY(newSize);
|
||||||
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
if(first <= last) System.arraycopy(array, first, newArray, 0, last - first);
|
||||||
@@ -332,7 +307,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void clearAndTrim(int size) {
|
public void clearAndTrim(int size) {
|
||||||
int newSize = Math.max(minCapacity, size);
|
int newSize = Math.max(MIN_CAPACITY, size);
|
||||||
if(array.length <= newSize) {
|
if(array.length <= newSize) {
|
||||||
clear();
|
clear();
|
||||||
return;
|
return;
|
||||||
@@ -354,7 +329,7 @@ public class ARRAY_FIFO_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE K
|
|||||||
|
|
||||||
protected void reduce() {
|
protected void reduce() {
|
||||||
final int size = size();
|
final int size = size();
|
||||||
if (array.length > minCapacity && size <= array.length / 4) resize(size, Math.max(array.length / 2, minCapacity));
|
if (array.length > MIN_CAPACITY && size <= array.length / 4) resize(size, array.length / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expand() {
|
protected void expand() {
|
||||||
|
|||||||
+4
-24
@@ -14,7 +14,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
|||||||
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
* It is highly suggested to use HeapPriorityQueue otherwise, unless you know why you need this specific implementation
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
@@ -262,9 +262,9 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue(), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -307,31 +307,11 @@ public class ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new Iter();
|
return new Iter();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new ARRAY_PRIORITY_QUEUEBRACES();
|
|
||||||
queue.firstIndex = firstIndex;
|
|
||||||
queue.size = size;
|
|
||||||
queue.comparator = comparator;
|
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
return comparator;
|
return comparator;
|
||||||
|
|||||||
+4
-23
@@ -14,7 +14,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
|||||||
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
* It is a ArrayBased Alternative to TreeSets that has less object allocations
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEUE KEY_GENERIC_TYPE
|
public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE implements PRIORITY_QUEUE KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
/** The Backing Array */
|
/** The Backing Array */
|
||||||
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
protected transient KEY_TYPE[] array = EMPTY_KEY_ARRAY;
|
||||||
@@ -249,9 +249,9 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0,m=size;i<m;i++) action.accept(input, dequeue());
|
for(int i = 0,m=size;i<m;i++) action.accept(dequeue(), input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -294,16 +294,6 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(array[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean removeIndex(int index) {
|
protected boolean removeIndex(int index) {
|
||||||
array[index] = array[--size];
|
array[index] = array[--size];
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -319,15 +309,6 @@ public class HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE extends ABSTRACT_PRIORITY_QUEU
|
|||||||
ARRAYS.shiftDown(array, size, 0, comparator);
|
ARRAYS.shiftDown(array, size, 0, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE copy() {
|
|
||||||
HEAP_PRIORITY_QUEUE KEY_GENERIC_TYPE queue = new HEAP_PRIORITY_QUEUEBRACES();
|
|
||||||
queue.size = size;
|
|
||||||
queue.comparator = comparator;
|
|
||||||
queue.array = Arrays.copyOf(array, array.length);
|
|
||||||
return queue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() {
|
||||||
return comparator;
|
return comparator;
|
||||||
|
|||||||
-60
@@ -1,12 +1,5 @@
|
|||||||
package speiger.src.collections.PACKAGE.queues;
|
package speiger.src.collections.PACKAGE.queues;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
* A Type Speciifc PriorityDeque or Dequeue interface to allow implementations like FIFO queues.
|
||||||
* @Type(T)
|
* @Type(T)
|
||||||
@@ -18,56 +11,6 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
* @param e the element that should be inserted into the first place
|
* @param e the element that should be inserted into the first place
|
||||||
*/
|
*/
|
||||||
public void enqueueFirst(KEY_TYPE e);
|
public void enqueueFirst(KEY_TYPE e);
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert a elements into the first Index of the PriorityDequeue.
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAllFirst(KEY_TYPE... e) {
|
|
||||||
enqueueAllFirst(e, 0, e.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert a elements into the first Index of the PriorityDequeue.
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
* @param length the amount of elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAllFirst(KEY_TYPE[] e, int length) {
|
|
||||||
enqueueAllFirst(e, 0, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert a elements into the first Index of the PriorityDequeue.
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
* @param offset the offset where in the array should be started
|
|
||||||
* @param length the amount of elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAllFirst(KEY_TYPE[] e, int offset, int length) {
|
|
||||||
for(int i = 0;i<length;i++)
|
|
||||||
enqueueFirst(e[i+offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into first Index of the PriorityDequeue.
|
|
||||||
* @param c the elements that should be inserted from the Collection
|
|
||||||
*/
|
|
||||||
public default void enqueueAllFirst(COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
|
||||||
enqueueFirst(iter.NEXT());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into first Index of the PriorityDequeue.
|
|
||||||
* This method exists to add support for Java Collections to make it more useable
|
|
||||||
* @param c the elements that should be inserted from the Collection
|
|
||||||
*/
|
|
||||||
public default void enqueueAllFirst(Collection<? extends CLASS_TYPE> c) {
|
|
||||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
|
||||||
enqueueFirst(iter.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
/**
|
/**
|
||||||
* A Method to remove a element from the last place instead of the first
|
* A Method to remove a element from the last place instead of the first
|
||||||
* @return the last element inserted
|
* @return the last element inserted
|
||||||
@@ -79,7 +22,4 @@ public interface PRIORITY_DEQUEUE KEY_GENERIC_TYPE extends PRIORITY_QUEUE KEY_GE
|
|||||||
* @return the Last Element within the dequeue without deleting it
|
* @return the Last Element within the dequeue without deleting it
|
||||||
*/
|
*/
|
||||||
public default KEY_TYPE last() { return peek(size()-1); }
|
public default KEY_TYPE last() { return peek(size()-1); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy();
|
|
||||||
}
|
}
|
||||||
+1
-64
@@ -2,14 +2,11 @@ package speiger.src.collections.PACKAGE.queues;
|
|||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Collection;
|
import speiger.src.collections.objects.collections.ObjectIterator;
|
||||||
import java.util.Iterator;
|
|
||||||
#else
|
#else
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
import speiger.src.collections.PACKAGE.collections.ITERABLE;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
* A Simple PriorityQueue (or Queue) interface that provides with the nessesary functions to interact with it, without cluttering with the Collection interface.
|
||||||
@@ -36,57 +33,6 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
* @param e the element that should be inserted
|
* @param e the element that should be inserted
|
||||||
*/
|
*/
|
||||||
public void enqueue(KEY_TYPE e);
|
public void enqueue(KEY_TYPE e);
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAll(KEY_TYPE... e) {
|
|
||||||
enqueueAll(e, 0, e.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
* @param length the amount of elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int length) {
|
|
||||||
enqueueAll(e, 0, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
|
||||||
* @param e the elements that should be inserted
|
|
||||||
* @param offset the offset where in the array should be started
|
|
||||||
* @param length the amount of elements that should be inserted
|
|
||||||
*/
|
|
||||||
public default void enqueueAll(KEY_TYPE[] e, int offset, int length) {
|
|
||||||
for(int i = 0;i<length;i++)
|
|
||||||
enqueue(e[i+offset]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
|
||||||
* @param c the elements that should be inserted from the Collection
|
|
||||||
*/
|
|
||||||
public default void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) {
|
|
||||||
for(ITERATOR KEY_GENERIC_TYPE iter = c.iterator();iter.hasNext();)
|
|
||||||
enqueue(iter.NEXT());
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
/**
|
|
||||||
* Method to mass insert elements into the PriorityQueue
|
|
||||||
* This method exists to add support for Java Collections to make it more useable
|
|
||||||
* @param c the elements that should be inserted from the Collection
|
|
||||||
*/
|
|
||||||
public default void enqueueAll(Collection<? extends CLASS_TYPE> c) {
|
|
||||||
for(Iterator<? extends CLASS_TYPE> iter = c.iterator();iter.hasNext();)
|
|
||||||
enqueue(iter.next());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to extract a element from the PriorityQueue
|
* Method to extract a element from the PriorityQueue
|
||||||
* @return a element from the Queue
|
* @return a element from the Queue
|
||||||
@@ -124,15 +70,6 @@ public interface PRIORITY_QUEUE KEY_GENERIC_TYPE extends ITERABLE KEY_GENERIC_TY
|
|||||||
*/
|
*/
|
||||||
public void onChanged();
|
public void onChanged();
|
||||||
|
|
||||||
/**
|
|
||||||
* A Function that does a shallow clone of the PriorityQueue itself.
|
|
||||||
* This function is more optimized then a copy constructor since the PriorityQueue does not have to be unsorted/resorted.
|
|
||||||
* It can be compared to Cloneable but with less exception risk
|
|
||||||
* @return a Shallow Copy of the PriorityQueue
|
|
||||||
* @note Wrappers and view PriorityQueues will not support this feature
|
|
||||||
*/
|
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the sorter of the Queue, can be null
|
* @return the sorter of the Queue, can be null
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-59
@@ -13,7 +13,7 @@ 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
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.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;
|
||||||
@@ -304,10 +304,10 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -346,16 +346,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
||||||
Entry KEY_GENERIC_TYPE node = tree;
|
Entry KEY_GENERIC_TYPE node = tree;
|
||||||
int compare;
|
int compare;
|
||||||
@@ -538,21 +528,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
tree = null;
|
tree = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AVL_TREE_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
AVL_TREE_SET KEY_GENERIC_TYPE set = new AVL_TREE_SETBRACES();
|
|
||||||
set.size = size;
|
|
||||||
if(tree != null) {
|
|
||||||
set.tree = tree.copy();
|
|
||||||
Entry KEY_GENERIC_TYPE lastFound = null;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
|
||||||
set.first = lastFound;
|
|
||||||
lastFound = null;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
|
||||||
set.last = lastFound;
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||||
|
|
||||||
@@ -1024,9 +999,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return fromStart && toEnd ? set.size() : iterator().skip(Integer.MAX_VALUE);
|
return fromStart && toEnd ? set.size() : iterator().skip(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubSet KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1036,10 +1008,10 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
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))
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1078,16 +1050,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE previous;
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
@@ -1268,22 +1230,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry KEY_GENERIC_TYPE copy() {
|
|
||||||
Entry KEY_GENERIC_TYPE entry = new EntryBRACES(key, null);
|
|
||||||
entry.state = state;
|
|
||||||
if(left != null) {
|
|
||||||
Entry KEY_GENERIC_TYPE newLeft = left.copy();
|
|
||||||
entry.left = newLeft;
|
|
||||||
newLeft.parent = entry;
|
|
||||||
}
|
|
||||||
if(right != null) {
|
|
||||||
Entry KEY_GENERIC_TYPE newRight = right.copy();
|
|
||||||
entry.right = newRight;
|
|
||||||
newRight.parent = entry;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getHeight() { return state; }
|
int getHeight() { return state; }
|
||||||
|
|
||||||
void updateHeight() { state = (1 + Math.max(left == null ? -1 : left.getHeight(), right == null ? -1 : right.getHeight())); }
|
void updateHeight() { state = (1 + Math.max(left == null ? -1 : left.getHeight(), right == null ? -1 : right.getHeight())); }
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
@Override
|
|
||||||
public ABSTRACT_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
@@ -350,10 +350,10 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(int i = 0;i<size;i++)
|
for(int i = 0;i<size;i++)
|
||||||
action.accept(input, data[i]);
|
action.accept(data[i], input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -392,16 +392,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(int i = 0;i<size;i++) {
|
|
||||||
if(filter.TEST_VALUE(data[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
protected int findIndex(KEY_TYPE o) {
|
protected int findIndex(KEY_TYPE o) {
|
||||||
for(int i = size-1;i>=0;i--)
|
for(int i = size-1;i>=0;i--)
|
||||||
@@ -450,13 +440,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
return new SubSet(fromIndex, size - fromIndex);
|
return new SubSet(fromIndex, size - fromIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ARRAY_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
ARRAY_SET KEY_GENERIC_TYPE set = new ARRAY_SETBRACES();
|
|
||||||
set.data = Arrays.copyOf(data, data.length);
|
|
||||||
set.size = size;
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
public COMPARATOR KEY_GENERIC_TYPE comparator() {
|
||||||
return null;
|
return null;
|
||||||
@@ -682,10 +665,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||||||
if(index != -1) return new SetIterator(index);
|
if(index != -1) return new SetIterator(index);
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubSet copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) {
|
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) {
|
||||||
int fromIndex = findIndex(fromElement);
|
int fromIndex = findIndex(fromElement);
|
||||||
|
|||||||
+3
-40
@@ -4,7 +4,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -17,7 +16,7 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
import speiger.src.collections.PACKAGE.functions.COMPARATOR;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
@@ -51,12 +50,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
/** The Last Index in the Map */
|
/** The Last Index in the Map */
|
||||||
protected int lastIndex = -1;
|
protected int lastIndex = -1;
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper constructor to optimize the copying
|
|
||||||
* Only accessible through implementations
|
|
||||||
*/
|
|
||||||
protected IMMUTABLE_HASH_SET() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper constructor that allow to create a set from unboxed values
|
* Helper constructor that allow to create a set from unboxed values
|
||||||
* @param array the elements that should be put into the set
|
* @param array the elements that should be put into the set
|
||||||
@@ -304,11 +297,11 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -319,7 +312,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.TEST_VALUE(keys[index])) return true;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -330,7 +322,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -341,7 +332,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -352,23 +342,10 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator();
|
return new SetIterator();
|
||||||
@@ -379,20 +356,6 @@ public class IMMUTABLE_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERI
|
|||||||
return new SetIterator(fromElement);
|
return new SetIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMMUTABLE_HASH_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
IMMUTABLE_HASH_SET KEY_GENERIC_TYPE set = new IMMUTABLE_HASH_SETBRACES();
|
|
||||||
set.containsNull = containsNull;
|
|
||||||
set.firstIndex = firstIndex;
|
|
||||||
set.lastIndex = lastIndex;
|
|
||||||
set.size = size;
|
|
||||||
set.mask = mask;
|
|
||||||
set.nullIndex = nullIndex;
|
|
||||||
set.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
set.links = Arrays.copyOf(links, links.length);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
|
|||||||
+3
-36
@@ -4,7 +4,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -23,7 +22,7 @@ import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
@@ -535,11 +534,11 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -550,7 +549,6 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.TEST_VALUE(keys[index])) return true;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -561,7 +559,6 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -572,7 +569,6 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -583,23 +579,10 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator();
|
return new SetIterator();
|
||||||
@@ -610,22 +593,6 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
|||||||
return new SetIterator(fromElement);
|
return new SetIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE set = new LINKED_CUSTOM_HASH_SETBRACES(0, loadFactor, strategy);
|
|
||||||
set.minCapacity = minCapacity;
|
|
||||||
set.mask = mask;
|
|
||||||
set.maxFill = maxFill;
|
|
||||||
set.nullIndex = nullIndex;
|
|
||||||
set.containsNull = containsNull;
|
|
||||||
set.size = size;
|
|
||||||
set.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
set.links = Arrays.copyOf(links, links.length);
|
|
||||||
set.firstIndex = firstIndex;
|
|
||||||
set.lastIndex = lastIndex;
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
|
|||||||
+3
-36
@@ -3,7 +3,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
#endif
|
#endif
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
@@ -21,7 +20,7 @@ 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
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
import speiger.src.collections.PACKAGE.lists.LIST_ITERATOR;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -390,11 +389,11 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
action.accept(input, keys[index]);
|
action.accept(keys[index], input);
|
||||||
index = (int)links[index];
|
index = (int)links[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -405,7 +404,6 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return true;
|
if(filter.TEST_VALUE(keys[index])) return true;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -416,7 +414,6 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return false;
|
if(filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -427,7 +424,6 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(!filter.TEST_VALUE(keys[index])) return false;
|
if(!filter.TEST_VALUE(keys[index])) return false;
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -438,23 +434,10 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
int index = firstIndex;
|
int index = firstIndex;
|
||||||
while(index != -1) {
|
while(index != -1) {
|
||||||
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
if(filter.TEST_VALUE(keys[index])) return keys[index];
|
||||||
index = (int)links[index];
|
|
||||||
}
|
}
|
||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
int index = firstIndex;
|
|
||||||
while(index != -1) {
|
|
||||||
if(filter.TEST_VALUE(keys[index])) result++;
|
|
||||||
index = (int)links[index];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNodeAdded(int pos) {
|
protected void onNodeAdded(int pos) {
|
||||||
if(size == 0) {
|
if(size == 0) {
|
||||||
@@ -581,22 +564,6 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
|||||||
return new SetIterator(fromElement);
|
return new SetIterator(fromElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public LINKED_HASH_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
LINKED_HASH_SET KEY_GENERIC_TYPE set = new LINKED_HASH_SETBRACES(0, loadFactor);
|
|
||||||
set.minCapacity = minCapacity;
|
|
||||||
set.mask = mask;
|
|
||||||
set.maxFill = maxFill;
|
|
||||||
set.nullIndex = nullIndex;
|
|
||||||
set.containsNull = containsNull;
|
|
||||||
set.size = size;
|
|
||||||
set.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
set.links = Arrays.copyOf(links, links.length);
|
|
||||||
set.firstIndex = firstIndex;
|
|
||||||
set.lastIndex = lastIndex;
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return null; }
|
||||||
|
|
||||||
|
|||||||
@@ -115,8 +115,6 @@ public interface NAVIGABLE_SET KEY_GENERIC_TYPE extends NavigableSet<CLASS_TYPE>
|
|||||||
/** @return a Type Specific desendingSet */
|
/** @return a Type Specific desendingSet */
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet();
|
public NAVIGABLE_SET KEY_GENERIC_TYPE descendingSet();
|
||||||
@Override
|
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
* A Type Specific Type Splititerator to reduce boxing/unboxing
|
||||||
|
|||||||
+5
-34
@@ -2,7 +2,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
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;
|
||||||
@@ -18,7 +17,7 @@ import speiger.src.collections.PACKAGE.lists.LIST;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
import speiger.src.collections.PACKAGE.utils.STRATEGY;
|
||||||
|
|
||||||
@@ -430,10 +429,7 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
int newMask = newSize - 1;
|
int newMask = newSize - 1;
|
||||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||||
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||||
while(true) {
|
while(strategy.equals(keys[--i], EMPTY_KEY_VALUE));
|
||||||
if(--i < 0) throw new ConcurrentModificationException("Set was modified during rehash");
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) break;
|
|
||||||
}
|
|
||||||
if(!strategy.equals(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask], EMPTY_KEY_VALUE))
|
if(!strategy.equals(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask], EMPTY_KEY_VALUE))
|
||||||
while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_KEY_VALUE));
|
while(!strategy.equals(newKeys[pos = (++pos & newMask)], EMPTY_KEY_VALUE));
|
||||||
newKeys[pos] = keys[i];
|
newKeys[pos] = keys[i];
|
||||||
@@ -449,19 +445,6 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
return new SetIterator();
|
return new SetIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CUSTOM_HASH_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
CUSTOM_HASH_SET KEY_GENERIC_TYPE set = new CUSTOM_HASH_SETBRACES(0, loadFactor, strategy);
|
|
||||||
set.minCapacity = minCapacity;
|
|
||||||
set.mask = mask;
|
|
||||||
set.maxFill = maxFill;
|
|
||||||
set.nullIndex = nullIndex;
|
|
||||||
set.containsNull = containsNull;
|
|
||||||
set.size = size;
|
|
||||||
set.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(size == 0) return;
|
if(size == 0) return;
|
||||||
@@ -485,12 +468,12 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(input, keys[i]);
|
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE)) action.accept(keys[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -538,18 +521,6 @@ public class CUSTOM_HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_T
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(!strategy.equals(keys[i], EMPTY_KEY_VALUE) && filter.TEST_VALUE(keys[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SetIterator implements ITERATOR KEY_GENERIC_TYPE {
|
private class SetIterator implements ITERATOR KEY_GENERIC_TYPE {
|
||||||
int pos = nullIndex;
|
int pos = nullIndex;
|
||||||
int lastReturned = -1;
|
int lastReturned = -1;
|
||||||
|
|||||||
+5
-34
@@ -2,7 +2,6 @@ package speiger.src.collections.PACKAGE.sets;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
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;
|
||||||
@@ -18,7 +17,7 @@ import speiger.src.collections.PACKAGE.lists.LIST;
|
|||||||
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
import speiger.src.collections.PACKAGE.utils.ITERATORS;
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
||||||
import speiger.src.collections.utils.HashUtil;
|
import speiger.src.collections.utils.HashUtil;
|
||||||
import speiger.src.collections.utils.ITrimmable;
|
import speiger.src.collections.utils.ITrimmable;
|
||||||
@@ -338,12 +337,12 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
if(size() <= 0) return;
|
if(size() <= 0) return;
|
||||||
if(containsNull) action.accept(input, keys[nullIndex]);
|
if(containsNull) action.accept(keys[nullIndex], input);
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
for(int i = nullIndex-1;i>=0;i--) {
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(input, keys[i]);
|
if(KEY_EQUALS_NOT_NULL(keys[i])) action.accept(keys[i], input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,18 +390,6 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
if(size() <= 0) return 0;
|
|
||||||
int result = 0;
|
|
||||||
if(containsNull && filter.TEST_VALUE(keys[nullIndex])) result++;
|
|
||||||
for(int i = nullIndex-1;i>=0;i--) {
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i]) && filter.TEST_VALUE(keys[i])) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureCapacity(int newCapacity) {
|
private void ensureCapacity(int newCapacity) {
|
||||||
int size = HashUtil.arraySize(newCapacity, loadFactor);
|
int size = HashUtil.arraySize(newCapacity, loadFactor);
|
||||||
if(size > nullIndex) rehash(size);
|
if(size > nullIndex) rehash(size);
|
||||||
@@ -462,10 +449,7 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
int newMask = newSize - 1;
|
int newMask = newSize - 1;
|
||||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||||
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
for(int i = nullIndex, pos = 0, j = (size - (containsNull ? 1 : 0));j-- != 0;) {
|
||||||
while(true) {
|
while(KEY_EQUALS_NULL(keys[--i]));
|
||||||
if(--i < 0) throw new ConcurrentModificationException("Set was modified during rehash");
|
|
||||||
if(KEY_EQUALS_NOT_NULL(keys[i])) break;
|
|
||||||
}
|
|
||||||
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
if(KEY_EQUALS_NOT_NULL(newKeys[pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask]))
|
||||||
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
while(KEY_EQUALS_NOT_NULL(newKeys[pos = (++pos & newMask)]));
|
||||||
newKeys[pos] = keys[i];
|
newKeys[pos] = keys[i];
|
||||||
@@ -481,19 +465,6 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
|||||||
return new SetIterator();
|
return new SetIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HASH_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
HASH_SET KEY_GENERIC_TYPE set = new HASH_SETBRACES(0, loadFactor);
|
|
||||||
set.minCapacity = minCapacity;
|
|
||||||
set.mask = mask;
|
|
||||||
set.maxFill = maxFill;
|
|
||||||
set.nullIndex = nullIndex;
|
|
||||||
set.containsNull = containsNull;
|
|
||||||
set.size = size;
|
|
||||||
set.keys = Arrays.copyOf(keys, keys.length);
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void clear() {
|
public void clear() {
|
||||||
if(size == 0) return;
|
if(size == 0) return;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ 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
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.consumer.BI_OBJECT_CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
import speiger.src.collections.PACKAGE.functions.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;
|
||||||
@@ -304,10 +304,10 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next())
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -346,16 +346,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = first;entry != null;entry = entry.next()) {
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
protected Entry KEY_GENERIC_TYPE findNode(KEY_TYPE o) {
|
||||||
Entry KEY_GENERIC_TYPE node = tree;
|
Entry KEY_GENERIC_TYPE node = tree;
|
||||||
int compare;
|
int compare;
|
||||||
@@ -540,21 +530,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
tree = null;
|
tree = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RB_TREE_SET KEY_GENERIC_TYPE copy() {
|
|
||||||
RB_TREE_SET KEY_GENERIC_TYPE set = new RB_TREE_SETBRACES();
|
|
||||||
set.size = size;
|
|
||||||
if(tree != null) {
|
|
||||||
set.tree = tree.copy();
|
|
||||||
Entry KEY_GENERIC_TYPE lastFound = null;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = tree;entry != null;entry = entry.left) lastFound = entry;
|
|
||||||
set.first = lastFound;
|
|
||||||
lastFound = null;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = tree;entry != null;entry = entry.right) lastFound = entry;
|
|
||||||
set.last = lastFound;
|
|
||||||
}
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||||
|
|
||||||
@@ -1085,9 +1060,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return fromStart && toEnd ? set.size() : iterator().skip(Integer.MAX_VALUE);
|
return fromStart && toEnd ? set.size() : iterator().skip(Integer.MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubSet KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
@@ -1097,10 +1069,10 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) {
|
public <E> void forEach(E input, BI_OBJECT_CONSUMER KKS_GENERIC_TYPE<E> action) {
|
||||||
Objects.requireNonNull(action);
|
Objects.requireNonNull(action);
|
||||||
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))
|
||||||
action.accept(input, entry.key);
|
action.accept(entry.key, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1139,16 +1111,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
return EMPTY_VALUE;
|
return EMPTY_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
Objects.requireNonNull(filter);
|
|
||||||
int result = 0;
|
|
||||||
for(Entry KEY_GENERIC_TYPE entry = start();entry != null && inRange(entry.key);entry = next(entry)) {
|
|
||||||
if(filter.TEST_VALUE(entry.key)) result++;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
class SubSetIterator implements LIST_ITERATOR KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
Entry KEY_GENERIC_TYPE previous;
|
Entry KEY_GENERIC_TYPE previous;
|
||||||
@@ -1332,22 +1294,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry KEY_GENERIC_TYPE copy() {
|
|
||||||
Entry KEY_GENERIC_TYPE entry = new EntryBRACES(key, null);
|
|
||||||
entry.state = state;
|
|
||||||
if(left != null) {
|
|
||||||
Entry KEY_GENERIC_TYPE newLeft = left.copy();
|
|
||||||
entry.left = newLeft;
|
|
||||||
newLeft.parent = entry;
|
|
||||||
}
|
|
||||||
if(right != null) {
|
|
||||||
Entry KEY_GENERIC_TYPE newRight = right.copy();
|
|
||||||
entry.right = newRight;
|
|
||||||
newRight.parent = entry;
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isBlack() {
|
boolean isBlack() {
|
||||||
return (state & BLACK) != 0;
|
return (state & BLACK) != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,10 @@ import speiger.src.collections.PACKAGE.utils.SPLIT_ITERATORS;
|
|||||||
* @Type(T)
|
* @Type(T)
|
||||||
*/
|
*/
|
||||||
public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE
|
public interface SET KEY_GENERIC_TYPE extends Set<CLASS_TYPE>, COLLECTION KEY_GENERIC_TYPE
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator();
|
public ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
|
|
||||||
@Override
|
|
||||||
public SET KEY_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type Specific remove function to reduce boxing/unboxing
|
* A Type Specific remove function to reduce boxing/unboxing
|
||||||
|
|||||||
@@ -60,9 +60,6 @@ public interface SORTED_SET KEY_GENERIC_TYPE extends SET KEY_GENERIC_TYPE, Sorte
|
|||||||
@Override
|
@Override
|
||||||
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
public COMPARATOR KEY_GENERIC_TYPE comparator();
|
||||||
|
|
||||||
@Override
|
|
||||||
public SORTED_SET KEY_GENERIC_TYPE copy();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
-39
@@ -15,8 +15,7 @@ import speiger.src.collections.objects.utils.ObjectArrays;
|
|||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
||||||
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
import speiger.src.collections.PACKAGE.utils.ARRAYS;
|
||||||
#endif
|
#endif
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for Collections
|
* A Helper class for Collections
|
||||||
*/
|
*/
|
||||||
@@ -93,16 +92,18 @@ public class COLLECTIONS
|
|||||||
public boolean add(KEY_TYPE o) { synchronized(mutex) { return c.add(o); } }
|
public boolean add(KEY_TYPE o) { synchronized(mutex) { return c.add(o); } }
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(Collection<? extends CLASS_TYPE> c) { synchronized(mutex) { return this.c.addAll(c); } }
|
public boolean addAll(Collection<? extends CLASS_TYPE> c) { synchronized(mutex) { return this.c.addAll(c); } }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) { synchronized(mutex) { return this.c.addAll(c); } }
|
public boolean addAll(COLLECTION KEY_GENERIC_TYPE c) { synchronized(mutex) { return this.c.addAll(c); } }
|
||||||
@Override
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) { synchronized(mutex) { return c.addAll(e, offset, length); } }
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { synchronized(mutex) { return c.contains(o); } }
|
public boolean contains(KEY_TYPE o) { synchronized(mutex) { return c.contains(o); } }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) { synchronized(mutex) { return c.contains(o); } }
|
public boolean contains(Object o) { synchronized(mutex) { return c.contains(o); } }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
@@ -129,9 +130,6 @@ public class COLLECTIONS
|
|||||||
return c.iterator();
|
return c.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean remove(Object o) { synchronized(mutex) { return c.remove(o); } }
|
public boolean remove(Object o) { synchronized(mutex) { return c.remove(o); } }
|
||||||
@@ -181,18 +179,6 @@ public class COLLECTIONS
|
|||||||
public boolean equals(Object obj) { synchronized(mutex) { return c.equals(obj); } }
|
public boolean equals(Object obj) { synchronized(mutex) { return c.equals(obj); } }
|
||||||
@Override
|
@Override
|
||||||
public String toString() { synchronized(mutex) { return c.toString(); } }
|
public String toString() { synchronized(mutex) { return c.toString(); } }
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { synchronized(mutex) { c.forEach(input, action); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.matchesAny(filter); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.matchesNone(filter); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.matchesAll(filter); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.findFirst(filter); } }
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return c.count(filter); } }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,8 +198,6 @@ public class COLLECTIONS
|
|||||||
public boolean addAll(Collection<? extends CLASS_TYPE> c) { throw new UnsupportedOperationException(); }
|
public boolean addAll(Collection<? extends CLASS_TYPE> c) { throw new UnsupportedOperationException(); }
|
||||||
@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
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) { throw new UnsupportedOperationException(); }
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { return c.contains(o); }
|
public boolean contains(KEY_TYPE o) { return c.contains(o); }
|
||||||
@@ -238,8 +222,6 @@ public class COLLECTIONS
|
|||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(c.iterator()); }
|
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.unmodifiable(c.iterator()); }
|
||||||
@Override
|
@Override
|
||||||
public COLLECTION KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
|
public boolean remove(Object o) { throw new UnsupportedOperationException(); }
|
||||||
@Override
|
@Override
|
||||||
@@ -291,18 +273,6 @@ public class COLLECTIONS
|
|||||||
public boolean equals(Object obj) { return c.equals(obj); }
|
public boolean equals(Object obj) { return c.equals(obj); }
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return c.toString(); }
|
public String toString() { return c.toString(); }
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { c.forEach(input, action); }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { return c.matchesAny(filter); }
|
|
||||||
@Override
|
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { return c.matchesNone(filter); }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { return c.matchesAll(filter); }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { return c.findFirst(filter); }
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { return c.count(filter); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -315,8 +285,6 @@ public class COLLECTIONS
|
|||||||
|
|
||||||
@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
|
|
||||||
public boolean addAll(KEY_TYPE[] e, int offset, int length) { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@@ -388,7 +356,5 @@ public class COLLECTIONS
|
|||||||
public void clear() {}
|
public void clear() {}
|
||||||
@Override
|
@Override
|
||||||
public int size() { return 0; }
|
public int size() { return 0; }
|
||||||
@Override
|
|
||||||
public EmptyCollection KEY_GENERIC_TYPE copy() { return this; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,18 +14,6 @@ import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|||||||
*/
|
*/
|
||||||
public class ITERABLES
|
public class ITERABLES
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* A Helper function that maps a Java-Iterable into a new Type.
|
|
||||||
* @param iterable the iterable that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterable that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E> ObjectIterable<E> map(Iterable<? extends CLASS_TYPE> iterable, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
|
||||||
return new MappedIterable<>(wrap(iterable), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that maps a Iterable into a new Type.
|
* A Helper function that maps a Iterable into a new Type.
|
||||||
* @param iterable the iterable that should be mapped
|
* @param iterable the iterable that should be mapped
|
||||||
@@ -38,19 +26,6 @@ public class ITERABLES
|
|||||||
return new MappedIterable<>(iterable, mapper);
|
return new MappedIterable<>(iterable, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
|
||||||
* @param iterable the iterable that should be flatMapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <V> The return type supplier.
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterable that is flatMapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E, V extends Iterable<E>> ObjectIterable<E> flatMap(Iterable<? extends CLASS_TYPE> iterable, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
|
||||||
return new FlatMappedIterable<>(wrap(iterable), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Iterable into a new Type.
|
* A Helper function that flatMaps a Iterable into a new Type.
|
||||||
* @param iterable the iterable that should be flatMapped
|
* @param iterable the iterable that should be flatMapped
|
||||||
@@ -64,18 +39,6 @@ public class ITERABLES
|
|||||||
return new FlatMappedIterable<>(iterable, mapper);
|
return new FlatMappedIterable<>(iterable, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that flatMaps a Java-Iterable into a new Type.
|
|
||||||
* @param iterable the iterable that should be flatMapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterable that is flatMapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E> ObjectIterable<E> arrayFlatMap(Iterable<? extends CLASS_TYPE> iterable, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
|
||||||
return new FlatMappedArrayIterable<>(wrap(iterable), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Iterable into a new Type.
|
* A Helper function that flatMaps a Iterable into a new Type.
|
||||||
* @param iterable the iterable that should be flatMapped
|
* @param iterable the iterable that should be flatMapped
|
||||||
@@ -88,17 +51,6 @@ public class ITERABLES
|
|||||||
return new FlatMappedArrayIterable<>(iterable, mapper);
|
return new FlatMappedArrayIterable<>(iterable, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that filters out all desired elements from a Java-Iterable
|
|
||||||
* @param iterable that should be filtered.
|
|
||||||
* @param filter the filter that decides that should be let through
|
|
||||||
* @Type(T)
|
|
||||||
* @return a filtered iterable
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ITERABLE KEY_GENERIC_TYPE filter(Iterable<? extends CLASS_TYPE> iterable, PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
return new FilteredIterableBRACES(wrap(iterable), filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that filters out all desired elements
|
* A Helper function that filters out all desired elements
|
||||||
* @param iterable that should be filtered.
|
* @param iterable that should be filtered.
|
||||||
@@ -110,29 +62,6 @@ public class ITERABLES
|
|||||||
return new FilteredIterableBRACES(iterable, filter);
|
return new FilteredIterableBRACES(iterable, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Wrapper function that wraps a Java-Iterable into a Type Specific Iterable
|
|
||||||
* @param iterable that should be wrapped
|
|
||||||
* @Type(T)
|
|
||||||
* @return a type specific iterable
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ITERABLE KEY_GENERIC_TYPE wrap(Iterable<? extends CLASS_TYPE> iterable) {
|
|
||||||
return new WrappedIterableBRACES(iterable);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class WrappedIterable KEY_GENERIC_TYPE implements ITERABLE KEY_GENERIC_TYPE
|
|
||||||
{
|
|
||||||
Iterable<? extends CLASS_TYPE> iterable;
|
|
||||||
|
|
||||||
public WrappedIterable(Iterable<? extends CLASS_TYPE> iterable) {
|
|
||||||
this.iterable = iterable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() {
|
|
||||||
return ITERATORS.wrap(iterable.iterator());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>
|
private static class MappedIterable KSS_GENERIC_TYPE<E, T> implements ObjectIterable<T>
|
||||||
{
|
{
|
||||||
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
ITERABLE KEY_SPECIAL_GENERIC_TYPE<E> iterable;
|
||||||
|
|||||||
@@ -89,18 +89,6 @@ public class ITERATORS
|
|||||||
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
return iterator instanceof UnmodifiableListIterator ? iterator : new UnmodifiableListIteratorBRACES(iterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that maps a Java-Iterator into a new Type.
|
|
||||||
* @param iterator that should be mapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterator that is mapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E> ObjectIterator<E> map(Iterator<? extends CLASS_TYPE> iterator, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E> mapper) {
|
|
||||||
return new MappedIterator<>(wrap(iterator), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that maps a Iterator into a new Type.
|
* A Helper function that maps a Iterator into a new Type.
|
||||||
* @param iterator that should be mapped
|
* @param iterator that should be mapped
|
||||||
@@ -113,19 +101,6 @@ public class ITERATORS
|
|||||||
return new MappedIterator<>(iterator, mapper);
|
return new MappedIterator<>(iterator, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
|
||||||
* @param iterator that should be flatMapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <V> The return type supplier.
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterator that is flatMapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E, V extends Iterable<E>> ObjectIterator<E> flatMap(Iterator<? extends CLASS_TYPE> iterator, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<V> mapper) {
|
|
||||||
return new FlatMappedIterator<>(wrap(iterator), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Iterator into a new Type.
|
* A Helper function that flatMaps a Iterator into a new Type.
|
||||||
* @param iterator that should be flatMapped
|
* @param iterator that should be flatMapped
|
||||||
@@ -139,18 +114,6 @@ public class ITERATORS
|
|||||||
return new FlatMappedIterator<>(iterator, mapper);
|
return new FlatMappedIterator<>(iterator, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that flatMaps a Java-Iterator into a new Type.
|
|
||||||
* @param iterator that should be flatMapped
|
|
||||||
* @param mapper the function that decides what the result turns into.
|
|
||||||
* @Type(T)
|
|
||||||
* @param <E> The return type.
|
|
||||||
* @return a iterator that is flatMapped to a new result
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_SPECIAL_BRACES<E> ObjectIterator<E> arrayFlatMap(Iterator<? extends CLASS_TYPE> iterator, TO_OBJECT_FUNCTION KKS_GENERIC_TYPE<E[]> mapper) {
|
|
||||||
return new FlatMappedArrayIterator<>(wrap(iterator), mapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that flatMaps a Iterator into a new Type.
|
* A Helper function that flatMaps a Iterator into a new Type.
|
||||||
* @param iterator that should be flatMapped
|
* @param iterator that should be flatMapped
|
||||||
@@ -163,17 +126,6 @@ public class ITERATORS
|
|||||||
return new FlatMappedArrayIterator<>(iterator, mapper);
|
return new FlatMappedArrayIterator<>(iterator, mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A Helper function that filters out all desired elements from a Java-Iterator
|
|
||||||
* @param iterator that should be filtered.
|
|
||||||
* @param filter the filter that decides that should be let through
|
|
||||||
* @Type(T)
|
|
||||||
* @return a filtered iterator
|
|
||||||
*/
|
|
||||||
public static GENERIC_KEY_BRACES ITERATOR KEY_GENERIC_TYPE filter(Iterator<? extends CLASS_TYPE> iterator, PREDICATE KEY_GENERIC_TYPE filter) {
|
|
||||||
return new FilteredIteratorBRACES(wrap(iterator), filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper function that filters out all desired elements
|
* A Helper function that filters out all desired elements
|
||||||
* @param iterator that should be filtered.
|
* @param iterator that should be filtered.
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import java.util.Objects;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.RandomAccess;
|
import java.util.RandomAccess;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
#if PRIMITIVES
|
|
||||||
import java.nio.JAVA_BUFFER;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@@ -207,11 +204,7 @@ public class LISTS
|
|||||||
a[offset] = element;
|
a[offset] = element;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
#if PRIMITIVES
|
|
||||||
@Override
|
|
||||||
public void fillBuffer(JAVA_BUFFER buffer) { buffer.put(element); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeElements(int from, int to) { throw new UnsupportedOperationException(); }
|
public void removeElements(int from, int to) { throw new UnsupportedOperationException(); }
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
@@ -223,9 +216,6 @@ public class LISTS
|
|||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public int size() { return 1; }
|
public int size() { return 1; }
|
||||||
|
|
||||||
@Override
|
|
||||||
public SingletonList KEY_GENERIC_TYPE copy() { return new SingletonListBRACES(element); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
|
private static class SynchronizedArrayList KEY_GENERIC_TYPE extends SynchronizedList KEY_GENERIC_TYPE implements IARRAY KEY_GENERIC_TYPE
|
||||||
@@ -364,9 +354,6 @@ public class LISTS
|
|||||||
@Override
|
@Override
|
||||||
public <K> K[] extractElements(int from, int to, Class<K> clz) { synchronized(mutex) { return l.extractElements(from, to, clz); } }
|
public <K> K[] extractElements(int from, int to, Class<K> clz) { synchronized(mutex) { return l.extractElements(from, to, clz); } }
|
||||||
|
|
||||||
#endif
|
|
||||||
#if PRIMITIVES
|
|
||||||
public void fillBuffer(JAVA_BUFFER buffer) { synchronized(mutex) { l.fillBuffer(buffer); } }
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
||||||
@@ -385,9 +372,6 @@ public class LISTS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) { synchronized(mutex) { l.size(size); } }
|
public void size(int size) { synchronized(mutex) { l.size(size); } }
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class UnmodifiableRandomList KEY_GENERIC_TYPE extends UnmodifiableList KEY_GENERIC_TYPE implements RandomAccess
|
private static class UnmodifiableRandomList KEY_GENERIC_TYPE extends UnmodifiableList KEY_GENERIC_TYPE implements RandomAccess
|
||||||
@@ -479,10 +463,6 @@ public class LISTS
|
|||||||
@Override
|
@Override
|
||||||
public <K> K[] extractElements(int from, int to, Class<K> clz) { throw new UnsupportedOperationException(); }
|
public <K> K[] extractElements(int from, int to, Class<K> clz) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
#endif
|
|
||||||
#if PRIMITIVES
|
|
||||||
public void fillBuffer(JAVA_BUFFER buffer) { l.fillBuffer(buffer); }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
public LIST_ITERATOR KEY_GENERIC_TYPE listIterator() {
|
||||||
@@ -501,9 +481,6 @@ public class LISTS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) { throw new UnsupportedOperationException(); }
|
public void size(int size) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public LIST KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmptyList KEY_GENERIC_TYPE extends COLLECTIONS.EmptyCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
|
private static class EmptyList KEY_GENERIC_TYPE extends COLLECTIONS.EmptyCollection KEY_GENERIC_TYPE implements LIST KEY_GENERIC_TYPE
|
||||||
@@ -586,8 +563,5 @@ public class LISTS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void size(int size) { throw new UnsupportedOperationException(); }
|
public void size(int size) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
@Override
|
|
||||||
public EmptyList KEY_GENERIC_TYPE copy() { return this; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-42
@@ -1,23 +1,15 @@
|
|||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.function.Consumer;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
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
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_DEQUEUE;
|
||||||
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
import speiger.src.collections.PACKAGE.queues.PRIORITY_QUEUE;
|
||||||
#if !TYPE_OBJECT
|
|
||||||
import speiger.src.collections.PACKAGE.functions.CONSUMER;
|
|
||||||
#endif
|
|
||||||
import speiger.src.collections.PACKAGE.functions.function.PREDICATE;
|
|
||||||
import speiger.src.collections.objects.functions.consumer.BI_FROM_OBJECT_CONSUMER;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Helper class for PriorityQueues
|
* A Helper class for PriorityQueues
|
||||||
@@ -94,14 +86,6 @@ public class PRIORITY_QUEUES
|
|||||||
public void clear() { synchronized(mutex) { queue.clear(); } }
|
public void clear() { synchronized(mutex) { queue.clear(); } }
|
||||||
@Override
|
@Override
|
||||||
public void enqueue(KEY_TYPE e) { synchronized(mutex) { queue.enqueue(e); } }
|
public void enqueue(KEY_TYPE e) { synchronized(mutex) { queue.enqueue(e); } }
|
||||||
@Override
|
|
||||||
public void enqueueAll(KEY_TYPE[] e, int offset, int length) { synchronized(mutex) { queue.enqueueAll(e, offset, length); } }
|
|
||||||
@Override
|
|
||||||
public void enqueueAll(COLLECTION KEY_GENERIC_TYPE c) { synchronized(mutex) { queue.enqueueAll(c); } }
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
public void enqueueAll(Collection<? extends CLASS_TYPE> c) { synchronized(mutex) { queue.enqueueAll(c); } }
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeue() { synchronized(mutex) { return queue.dequeue(); } }
|
public KEY_TYPE dequeue() { synchronized(mutex) { return queue.dequeue(); } }
|
||||||
@Override
|
@Override
|
||||||
@@ -116,22 +100,6 @@ public class PRIORITY_QUEUES
|
|||||||
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { synchronized(mutex) { return queue.comparator(); } }
|
public COMPARATOR KEY_SUPER_GENERIC_TYPE comparator() { synchronized(mutex) { return queue.comparator(); } }
|
||||||
@Override
|
@Override
|
||||||
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) { synchronized(mutex) { return queue.TO_ARRAY(input); } }
|
public GENERIC_SPECIAL_KEY_BRACES<E> KEY_SPECIAL_TYPE[] TO_ARRAY(KEY_SPECIAL_TYPE[] input) { synchronized(mutex) { return queue.TO_ARRAY(input); } }
|
||||||
@Override
|
|
||||||
public PRIORITY_QUEUE KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public void forEach(CONSUMER KEY_SUPER_GENERIC_TYPE action) { synchronized(mutex) { queue.forEach(action); } }
|
|
||||||
@Override
|
|
||||||
public <E> void forEach(E input, BI_FROM_OBJECT_CONSUMER KSK_GENERIC_TYPE<E> action) { synchronized(mutex) { queue.forEach(input, action); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAny(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAny(filter); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesNone(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesNone(filter); } }
|
|
||||||
@Override
|
|
||||||
public boolean matchesAll(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.matchesAll(filter); } }
|
|
||||||
@Override
|
|
||||||
public KEY_TYPE findFirst(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.findFirst(filter); } }
|
|
||||||
@Override
|
|
||||||
public int count(PREDICATE KEY_GENERIC_TYPE filter) { synchronized(mutex) { return queue.count(filter); } }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -153,17 +121,7 @@ public class PRIORITY_QUEUES
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enqueueFirst(KEY_TYPE e) { synchronized(mutex) { dequeue.enqueueFirst(e); } }
|
public void enqueueFirst(KEY_TYPE e) { synchronized(mutex) { dequeue.enqueueFirst(e); } }
|
||||||
@Override
|
|
||||||
public void enqueueAllFirst(KEY_TYPE[] e, int offset, int length) { synchronized(mutex) { dequeue.enqueueAllFirst(e, offset, length); } }
|
|
||||||
@Override
|
|
||||||
public void enqueueAllFirst(COLLECTION KEY_GENERIC_TYPE c) { synchronized(mutex) { dequeue.enqueueAllFirst(c); } }
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
@Override
|
|
||||||
public void enqueueAllFirst(Collection<? extends CLASS_TYPE> c) { synchronized(mutex) { dequeue.enqueueAllFirst(c); } }
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE dequeueLast() { synchronized(mutex) { return dequeue.dequeueLast(); } }
|
public KEY_TYPE dequeueLast() { synchronized(mutex) { return dequeue.dequeueLast(); } }
|
||||||
@Override
|
|
||||||
public PRIORITY_DEQUEUE KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,9 +190,6 @@ public class SETS
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int size() { return 1; }
|
public int size() { return 1; }
|
||||||
|
|
||||||
@Override
|
|
||||||
public SingletonSet KEY_GENERIC_TYPE copy() { return new SingletonSetBRACES(element); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmptySet KEY_GENERIC_TYPE extends EmptyCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
private static class EmptySet KEY_GENERIC_TYPE extends EmptyCollection KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
||||||
@@ -201,8 +198,6 @@ public class SETS
|
|||||||
@Override
|
@Override
|
||||||
public boolean remove(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean remove(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_BOOLEAN
|
#if !TYPE_BOOLEAN
|
||||||
@@ -250,9 +245,6 @@ public class SETS
|
|||||||
public KEY_TYPE getDefaultMinValue() { return n.getDefaultMinValue(); }
|
public KEY_TYPE getDefaultMinValue() { return n.getDefaultMinValue(); }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { return unmodifiable(n.subSet(fromElement, fromInclusive, toElement, toInclusive)); }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { return unmodifiable(n.subSet(fromElement, fromInclusive, toElement, toInclusive)); }
|
||||||
|
|
||||||
@@ -308,9 +300,6 @@ public class SETS
|
|||||||
@Override
|
@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
|
|
||||||
public SORTED_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { return unmodifiable(s.subSet(fromElement, toElement)); }
|
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { return unmodifiable(s.subSet(fromElement, toElement)); }
|
||||||
|
|
||||||
@@ -347,9 +336,6 @@ public class SETS
|
|||||||
s = c;
|
s = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public boolean remove(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
@@ -426,9 +412,6 @@ public class SETS
|
|||||||
public KEY_TYPE getDefaultMinValue() { synchronized(mutex) { return n.getDefaultMinValue(); } }
|
public KEY_TYPE getDefaultMinValue() { synchronized(mutex) { return n.getDefaultMinValue(); } }
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { synchronized(mutex) { return synchronize(n.subSet(fromElement, fromInclusive, toElement, toInclusive), mutex); } }
|
public NAVIGABLE_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, boolean fromInclusive, KEY_TYPE toElement, boolean toInclusive) { synchronized(mutex) { return synchronize(n.subSet(fromElement, fromInclusive, toElement, toInclusive), mutex); } }
|
||||||
|
|
||||||
@@ -509,10 +492,7 @@ public class SETS
|
|||||||
|
|
||||||
@Override
|
@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
|
|
||||||
public SORTED_SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { synchronized(mutex) { return synchronize(s.subSet(fromElement, toElement), mutex); } }
|
public SORTED_SET KEY_GENERIC_TYPE subSet(KEY_TYPE fromElement, KEY_TYPE toElement) { synchronized(mutex) { return synchronize(s.subSet(fromElement, toElement), mutex); } }
|
||||||
|
|
||||||
@@ -576,9 +556,6 @@ public class SETS
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SET KEY_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
public boolean remove(KEY_TYPE o) { synchronized(mutex) { return s.remove(o); } }
|
||||||
|
|||||||
+1
-17
@@ -277,8 +277,6 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return EQUALS_KEY_TYPE(key, this.key) ? value : defaultValue; }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public SingletonMap KEY_VALUE_GENERIC_TYPE copy() { return new SingletonMapKV_BRACES(key, value); }
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keySet == null) keySet = SETS.singleton(key);
|
if(keySet == null) keySet = SETS.singleton(key);
|
||||||
@@ -331,8 +329,6 @@ public class MAPS
|
|||||||
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() { return VALUE_COLLECTIONS.empty(); }
|
public VALUE_COLLECTION VALUE_GENERIC_TYPE values() { return VALUE_COLLECTIONS.empty(); }
|
||||||
@Override
|
@Override
|
||||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() { return ObjectSets.empty(); }
|
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() { return ObjectSets.empty(); }
|
||||||
@Override
|
|
||||||
public EmptyMap KEY_VALUE_GENERIC_TYPE copy() { return this; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -419,8 +415,6 @@ public class MAPS
|
|||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { return unmodifiable(map.floorEntry(key)); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { return unmodifiable(map.floorEntry(key)); }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return unmodifiable(map.ceilingEntry(key)); }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { return unmodifiable(map.ceilingEntry(key)); }
|
||||||
@Override
|
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -468,8 +462,6 @@ public class MAPS
|
|||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { return map.FIRST_ENTRY_VALUE(); }
|
||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
public VALUE_TYPE LAST_ENTRY_VALUE() { return map.LAST_ENTRY_VALUE(); }
|
||||||
@Override
|
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,8 +501,6 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) { return map.getOrDefault(key, defaultValue); }
|
||||||
#endif
|
#endif
|
||||||
@Override
|
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
@@ -624,9 +614,7 @@ public class MAPS
|
|||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { synchronized(mutex) { return map.floorEntry(key); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE floorEntry(KEY_TYPE key) { synchronized(mutex) { return map.floorEntry(key); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
public MAP.Entry KEY_VALUE_GENERIC_TYPE ceilingEntry(KEY_TYPE key) { synchronized(mutex) { return map.ceilingEntry(key); } }
|
||||||
@Override
|
#if !TYPE_OBJECT
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
#if !TYPE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, boolean fromInclusive, CLASS_TYPE toKey, boolean toInclusive) { synchronized(mutex) { return synchronize(map.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
|
public NAVIGABLE_MAP KEY_VALUE_GENERIC_TYPE subMap(CLASS_TYPE fromKey, boolean fromInclusive, CLASS_TYPE toKey, boolean toInclusive) { synchronized(mutex) { return synchronize(map.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } }
|
||||||
@@ -730,8 +718,6 @@ public class MAPS
|
|||||||
public VALUE_TYPE FIRST_ENTRY_VALUE() { synchronized(mutex) { return map.FIRST_ENTRY_VALUE(); } }
|
public VALUE_TYPE FIRST_ENTRY_VALUE() { synchronized(mutex) { return map.FIRST_ENTRY_VALUE(); } }
|
||||||
@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
|
|
||||||
public SORTED_MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@@ -845,8 +831,6 @@ public class MAPS
|
|||||||
@Override
|
@Override
|
||||||
public int size() { synchronized(mutex) { return super.size(); } }
|
public int size() { synchronized(mutex) { return super.size(); } }
|
||||||
@Override
|
@Override
|
||||||
public MAP KEY_VALUE_GENERIC_TYPE copy() { throw new UnsupportedOperationException(); }
|
|
||||||
@Override
|
|
||||||
public SET KEY_GENERIC_TYPE keySet() {
|
public SET KEY_GENERIC_TYPE keySet() {
|
||||||
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
if(keys == null) keys = SETS.synchronize(map.keySet(), mutex);
|
||||||
return keys;
|
return keys;
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ public interface IArray extends RandomAccess, ITrimmable
|
|||||||
*
|
*
|
||||||
* @param size the desired minimum capacity
|
* @param size the desired minimum capacity
|
||||||
*/
|
*/
|
||||||
public void ensureCapacity(int size);
|
void ensureCapacity(int size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public interface ITrimmable
|
|||||||
* Trims the original collection down to the size of the current elements
|
* Trims the original collection down to the size of the current elements
|
||||||
* @return if the internal array has been trimmed.
|
* @return if the internal array has been trimmed.
|
||||||
*/
|
*/
|
||||||
public default boolean trim() {
|
default boolean trim() {
|
||||||
return trim(0);
|
return trim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,12 +19,12 @@ public interface ITrimmable
|
|||||||
* @param size the requested trim size.
|
* @param size the requested trim size.
|
||||||
* @return if the internal array has been trimmed.
|
* @return if the internal array has been trimmed.
|
||||||
*/
|
*/
|
||||||
public boolean trim(int size);
|
boolean trim(int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trims the collection down to the original size and clears all present elements with it.
|
* Trims the collection down to the original size and clears all present elements with it.
|
||||||
*/
|
*/
|
||||||
public default void clearAndTrim() {
|
default void clearAndTrim() {
|
||||||
clearAndTrim(0);
|
clearAndTrim(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,5 +33,5 @@ public interface ITrimmable
|
|||||||
* @param size the amount of elements that should be allowed
|
* @param size the amount of elements that should be allowed
|
||||||
* @note this will enforce minimum size of the collection itself
|
* @note this will enforce minimum size of the collection itself
|
||||||
*/
|
*/
|
||||||
public void clearAndTrim(int size);
|
void clearAndTrim(int size);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package speiger.src.collections.utils;
|
package speiger.src.collections.utils;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ForkJoinPool;
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ForkJoinTask;
|
import java.util.concurrent.ForkJoinTask;
|
||||||
@@ -8,15 +11,15 @@ import java.util.concurrent.ForkJoinTask;
|
|||||||
* Helper class that provides functions that are shared within the library.
|
* Helper class that provides functions that are shared within the library.
|
||||||
* On top of that it provides some helper functions that allow control of some internals of the Library
|
* On top of that it provides some helper functions that allow control of some internals of the Library
|
||||||
*/
|
*/
|
||||||
public class SanityChecks
|
public final class SanityChecks
|
||||||
{
|
{
|
||||||
/** Max Possible ArraySize without the JVM Crashing */
|
/** Max Possible ArraySize without the JVM Crashing */
|
||||||
public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||||
private static ForkJoinPool WORK_POOL = ForkJoinPool.commonPool();
|
private static ForkJoinPool WORK_POOL = ForkJoinPool.commonPool();
|
||||||
private static boolean FORCE_IGNORE_PARALLELISM = false;
|
private static boolean FORCE_IGNORE_PARALLELISM = false;
|
||||||
private static ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
|
private static final ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
|
||||||
private static ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
|
private static final ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
|
||||||
private static ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
|
private static final ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function to cast a Integer to a Byte
|
* Internal function to cast a Integer to a Byte
|
||||||
@@ -90,8 +93,8 @@ public class SanityChecks
|
|||||||
* @param task the Task to invoke
|
* @param task the Task to invoke
|
||||||
* @param <T> the type of the task
|
* @param <T> the type of the task
|
||||||
*/
|
*/
|
||||||
public static <T> void invokeTask(ForkJoinTask<T> task) {
|
public static <T> void invokeTask(@NotNull ForkJoinTask<T> task) {
|
||||||
if(FORCE_ASYNC.get().booleanValue()) invokeAsyncTask(task);
|
if(FORCE_ASYNC.get()) invokeAsyncTask(task);
|
||||||
else getPool().invoke(task);
|
else getPool().invoke(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +103,7 @@ public class SanityChecks
|
|||||||
* @param task the Task to invoke
|
* @param task the Task to invoke
|
||||||
* @param <T> the type of the task
|
* @param <T> the type of the task
|
||||||
*/
|
*/
|
||||||
public static <T> void invokeAsyncTask(ForkJoinTask<T> task) {
|
public static <T> void invokeAsyncTask(@NotNull ForkJoinTask<T> task) {
|
||||||
getPool().execute(task);
|
getPool().execute(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +112,12 @@ public class SanityChecks
|
|||||||
* @note this method is not thread-save. It is only there to provide control over how Library specific Threaded tasks are handled.
|
* @note this method is not thread-save. It is only there to provide control over how Library specific Threaded tasks are handled.
|
||||||
* @param pool The ForkJoinPool that should receive the tasks. If null {@link ForkJoinPool#commonPool()} is set instead
|
* @param pool The ForkJoinPool that should receive the tasks. If null {@link ForkJoinPool#commonPool()} is set instead
|
||||||
*/
|
*/
|
||||||
public static void setWorkPool(ForkJoinPool pool) {
|
public static void setWorkPool(@Nullable ForkJoinPool pool) {
|
||||||
WORK_POOL = pool == null ? ForkJoinPool.commonPool() : pool;
|
WORK_POOL = pool == null ? ForkJoinPool.commonPool() : pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ForkJoinPool getPool() {
|
private static @NotNull ForkJoinPool getPool() {
|
||||||
if(FORCE_TASK_POOL.get().booleanValue()) {
|
if(FORCE_TASK_POOL.get()) {
|
||||||
ForkJoinPool pool = ForkJoinTask.getPool();
|
ForkJoinPool pool = ForkJoinTask.getPool();
|
||||||
if(pool != null) return pool;
|
if(pool != null) return pool;
|
||||||
}
|
}
|
||||||
@@ -126,7 +129,7 @@ public class SanityChecks
|
|||||||
* @return if the Current Thread has not to await task completion.
|
* @return if the Current Thread has not to await task completion.
|
||||||
*/
|
*/
|
||||||
public static boolean isForcedAsync() {
|
public static boolean isForcedAsync() {
|
||||||
return FORCE_ASYNC.get().booleanValue();
|
return FORCE_ASYNC.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -134,7 +137,7 @@ public class SanityChecks
|
|||||||
* @return if the task checks the current pool to be executed in if it is valid.
|
* @return if the task checks the current pool to be executed in if it is valid.
|
||||||
*/
|
*/
|
||||||
public static boolean isForcedTaskPool() {
|
public static boolean isForcedTaskPool() {
|
||||||
return FORCE_TASK_POOL.get().booleanValue();
|
return FORCE_TASK_POOL.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,7 +145,7 @@ public class SanityChecks
|
|||||||
* @param value it tasks should not be awaited for
|
* @param value it tasks should not be awaited for
|
||||||
*/
|
*/
|
||||||
public static void setForcedAsync(boolean value) {
|
public static void setForcedAsync(boolean value) {
|
||||||
FORCE_ASYNC.set(Boolean.valueOf(value));
|
FORCE_ASYNC.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +153,7 @@ public class SanityChecks
|
|||||||
* @param value if the current thread should check if it is a ThreadPoolWorker.
|
* @param value if the current thread should check if it is a ThreadPoolWorker.
|
||||||
*/
|
*/
|
||||||
public static void setForcedTaskPool(boolean value) {
|
public static void setForcedTaskPool(boolean value) {
|
||||||
FORCE_TASK_POOL.set(Boolean.valueOf(value));
|
FORCE_TASK_POOL.set(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +167,7 @@ public class SanityChecks
|
|||||||
/**
|
/**
|
||||||
* @return Thread Specific Random needed for internal functions in this library.
|
* @return Thread Specific Random needed for internal functions in this library.
|
||||||
*/
|
*/
|
||||||
public static Random getRandom() {
|
public static @NotNull Random getRandom() {
|
||||||
return RANDOM.get();
|
return RANDOM.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package speiger.src.collections.utils;
|
package speiger.src.collections.utils;
|
||||||
|
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Stack Interface represents the Last-In-First-Out layout (LIFO).
|
* The Stack Interface represents the Last-In-First-Out layout (LIFO).
|
||||||
* It provides a simple {@link #push(Object)}, {@link #pop()} function,
|
* It provides a simple {@link #push(Object)}, {@link #pop()} function,
|
||||||
@@ -14,40 +16,40 @@ public interface Stack<T>
|
|||||||
* Inserts a given Object on top of the stack
|
* Inserts a given Object on top of the stack
|
||||||
* @param e the Object to insert
|
* @param e the Object to insert
|
||||||
*/
|
*/
|
||||||
public void push(T e);
|
void push(@NotNull T e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the Object on top of the stack.
|
* Removes the Object on top of the stack.
|
||||||
* @return the element that is on top of the stack
|
* @return the element that is on top of the stack
|
||||||
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||||
*/
|
*/
|
||||||
public T pop();
|
@NotNull T pop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the amount of elements currently in the stack
|
* Provides the amount of elements currently in the stack
|
||||||
* @return amount of elements in the list
|
* @return amount of elements in the list
|
||||||
*/
|
*/
|
||||||
public int size();
|
int size();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the stack is empty
|
* @return if the stack is empty
|
||||||
*/
|
*/
|
||||||
public default boolean isEmpty() {
|
default boolean isEmpty() {
|
||||||
return size() == 0;
|
return size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the stack
|
* Clears the stack
|
||||||
*/
|
*/
|
||||||
public void clear();
|
void clear();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the Object on top of the stack
|
* Provides the Object on top of the stack
|
||||||
* @return the element that is on top of the stack
|
* @return the element that is on top of the stack
|
||||||
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||||
*/
|
*/
|
||||||
public default T top() {
|
default @NotNull T top() {
|
||||||
return peek(0);
|
return peek(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,5 +60,5 @@ public interface Stack<T>
|
|||||||
* @return the element that was requested
|
* @return the element that was requested
|
||||||
* @throws ArrayIndexOutOfBoundsException if the index is out of bounds
|
* @throws ArrayIndexOutOfBoundsException if the index is out of bounds
|
||||||
*/
|
*/
|
||||||
public T peek(int index);
|
@NotNull T peek(int index);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,16 +135,6 @@ public abstract class BaseInt2IntMapTest
|
|||||||
Assert.assertTrue(map.remove(PUT_VALUE_ARRAY[51], PUT_ARRAY[51]));
|
Assert.assertTrue(map.remove(PUT_VALUE_ARRAY[51], PUT_ARRAY[51]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSort()
|
|
||||||
{
|
|
||||||
if(!getValidMapTests().contains(MapTests.COPY)) return;
|
|
||||||
Int2IntMap map = createMap(TEST_ARRAY, TEST_ARRAY);
|
|
||||||
Int2IntMap copy = map.copy();
|
|
||||||
Assert.assertFalse(map == copy);
|
|
||||||
Assert.assertEquals(map, copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Strategy implements IntStrategy
|
public static class Strategy implements IntStrategy
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -178,13 +178,4 @@ public abstract class BaseIntCollectionTest extends BaseIntIterableTest
|
|||||||
Assert.assertEquals(base, IntCollections.synchronize(collection).toString());
|
Assert.assertEquals(base, IntCollections.synchronize(collection).toString());
|
||||||
Assert.assertEquals(base, IntCollections.unmodifiable(collection).toString());
|
Assert.assertEquals(base, IntCollections.unmodifiable(collection).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCopy() {
|
|
||||||
if(!getValidCollectionTests().contains(CollectionTest.COPY)) return;
|
|
||||||
IntCollection collection = create(BULK_ADD_ARRAY);
|
|
||||||
IntCollection copy = collection.copy();
|
|
||||||
Assert.assertFalse(collection == copy);
|
|
||||||
Assert.assertEquals(collection, copy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -120,13 +120,4 @@ public abstract class BaseIntPriorityQueueTest extends BaseIntIterableTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCopy() {
|
|
||||||
if(!getValidPriorityQueueTests().contains(PriorityQueueTest.COPY)) return;
|
|
||||||
IntPriorityQueue queue = create(TEST_ARRAY);
|
|
||||||
IntPriorityQueue copy = queue.copy();
|
|
||||||
Assert.assertFalse(queue == copy);
|
|
||||||
Assert.assertEquals(queue, copy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,13 +22,6 @@ public class ObjectArrayListTest
|
|||||||
testCastable(ObjectArrayList.wrap("Test", "Testing", "Testing stuff"), true);
|
testCastable(ObjectArrayList.wrap("Test", "Testing", "Testing stuff"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEmptyCreation()
|
|
||||||
{
|
|
||||||
ObjectArrayList<String> test = ObjectArrayList.of(String.class);
|
|
||||||
Assert.assertTrue(test.isCastable());
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> void testCastable(IObjectArray<T> castable, boolean result)
|
public <T> void testCastable(IObjectArray<T> castable, boolean result)
|
||||||
{
|
{
|
||||||
Assert.assertTrue(castable.isCastable() == result);
|
Assert.assertTrue(castable.isCastable() == result);
|
||||||
|
|||||||
@@ -15,6 +15,5 @@ public enum CollectionTest
|
|||||||
TO_ARRAY,
|
TO_ARRAY,
|
||||||
CLEAR,
|
CLEAR,
|
||||||
WRAPPER,
|
WRAPPER,
|
||||||
TO_STRING,
|
TO_STRING;
|
||||||
COPY;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,5 @@ public enum MapTests
|
|||||||
MERGE,
|
MERGE,
|
||||||
GET,
|
GET,
|
||||||
ITERATORS,
|
ITERATORS,
|
||||||
REMOVE,
|
REMOVE;
|
||||||
COPY;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,5 +7,4 @@ public enum PriorityQueueTest
|
|||||||
PEEK,
|
PEEK,
|
||||||
REMOVE,
|
REMOVE,
|
||||||
TO_ARRAY,
|
TO_ARRAY,
|
||||||
COPY;
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user