https://github.com/biojulia/indexablebitvectors.jl
Fully indexable dictionaries - access/rank/select operations
https://github.com/biojulia/indexablebitvectors.jl
Last synced: about 1 year ago
JSON representation
Fully indexable dictionaries - access/rank/select operations
- Host: GitHub
- URL: https://github.com/biojulia/indexablebitvectors.jl
- Owner: BioJulia
- License: other
- Created: 2015-05-30T22:58:07.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-09-10T17:04:32.000Z (over 7 years ago)
- Last Synced: 2025-04-11T12:53:02.489Z (about 1 year ago)
- Language: Jupyter Notebook
- Size: 721 KB
- Stars: 12
- Watchers: 14
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# IndexableBitVectors
[](https://travis-ci.org/BioJulia/IndexableBitVectors.jl)
[](http://pkg.julialang.org/?pkg=IndexableBitVectors&ver=0.4)
This package exports following operations over bit vectors with extremely fast
speed while keeping extra memory usage small:
* `getindex(bv::IndexableBitVectors, i::Integer)`: `i`-th element of `bv`
* `rank(b::Bool, bv::AbstractIndexableBitVector, i::Integer)`: the number of occurrences of bit `b` in `bv[1:i]`
* `select(b::Bool, bv::AbstractIndexableBitVector, i::Integer)`: the index of `i`-th occurrence of `b` in `bv`.
And other shortcuts:
* `rank0(bv, i)` = `rank(false, bv, i)`
* `rank1(bv, i)` = `rank(true, bv, i)`
* `select0(bv, i)` = `select(0, bv, i)`
* `select1(bv, i)` = `select(1, bv, i)`
The following two types are exported:
* `SucVector`: rank values are precomputed in blocks.
* `RRR`: compressible indexable bit vector.
In general, queries on `SucVector` is faster than those on `RRR`, but `RRR` is compressible.
Conversions from bit vectors are defined for these types. So you just pass a bit vector to them:
```
julia> using IndexableBitVectors
julia> SucVector(bitrand(10))
10-element IndexableBitVectors.SucVector:
false
false
false
false
true
true
false
false
false
true
julia> RRR(bitrand(10))
10-element IndexableBitVectors.RRR:
false
false
false
false
true
false
false
false
true
false
```
## Benchmarks:
The script and result of benchmarks can be found in the [benchmarks](./benchmarks)
directory. Plots are in a Jupyter notebook: [benchmarks/plot.ipynb](./benchmarks/plot.ipynb).