Standard library / std::set

std::set

std::set provides set containers:

  • SetMap(T) (unordered set, open addressing),
  • TreeSet(T) (ordered set, red-black tree).

Full reference: set.

Notes#

  • Supported forms: usable in Silk with documented limits.
  • Full reference: set

Importing#

import std::set;

Examples#

Example: SetMap(u64) basic usage#

import std::set;
import std::result;
import std::memory;

type Set = std::set::SetMap(u64);
type InsertResult = std::result::Result(bool, std::memory::OutOfMemory);

fn main () -> int {
  match (Set.init(4)) {
    Ok(set) => {
      let mut s: Set = set;

      let insert_r: InsertResult = s.insert(1);
      if insert_r.is_err() { s.drop(); return 2; }
      let ok: bool = s.contains(1);
      s.drop();
      if ok { return 0; }
      return 1;
    },
    Err(_) => {
      return 1;
    },
  }
}

See also#

Source repository · Edit this page · View Markdown

Quick links

Type to search across the site. Use the up and down arrow keys to choose a result, Enter to open it, and Escape to close.