src/necsus/util/bits

Types

Bits = ref object
A bitset without a limit on the number of bits that can be set
BitsFilter = ref object
Uses bitsets to determine whether another bit set 'matches' a set of conditions

Procs

proc `$`(bitset: Bits): string {....raises: [], tags: [], forbids: [].}
proc `+`(a, b: Bits): Bits {....raises: [], tags: [], forbids: [].}
Union of two sets
proc `+=`(a: var Bits; b: Bits) {....raises: [], tags: [], forbids: [].}
Union of two sets
proc `-`(a, b: Bits): Bits {....raises: [], tags: [], forbids: [].}
Remove elements of set b from set a and return the new value
proc `<`(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
Returns whether a is a strict subset of b
proc `<=`(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
Returns whether a is a subset of b
proc `==`(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
Returns whether two sets contain the exact same set of values
proc `>`(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
Returns whether a contains bits not set in b
proc anyIntersect(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
Returns whether any of the bits overlap
proc card(bitset: Bits): int {....raises: [], tags: [], forbids: [].}
The number of bits that have been set -- the cardinality
proc contains(bitset: Bits; value: uint16): bool {....raises: [], tags: [],
    forbids: [].}
Returns whether any of the bits overlap
proc hash(bitset: Bits): Hash {....raises: [], tags: [], forbids: [].}
proc hash(filter: BitsFilter): Hash {....raises: [], tags: [], forbids: [].}
proc incl(bitset: var Bits; value: uint16) {....raises: [], tags: [], forbids: [].}
Add a value to this set
proc matches(filter: BitsFilter; all: Bits; optional: Bits = newBits()): bool {.
    ...raises: [], tags: [], forbids: [].}
Whether a target matches a filter
proc newBits(values: varargs[uint16]): Bits {....raises: [], tags: [], forbids: [].}
Create a new bit set
proc newFilter(mustContain, mustExclude: Bits): BitsFilter {....raises: [],
    tags: [], forbids: [].}
Creates a new filter

Iterators

iterator items(bitset: Bits): uint16 {....raises: [], tags: [], forbids: [].}
Returns the index of every bit that has been set