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>
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 -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified element to this set if it is not already present.booleanaddAll(Collection coll) voidclear()Removes all of the elements from this set.booleanReturns true if this set contains the specified element.booleancontainsAll(Collection coll) booleaninthashCode()booleanisEmpty()Returns true if this set contains no elements.iterator()Returns an iterator over the elements in this set.booleanRemoves 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) toString()Methods inherited from class net.ontopia.utils.CompactHashSet
dump, rehash, rehashMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
spliterator
-
Constructor Details
-
SynchronizedCompactHashSet
public SynchronizedCompactHashSet() -
SynchronizedCompactHashSet
-
SynchronizedCompactHashSet
public SynchronizedCompactHashSet(int size)
-
-
Method Details
-
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
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
- 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
Description copied from class:CompactHashSetReturns an iterator over the elements in this set. The elements are returned in no particular order. -
add
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
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
- Specified by:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Overrides:
containsAllin classAbstractCollection<E>
-
addAll
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceSet<E>- Overrides:
addAllin classAbstractCollection<E>
-
removeAll
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceSet<E>- Overrides:
removeAllin classAbstractSet<E>
-
retainAll
- 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
- Overrides:
toStringin classAbstractCollection<E>
-
equals
- 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>
-