Succinct Trees
Balanced Parentheses Trees
The crate has a new data structure: Succinct trees using the well-known BP representation.
- The tree supports tree navigation to parent, children, and siblings, as well as
subtree_size
andis_ancestor
inO(log n)
- Further, it supports level-tree navigation (i.e. navigation in level-order), also in
O(log n)
- It supports fast depth-first postorder iteration of the entire tree, or individual subtrees.
- It exposes the usual internal BP helper functions
open
,close
,enclose
, and evenfwd_search
andbwd_search
. - It is written to support unbalanced parenthesis expressions without panicking on the navigation functions (iterators excluded).
Sparse RsVec
And another new data structure: A sparse bit vector which supports rank1
, select1
, and rank0
(among the usual convenience features).
It is a thin wrapper around an Elias-Fano vector.
It can be efficiently constructed from a collection of indices of set bits, or from an existing BitVec
.
New APIs
Elias Fano
- Added a
rank(i)
andselect(i)
function (the latter being an alias forget(i)
) - Added a
delta(i)
function, which returns the delta between entriesi - 1
andi
. - Elias Fano construction is a bit over 5% faster
Bit Vectors
- Added a function
append_bits_unchecked
which leaves out some housekeeping thatappend_bit
normally does. - Added a function
unpack_bits(i, n)
as a convenient counterpart to thepack_sequence_*
constructors. It is an alias forget_bits(i * n, n)
, and it has an unchecked version too.
Other Fixes
- small correction in the documentation for rank and select, clarifying the invariant.