public class HashSet<T> extends Object implements Set<T>:
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.
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly native property | sizesize as ULong |
Number of elements in the set. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | HashSetHashSet(): |
Creates an empty hash set. |
| public | HashSetHashSet(collection as Collection<T>): |
Creates a hash set from a collection. |
| public | HashSet | Creates a hash set from a read-only list. |
| public | HashSet | Creates a hash set from another hash set. |
| public | HashSetHashSet(source as HashSetSync<T>): |
Creates a hash set from a synchronized hash set. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | _items_items() as ArrayList<T> |
No summary. |
| public native | addadd(item as T) as Void |
Adds an element to the set. |
| public native | clearclear() as Void |
Clears all elements. |
| public native | countcount(item as T) as ULong |
Counts occurrences of the given element in the set. |
| public native | removeremove(item as T) as Boolean |
Removes an element from the set. |
| public native | toStringtoString() as String |
Returns a string representation of the set. |
| Modifier and Type | Member | Description |
|---|---|---|
| public native | operator in(item as T) as Boolean | Returns true if the set contains the element. |