Fixed Bugs found with wrapper collections
-Fixed: AbstractCollection.Iterator was changing the pointer before validating if the element was added. (ImmutableLists) -Fixed: EmptyCollections containsAll should return true if it is compared against a emptyCollection. -Fixed: HashCode/Equals for the Lists/Sets implementations. -Changed: Iterators.wrap(Array) allows now dynamic arrays.
This commit is contained in:
parent
9eb220194f
commit
1e7da394a1
|
@ -18,7 +18,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
archivesBaseName = 'Primitive Collections'
|
archivesBaseName = 'Primitive Collections'
|
||||||
version = '0.6.2.6-SNAPSHOT';
|
version = '0.6.2.8-SNAPSHOT';
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaVersion.current();
|
||||||
|
|
||||||
|
|
|
@ -540,7 +540,8 @@ public abstract class ABSTRACT_LIST KEY_GENERIC_TYPE extends ABSTRACT_COLLECTION
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(KEY_TYPE e) {
|
public void add(KEY_TYPE e) {
|
||||||
ABSTRACT_LIST.this.add(index++, e);
|
ABSTRACT_LIST.this.add(index, e);
|
||||||
|
index++;
|
||||||
lastReturned = -1;
|
lastReturned = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -350,7 +350,7 @@ public class COLLECTIONS
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) { return false; }
|
public boolean contains(KEY_TYPE o) { return false; }
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
public boolean containsAll(COLLECTION KEY_GENERIC_TYPE c) { return c.isEmpty(); }
|
||||||
@Override
|
@Override
|
||||||
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
public boolean containsAny(COLLECTION KEY_GENERIC_TYPE c) { return false; }
|
||||||
#else
|
#else
|
||||||
|
@ -362,7 +362,7 @@ public class COLLECTIONS
|
||||||
public boolean containsAny(Collection<?> c) { return false; }
|
public boolean containsAny(Collection<?> c) { return false; }
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAll(Collection<?> c) { return false; }
|
public boolean containsAll(Collection<?> c) { return c.isEmpty(); }
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() { return 0; }
|
public int hashCode() { return 0; }
|
||||||
|
|
||||||
|
@ -401,14 +401,28 @@ public class COLLECTIONS
|
||||||
public Object[] toArray() { return ObjectArrays.EMPTY_ARRAY; }
|
public Object[] toArray() { return ObjectArrays.EMPTY_ARRAY; }
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public <T> T[] toArray(T[] a) { return a; }
|
public <T> T[] toArray(T[] a) {
|
||||||
|
if(a != null && a.length > 0)
|
||||||
|
a[0] = null;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE[] TO_ARRAY() { return ARRAYS.EMPTY_ARRAY; }
|
public KEY_TYPE[] TO_ARRAY() { return ARRAYS.EMPTY_ARRAY; }
|
||||||
@Override
|
@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
|
#else
|
||||||
@Override
|
@Override
|
||||||
public <E> E[] toArray(E[] a) { return a; }
|
public <E> E[] toArray(E[] a) {
|
||||||
|
if(a != null && a.length > 0)
|
||||||
|
a[0] = EMPTY_KEY_VALUE;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.empty(); }
|
public ITERATOR KEY_GENERIC_TYPE iterator() { return ITERATORS.empty(); }
|
||||||
|
|
|
@ -299,7 +299,7 @@ public class ITERATORS
|
||||||
* @ArrayType(T)
|
* @ArrayType(T)
|
||||||
* @return a Iterator that is wrapping a array.
|
* @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);
|
return wrap(a, 0, a.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,7 +755,7 @@ public class ITERATORS
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int previousIndex() {
|
public int previousIndex() {
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.RandomAccess;
|
import java.util.RandomAccess;
|
||||||
|
@ -601,6 +602,16 @@ public class LISTS
|
||||||
return ITERATORS.empty();
|
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
|
@Override
|
||||||
public LIST KEY_GENERIC_TYPE subList(int from, int to) { throw new UnsupportedOperationException(); }
|
public LIST KEY_GENERIC_TYPE subList(int from, int to) { throw new UnsupportedOperationException(); }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package speiger.src.collections.PACKAGE.utils;
|
package speiger.src.collections.PACKAGE.utils;
|
||||||
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Set;
|
||||||
#if TYPE_BOOLEAN
|
#if TYPE_BOOLEAN
|
||||||
import speiger.src.collections.booleans.collections.BooleanIterator;
|
import speiger.src.collections.booleans.collections.BooleanIterator;
|
||||||
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
import speiger.src.collections.booleans.sets.AbstractBooleanSet;
|
||||||
|
@ -242,6 +243,13 @@ public class SETS
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
public KEY_TYPE addOrGet(KEY_TYPE o) { throw new UnsupportedOperationException(); }
|
||||||
#endif
|
#endif
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if(o == this) return true;
|
||||||
|
if(!(o instanceof Set)) return false;
|
||||||
|
return ((Set<?>)o).isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
public EmptySet KEY_GENERIC_TYPE copy() { return this; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue