| 1 |
Welcome to the C++ part of the sux project. |
| 2 |
|
| 3 |
We provide two implementations of rank/select queries for bit arrays of up |
| 4 |
to 2^64 bits. The constructor requires a pointer to a uint_64 array and |
| 5 |
a number of bits. The classes provide obvious rank/select methods. |
| 6 |
Please see my paper "Broadword Implementation of Rank/Select Queries" |
| 7 |
for details about the implementations. |
| 8 |
|
| 9 |
We also provide an implementation of Jacobson's balanced parentheses data |
| 10 |
structure. Please see my paper "Broadword Implementation of Parenthesis |
| 11 |
Queries" for details about the implementations. |
| 12 |
|
| 13 |
The documentation is definitely lacking. It is coming: it is also likely |
| 14 |
that a scheme similar to Sux4J will be implemented--e.g., select9 will |
| 15 |
be implemented by a separate class that will require a rank9 instance |
| 16 |
in its constructor. |
| 17 |
|
| 18 |
- rank9sel.cpp/rank9sel.h uses broadword algorithms, rank9 as basic structure, |
| 19 |
and adds select9 (+25%-+37.5% depending on data) which provides constant |
| 20 |
time selection using further broadword techniques. There is also a version |
| 21 |
limited to 32-bit addressing. |
| 22 |
|
| 23 |
- simple_select.cpp/simple_select.h uses broadword bit search to implement a |
| 24 |
very efficient selection structure that on uniformly distributed arrays |
| 25 |
uses ~13.8% additional space and is very fast. simple_select_zero.cpp |
| 26 |
does the same for selecting zeroes. |
| 27 |
|
| 28 |
- rank9b.cpp/rank9b.h uses broadword algorithms, rank9 as basic ranking |
| 29 |
structure (+25% in size), and performs selection using hinted binary |
| 30 |
search (at most +12.5% in size). Mainly useful for testing. There is also |
| 31 |
a version limited to 32-bit addressing. |
| 32 |
|
| 33 |
- sparse.cpp/sparse.h implements an opportunistic data structure: the |
| 34 |
original bit array is not required. It uses simple_select_half--a |
| 35 |
data structure identical to simple_select but with constants hardwired |
| 36 |
for density 1/2. |
| 37 |
|
| 38 |
- jacobson.cpp/jacobson.h implements Jacobson's o(n) constant-time rank |
| 39 |
structure. |
| 40 |
|
| 41 |
By defining some symbols you can conditionally compile different behaviours: |
| 42 |
|
| 43 |
- RANKPOPCOUNT in rank9.cpp will use popcounts for ranking instead of broadword algorithms; |
| 44 |
- RANKPOPCOUNT2 in rank9.cpp will use *unrolled* popcounts; |
| 45 |
- NOINVENTORY for rank9.cpp will eliminate the inventory and use a pure binary search. |
| 46 |
|
| 47 |
- SELPOPCOUNT will use popcounts for selection instead of broadword algorithms; |
| 48 |
|
| 49 |
- bal_paren.cpp/bal_paren.h implements Jacobson's o(n) constant-time rank |
| 50 |
structure. In that case, SLOW_NO_TABS compiles in for-loop instead of |
| 51 |
broadword implementations. |
| 52 |
|
| 53 |
All classes are heavily asserted. For testing speed, remember to use |
| 54 |
-DNDEBUG. |
| 55 |
|
| 56 |
The files testcount64.cpp and testselect64.cpp provide testing in isolation |
| 57 |
for rank/select techniques inside a word. testranksel.cpp can be compiled |
| 58 |
with more or less any structure by defining CLASS to the structure name, |
| 59 |
and provides testing of rank/select primitives (please see the makefile). |
| 60 |
Beside the number of bits, you can provide one or two probabilities. Bits |
| 61 |
will be set to one with the given probability in the first half of the test |
| 62 |
array, and with the second probability in the second half (if no second |
| 63 |
probability is specified, it is assumed to be equal to the first one). This |
| 64 |
setup is necessary to show the slow behaviour of naive implementations on |
| 65 |
half-almost-empty-half-almost-full arrays. |
| 66 |
|
| 67 |
testbalparen.cpp tests the speed of finding a matching close parenthesis, |
| 68 |
and requires the number of parentheses in the test stirng. By providing an |
| 69 |
additional twist between 0 and 1 you can skew the string distribution |
| 70 |
towards strings with deeper nestings (1 means no twist). |
| 71 |
|
| 72 |
Enjoy, |
| 73 |
|
| 74 |
seba ([email protected]) |