Skip to content

Commit ec94f83

Browse files
committed
Add more concurrent chained map implementations
There are really only a few different types of implementations that we need to consider: - primitive mapped keys - primitive (+number) mapped values - reference vs object mapped key/values However, if we want keys/values to have the following types: - reference - object - int - long Then we need 16 map implementations. This is unacceptable maintenance burden for maintaining what is truly only one map implementation with a small set of changes. To address this problem, we now have the capability of generating source files from a template file. Please see templates/template_spec.txt for details. Using the template system, we can generate all map implementations from one template file.
1 parent 5ae00b9 commit ec94f83

32 files changed

Lines changed: 2113 additions & 1969 deletions

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ jobs:
1919
distribution: 'temurin'
2020
java-version: 25
2121
- name: setup gradle
22-
uses: gradle/actions/setup-gradle@v5
22+
uses: gradle/actions/setup-gradle@v6
23+
- name: generate sources
24+
run: ./gen_sources.sh
2325
- name: "build"
2426
run: ./gradlew build
2527
- name: "determine status"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ out/
3333

3434
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
3535
hs_err_pid*
36+
37+
# generated sources
38+
src/main/java/ca/spottedleaf/concurrentutil/map/concurrent/*

gen_sources.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
cd templates
6+
7+
rm -f *.class
8+
9+
javac --release 25 GenerateSources.java Preprocessor.java
10+
11+
java GenerateSources . ..

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[versions]
22
it-unimi-dsi-fastutil = "8.5.15"
33
org-slf4j-slf4j-api = "2.0.17"
4-
net-java-dev-jna = "5.17.0"
4+
net-java-dev-jna = "5.18.1"
55

66
[libraries]
77
it-unimi-dsi-fastutil = { module = "it.unimi.dsi:fastutil", version.ref = "it-unimi-dsi-fastutil" }

gradle/wrapper/gradle-wrapper.jar

3.25 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ca.spottedleaf.concurrentutil.collection.iterator;
2+
3+
public abstract class BaseBooleanIterator extends BaseObjectIterator<Boolean> {
4+
5+
@Override
6+
public final Boolean next() {
7+
return Boolean.valueOf(this.nextBoolean());
8+
}
9+
10+
public abstract boolean nextBoolean();
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ca.spottedleaf.concurrentutil.collection.iterator;
2+
3+
public abstract class BaseByteIterator extends BaseObjectIterator<Byte> {
4+
5+
@Override
6+
public final Byte next() {
7+
return Byte.valueOf(this.nextByte());
8+
}
9+
10+
public abstract byte nextByte();
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ca.spottedleaf.concurrentutil.collection.iterator;
2+
3+
import java.util.Objects;
4+
import java.util.PrimitiveIterator;
5+
import java.util.function.DoubleConsumer;
6+
7+
public abstract class BaseDoubleIterator extends BaseObjectIterator<Double> implements PrimitiveIterator.OfDouble {
8+
9+
@Override
10+
public final Double next() {
11+
return Double.valueOf(this.nextDouble());
12+
}
13+
14+
@Override
15+
public abstract double nextDouble();
16+
17+
@Override
18+
public final void forEachRemaining(final DoubleConsumer action) {
19+
Objects.requireNonNull(action, "Action may not be null");
20+
while (this.hasNext()) {
21+
action.accept(this.nextDouble());
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)