Package net.ontopia.utils
Class UniqueSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- net.ontopia.utils.CompactHashSet<E>
-
- net.ontopia.utils.UniqueSet<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
public class UniqueSet<E> extends CompactHashSet<E>
INTERNAL:
-
-
Field Summary
Fields Modifier and Type Field Description protected int
hc
protected int
hc_modCount
-
Fields inherited from class net.ontopia.utils.CompactHashSet
deletedObject, elements, freecells, INITIAL_SIZE, LOAD_FACTOR, modCount, nullObject, objects
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(Object o)
Adds the specified element to this set if it is not already present.UniqueSet<E>
add(UniqueSet<E> set, Object o, boolean dereference)
boolean
addAll(Collection<? extends E> coll)
void
clear()
Removes all of the elements from this set.void
dereference(UniqueSet<E> set)
void
dump()
INTERNAL: Used for debugging only.protected boolean
equalsAdd(UniqueSet<E> other, Object o)
protected boolean
equalsRemove(UniqueSet<E> other, Object o)
UniqueSet<E>
get(Set<E> set)
INTERNAL: Get the internal representation of a given set.int
getReferenceCount()
int
hashCode()
protected E
lookup(Object o)
INTERNAL: Looks up the object in the hashset and returns the actual object stored at the hashset.boolean
remove(Object o)
Removes the specified element from the set.UniqueSet<E>
remove(UniqueSet<E> set, Object o, boolean dereference)
boolean
removeAll(Collection<?> coll)
boolean
retainAll(Collection<?> coll)
String
toString()
-
Methods inherited from class net.ontopia.utils.CompactHashSet
contains, isEmpty, iterator, rehash, rehash, size, toArray, toArray
-
Methods inherited from class java.util.AbstractSet
equals
-
Methods inherited from class java.util.AbstractCollection
containsAll
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.Set
containsAll, spliterator
-
-
-
-
Method Detail
-
getReferenceCount
public int getReferenceCount()
-
get
public UniqueSet<E> get(Set<E> set)
INTERNAL: Get the internal representation of a given set. The initial reference count is 1.
-
lookup
protected E lookup(Object o)
INTERNAL: Looks up the object in the hashset and returns the actual object stored at the hashset. Note that this might be another object, but one that is considered to be equal.
-
dump
public void dump()
Description copied from class:CompactHashSet
INTERNAL: Used for debugging only.- Overrides:
dump
in classCompactHashSet<E>
-
add
public boolean add(Object o)
Description copied from class:CompactHashSet
Adds the specified element to this set if it is not already present.- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classCompactHashSet<E>
- Parameters:
o
- element to be added to this set.- Returns:
- true if the set did not already contain the specified element.
-
remove
public boolean remove(Object o)
Description copied from class:CompactHashSet
Removes the specified element from the set.- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classCompactHashSet<E>
-
addAll
public boolean addAll(Collection<? extends E> coll)
- Specified by:
addAll
in interfaceCollection<E>
- Specified by:
addAll
in interfaceSet<E>
- Overrides:
addAll
in classAbstractCollection<E>
-
removeAll
public boolean removeAll(Collection<?> coll)
- Specified by:
removeAll
in interfaceCollection<E>
- Specified by:
removeAll
in interfaceSet<E>
- Overrides:
removeAll
in classAbstractSet<E>
-
retainAll
public boolean retainAll(Collection<?> coll)
- Specified by:
retainAll
in interfaceCollection<E>
- Specified by:
retainAll
in interfaceSet<E>
- Overrides:
retainAll
in classAbstractCollection<E>
-
clear
public void clear()
Description copied from class:CompactHashSet
Removes all of the elements from this set.- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classCompactHashSet<E>
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<E>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceSet<E>
- Overrides:
hashCode
in classAbstractSet<E>
-
-