Package org.gbif.utils.collection
Class CompactHashSet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
org.gbif.utils.collection.CompactHashSet<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
A HashSet implementation taken from Ontopia
which is both faster and more compact than java.util.HashSet
INTERNAL: Implements the Set interface more compactly than
java.util.HashSet by using a closed hashtable.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty set.CompactHashSet(int size) Constructs a new, empty set.Constructs a new set containing the elements in the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified element to this set if it is not already present.voidclear()Removes all of the elements from this set.booleanReturns true if this set contains the specified element.voiddump()INTERNAL: Used for debugging only.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.intsize()Returns the number of elements in this set (its cardinality).Object[]toArray()Object[]Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAllMethods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toStringMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
addAll, containsAll, retainAll, spliterator
-
Constructor Details
-
CompactHashSet
public CompactHashSet()Constructs a new, empty set. -
CompactHashSet
Constructs a new set containing the elements in the specified collection.- Parameters:
c- the collection whose elements are to be placed into this set.
-
CompactHashSet
Constructs a new, empty set.
-
-
Method Details
-
add
Adds the specified element to this set if it is not already present.- Specified by:
addin interfaceCollection<T>- Specified by:
addin interfaceSet<T>- Overrides:
addin classAbstractCollection<T>- Parameters:
x- element to be added to this set.- Returns:
- true if the set did not already contain the specified element.
-
clear
Removes all of the elements from this set.- Specified by:
clearin interfaceCollection<T>- Specified by:
clearin interfaceSet<T>- Overrides:
clearin classAbstractCollection<T>
-
contains
Returns true if this set contains the specified element.- Specified by:
containsin interfaceCollection<T>- Specified by:
containsin interfaceSet<T>- Overrides:
containsin classAbstractCollection<T>- Parameters:
o- element whose presence in this set is to be tested.- Returns:
- true if this set contains the specified element.
-
dump
INTERNAL: Used for debugging only. -
isEmpty
Returns true if this set contains no elements.- Specified by:
isEmptyin interfaceCollection<T>- Specified by:
isEmptyin interfaceSet<T>- Overrides:
isEmptyin classAbstractCollection<T>
-
iterator
Returns an iterator over the elements in this set. The elements are returned in no particular order. -
remove
Removes the specified element from the set.- Specified by:
removein interfaceCollection<T>- Specified by:
removein interfaceSet<T>- Overrides:
removein classAbstractCollection<T>
-
size
Returns the number of elements in this set (its cardinality).- Specified by:
sizein interfaceCollection<T>- Specified by:
sizein interfaceSet<T>- Specified by:
sizein classAbstractCollection<T>
-
toArray
- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceSet<T>- Overrides:
toArrayin classAbstractCollection<T>
-
toArray
- Specified by:
toArrayin interfaceCollection<T>- Specified by:
toArrayin interfaceSet<T>- Overrides:
toArrayin classAbstractCollection<T>
-