Package org.teavm.classlib.java.util
Class THashSet<E>
java.lang.Object
org.teavm.classlib.java.lang.TObject
org.teavm.classlib.java.util.TAbstractCollection<E>
org.teavm.classlib.java.util.TAbstractSet<E>
org.teavm.classlib.java.util.THashSet<E>
- Type Parameters:
E-
- All Implemented Interfaces:
TSerializable,TCloneable,TIterable<E>,TCollection<E>,TSet<E>
- Direct Known Subclasses:
TLinkedHashSet
-
Constructor Summary
ConstructorsConstructorDescriptionTHashSet()Constructs a new empty instance ofHashSet.THashSet(int capacity) Constructs a new instance ofHashSetwith the specified capacity.THashSet(int capacity, float loadFactor) Constructs a new instance ofHashSetwith the specified capacity and load factor.THashSet(TCollection<? extends E> collection) Constructs a new instance ofHashSetcontaining the unique elements in the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the specified object to thisHashSetif not already present.voidclear()Removes all elements from thisHashSet, leaving it empty.clone()clone0()Returns a newHashSetwith the same elements and size as thisHashSet.booleanSearches thisHashSetfor the specified object.booleanisEmpty()Returns true if thisHashSethas no elements, false otherwise.iterator()Returns an Iterator on the elements of thisHashSet.static <T> THashSet<T> newHashSet(int size) booleanRemoves the specified object from thisHashSet.intsize()Returns the number of elements in thisHashSet.Methods inherited from class org.teavm.classlib.java.util.TAbstractSet
equals, hashCode, removeAllMethods inherited from class org.teavm.classlib.java.util.TAbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toStringMethods inherited from class org.teavm.classlib.java.lang.TObject
equals0, finalize, getClass0, notify0, notifyAll0, wait0, wait0, waitImplMethods inherited from interface org.teavm.classlib.java.util.TCollection
addAll, containsAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
Constructor Details
-
THashSet
public THashSet()Constructs a new empty instance ofHashSet. -
THashSet
public THashSet(int capacity) Constructs a new instance ofHashSetwith the specified capacity.- Parameters:
capacity- the initial capacity of thisHashSet.
-
THashSet
public THashSet(int capacity, float loadFactor) Constructs a new instance ofHashSetwith the specified capacity and load factor.- Parameters:
capacity- the initial capacity.loadFactor- the initial load factor.
-
THashSet
Constructs a new instance ofHashSetcontaining the unique elements in the specified collection.- Parameters:
collection- the collection of elements to add.
-
-
Method Details
-
add
Adds the specified object to thisHashSetif not already present.- Specified by:
addin interfaceTCollection<E>- Overrides:
addin classTAbstractCollection<E>- Parameters:
object- the object to add.- Returns:
truewhen thisHashSetdid not already contain the object,falseotherwise
-
clear
public void clear()Removes all elements from thisHashSet, leaving it empty.- Specified by:
clearin interfaceTCollection<E>- Overrides:
clearin classTAbstractCollection<E>- See Also:
-
clone0
Returns a newHashSetwith the same elements and size as thisHashSet.- Returns:
- a shallow copy of this
HashSet. - See Also:
-
contains
Searches thisHashSetfor the specified object.- Specified by:
containsin interfaceTCollection<E>- Overrides:
containsin classTAbstractCollection<E>- Parameters:
object- the object to search for.- Returns:
trueifobjectis an element of thisHashSet,falseotherwise.
-
isEmpty
public boolean isEmpty()Returns true if thisHashSethas no elements, false otherwise.- Specified by:
isEmptyin interfaceTCollection<E>- Overrides:
isEmptyin classTAbstractCollection<E>- Returns:
trueif thisHashSethas no elements,falseotherwise.- See Also:
-
iterator
Returns an Iterator on the elements of thisHashSet. -
remove
Removes the specified object from thisHashSet.- Specified by:
removein interfaceTCollection<E>- Overrides:
removein classTAbstractCollection<E>- Parameters:
object- the object to remove.- Returns:
trueif the object was removed,falseotherwise.
-
size
public int size()Returns the number of elements in thisHashSet.- Specified by:
sizein interfaceTCollection<E>- Returns:
- the number of elements in this
HashSet.
-
clone
-
newHashSet
-