OxL Справочник OxL
РусскийEnglish

data Set

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

Example:

oxl✓ проверяется в CI
fn main() io {
  var seen: Set<str> = Set.new()
  print("{seen.insert("a")} {seen.insert("a")} {seen.len()}")
}
Вывод
true false 1
@builtin("Set") pub(api) data Set<T>

Сложность. `insert`, `remove` and `contains` are O(1) on average.

Потокобезопасность. not shared between tasks; send a copy (or a `frozen` set) to another task.

С версии. 1.0.0-beta

Методы

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).

Определено в: std/core/types.oxl:62

См. также