A set implementation with fast lookup and ordered iteration.
-
_rm: dict[any, boolean]
?
-
static new(values?)
Create a new set
- Parameters:
values? (list[any]
) – List of initial values
- Return type:
Set
-
add(value)
Add a value to the set
- Parameters:
value (any
)
-
remove(value)
Remove a value from the set
- Parameters:
value (any
)
-
removeIf(predicate)
Remove all elements matching a predicate
- Parameters:
predicate (fun(any):boolean
)
-
forEach(func)
Iterate over each element in the set
- Parameters:
func (fun(any):boolean or nil
)
-
union(other)
Get the union of this set and another
- Parameters:
other (Set
)
- Return type:
Set
-
intersection(other)
Get the intersection of this set and another
- Parameters:
other (Set
)
- Return type:
Set
-
size()
Get the number of elements in the set
- Return type:
number
-
contains(value)
Check if set contains a value
- Parameters:
value (any
)
- Return type:
boolean
-
toList()
Return all elements as a list
- Return type:
list[any]