pub fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type
A multiset of enum elements up to CountSize.
- Kind
- type function
- Module
std.enums
pub fn add(self: *Self, key: E, c: CountSize) error
Increases the key count by given amount.
- Kind
- function
- Module
std.enums
pub fn addAssertSafe(self: *Self, key: E, c: CountSize) void
Increases the key count by given amount.
- Kind
- function
- Module
std.enums
pub fn addSet(self: *Self, other: Self) error
Increases the all key counts by given multiset.
- Kind
- function
- Module
std.enums
pub fn addSetAssertSafe(self: *Self, other: Self) void
Increases the all key counts by given multiset.
- Kind
- function
- Module
std.enums
pub fn contains(self: Self, key: E) bool
Checks if at least one key in multiset.
- Kind
- function
- Module
std.enums
pub fn count(self: Self) usize
Returns the total number of key counts in the multiset.
- Kind
- function
- Module
std.enums
A multiset with a count of zero.
- Kind
- constant
- Module
std.enums
- Kind
- type
- Module
std.enums
pub fn eql(self: Self, other: Self) bool
Returns true iff all key counts are the same as given multiset.
- Kind
- function
- Module
std.enums
pub fn getCount(self: Self, key: E) CountSize
Returns the count for a key.
- Kind
- function
- Module
std.enums
pub fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self
Initializes the multiset using a struct of counts.
- Kind
- function
- Module
std.enums
pub fn initWithCount(comptime c: CountSize) Self
Initializes the multiset with all keys at the same count.
- Kind
- function
- Module
std.enums
- Kind
- type
- Module
std.enums
pub fn iterator(self: *Self) Iterator
Returns an iterator over this multiset.
- Kind
- function
- Module
std.enums
pub fn minus(self: Self, other: Self) Self
Returns a multiset with the key count of this multiset minus the corresponding key count in the other multiset.
- Kind
- function
- Module
std.enums
pub fn plus(self: Self, other: Self) error
Returns a multiset with the total key count of this multiset and the other multiset.
- Kind
- function
- Module
std.enums
pub fn plusAssertSafe(self: Self, other: Self) Self
Returns a multiset with the total key count of this multiset and the other multiset.
- Kind
- function
- Module
std.enums
pub fn remove(self: *Self, key: E, c: CountSize) void
Decreases the key count by given amount.
- Kind
- function
- Module
std.enums
pub fn removeAll(self: *Self, key: E) void
Removes all instance of a key from multiset.
- Kind
- function
- Module
std.enums
pub fn removeSet(self: *Self, other: Self) void
Decreases the all key counts by given multiset.
- Kind
- function
- Module
std.enums
pub fn setCount(self: *Self, key: E, c: CountSize) void
Set the count for a key.
- Kind
- function
- Module
std.enums
pub fn subsetOf(self: Self, other: Self) bool
Returns true iff all key counts less than or equal to the given multiset.
- Kind
- function
- Module
std.enums
pub fn supersetOf(self: Self, other: Self) bool
Returns true iff all key counts greater than or equal to the given multiset.
- Kind
- function
- Module
std.enums
pub fn directEnumArray(comptime E: type, comptime Data: type, comptime max_unused_slots: comptime_int, init_values: EnumFieldStruct(E, Data, null)) [directEnumArrayLen(E, max_unused_slots)]Data
Initializes an array of Data which can be indexed by @intCast(usize, @intFromEnum(enum_value)).
- Kind
- function
- Module
std.enums
pub fn directEnumArrayDefault(comptime E: type, comptime Data: type, comptime default: ?Data, comptime max_unused_slots: comptime_int, init_values: EnumFieldStruct(E, Data, default)) [directEnumArrayLen(E, max_unused_slots)]Data
Initializes an array of Data which can be indexed by @intCast(usize, @intFromEnum(enum_value)).
- Kind
- function
- Module
std.enums
pub fn directEnumArrayLen(comptime E: type, comptime max_unused_slots: comptime_int) comptime_int
Determines the length of a direct-mapped enum array, indexed by @intCast(usize, @intFromEnum(enum_value)).
- Kind
- function
- Module
std.enums
pub fn EnumArray(comptime E: type, comptime V: type) type
An array keyed by an enum, backed by a dense array.
- Kind
- type function
- Module
std.enums
An entry in the array.
- Kind
- struct
- Module
std.enums
pub fn get(self: Self, key: Key) Value
Returns the value in the array associated with a key.
- Kind
- function
- Module
std.enums
pub fn getPtr(self: *Self, key: Key) *Value
Returns a pointer to the slot in the array associated with a key.
- Kind
- function
- Module
std.enums
pub fn getPtrConst(self: *const Self, key: Key) *const Value
Returns a const pointer to the slot in the array associated with a key.
- Kind
- function
- Module
std.enums
The index mapping for this map.
- Kind
- type
- Module
std.enums
pub fn init(init_values: EnumFieldStruct(E, Value, null)) Self
- Kind
- function
- Module
std.enums
pub fn initDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self
Initializes values in the enum array, with the specified default.
- Kind
- function
- Module
std.enums
pub fn initFill(v: Value) Self
- Kind
- function
- Module
std.enums
pub fn initUndefined() Self
- Kind
- function
- Module
std.enums
- Kind
- struct
- Module
std.enums
pub fn iterator(self: *Self) Iterator
Iterates over the items in the array, in index order.
- Kind
- function
- Module
std.enums
pub fn next(self: *Iterator) ?Entry
- Kind
- function
- Module
std.enums
The key type used to index this map.
- Kind
- type
- Module
std.enums
The number of possible keys in the map.
- Kind
- constant
- Module
std.enums
pub fn set(self: *Self, key: Key, value: Value) void
Sets the value in the slot associated with a key.
- Kind
- function
- Module
std.enums
The value type stored in this map.
- Kind
- type
- Module
std.enums
pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type
Returns a struct with a field matching each unique named enum element.
- Kind
- type function
- Module
std.enums
pub fn EnumIndexer(comptime E: type) type
- Kind
- type function
- Module
std.enums
- Kind
- constant
- Module
std.enums
pub fn indexOf(e: E) usize
- Kind
- function
- Module
std.enums
- Kind
- type
- Module
std.enums
pub fn keyForIndex(i: usize) E
- Kind
- function
- Module
std.enums
pub fn EnumMap(comptime E: type, comptime V: type) type
A map keyed by an enum, backed by a bitfield and a dense array.
- Kind
- type function
- Module
std.enums
pub fn contains(self: *const Self, key: Key) bool
Checks if the map contains an item.
- Kind
- function
- Module
std.enums
pub fn count(self: *const Self) usize
The number of items in the map.
- Kind
- function
- Module
std.enums
- Kind
- constant
- Module
std.enums
An entry in the map.
- Kind
- struct
- Module
std.enums
pub fn fetchPut(self: *Self, key: Key, value: Value) ?Value
Sets the value associated with the key in the map, and returns the old value.
- Kind
- function
- Module
std.enums
pub fn fetchRemove(self: *Self, key: Key) ?Value
Removes a key from the map, and returns the old value.
- Kind
- function
- Module
std.enums
pub fn get(self: *const Self, key: Key) ?Value
Gets the value associated with a key.
- Kind
- function
- Module
std.enums
pub fn getAssertContains(self: *const Self, key: Key) Value
Gets the value associated with a key, which must exist in the map.
- Kind
- function
- Module
std.enums
pub fn getPtr(self: *Self, key: Key) ?*Value
Gets the address of the value associated with a key.
- Kind
- function
- Module
std.enums
pub fn getPtrAssertContains(self: *Self, key: Key) *Value
Gets the address of the value associated with a key.
- Kind
- function
- Module
std.enums
pub fn getPtrConst(self: *const Self, key: Key) ?*const Value
Gets the address of the const value associated with a key.
- Kind
- function
- Module
std.enums
pub fn getPtrConstAssertContains(self: *const Self, key: Key) *const Value
Gets the address of the const value associated with a key.
- Kind
- function
- Module
std.enums
The index mapping for this map.
- Kind
- type
- Module
std.enums
pub fn init(init_values: EnumFieldStruct(E, ?Value, @as(?Value, null))) Self
Initializes the map using a sparse struct of optionals.
- Kind
- function
- Module
std.enums
pub fn initFull(value: Value) Self
Initializes a full mapping with all keys set to value.
- Kind
- function
- Module
std.enums
pub fn initFullWith(init_values: EnumFieldStruct(E, Value, null)) Self
Initializes a full mapping with supplied values.
- Kind
- function
- Module
std.enums
pub fn initFullWithDefault(comptime default: ?Value, init_values: EnumFieldStruct(E, Value, default)) Self
Initializes a full mapping with a provided default.
- Kind
- function
- Module
std.enums
- Kind
- struct
- Module
std.enums
pub fn iterator(self: *Self) Iterator
Returns an iterator over the map, which visits items in index order.
- Kind
- function
- Module
std.enums
pub fn next(self: *Iterator) ?Entry
- Kind
- function
- Module
std.enums
The key type used to index this map.
- Kind
- type
- Module
std.enums
The number of possible keys in the map.
- Kind
- constant
- Module
std.enums
pub fn put(self: *Self, key: Key, value: Value) void
Adds the key to the map with the supplied value.
- Kind
- function
- Module
std.enums
pub fn putUninitialized(self: *Self, key: Key) *Value
Adds the key to the map with an undefined value.
- Kind
- function
- Module
std.enums
pub fn remove(self: *Self, key: Key) void
Removes a key from the map.
- Kind
- function
- Module
std.enums
The value type stored in this map.
- Kind
- type
- Module
std.enums
pub fn EnumMultiset(comptime E: type) type
A multiset of enum elements up to a count of usize.
- Kind
- type function
- Module
std.enums
pub fn EnumSet(comptime E: type) type
A set of enum elements, backed by a bitfield.
- Kind
- type function
- Module
std.enums
pub fn complement(self: Self) Self
Returns a set with all the keys not in this set.
- Kind
- function
- Module
std.enums
pub fn contains(self: Self, key: Key) bool
Checks if a key is in the set.
- Kind
- function
- Module
std.enums
pub fn count(self: Self) usize
Returns the number of keys in the set.
- Kind
- function
- Module
std.enums
pub fn differenceWith(self: Self, other: Self) Self
Returns a set with keys that are in this set except for keys in the other set.
- Kind
- function
- Module
std.enums
A set containing no keys.
- Kind
- constant
- Module
std.enums
pub fn eql(self: Self, other: Self) bool
Returns true iff both sets have the same keys.
- Kind
- function
- Module
std.enums
A set containing all possible keys.
- Kind
- constant
- Module
std.enums
The indexing rules for converting between keys and indices.
- Kind
- type
- Module
std.enums
pub fn init(init_values: EnumFieldStruct(E, bool, false)) Self
Initializes the set using a struct of bools.
- Kind
- function
- Module
std.enums
pub fn initMany(keys: []const Key) Self
Returns a set containing multiple keys.
- Kind
- function
- Module
std.enums
pub fn initOne(key: Key) Self
Returns a set containing a single key.
- Kind
- function
- Module
std.enums
pub fn insert(self: *Self, key: Key) void
Puts a key in the set.
- Kind
- function
- Module
std.enums
pub fn intersectWith(self: Self, other: Self) Self
Returns a set with keys that are in both this set and the other set.
- Kind
- function
- Module
std.enums
- Kind
- struct
- Module
std.enums
pub fn iterator(self: *const Self) Iterator
Returns an iterator over this set, which iterates in index order.
- Kind
- function
- Module
std.enums
pub fn next(self: *Iterator) ?Key
- Kind
- function
- Module
std.enums
The element type for this set.
- Kind
- type
- Module
std.enums
The maximum number of items in this set.
- Kind
- constant
- Module
std.enums
pub fn remove(self: *Self, key: Key) void
Removes a key from the set.
- Kind
- function
- Module
std.enums
pub fn setIntersection(self: *Self, other: Self) void
Removes all keys which are not in the passed set.
- Kind
- function
- Module
std.enums
pub fn setPresent(self: *Self, key: Key, present: bool) void
Changes the presence of a key in the set to match the passed bool.
- Kind
- function
- Module
std.enums
pub fn setUnion(self: *Self, other: Self) void
Adds all keys in the passed set to this set.
- Kind
- function
- Module
std.enums
pub fn subsetOf(self: Self, other: Self) bool
Returns true iff all the keys in this set are in the other set.
- Kind
- function
- Module
std.enums
pub fn supersetOf(self: Self, other: Self) bool
Returns true iff this set contains all the keys in the other set.
- Kind
- function
- Module
std.enums
pub fn toggle(self: *Self, key: Key) void
Toggles the presence of a key in the set.
- Kind
- function
- Module
std.enums
pub fn toggleAll(self: *Self) void
Toggles all possible keys in the set.
- Kind
- function
- Module
std.enums
pub fn toggleSet(self: *Self, other: Self) void
Toggles the presence of all keys in the passed set.
- Kind
- function
- Module
std.enums
pub fn unionWith(self: Self, other: Self) Self
Returns a set with keys that are in either this set or the other set.
- Kind
- function
- Module
std.enums
pub fn xorWith(self: Self, other: Self) Self
Returns a set with keys that are in either this set or the other set, but not both.
- Kind
- function
- Module
std.enums
pub fn fromInt(comptime E: type, integer: anytype) ?E
- Kind
- function
- Module
std.enums
pub fn tagName(comptime E: type, e: E) ?[:0]const u8
A safe alternative to @tagName() for non-exhaustive enums that doesn't panic when `e` has no tagged value.
- Kind
- function
- Module
std.enums
pub fn values(comptime E: type) []const E
Returns the set of all named values in the given enum, in declaration order.
- Kind
- function
- Module
std.enums
pub fn valuesFromFields(comptime E: type, comptime field_values: []const comptime_int) []const E
Looks up the supplied field values in the given enum type.
- Kind
- function
- Module
std.enums