fn BoundedEnumMultiset(comptime E: type, comptime CountSize: type) type

A multiset of enum elements up to CountSize. Backed by an EnumArray. This type does no dynamic allocation and can be copied by value.

Parameters

E: type,
CountSize: type,

Fields

counts: EnumArray(E, CountSize),

Functions

fn add(self: *Self, key: E, c: CountSize) error{Overflow}!void

Increases the key count by given amount.

fn addAssertSafe(self: *Self, key: E, c: CountSize) void

Increases the key count by given amount. Caller asserts operation will not over…

Increases the key count by given amount. Caller asserts operation will not overflow.

fn addSet(self: *Self, other: Self) error{Overflow}!void

Increases the all key counts by given multiset.

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

Increases the all key counts by given multiset. Caller asserts operation will n…

Increases the all key counts by given multiset. Caller asserts operation will not overflow any key.

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

Checks if at least one key in multiset.

fn count(self: Self) usize

Returns the total number of key counts in the multiset.

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

Returns true iff all key counts are the same as given multiset.

fn getCount(self: Self, key: E) CountSize

Returns the count for a key.

fn init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self

Initializes the multiset using a struct of counts.

fn initEmpty() Self

Initializes the multiset with a count of zero.

fn initWithCount(comptime c: CountSize) Self

Initializes the multiset with all keys at the same count.

fn iterator(self: *Self) Iterator

Returns an iterator over this multiset. Keys with zero counts are included. Mod…

Returns an iterator over this multiset. Keys with zero counts are included. Modifications to the set during iteration may or may not be observed by the iterator, but will not invalidate it.

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

Returns a multiset with the key count of this multiset minus the corresponding …

Returns a multiset with the key count of this multiset minus the corresponding key count in the other multiset. If the other multiset contains more key count than this set, that key will have a count of zero.

fn plus(self: Self, other: Self) error{Overflow}!Self

Returns a multiset with the total key count of this multiset and the other mult…

Returns a multiset with the total key count of this multiset and the other multiset.

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

Returns a multiset with the total key count of this multiset and the other mult…

Returns a multiset with the total key count of this multiset and the other multiset. Caller asserts operation will not overflow any key.

fn remove(self: *Self, key: E, c: CountSize) void

Decreases the key count by given amount. If amount is greater than the number o…

Decreases the key count by given amount. If amount is greater than the number of keys in multset, then key count will be set to zero.

fn removeAll(self: *Self, key: E) void

Removes all instance of a key from multiset. Same as setCount(key, 0).

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

Deccreases the all key counts by given multiset. If the given multiset has more…

Deccreases the all key counts by given multiset. If the given multiset has more key counts than this, then that key will have a key count of zero.

fn setCount(self: *Self, key: E, c: CountSize) void

Set the count for a key.

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

Returns true iff all key counts less than or equal to the given multiset.

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

Returns true iff all key counts greater than or equal to the given multiset.

Values

Entry
undefined
Iterator
undefined