fn IndexedSet(comptime I: type, comptime Ext: ?fn (type) type) type

A set type with an Indexer mapping from keys to indices. Presence or absence is stored as a dense bitfield. This type does no allocation and can be copied by value.

Parameters

I: type,
Ext: ?fn (type) type,

Fields

bits: BitSet = field_call,

Types

Functions

fn complement(self: Self) Self

Returns a set with all the keys not in this set.

fn contains(self: Self, key: Key) bool

Checks if a key is in the set.

fn count(self: Self) usize

Returns the number of keys in the set.

fn differenceWith(self: Self, other: Self) Self

Returns a set with keys that are in this set except for keys in the other set.

fn eql(self: Self, other: Self) bool

Returns true iff both sets have the same keys.

fn initEmpty() Self

Returns a set containing no keys.

fn initFull() Self

Returns a set containing all possible keys.

fn initMany(keys: []const Key) Self

Returns a set containing multiple keys.

fn initOne(key: Key) Self

Returns a set containing a single key.

fn insert(self: *Self, key: Key) void

Puts a key in the set.

fn intersectWith(self: Self, other: Self) Self

Returns a set with keys that are in both this set and the other set.

fn iterator(self: *const Self) Iterator

Returns an iterator over this set, which iterates in index order. Modification…

Returns an iterator over this set, which iterates in index order. Modifications to the set during iteration may or may not be observed by the iterator, but will not invalidate it.

fn remove(self: *Self, key: Key) void

Removes a key from the set.

fn setIntersection(self: *Self, other: Self) void

Removes all keys which are not in the passed set.

fn setPresent(self: *Self, key: Key, present: bool) void

Changes the presence of a key in the set to match the passed bool.

fn setUnion(self: *Self, other: Self) void

Adds all keys in the passed set to this set.

fn subsetOf(self: Self, other: Self) bool

Returns true iff all the keys in this set are in the other set. The other set m…

Returns true iff all the keys in this set are in the other set. The other set may have keys not found in this set.

fn supersetOf(self: Self, other: Self) bool

Returns true iff this set contains all the keys in the other set. This set may …

Returns true iff this set contains all the keys in the other set. This set may have keys not found in the other set.

fn toggle(self: *Self, key: Key) void

Toggles the presence of a key in the set. If the key is in the set, removes it…

Toggles the presence of a key in the set. If the key is in the set, removes it. Otherwise adds it.

fn toggleAll(self: *Self) void

Toggles all possible keys in the set.

fn toggleSet(self: *Self, other: Self) void

Toggles the presence of all keys in the passed set.

fn unionWith(self: Self, other: Self) Self

Returns a set with keys that are in either this set or the other set.

fn xorWith(self: Self, other: Self) Self

Returns a set with keys that are in either this set or the other set, but not b…

Returns a set with keys that are in either this set or the other set, but not both.

Values

Indexer
undefined

The indexing rules for converting between keys and indices.

Key
undefined

The element type for this set.

len
undefined

The maximum number of items in this set.