forked from Speiger/Primitive-Collections
Fixing some inconsistencies that were found.
This commit is contained in:
parent
75c6784ab6
commit
0123cb8937
30
build.gradle
30
build.gradle
|
@ -1,15 +1,15 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'java-library'
|
id 'java-library'
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = 'UTF-8'
|
options.encoding = 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,16 +54,6 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean containsAll(Collection<?> c)
|
|
||||||
{
|
|
||||||
return c instanceof COLLECTION ? containsAll((COLLECTION KEY_GENERIC_TYPE)c) : super.containsAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
/** {@inheritDoc}
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
* <p>This default implementation delegates to the corresponding type-specific function.
|
||||||
|
@ -76,28 +66,6 @@ public abstract class ABSTRACT_COLLECTION KEY_GENERIC_TYPE extends AbstractColle
|
||||||
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
return c instanceof COLLECTION ? addAll((COLLECTION KEY_GENERIC_TYPE)c) : super.addAll(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Primitive
|
|
||||||
public boolean removeAll(Collection<?> c)
|
|
||||||
{
|
|
||||||
return c instanceof COLLECTION ? removeAll((COLLECTION KEY_GENERIC_TYPE)c) : super.removeAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc}
|
|
||||||
* <p>This default implementation delegates to the corresponding type-specific function.
|
|
||||||
* @deprecated Please use the corresponding type-specific function instead.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Primitive
|
|
||||||
public boolean retainAll(Collection<?> c)
|
|
||||||
{
|
|
||||||
return c instanceof COLLECTION ? retainAll((COLLECTION KEY_GENERIC_TYPE)c) : super.retainAll(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
* A Type-Specific implementation of containsAll. This implementation iterates over all elements and checks all elements are present in the other collection.
|
||||||
* @param the collection that should be checked if it contains all elements.
|
* @param the collection that should be checked if it contains all elements.
|
||||||
|
|
|
@ -63,7 +63,7 @@ public interface COLLECTION KEY_GENERIC_TYPE extends Collection<CLASS_TYPE>, ITE
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAny(Collection<?> c);
|
public boolean containsAny(Collection<?> c);
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
/**
|
/**
|
||||||
* A Type-Specific remove function that reduces (un)boxing.
|
* A Type-Specific remove function that reduces (un)boxing.
|
||||||
* @return true if the element was removed
|
* @return true if the element was removed
|
||||||
|
|
|
@ -369,7 +369,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAll(Collection<?> c) {
|
public boolean containsAll(Collection<?> c) {
|
||||||
if(c instanceof COLLECTION) return containsAll((COLLECTION KEY_GENERIC_TYPE)c);
|
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
for(int i = 0,m=size;i<m;i++) {
|
for(int i = 0,m=size;i<m;i++) {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
@ -391,9 +390,7 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean containsAny(Collection<?> c)
|
public boolean containsAny(Collection<?> c) {
|
||||||
{
|
|
||||||
if(c instanceof COLLECTION) return containsAny((COLLECTION KEY_GENERIC_TYPE)c);
|
|
||||||
Objects.requireNonNull(c);
|
Objects.requireNonNull(c);
|
||||||
for(int i = 0,m=size;i<m;i++) {
|
for(int i = 0,m=size;i<m;i++) {
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
@ -405,6 +402,18 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function to find if the Element is present in this list.
|
||||||
|
* @param e the element that is searched for
|
||||||
|
* @return if the element was found.
|
||||||
|
* @deprecated if type-specific but still supported because of special edgecase Object-Comparason features
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Primitive
|
||||||
|
public boolean contains(Object o) {
|
||||||
|
return indexOf(o) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A function to find the index of a given element
|
* A function to find the index of a given element
|
||||||
* @param e the element that is searched for
|
* @param e the element that is searched for
|
||||||
|
@ -508,6 +517,16 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !TYPE_OBJECT
|
#if !TYPE_OBJECT
|
||||||
|
/**
|
||||||
|
* A Type Specific implementation of the Collection#contains function.
|
||||||
|
* @param the element that is searched for.
|
||||||
|
* @returns if the element was found
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean contains(KEY_TYPE e) {
|
||||||
|
return indexOf(e) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Type-Specific function to find the index of a given element
|
* A Type-Specific function to find the index of a given element
|
||||||
* @param e the element that is searched for
|
* @param e the element that is searched for
|
||||||
|
@ -725,7 +744,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
@Primitive
|
@Primitive
|
||||||
public boolean removeAll(Collection<?> c) {
|
public boolean removeAll(Collection<?> c) {
|
||||||
if(c.isEmpty()) return false;
|
if(c.isEmpty()) return false;
|
||||||
if(c instanceof COLLECTION) return removeAll((COLLECTION KEY_GENERIC_TYPE)c);
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
|
@ -755,7 +773,6 @@ public class ARRAY_LIST KEY_GENERIC_TYPE extends ABSTRACT_LIST KEY_GENERIC_TYPE
|
||||||
clear();
|
clear();
|
||||||
return modifed;
|
return modifed;
|
||||||
}
|
}
|
||||||
if(c instanceof COLLECTION) return retainAll((COLLECTION KEY_GENERIC_TYPE)c);
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for(int i = 0;i<size;i++) {
|
for(int i = 0;i<size;i++) {
|
||||||
|
|
|
@ -240,13 +240,12 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return findNode(e) != null;
|
return findNode(e) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return findNode((T)e) != null;
|
return findNode(OBJ_TO_KEY(((CLASS_TYPE)e))) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(tree == null) throw new NoSuchElementException();
|
if(tree == null) throw new NoSuchElementException();
|
||||||
|
@ -271,11 +270,11 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if(tree == null) return false;
|
if(tree == null) return false;
|
||||||
Entry KEY_GENERIC_TYPE entry = findNode((T)o);
|
Entry KEY_GENERIC_TYPE entry = findNode(OBJ_TO_KEY(((CLASS_TYPE)o)));
|
||||||
if(entry != null) {
|
if(entry != null) {
|
||||||
removeNode(entry);
|
removeNode(entry);
|
||||||
return true;
|
return true;
|
||||||
|
@ -283,7 +282,6 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(tree == null) throw new NoSuchElementException();
|
if(tree == null) throw new NoSuchElementException();
|
||||||
|
@ -708,18 +706,19 @@ public class AVL_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return inRange(o) && set.remove(o);
|
return inRange(o) && set.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return inRange((T)e) && set.contains((T)e);
|
KEY_TYPE o = OBJ_TO_KEY(((CLASS_TYPE)e));
|
||||||
|
return inRange(o) && set.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object e) {
|
||||||
return inRange((T)o) && set.remove((T)o);
|
KEY_TYPE o = OBJ_TO_KEY(((CLASS_TYPE)e));
|
||||||
|
return inRange(o) && set.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE lower(KEY_TYPE e) {
|
public KEY_TYPE lower(KEY_TYPE e) {
|
||||||
if(tooHigh(e)) {
|
if(tooHigh(e)) {
|
||||||
|
|
|
@ -4,11 +4,9 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
#if TYPE_OBJECT
|
#if TYPE_OBJECT
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
#endif
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#else
|
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
#endif
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.BI_ITERATOR;
|
||||||
|
@ -150,7 +148,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return findIndex((KEY_TYPE)e) != -1;
|
return findIndex(e) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -180,7 +178,7 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
#else
|
#else
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
int index = findIndex((KEY_TYPE)o);
|
int index = findIndex(o);
|
||||||
if(index != -1) {
|
if(index != -1) {
|
||||||
System.arraycopy(data, index+1, data, index, size - index);
|
System.arraycopy(data, index+1, data, index, size - index);
|
||||||
data[size-1] = EMPTY_VALUE;
|
data[size-1] = EMPTY_VALUE;
|
||||||
|
@ -213,12 +211,20 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !TYPE_OBJECT
|
||||||
protected int findIndex(KEY_TYPE o) {
|
protected int findIndex(KEY_TYPE o) {
|
||||||
for(int i = size-1;i>=0;i--)
|
for(int i = size-1;i>=0;i--)
|
||||||
if(EQUALS(data[i], o)) return i;
|
if(EQUALS(data[i], o)) return i;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected int findIndex(Object o) {
|
||||||
|
for(int i = size-1;i>=0;i--)
|
||||||
|
if(EQUALS_KEY_TYPE(data[i], o)) return i;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
public BI_ITERATOR KEY_GENERIC_TYPE iterator() {
|
||||||
return new SetIterator(0);
|
return new SetIterator(0);
|
||||||
|
@ -359,13 +365,12 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
return findIndex(e) != -1;
|
return findIndex(e) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return findIndex((KEY_TYPE)e) != -1;
|
return findIndex(e) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(length == 0) throw new NoSuchElementException();
|
if(length == 0) throw new NoSuchElementException();
|
||||||
|
@ -391,10 +396,10 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
int index = findIndex((KEY_TYPE)o);
|
int index = findIndex(o);
|
||||||
if(index != -1) {
|
if(index != -1) {
|
||||||
System.arraycopy(data, index+1, data, index, size - index);
|
System.arraycopy(data, index+1, data, index, size - index);
|
||||||
data[size-1] = EMPTY_VALUE;
|
data[size-1] = EMPTY_VALUE;
|
||||||
|
@ -405,7 +410,6 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(length == 0) throw new NoSuchElementException();
|
if(length == 0) throw new NoSuchElementException();
|
||||||
|
@ -476,9 +480,17 @@ public class ARRAY_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE im
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findIndex(KEY_TYPE o) {
|
#if !TYPE_OBJECT
|
||||||
for(int i = length-1;i>=0;i--)
|
protected int findIndex(KEY_TYPE o) {
|
||||||
if(data[offset+i] == o) return i + offset;
|
for(int i = size-1;i>=0;i--)
|
||||||
|
if(EQUALS(data[offset+i], o)) return i + offset;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
protected int findIndex(Object o) {
|
||||||
|
for(int i = size-1;i>=0;i--)
|
||||||
|
if(EQUALS_KEY_TYPE(data[offset+i], o)) return i + offset;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,7 @@ import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
#if TYPE_OBJECT
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
#endif
|
|
||||||
|
|
||||||
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
import speiger.src.collections.PACKAGE.collections.COLLECTION;
|
||||||
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
import speiger.src.collections.PACKAGE.collections.ITERATOR;
|
||||||
|
@ -152,34 +150,33 @@ public class HASH_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE imp
|
||||||
return super.addAll(c);
|
return super.addAll(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TYPE_OBJECT
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object o) {
|
public boolean contains(Object o) {
|
||||||
if(EQUALS_NULL(o)) return containsNull;
|
if(o == null) return containsNull;
|
||||||
int pos = HashUtil.mix(TO_HASH(o)) & mask;
|
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(EQUALS_NULL(current)) return false;
|
if(EQUALS_NULL(current)) return false;
|
||||||
if(EQUALS(current, o)) return true;
|
if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||||
while(true) {
|
while(true) {
|
||||||
if(EQUALS_NULL((current = keys[++pos & mask]))) return false;
|
if(EQUALS_NULL((current = keys[++pos & mask]))) return false;
|
||||||
else if(EQUALS(current, o)) return true;
|
else if(EQUALS_KEY_TYPE(current, o)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if(EQUALS_NULL(o)) return (containsNull ? removeNullIndex() : false);
|
if(o == null) return (containsNull ? removeNullIndex() : false);
|
||||||
int pos = HashUtil.mix(TO_HASH(o)) & mask;
|
int pos = HashUtil.mix(o.hashCode()) & mask;
|
||||||
KEY_TYPE current = keys[pos];
|
KEY_TYPE current = keys[pos];
|
||||||
if(EQUALS_NULL(current)) return false;
|
if(EQUALS_NULL(current)) return false;
|
||||||
if(EQUALS(current, o)) return removeIndex(pos);
|
if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||||
while(true) {
|
while(true) {
|
||||||
if(EQUALS_NULL((current = keys[++pos & mask]))) return false;
|
if(EQUALS_NULL((current = keys[++pos & mask]))) return false;
|
||||||
else if(EQUALS(current, o)) return removeIndex(pos);
|
else if(EQUALS_KEY_TYPE(current, o)) return removeIndex(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#if !TYPE_OBJECT
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(KEY_TYPE o) {
|
public boolean contains(KEY_TYPE o) {
|
||||||
if(EQUALS_NULL(o)) return containsNull;
|
if(EQUALS_NULL(o)) return containsNull;
|
||||||
|
|
|
@ -240,13 +240,12 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return findNode(e) != null;
|
return findNode(e) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return findNode((T)e) != null;
|
return findNode(OBJ_TO_KEY(((CLASS_TYPE)e))) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE FIRST_KEY() {
|
public KEY_TYPE FIRST_KEY() {
|
||||||
if(tree == null) throw new NoSuchElementException();
|
if(tree == null) throw new NoSuchElementException();
|
||||||
|
@ -271,11 +270,11 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object o) {
|
||||||
if(tree == null) return false;
|
if(tree == null) return false;
|
||||||
Entry KEY_GENERIC_TYPE entry = findNode((T)o);
|
Entry KEY_GENERIC_TYPE entry = findNode(OBJ_TO_KEY(((CLASS_TYPE)o)));
|
||||||
if(entry != null) {
|
if(entry != null) {
|
||||||
removeNode(entry);
|
removeNode(entry);
|
||||||
return true;
|
return true;
|
||||||
|
@ -283,7 +282,6 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE POLL_FIRST_KEY() {
|
public KEY_TYPE POLL_FIRST_KEY() {
|
||||||
if(tree == null) throw new NoSuchElementException();
|
if(tree == null) throw new NoSuchElementException();
|
||||||
|
@ -766,18 +764,19 @@ public class RB_TREE_SET KEY_GENERIC_TYPE extends ABSTRACT_SET KEY_GENERIC_TYPE
|
||||||
return inRange(o) && set.remove(o);
|
return inRange(o) && set.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#endif
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(Object e) {
|
public boolean contains(Object e) {
|
||||||
return inRange((T)e) && set.contains((T)e);
|
KEY_TYPE o = OBJ_TO_KEY(((CLASS_TYPE)e));
|
||||||
|
return inRange(o) && set.contains(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean remove(Object o) {
|
public boolean remove(Object e) {
|
||||||
return inRange((T)o) && set.remove((T)o);
|
KEY_TYPE o = OBJ_TO_KEY(((CLASS_TYPE)e));
|
||||||
|
return inRange(o) && set.remove(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
@Override
|
@Override
|
||||||
public KEY_TYPE lower(KEY_TYPE e) {
|
public KEY_TYPE lower(KEY_TYPE e) {
|
||||||
if(tooHigh(e)) {
|
if(tooHigh(e)) {
|
||||||
|
|
Loading…
Reference in New Issue