Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
Alexander Hinze | 3f6ffea14e | |
Alexander Hinze | 9c09f2ee70 | |
Alexander Hinze | 3fc6bed79a |
|
@ -11,15 +11,23 @@ gradle-app.setting
|
|||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
.classpath
|
||||
.project
|
||||
|
||||
---> Custom
|
||||
# IntelliJ
|
||||
|
||||
.idea/
|
||||
out/
|
||||
*.iws
|
||||
*.ipr
|
||||
*.iml
|
||||
|
||||
# ---> Custom
|
||||
!/libs/
|
||||
/.settings/
|
||||
/bin/
|
||||
/storage/
|
||||
|
||||
#Generated Code
|
||||
/src/main/java/speiger/src/collections/booleans/*
|
||||
/src/main/java/speiger/src/collections/bytes/*
|
||||
|
@ -32,4 +40,4 @@ gradle-app.setting
|
|||
/src/main/java/speiger/src/collections/objects/*
|
||||
|
||||
#Cache result
|
||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
||||
|
|
48
build.gradle
48
build.gradle
|
@ -1,9 +1,7 @@
|
|||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
buildscript {
|
||||
def config = new Properties()
|
||||
file('build.properties').withInputStream(config.&load)
|
||||
project.ext.config = config
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
|
@ -12,24 +10,31 @@ apply plugin: 'maven'
|
|||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
|
||||
maven {
|
||||
url = "https://maven.speiger.com/repository/main"
|
||||
}
|
||||
}
|
||||
|
||||
archivesBaseName = 'Primitive Collections'
|
||||
version = '0.4.0';
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
|
||||
archivesBaseName = config.project_name
|
||||
version = config.project_version
|
||||
group = config.project_group
|
||||
sourceCompatibility = config.java_source_version
|
||||
targetCompatibility = config.java_target_version
|
||||
|
||||
javadoc {
|
||||
options.tags = [ "implSpec", "note" ]
|
||||
options.tags = [ "implSpec", "note" ]
|
||||
failOnError = false
|
||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
options.quiet()
|
||||
}
|
||||
|
||||
eclipse {
|
||||
classpath {
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
|
||||
file {
|
||||
whenMerged {
|
||||
//Enforce a custom container and allowing access to the sun.misc package which is nessesary for EnumMaps
|
||||
|
@ -39,6 +44,12 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -54,8 +65,11 @@ configurations {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
builderCompile 'de.speiger:Simple-Code-Generator:1.0.4'
|
||||
runtimeOnly 'de.speiger:Simple-Code-Generator:1.0.4'
|
||||
implementation group: 'org.jetbrains', name: 'annotations', version: config.annotations_version
|
||||
|
||||
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'
|
||||
}
|
||||
|
||||
|
@ -84,10 +98,6 @@ task srcJar(type: Jar) {
|
|||
classifier = 'sources'
|
||||
}
|
||||
|
||||
javadoc.failOnError = false
|
||||
javadoc.options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||
javadoc.options.quiet()
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
archives srcJar
|
||||
|
@ -107,8 +117,8 @@ uploadArchives {
|
|||
}
|
||||
pom {
|
||||
version = project.version
|
||||
artifactId = project.archivesBaseName.replace(" ", "-")
|
||||
groupId = 'de.speiger'
|
||||
artifactId = config.artifact_id
|
||||
groupId = config.artifact_group
|
||||
project {
|
||||
licenses {
|
||||
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
|
|
@ -16,5 +16,5 @@ public interface IArray extends RandomAccess, ITrimmable
|
|||
*
|
||||
* @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
|
||||
* @return if the internal array has been trimmed.
|
||||
*/
|
||||
public default boolean trim() {
|
||||
default boolean trim() {
|
||||
return trim(0);
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,12 @@ public interface ITrimmable
|
|||
* @param size the requested trim size.
|
||||
* @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.
|
||||
*/
|
||||
public default void clearAndTrim() {
|
||||
default void clearAndTrim() {
|
||||
clearAndTrim(0);
|
||||
}
|
||||
|
||||
|
@ -33,5 +33,5 @@ public interface ITrimmable
|
|||
* @param size the amount of elements that should be allowed
|
||||
* @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;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
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.
|
||||
* 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 */
|
||||
public static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
|
||||
private static ForkJoinPool WORK_POOL = ForkJoinPool.commonPool();
|
||||
private static boolean FORCE_IGNORE_PARALLELISM = false;
|
||||
private static ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
|
||||
private static ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
|
||||
private static ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
|
||||
private static final ThreadLocal<Random> RANDOM = ThreadLocal.withInitial(Random::new);
|
||||
private static final ThreadLocal<Boolean> FORCE_ASYNC = ThreadLocal.withInitial(() -> false);
|
||||
private static final ThreadLocal<Boolean> FORCE_TASK_POOL = ThreadLocal.withInitial(() -> false);
|
||||
|
||||
/**
|
||||
* Internal function to cast a Integer to a Byte
|
||||
|
@ -90,8 +93,8 @@ public class SanityChecks
|
|||
* @param task the Task to invoke
|
||||
* @param <T> the type of the task
|
||||
*/
|
||||
public static <T> void invokeTask(ForkJoinTask<T> task) {
|
||||
if(FORCE_ASYNC.get().booleanValue()) invokeAsyncTask(task);
|
||||
public static <T> void invokeTask(@NotNull ForkJoinTask<T> task) {
|
||||
if(FORCE_ASYNC.get()) invokeAsyncTask(task);
|
||||
else getPool().invoke(task);
|
||||
}
|
||||
|
||||
|
@ -100,7 +103,7 @@ public class SanityChecks
|
|||
* @param task the Task to invoke
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
* @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;
|
||||
}
|
||||
|
||||
private static ForkJoinPool getPool() {
|
||||
if(FORCE_TASK_POOL.get().booleanValue()) {
|
||||
private static @NotNull ForkJoinPool getPool() {
|
||||
if(FORCE_TASK_POOL.get()) {
|
||||
ForkJoinPool pool = ForkJoinTask.getPool();
|
||||
if(pool != null) return pool;
|
||||
}
|
||||
|
@ -126,7 +129,7 @@ public class SanityChecks
|
|||
* @return if the Current Thread has not to await task completion.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public static Random getRandom() {
|
||||
public static @NotNull Random getRandom() {
|
||||
return RANDOM.get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package speiger.src.collections.utils;
|
||||
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* The Stack Interface represents the Last-In-First-Out layout (LIFO).
|
||||
* 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
|
||||
* @param e the Object to insert
|
||||
*/
|
||||
public void push(T e);
|
||||
void push(@NotNull T e);
|
||||
|
||||
/**
|
||||
* Removes the Object on top of the stack.
|
||||
* @return the element that is on top of the stack
|
||||
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||
*/
|
||||
public T pop();
|
||||
@NotNull T pop();
|
||||
|
||||
/**
|
||||
* Provides the amount of elements currently in the stack
|
||||
* @return amount of elements in the list
|
||||
*/
|
||||
public int size();
|
||||
int size();
|
||||
|
||||
|
||||
/**
|
||||
* @return if the stack is empty
|
||||
*/
|
||||
public default boolean isEmpty() {
|
||||
default boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the stack
|
||||
*/
|
||||
public void clear();
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Provides the Object on top of the stack
|
||||
* @return the element that is on top of the stack
|
||||
* @throws ArrayIndexOutOfBoundsException if the stack is empty
|
||||
*/
|
||||
public default T top() {
|
||||
default @NotNull T top() {
|
||||
return peek(0);
|
||||
}
|
||||
|
||||
|
@ -58,5 +60,5 @@ public interface Stack<T>
|
|||
* @return the element that was requested
|
||||
* @throws ArrayIndexOutOfBoundsException if the index is out of bounds
|
||||
*/
|
||||
public T peek(int index);
|
||||
@NotNull T peek(int index);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue