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 `==`(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
- Returns whether two sets contain the exact same set of values
proc `==`(a, b: BitsFilter): bool {....raises: [], tags: [], forbids: [].}
proc acceptsAll(filter: BitsFilter): bool {....raises: [], tags: [], forbids: [].}
- Whether this filter lets through every possible set of bits
proc anyIntersect(a, b: Bits): bool {....raises: [], tags: [], forbids: [].}
- Returns whether any of the bits overlap
proc hash(filter: BitsFilter): Hash {....raises: [], tags: [], forbids: [].}
proc isSubsetOfUnion(a, b, c: Bits): bool {....raises: [], tags: [], forbids: [].}
- Whether a is a subset of b + c, without building the union to find out
proc matches(filter: BitsFilter; all: Bits): bool {....raises: [], tags: [], forbids: [].}
- Whether a target matches a filter
proc matches(filter: BitsFilter; all: Bits; optional: Bits): bool {....raises: [], tags: [], forbids: [].}
- Whether a target matches a filter, disregarding any optional components
proc mentioned(filter: BitsFilter): Bits {....raises: [], tags: [], forbids: [].}
- Every component a filter asks after, whether it insists on one or rules it out. A caller that wants to know which components a filter can tell apart wants this
proc newFilter(mustContain, mustExclude: Bits): BitsFilter {....raises: [], tags: [], forbids: [].}
- Creates a new filter
proc withoutRequired(filter: BitsFilter; component: uint16): BitsFilter {. ...raises: [], tags: [], forbids: [].}
- The same filter, minus one component it requires. Useful where a caller has already established that component is present and would rather not pay to confirm it
Iterators
iterator required(filter: BitsFilter): uint16 {....raises: [], tags: [], forbids: [].}
- Yields every component a filter insists on being present. A set missing any one of these can never match, which makes them usable as a cheap precondition