Map Tests & BugFixes.
-Added: Tests for all map implementations. -Added: Missing Map Constructors. -Fixed: Bugs with Maps & Sets. -Fixed: Gradle Java Container. -Fixed: Some javadoc stuff. -Note: SubMap/List implementation are not really well tested and most likely buggy -Changed: set JavaDoc to be quiet for now. Later goal.
This commit is contained in:
+54
-1
@@ -38,6 +38,10 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
public AVL_TREE_SET() {
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(KEY_TYPE[] array) {
|
||||
this(array, 0, array.length);
|
||||
}
|
||||
@@ -47,15 +51,41 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
this(array, 0, array.length, comp);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(KEY_TYPE[] array, int offset, int length, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(SORTED_SET KEY_GENERIC_TYPE sortedSet) {
|
||||
comparator = sortedSet.comparator();
|
||||
addAll(sortedSet);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AVL_TREE_SET(Collection<? extends CLASS_TYPE> collection) {
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public AVL_TREE_SET(Collection<? extends CLASS_TYPE> collection, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(COLLECTION KEY_GENERIC_TYPE collection) {
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(COLLECTION KEY_GENERIC_TYPE collection, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(Iterator<CLASS_TYPE> iterator) {
|
||||
#if !TYPE_OBJECT
|
||||
this(ITERATORS.wrap(iterator));
|
||||
@@ -64,10 +94,24 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
#endif
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(Iterator<CLASS_TYPE> iterator, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
#if !TYPE_OBJECT
|
||||
this(ITERATORS.wrap(iterator), comp);
|
||||
#else
|
||||
comparator = comp;
|
||||
while(iterator.hasNext()) add(iterator.next());
|
||||
#endif
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(ITERATOR KEY_GENERIC_TYPE iterator) {
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
public AVL_TREE_SET(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||
@@ -339,6 +383,14 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
size = 0;
|
||||
first = null;
|
||||
last = null;
|
||||
tree = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||
|
||||
@@ -533,7 +585,8 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||
DescendingSubSet(AVL_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
||||
super(set, fromStart, start, loInclusive, toEnd, end, hiInclusive);
|
||||
comparator = set.comparator().reversed();
|
||||
comparator = set.comparator();
|
||||
if(comparator != null) comparator = comparator.reversed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -346,8 +346,9 @@ public class LINKED_CUSTOM_HASH_SET KEY_GENERIC_TYPE extends CUSTOM_HASH_SET KEY
|
||||
int newMask = newSize - 1;
|
||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||
long[] newLinks = new long[newSize + 1];
|
||||
int newPrev = -1;
|
||||
for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) {
|
||||
int i = firstIndex, prev = -1, newPrev = -1, pos;
|
||||
firstIndex = -1;
|
||||
for(int j = size; j-- != 0;) {
|
||||
if(strategy.equals(keys[i], EMPTY_KEY_VALUE)) pos = newSize;
|
||||
else {
|
||||
pos = HashUtil.mix(strategy.hashCode(keys[i])) & newMask;
|
||||
|
||||
+3
-2
@@ -348,8 +348,9 @@ public class LINKED_HASH_SET KEY_GENERIC_TYPE extends HASH_SET KEY_GENERIC_TYPE
|
||||
int newMask = newSize - 1;
|
||||
KEY_TYPE[] newKeys = NEW_KEY_ARRAY(newSize + 1);
|
||||
long[] newLinks = new long[newSize + 1];
|
||||
int newPrev = -1;
|
||||
for(int j = size, i = firstIndex, pos = 0, prev = -1;j != 0;) {
|
||||
int i = firstIndex, prev = -1, newPrev = -1, pos;
|
||||
firstIndex = -1;
|
||||
for(int j = size; j-- != 0;) {
|
||||
if(KEY_EQUALS_NULL(keys[i])) pos = newSize;
|
||||
else {
|
||||
pos = HashUtil.mix(KEY_TO_HASH(keys[i])) & newMask;
|
||||
|
||||
@@ -38,6 +38,10 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
public RB_TREE_SET() {
|
||||
}
|
||||
|
||||
public RB_TREE_SET(COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
}
|
||||
|
||||
public RB_TREE_SET(KEY_TYPE[] array) {
|
||||
this(array, 0, array.length);
|
||||
}
|
||||
@@ -47,14 +51,40 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(KEY_TYPE[] array, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
this(array, 0, array.length, comp);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(KEY_TYPE[] array, int offset, int length, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
SanityChecks.checkArrayCapacity(array.length, offset, length);
|
||||
for(int i = 0;i<length;i++) add(array[offset+i]);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(SORTED_SET KEY_GENERIC_TYPE sortedSet) {
|
||||
comparator = sortedSet.comparator();
|
||||
addAll(sortedSet);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RB_TREE_SET(Collection<? extends CLASS_TYPE> collection) {
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public RB_TREE_SET(Collection<? extends CLASS_TYPE> collection, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(COLLECTION KEY_GENERIC_TYPE collection) {
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(COLLECTION KEY_GENERIC_TYPE collection, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
addAll(collection);
|
||||
}
|
||||
|
||||
public RB_TREE_SET(Iterator<CLASS_TYPE> iterator) {
|
||||
#if !TYPE_OBJECT
|
||||
@@ -63,11 +93,25 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
while(iterator.hasNext()) add(iterator.next());
|
||||
#endif
|
||||
}
|
||||
|
||||
public RB_TREE_SET(Iterator<CLASS_TYPE> iterator, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
#if !TYPE_OBJECT
|
||||
this(ITERATORS.wrap(iterator), comp);
|
||||
#else
|
||||
comparator = comp;
|
||||
while(iterator.hasNext()) add(iterator.next());
|
||||
#endif
|
||||
}
|
||||
|
||||
public RB_TREE_SET(ITERATOR KEY_GENERIC_TYPE iterator) {
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
public RB_TREE_SET(ITERATOR KEY_GENERIC_TYPE iterator, COMPARATOR KEY_GENERIC_TYPE comp) {
|
||||
comparator = comp;
|
||||
while(iterator.hasNext()) add(iterator.NEXT());
|
||||
}
|
||||
|
||||
#if !TYPE_OBJECT
|
||||
@Override
|
||||
public void setDefaultMaxValue(KEY_TYPE value) { defaultMaxNotFound = value; }
|
||||
@@ -341,6 +385,14 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
@Override
|
||||
public int size() { return size; }
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
size = 0;
|
||||
first = null;
|
||||
last = null;
|
||||
tree = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public COMPARATOR KEY_GENERIC_TYPE comparator() { return comparator; }
|
||||
|
||||
@@ -593,7 +645,8 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||
COMPARATOR KEY_GENERIC_TYPE comparator;
|
||||
DescendingSubSet(RB_TREE_SET KEY_GENERIC_TYPE set, boolean fromStart, KEY_TYPE start, boolean loInclusive, boolean toEnd, KEY_TYPE end, boolean hiInclusive) {
|
||||
super(set, fromStart, start, loInclusive, toEnd, end, hiInclusive);
|
||||
comparator = set.comparator().reversed();
|
||||
comparator = set.comparator();
|
||||
if(comparator != null) comparator = comparator.reversed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user