func WriteBitstring(w io.Writer, bs *cf.Bitstring) (err error) { err = WriteInt(w, bs.BitLen()) if err != nil { return } err = WriteInt(w, len(bs.Bytes())) if err != nil { return } _, err = w.Write(bs.Bytes()) return }
func (t *MemPrefixTree) Node(bs *cf.Bitstring) (PrefixNode, error) { node := t.root nbq := t.BitQuantum for i := 0; i < bs.BitLen() && !node.IsLeaf(); i += nbq { childIndex := 0 for j := 0; j < nbq; j++ { mask := 1 << uint(j) if bs.Get(i+j) == 1 { childIndex |= mask } } node = node.children[childIndex] } return node, nil }