OxL Reference

data Set

Hash set with insertion-ordered iteration (§3.3).

Example:

oxl✓ checked in CI
fn main() io {
  var seen: Set<str> = Set.new()
  print("{seen.insert("a")} {seen.insert("a")} {seen.len()}")
}
Output
true false 1
@builtin("Set") pub(api) data Set<T>

Complexity. `insert`, `remove` and `contains` are O(1) on average.

Thread safety. not shared between tasks; send a copy (or a `frozen` set) to another task.

Since. 1.0.0-beta

Methods

new() -> Self
True when the set has no elements.
len() -> usize
The number of elements.
isEmpty() -> bool
Whether the set has no elements.
insert(x: T) -> bool
True when x is in the set.
remove(x: T) -> bool
Removes x; true when it was in the set.
contains(x: T) -> bool
Whether x is in the set.
iter() -> iter<T>
Lazy iterator over a snapshot of the elements (insertion order).

Defined in: std/core/types.oxl:62

See also