HashSet
classin packageklyn.collections
public class HashSet<T> extends Object implements Set<T>:
All Implemented Interfaces: Set
Hash set implementation.
Unordered collection of unique elements with average O(1) add/contains/remove.
Internally backed by a HashMap<T, Boolean>.
Example:
s = HashSet<String>()
s.add("red")
s.add("blue")
s.add("red") # duplicate, size stays 2
assert "blue" in s
assert s.count("red") == 1
s.remove("red")
@param <T> Element type.
Properties
| Modifier and Type |
Member |
Description |
| public readonly native property |
size |
Number of elements in the set. |
Methods
| Modifier and Type |
Member |
Description |
| public native |
add |
Adds an element to the set. |
| public native |
clear clear() as Void
|
Clears all elements. |
| public native |
contains |
Returns true if the set contains the element. |
| public native |
count |
Counts occurrences of the given element in the set. |
| public native |
remove |
Removes an element from the set. |
| public native |
toString |
Returns a string representation of the set. |
Operators