Nimony

The road to Nim 3

packedsets

nimony/lib/std/packedsets.nim

The packedsets module implements an efficient set of Ordinal values as a sparse bit set:idx:. Values that cluster -- symbol ids, file ids, node positions -- cost about one bit each, while values far apart cost one small block each.

Unlike HashSet no hash is required of the element type: the element's ordinal value is the bit index. That is exactly what Ordinal gives us -- int(x) to find the bit and A(i) to hand the element back out of items -- so Ordinal is the constraint, and it is enough to typecheck every body here up front. Routines needing more say so: $ also asks for Stringable.

See also ========