fn EnumMultiset(comptime E: type) type
A multiset of enum elements up to a count of usize. Backed by an EnumArray. This type does no dynamic allocation and can be copied by value.
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 init(init_counts: EnumFieldStruct(E, CountSize, 0)) Self
Initializes the multiset using a struct of counts.
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 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.