Project is now buildable.
-Moved: Code generation is in its own sourceset. -Fixed: Bugs that caused that the project isnt buildable. -Changed: Made build.gradle to a standard.
This commit is contained in:
parent
0cb07398f9
commit
aaee550ea9
|
@ -14,30 +14,9 @@ gradle-app.setting
|
|||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
.classpath
|
||||
.project
|
||||
gradle-wrapper.jar
|
||||
|
||||
---> Custom
|
||||
!/libs/
|
||||
|
@ -56,4 +35,4 @@ hs_err_pid*
|
|||
/src/main/java/speiger/src/collections/objects/*
|
||||
|
||||
#Cache result
|
||||
/src/main/resources/speiger/assets/collections/cache.bin
|
||||
/src/builder/resources/speiger/assets/collections/cache.bin
|
|
@ -9,13 +9,14 @@ ArraysList, HashSet/Map (Linked & HashControl), TreeSet/Map (RB & AVL), Priority
|
|||
|
||||
# Guide
|
||||
|
||||
Project is currently not buildable due to certain design flaws that are being redone,
|
||||
but the SourceCode can be already generated via: /gradlew.bat generateSource
|
||||
which will generate all the files and they shouldn't generate any errors.
|
||||
The SourceCode can be already generated via:
|
||||
/gradlew.bat generateSource
|
||||
to build the jar
|
||||
/gradlew.bat build
|
||||
do not combine the commands because they can not be executed at the same time.
|
||||
|
||||
Current Problem:
|
||||
EnumMaps use sun.misc package.
|
||||
Some methods are ambiguous and need to be adjusted.
|
||||
Some overhauls or missing implementations have to be added. (A couple passes)
|
||||
But technically Lists/Sets/PriorityQueues are fully usable, Maps are untested and just recently added.
|
||||
|
||||
|
|
37
build.gradle
37
build.gradle
|
@ -12,7 +12,7 @@ apply plugin: 'eclipse'
|
|||
repositories {
|
||||
jcenter()
|
||||
flatDir {
|
||||
dirs '/libs'
|
||||
dirs 'libs'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,12 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
task generateSource(type: JavaExec) {
|
||||
group = 'internal'
|
||||
description = 'Builds the sourcecode'
|
||||
classpath = sourceSets.main.runtimeClasspath
|
||||
main = 'speiger.src.builder.example.TestBuilder'
|
||||
sourceSets {
|
||||
builder
|
||||
}
|
||||
|
||||
configurations {
|
||||
builderCompile.extendsFrom compile
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -43,6 +44,30 @@ dependencies {
|
|||
testImplementation 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
task generateSource(type: JavaExec) {
|
||||
group = 'internal'
|
||||
description = 'Builds the sourcecode'
|
||||
classpath = sourceSets.builder.runtimeClasspath
|
||||
main = 'speiger.src.builder.PrimitiveCollectionsBuilder'
|
||||
}
|
||||
|
||||
task javadocJar(type: Jar) {
|
||||
from javadoc
|
||||
classifier = 'javadoc'
|
||||
}
|
||||
|
||||
task srcJar(type: Jar) {
|
||||
from sourceSets.main.allSource
|
||||
classifier = 'sources'
|
||||
}
|
||||
|
||||
javadoc.failOnError = false
|
||||
|
||||
artifacts {
|
||||
archives javadocJar
|
||||
archives srcJar
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnit()
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package speiger.src.builder.example;
|
||||
package speiger.src.builder;
|
||||
|
||||
public enum ClassType
|
||||
{
|
|
@ -1,4 +1,4 @@
|
|||
package speiger.src.builder.example;
|
||||
package speiger.src.builder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
|||
package speiger.src.builder.example;
|
||||
package speiger.src.builder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
@ -15,7 +15,7 @@ import java.util.function.Consumer;
|
|||
import speiger.src.builder.processor.TemplateProcess;
|
||||
import speiger.src.builder.processor.TemplateProcessor;
|
||||
|
||||
public class TestBuilder extends TemplateProcessor
|
||||
public class PrimitiveCollectionsBuilder extends TemplateProcessor
|
||||
{
|
||||
Map<String, EnumSet<ClassType>> blocked = new HashMap<>();
|
||||
Map<String, String> nameRemapper = new HashMap<>();
|
||||
|
@ -26,12 +26,12 @@ public class TestBuilder extends TemplateProcessor
|
|||
List<GlobalVariables> biVariables = new ArrayList<>();
|
||||
List<GlobalVariables> enumVariables = new ArrayList<>();
|
||||
|
||||
public TestBuilder()
|
||||
public PrimitiveCollectionsBuilder()
|
||||
{
|
||||
super(Paths.get("src/main/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/main/resources/speiger/assets/collections/"));
|
||||
super(Paths.get("src/builder/resources/speiger/assets/collections/templates/"), Paths.get("src/main/java/speiger/src/collections/"), Paths.get("src/builder/resources/speiger/assets/collections/"));
|
||||
}
|
||||
|
||||
public TestBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
public PrimitiveCollectionsBuilder(Path sourceFolder, Path outputFolder, Path dataFolder)
|
||||
{
|
||||
super(sourceFolder, outputFolder, dataFolder);
|
||||
}
|
||||
|
@ -145,9 +145,9 @@ public class TestBuilder extends TemplateProcessor
|
|||
try
|
||||
{
|
||||
if(args.length == 0) {
|
||||
new TestBuilder().process(false);
|
||||
new PrimitiveCollectionsBuilder().process(false);
|
||||
} else if(args.length == 3) {
|
||||
new TestBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
|
||||
new PrimitiveCollectionsBuilder(Paths.get(args[0]), Paths.get(args[1]), Paths.get(args[2])).process(false);
|
||||
} else {
|
||||
System.out.println("Invalid argument count passed in");
|
||||
System.exit(1);
|
|
@ -180,8 +180,8 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
VALUE_TYPE value = get(key);
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
CLASS_VALUE_TYPE value = get(key);
|
||||
return VALUE_EQUALS_NOT(value, getDefaultReturnValue()) || containsKey(key) ? value : defaultValue;
|
||||
}
|
||||
|
||||
|
@ -191,6 +191,11 @@ public abstract class ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE extends AbstractMap<CL
|
|||
return VALUE_TO_OBJ(key instanceof CLASS_TYPE ? GET_VALUE(CLASS_TO_KEY(key)) : getDefaultReturnValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
return VALUE_TO_OBJ(key instanceof CLASS_TYPE ? getOrDefault(CLASS_TO_KEY(key), OBJ_TO_VALUE(defaultValue)) : getDefaultReturnValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
VALUE_TYPE value = get(key);
|
|
@ -257,7 +257,14 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
return VALUE_TO_OBJ(slot < 0 ? getDefaultReturnValue() : values[slot]);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
return slot < 0 ? defaultValue : values[slot];
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
|
@ -265,12 +272,6 @@ public class CUSTOM_HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VAL
|
|||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
return slot < 0 ? defaultValue : VALUE_TO_OBJ(values[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||
if(entrySet == null) entrySet = new MapEntrySet();
|
|
@ -253,7 +253,14 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
return VALUE_TO_OBJ(slot < 0 ? getDefaultReturnValue() : values[slot]);
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
return slot < 0 ? defaultValue : values[slot];
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
|
@ -261,12 +268,6 @@ public class HASH_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENE
|
|||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
int slot = findIndex(key);
|
||||
return slot < 0 ? defaultValue : VALUE_TO_OBJ(values[slot]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> ENTRY_SET() {
|
||||
if(entrySet == null) entrySet = new MapEntrySet();
|
|
@ -153,7 +153,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return index < 0 ? getDefaultReturnValue() : values[index];
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
#if TYPE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
return index < 0 ? defaultValue : values[index];
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
|
@ -161,12 +168,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
return index < 0 ? defaultValue : VALUE_TO_OBJ(values[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
||||
|
@ -564,7 +565,14 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
return index < 0 ? getDefaultReturnValue() : values[index];
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
return index < 0 ? defaultValue : values[index];
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
|
@ -572,18 +580,6 @@ public class ARRAY_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GEN
|
|||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE get(Object key) {
|
||||
int index = findIndex(key);
|
||||
return VALUE_TO_OBJ(index < 0 ? getDefaultReturnValue() : values[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CLASS_VALUE_TYPE getOrDefault(Object key, CLASS_VALUE_TYPE defaultValue) {
|
||||
int index = findIndex(key);
|
||||
return index < 0 ? defaultValue : VALUE_TO_OBJ(values[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VALUE_TYPE getAndMoveToFirst(KEY_TYPE key) {
|
||||
int index = findIndex(key);
|
|
@ -16,7 +16,7 @@ import speiger.src.collections.objects.maps.abstracts.ABSTRACT_MAP;
|
|||
import speiger.src.collections.objects.maps.interfaces.MAP;
|
||||
import speiger.src.collections.objects.sets.AbstractObjectSet;
|
||||
import speiger.src.collections.objects.sets.ObjectSet;
|
||||
import sun.misc.SharedSecrets;
|
||||
//import sun.misc.SharedSecrets;
|
||||
|
||||
public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_GENERIC_TYPE
|
||||
{
|
||||
|
@ -182,7 +182,10 @@ public class ENUM_MAP KEY_ENUM_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE
|
|||
onNodeRemoved(index);
|
||||
}
|
||||
protected boolean isSet(int index) { return (present[index >> 6] & (1L << index)) != 0; }
|
||||
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) { return SharedSecrets.getJavaLangAccess().getEnumConstantsShared(keyType); }
|
||||
private static <K extends Enum<K>> K[] getKeyUniverse(Class<K> keyType) {
|
||||
return keyType.getEnumConstants();
|
||||
// return SharedSecrets.getJavaLangAccess().getEnumConstantsShared(keyType);
|
||||
}
|
||||
|
||||
class EntrySet extends AbstractObjectSet<MAP.Entry KEY_VALUE_GENERIC_TYPE> {
|
||||
|
|
@ -213,7 +213,7 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return node == null ? getDefaultReturnValue() : node.value;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
Entry KEY_VALUE_GENERIC_TYPE node = findNode((CLASS_TYPE)key);
|
||||
|
@ -918,6 +918,19 @@ public class AVL_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_
|
|||
return inRange(key) ? m.GET_VALUE(key) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
return inRange((KEY_TYPE)key) ? m.getOrDefault(key, defaultValue) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
return inRange(key) ? m.getOrDefault(key, defaultValue) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
|
||||
return inRange(key) ? m.remove(key) : getDefaultReturnValue();
|
|
@ -212,7 +212,7 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
return node == null ? getDefaultReturnValue() : node.value;
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
Entry KEY_VALUE_GENERIC_TYPE node = findNode((CLASS_TYPE)key);
|
||||
|
@ -975,6 +975,19 @@ public class RB_TREE_MAP KEY_VALUE_GENERIC_TYPE extends ABSTRACT_MAP KEY_VALUE_G
|
|||
return inRange(key) ? m.GET_VALUE(key) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#if TYPE_OBJECT && VALUE_OBJECT
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(Object key, VALUE_TYPE defaultValue) {
|
||||
return inRange((KEY_TYPE)key) ? m.getOrDefault(key, defaultValue) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#else
|
||||
@Override
|
||||
public VALUE_TYPE getOrDefault(KEY_TYPE key, VALUE_TYPE defaultValue) {
|
||||
return inRange(key) ? m.getOrDefault(key, defaultValue) : getDefaultReturnValue();
|
||||
}
|
||||
|
||||
#endif
|
||||
@Override
|
||||
public VALUE_TYPE REMOVE_KEY(KEY_TYPE key) {
|
||||
return inRange(key) ? m.remove(key) : getDefaultReturnValue();
|
|
@ -679,6 +679,9 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return set.comparator(); }
|
||||
|
||||
@Override
|
||||
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() {
|
||||
Entry KEY_GENERIC_TYPE entry = findLowest();
|
|
@ -9,6 +9,9 @@ import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
|||
|
||||
public abstract class ABSTRACT_SET KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION KEY_GENERIC_TYPE implements SET KEY_GENERIC_TYPE
|
||||
{
|
||||
@Override
|
||||
public abstract ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 1;
|
|
@ -221,7 +221,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
|||
Objects.requireNonNull(filter);
|
||||
boolean modified = false;
|
||||
int j = 0;
|
||||
for(int i = 0;i<data.length;i++) {
|
||||
for(int i = 0;i<size;i++) {
|
||||
if(!filter.test(data[i])) data[j++] = data[i];
|
||||
else modified = true;
|
||||
}
|
|
@ -739,6 +739,9 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
|||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return set.comparator(); }
|
||||
|
||||
@Override
|
||||
public abstract BI_ITERATOR KEY_GENERIC_TYPE iterator();
|
||||
|
||||
@Override
|
||||
public KEY_TYPE FIRST_KEY() {
|
||||
Entry KEY_GENERIC_TYPE entry = findLowest();
|
Loading…
Reference in New Issue