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
- Author:
- Alexey Andreev
-
Constructor Summary
ConstructorsConstructorDescriptionTHashSet()
Constructs a new empty instance ofHashSet
.THashSet(int capacity)
Constructs a new instance ofHashSet
with the specified capacity.THashSet(int capacity, float loadFactor)
Constructs a new instance ofHashSet
with the specified capacity and load factor.THashSet(TCollection<? extends E> collection)
Constructs a new instance ofHashSet
containing the unique elements in the specified collection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds the specified object to thisHashSet
if not already present.void
clear()
Removes all elements from thisHashSet
, leaving it empty.clone()
clone0()
Returns a newHashSet
with the same elements and size as thisHashSet
.boolean
Searches thisHashSet
for the specified object.boolean
isEmpty()
Returns true if thisHashSet
has no elements, false otherwise.iterator()
Returns an Iterator on the elements of thisHashSet
.boolean
Removes the specified object from thisHashSet
.int
size()
Returns the number of elements in thisHashSet
.Methods inherited from class org.teavm.classlib.java.util.TAbstractSet
equals, hashCode, removeAll
Methods inherited from class org.teavm.classlib.java.util.TAbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
Methods inherited from class org.teavm.classlib.java.lang.TObject
equals0, finalize, getClass0, notify0, notifyAll0, wait0, wait0, waitImpl
Methods 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 ofHashSet
with the specified capacity.- Parameters:
capacity
- the initial capacity of thisHashSet
.
-
THashSet
public THashSet(int capacity, float loadFactor)Constructs a new instance ofHashSet
with the specified capacity and load factor.- Parameters:
capacity
- the initial capacity.loadFactor
- the initial load factor.
-
THashSet
Constructs a new instance ofHashSet
containing the unique elements in the specified collection.- Parameters:
collection
- the collection of elements to add.
-
-
Method Details
-
add
Adds the specified object to thisHashSet
if not already present.- Specified by:
add
in interfaceTCollection<E>
- Overrides:
add
in classTAbstractCollection<E>
- Parameters:
object
- the object to add.- Returns:
true
when thisHashSet
did not already contain the object,false
otherwise
-
clear
public void clear()Removes all elements from thisHashSet
, leaving it empty.- Specified by:
clear
in interfaceTCollection<E>
- Overrides:
clear
in classTAbstractCollection<E>
- See Also:
isEmpty()
,size()
-
clone0
Returns a newHashSet
with the same elements and size as thisHashSet
.- Returns:
- a shallow copy of this
HashSet
. - See Also:
Cloneable
-
contains
Searches thisHashSet
for the specified object.- Specified by:
contains
in interfaceTCollection<E>
- Overrides:
contains
in classTAbstractCollection<E>
- Parameters:
object
- the object to search for.- Returns:
true
ifobject
is an element of thisHashSet
,false
otherwise.
-
isEmpty
public boolean isEmpty()Returns true if thisHashSet
has no elements, false otherwise.- Specified by:
isEmpty
in interfaceTCollection<E>
- Overrides:
isEmpty
in classTAbstractCollection<E>
- Returns:
true
if thisHashSet
has no elements,false
otherwise.- See Also:
size()
-
iterator
Returns an Iterator on the elements of thisHashSet
. -
remove
Removes the specified object from thisHashSet
.- Specified by:
remove
in interfaceTCollection<E>
- Overrides:
remove
in classTAbstractCollection<E>
- Parameters:
object
- the object to remove.- Returns:
true
if the object was removed,false
otherwise.
-
size
public int size()Returns the number of elements in thisHashSet
.- Specified by:
size
in interfaceTCollection<E>
- Returns:
- the number of elements in this
HashSet
.
-
clone
-