E
- Class being stored in SimpleHashSet.public class SimpleHashSet<E> extends Object
Constructor and Description |
---|
SimpleHashSet()
Constructs an empty HashSet with the default initial capacity
(16) and the default load factor (0.75).
|
SimpleHashSet(int initialCapacity)
Constructs an empty HashSet with the specified initial
capacity and the default load factor (0.75).
|
SimpleHashSet(int initialCapacity,
float loadFactor)
Constructs an empty HashSet with the specified initial
capacity and load factor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element)
Adds the specified element to this set.
|
void |
clear()
Removes all elements from this set.
|
Object |
clone()
Clones this set.
|
boolean |
contains(E element)
Returns the boolean value which specifies if given element is already in
this identity hash set.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
E |
removeFirst()
Removes and returns an entry removed from the HashSet.
|
int |
size()
Returns the number of elements in this set.
|
String |
toString()
Returns string representation of the hash set.
|
public SimpleHashSet()
public SimpleHashSet(int initialCapacity)
initialCapacity
- the initial capacity.IllegalArgumentException
- if the initial capacity is negative.public SimpleHashSet(int initialCapacity, float loadFactor)
initialCapacity
- The initial capacity.loadFactor
- The load factor.IllegalArgumentException
- if the initial capacity is negative or the load factor is
nonpositive.public boolean add(E element)
element
- element with which the specified value is to be associated.public void clear()
public boolean contains(E element)
element
- the element whose existence in the hash set is to be checked.public boolean isEmpty()
public E removeFirst()
public int size()
Copyright © 2022. All rights reserved.