diff --git a/build.gradle b/build.gradle index 300362a6..8d76ce72 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ repositories { } archivesBaseName = 'Primitive Collections' -version = '0.6.2.6-SNAPSHOT'; +version = '0.6.2.8-SNAPSHOT'; sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current(); diff --git a/src/builder/resources/speiger/assets/collections/templates/lists/AbstractList.template b/src/builder/resources/speiger/assets/collections/templates/lists/AbstractList.template index c678ef2f..15ab87c0 100644 --- a/src/builder/resources/speiger/assets/collections/templates/lists/AbstractList.template +++ b/src/builder/resources/speiger/assets/collections/templates/lists/AbstractList.template @@ -540,7 +540,8 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION @Override public void add(KEY_TYPE e) { - ABSTRACT_LIST.this.add(index++, e); + ABSTRACT_LIST.this.add(index, e); + index++; lastReturned = -1; } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template index 2045a766..03d554e0 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Collections.template @@ -350,7 +350,7 @@ public class COLLECTIONS @Override public boolean contains(KEY_TYPE o) { return false; } @Override - public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return false; } + public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return c.isEmpty(); } @Override public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) { return false; } #else @@ -362,7 +362,7 @@ public class COLLECTIONS public boolean containsAny(Collection c) { return false; } @Override @Primitive - public boolean containsAll(Collection c) { return false; } + public boolean containsAll(Collection c) { return c.isEmpty(); } @Override public int hashCode() { return 0; } @@ -401,14 +401,28 @@ public class COLLECTIONS public Object[] toArray() { return ObjectArrays.EMPTY_ARRAY; } #if !TYPE_OBJECT @Override - public T[] toArray(T[] a) { return a; } + public T[] toArray(T[] a) { + if(a != null && a.length > 0) + a[0] = null; + return a; + } + @Override public KEY_TYPE[] TO_ARRAY() { return ARRAYS.EMPTY_ARRAY; } @Override - public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) { return a; } + public KEY_TYPE[] TO_ARRAY(KEY_TYPE[] a) { + if(a != null && a.length > 0) + a[0] = EMPTY_KEY_VALUE; + return a; + } + #else @Override - public E[] toArray(E[] a) { return a; } + public E[] toArray(E[] a) { + if(a != null && a.length > 0) + a[0] = EMPTY_KEY_VALUE; + return a; + } #endif @Override public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.empty(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template index 7b068356..0defdd6c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Iterators.template @@ -299,7 +299,7 @@ public class ITERATORS * @ArrayType(T) * @return a Iterator that is wrapping a array. */ - public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE[] a) { + public static GENERIC_KEY_BRACES ArrayIterator KEY_GENERIC_TYPE wrap(KEY_TYPE... a) { return wrap(a, 0, a.length); } @@ -755,7 +755,7 @@ public class ITERATORS @Override public int previousIndex() { - return 0; + return -1; } @Override diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template b/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template index 7e08234b..2663a000 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Lists.template @@ -1,6 +1,7 @@ package speiger.src.collections.PACKAGE.utils; import java.util.Collection; +import java.util.List; import java.util.Objects; import java.util.Random; import java.util.RandomAccess; @@ -601,6 +602,16 @@ public class LISTS return ITERATORS.empty(); } + @Override + public int hashCode() { return 1; } + + @Override + public boolean equals(Object o) { + if(o == this) return true; + if(!(o instanceof List)) return false; + return ((List)o).isEmpty(); + } + @Override public LIST KEY_GENERIC_TYPE subList(int from, int to) { throw new UnsupportedOperationException(); } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template b/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template index a420738a..8d63b4c5 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/Sets.template @@ -1,6 +1,7 @@ package speiger.src.collections.PACKAGE.utils; import java.util.NoSuchElementException; +import java.util.Set; #if TYPE_BOOLEAN import speiger.src.collections.booleans.collections.BooleanIterator; import speiger.src.collections.booleans.sets.AbstractBooleanSet; @@ -242,6 +243,13 @@ public class SETS @Override public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); } #endif + @Override + public boolean equals(Object o) { + if(o == this) return true; + if(!(o instanceof Set)) return false; + return ((Set)o).isEmpty(); + } + @Override public EmptySet KEY_GENERIC_TYPE copy() { return this; } }