Level 149 Level 151
Level 150

Collections: HashSet Class


26 words 0 ignored

Ready to learn       Ready to review

Ignore words

Check the boxes below to ignore/unignore words, then click save at the bottom. Ignored words will never appear in any learning session.

All None

Ignore?
HashSet()
This constructor constructs a default HashSet.
HashSet(Collection c)
This constructor initializes the hash set by using the elements of the collection c.
HashSet(int capacity)
This constructor initializes the capacity of the hash set to the given integer value capacity. the capacity grows automatically as elements are added to the HashSet.
HashSet(int capacity, float fillRatio)
This constructor initializes both the capacity and the fill ratio (also called load capacity) of the hash set from its arguments
boolean add(Object o)
Adds the specified element to this set if it is not already present.
void clear()
Removes all of the elements from this set.
Object clone()
Returns a shallow copy of this HashSet instance: the elements themselves are not cloned.
boolean contains(Object o)
Returns true if this set contains the specified element
boolean isEmpty()
Returns true if this set contains no elements.
Iterator iterator()
Returns an iterator over the elements in this set.
boolean remove(Object o)
Removes the specified element from this set if it is present.
int size()
Returns the number of elements in this set (its cardinality).
LinkedHashSet(int capacity)
This constructor initializes the capacity of the linkedhashset to the given integer value capacity. the capacity grows automatically as elements are added to the HashSet.
TreeSet()
This constructor constructs an empty tree set that will be sorted in ascending order according to the natural order of its elements.
TreeSet(Collection c)
This constructor builds a tree set that contains the elements of the collection c.
TreeSet(Comparator comp)
This constructor constructs an empty tree set that will be sorted according to the given comparator.
TreeSet(SortedSet ss)
This constructor builds a TreeSet that contains the elements of the given SortedSet
void add(Object o)
Adds the specified element to this set if it is not already present.
boolean addAll(Collection c)
Adds all of the elements in the specified collection to this set.
Object clone()
Returns a shallow copy of this TreeSet instance.
Comparator comparator()
Returns the comparator used to order this sorted set, or null if this tree set uses its elements natural ordering.
boolean contains(Object o)
Returns true if this set contains the specified element.
Object first()
Returns the first (lowest) element currently in this sorted set.
SortedSet headSet(Object toElement)
Returns a view of the portion of this set whose elements are strictly less than toElement.
Object last()
Returns the last (highest) element currently in this sorted set.
SortedSet tailSet(Object fromElement)
Returns a view of the portion of this set whose elements are greater than or equal to fromElement.