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 booleanadd(Object o)Adds the specified element to this set if it is not already present.booleanaddAll(Collection coll)voidclear()Removes all of the elements from this set.booleancontains(Object o)Returns true if this set contains the specified element.booleancontainsAll(Collection coll)booleanequals(Object o)inthashCode()booleanisEmpty()Returns true if this set contains no elements.Iterator<E>iterator()Returns an iterator over the elements in this set.booleanremove(Object o)Removes the specified element from the set.booleanremoveAll(Collection coll)booleanretainAll(Collection coll)intsize()Returns the number of elements in this set (its cardinality).Object[]toArray()<E> E[]toArray(E[] a)StringtoString()-
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:CompactHashSetReturns the number of elements in this set (its cardinality).- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein interfaceSet<E>- Overrides:
sizein classCompactHashSet<E>
-
isEmpty
public boolean isEmpty()
Description copied from class:CompactHashSetReturns true if this set contains no elements.- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceSet<E>- Overrides:
isEmptyin classCompactHashSet<E>
-
contains
public boolean contains(Object o)
Description copied from class:CompactHashSetReturns true if this set contains the specified element.- Specified by:
containsin interfaceCollection<E>- Specified by:
containsin interfaceSet<E>- Overrides:
containsin 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:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classCompactHashSet<E>
-
toArray
public <E> E[] toArray(E[] a)
- Specified by:
toArrayin interfaceCollection<E>- Specified by:
toArrayin interfaceSet<E>- Overrides:
toArrayin classCompactHashSet<E>
-
iterator
public Iterator<E> iterator()
Description copied from class:CompactHashSetReturns an iterator over the elements in this set. The elements are returned in no particular order.- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin interfaceSet<E>- Overrides:
iteratorin classCompactHashSet<E>- Returns:
- an Iterator over the elements in this set.
- See Also:
ConcurrentModificationException
-
add
public boolean add(Object o)
Description copied from class:CompactHashSetAdds the specified element to this set if it is not already present.- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceSet<E>- Overrides:
addin 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:CompactHashSetRemoves the specified element from the set.- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceSet<E>- Overrides:
removein classCompactHashSet<E>
-
containsAll
public boolean containsAll(Collection coll)
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
public boolean addAll(Collection coll)
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classAbstractCollection<E>
-
removeAll
public boolean removeAll(Collection coll)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classAbstractSet<E>
-
retainAll
public boolean retainAll(Collection coll)
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceSet<E>- Overrides:
retainAllin classAbstractCollection<E>
-
clear
public void clear()
Description copied from class:CompactHashSetRemoves all of the elements from this set.- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceSet<E>- Overrides:
clearin classCompactHashSet<E>
-
toString
public String toString()
- Overrides:
toStringin classAbstractCollection<E>
-
equals
public boolean equals(Object o)
- Specified by:
equalsin interfaceCollection<E>- Specified by:
equalsin interfaceSet<E>- Overrides:
equalsin classAbstractSet<E>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceCollection<E>- Specified by:
hashCodein interfaceSet<E>- Overrides:
hashCodein classAbstractSet<E>
-
-