Reference
std/set
std/set
Set<T>, a collection of distinct values with union, intersection and difference.
narra
import * as Sets from "std/set"
The guide teaches it in chapter 13, The standard library.
This page is generated by scripts/std/generate.nra from narrac query --json interface std/set. Do not edit it.
Types
Set
narra
export opaque struct Set<T: Hashable>
Functions: create, add, has, remove, size, values, union, intersection, difference.
Functions
create
narra
export function create<T: Hashable>(): Set<T> uses alloc
Effects: alloc.
add
narra
export function add<T: Hashable>(mutable set: Set<T>, item: T): bool uses alloc
Effects: alloc.
has
narra
export function has<T: Hashable>(set: Set<T>, item: T): bool
Effects: none.
remove
narra
export function remove<T: Hashable>(mutable set: Set<T>, item: T): bool uses alloc
Effects: alloc.
size
narra
export function size<T: Hashable>(set: Set<T>): int
Effects: none.
values
narra
export function values<T: Hashable>(set: Set<T>): Array<T> uses alloc
Effects: alloc.
union
narra
export function union<T: Hashable>(first: Set<T>, second: Set<T>): Set<T> uses alloc
Effects: alloc.
intersection
narra
export function intersection<T: Hashable>(first: Set<T>, second: Set<T>): Set<T> uses alloc
Effects: alloc.
difference
narra
export function difference<T: Hashable>(first: Set<T>, second: Set<T>): Set<T> uses alloc
Effects: alloc.