Package net.ontopia.utils
Class SynchronizedCompactHashSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- net.ontopia.utils.CompactHashSet<E>
-
- net.ontopia.utils.SynchronizedCompactHashSet<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
public class SynchronizedCompactHashSet<E> extends CompactHashSet<E>
INTERNAL: Extends CompactHashSet to make it synchronized. Saves memory compared with having to wrap the set in a SynchronizedSet.
-
-
Field Summary
-
Fields inherited from class net.ontopia.utils.CompactHashSet
deletedObject, elements, freecells, INITIAL_SIZE, LOAD_FACTOR, modCount, nullObject, objects
-
-
Constructor Summary
Constructors Constructor Description SynchronizedCompactHashSet()
SynchronizedCompactHashSet(int size)
SynchronizedCompactHashSet(Collection c)
-
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.boolean
addAll(Collection coll)
void
clear()
Removes all of the elements from this set.boolean
contains(Object o)
Returns true if this set contains the specified element.boolean
containsAll(Collection coll)
boolean
equals(Object o)
int
hashCode()
boolean
isEmpty()
Returns true if this set contains no elements.Iterator<E>
iterator()
Returns an iterator over the elements in this set.boolean
remove(Object o)
Removes the specified element from the set.boolean
removeAll(Collection coll)
boolean
retainAll(Collection coll)
int
size()
Returns the number of elements in this set (its cardinality).Object[]
toArray()
<E> E[]
toArray(E[] a)
String
toString()
-
Methods inherited from class net.ontopia.utils.CompactHashSet
dump, rehash, rehash
-
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
spliterator
-
-
-
-
Constructor Detail
-
SynchronizedCompactHashSet
public SynchronizedCompactHashSet()
-
SynchronizedCompactHashSet
public SynchronizedCompactHashSet(Collection c)
-
SynchronizedCompactHashSet
public SynchronizedCompactHashSet(int size)
-
-
Method Detail
-
size
public int size()
Description copied from class:CompactHashSet
Returns the number of elements in this set (its cardinality).- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Overrides:
size
in classCompactHashSet<E>
-
isEmpty
public boolean isEmpty()
Description copied from class:CompactHashSet
Returns true if this set contains no elements.- Specified by:
isEmpty
in interfaceCollection<E>
- Specified by:
isEmpty
in interfaceSet<E>
- Overrides:
isEmpty
in classCompactHashSet<E>
-
contains
public boolean contains(Object o)
Description copied from class:CompactHashSet
Returns true if this set contains the specified element.- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classCompactHashSet<E>
- Parameters:
o
- element whose presence in this set is to be tested.- Returns:
- true if this set contains the specified element.
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classCompactHashSet<E>
-
toArray
public <E> E[] toArray(E[] a)
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classCompactHashSet<E>
-
iterator
public Iterator<E> iterator()
Description copied from class:CompactHashSet
Returns an iterator over the elements in this set. The elements are returned in no particular order.- Specified by:
iterator
in interfaceCollection<E>
- Specified by:
iterator
in interfaceIterable<E>
- Specified by:
iterator
in interfaceSet<E>
- Overrides:
iterator
in classCompactHashSet<E>
- Returns:
- an Iterator over the elements in this set.
- See Also:
ConcurrentModificationException
-
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>
-
containsAll
public boolean containsAll(Collection coll)
- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Overrides:
containsAll
in classAbstractCollection<E>
-
addAll
public boolean addAll(Collection 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>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceCollection<E>
- Specified by:
equals
in interfaceSet<E>
- Overrides:
equals
in classAbstractSet<E>
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Specified by:
hashCode
in interfaceSet<E>
- Overrides:
hashCode
in classAbstractSet<E>
-
-