├── .gitignore ├── external └── CMakeLists.txt ├── include ├── segment_tree │ ├── avx512 │ │ ├── print_table.py │ │ ├── node128.hpp │ │ ├── node256.hpp │ │ ├── node512.hpp │ │ ├── segment_tree_macros.hpp │ │ └── segment_tree.hpp │ └── avx2 │ │ ├── search_common.hpp │ │ ├── tables.hpp │ │ ├── node32.hpp │ │ ├── node128.hpp │ │ ├── node64.hpp │ │ └── segment_tree.hpp ├── hft │ ├── README.md │ ├── fenwick.hpp │ ├── fenwick │ │ ├── fixedf.hpp │ │ ├── fenwick_tree.hpp │ │ ├── hybrid.hpp │ │ ├── bytef.hpp │ │ ├── fixedl.hpp │ │ ├── bitf.hpp │ │ ├── bitl.hpp │ │ ├── bytel.hpp │ │ └── typef.hpp │ └── darray.hpp ├── mranisz │ └── README.md ├── poppy │ ├── README.md │ └── shared.h ├── util.hpp ├── types.hpp └── mutable_bitmap.hpp ├── src ├── collect_results.sh ├── collect_results_mutable_bitmap.py ├── CMakeLists.txt ├── perf_rank64.cpp ├── perf_select64.cpp ├── perf_rank512.cpp ├── perf_rank256.cpp ├── perf_select512.cpp ├── perf_select256.cpp ├── perf_popcnt_for_avx_select256.cpp ├── perf_popcnt_for_avx_select512.cpp ├── perf_popcnt256.cpp ├── perf_prefix_sum256.cpp ├── perf_search512.cpp └── perf_search256.cpp ├── .gitmodules ├── test ├── test_segment_tree.cpp ├── test_rank512.cpp ├── test_rank256.cpp ├── test_select256.cpp ├── test_select512.cpp ├── test_nodes.cpp ├── test_common.hpp ├── test_mutable_bitmap.cpp ├── test_mutable_bitmap.hpp ├── test_node.hpp ├── test_tree.hpp └── test_rank_select_algorithms.hpp ├── LICENSE ├── CMakeLists.txt ├── README.md └── .clang-format /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build* 3 | old -------------------------------------------------------------------------------- /external/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(sdsl-lite EXCLUDE_FROM_ALL) 2 | add_subdirectory(succinct EXCLUDE_FROM_ALL) 3 | -------------------------------------------------------------------------------- /include/segment_tree/avx512/print_table.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | n = int(sys.argv[1]) 4 | val = sys.argv[2] # +1 or -1 5 | for row in range(n+1): 6 | for col in range(row): 7 | print("0,", end='') 8 | for col in range(n - row): 9 | print(val+",", end='') 10 | print("") -------------------------------------------------------------------------------- /include/hft/README.md: -------------------------------------------------------------------------------- 1 | Hybrid Compact Fenwick Trees 2 | ---- 3 | 4 | Library implemented by Marchini and Vigna, available [here](https://github.com/pacman616/hybrid-fenwick-tree). 5 | 6 | The data structures are decribed in the paper *[Compact Fenwick trees for dynamic ranking and selection](https://arxiv.org/pdf/1904.12370.pdf)* by the same authors. -------------------------------------------------------------------------------- /include/mranisz/README.md: -------------------------------------------------------------------------------- 1 | Rank/Select by Marcin Raniszewski 2 | ---- 3 | 4 | Library implemented by Marcin Raniszewski, available [here](https://github.com/mranisz/rank-select). 5 | 6 | The data structures are decribed in the paper, *[Rank and select: Another lesson learned](https://arxiv.org/abs/1605.01539)* by Szymon Grabowski and Marcin Raniszewski. -------------------------------------------------------------------------------- /src/collect_results.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # $1 --> output file 3 | ./perf_prefix_sum avx2 sum 2>> $1.sum.txt 4 | ./perf_prefix_sum avx2 update 2>> $1.update.txt 5 | ./perf_prefix_sum avx2 search 2>> $1.search.txt 6 | ./perf_prefix_sum avx512 sum 2>> $1.sum.txt 7 | ./perf_prefix_sum avx512 update 2>> $1.update.txt 8 | ./perf_prefix_sum avx512 search 2>> $1.search.txt -------------------------------------------------------------------------------- /include/hft/fenwick.hpp: -------------------------------------------------------------------------------- 1 | #include "fenwick/fenwick_tree.hpp" 2 | 3 | #include "fenwick/fixedf.hpp" 4 | #include "fenwick/fixedl.hpp" 5 | 6 | #include "fenwick/typef.hpp" 7 | #include "fenwick/typel.hpp" 8 | 9 | #include "fenwick/bytef.hpp" 10 | #include "fenwick/bytel.hpp" 11 | 12 | #include "fenwick/bitf.hpp" 13 | #include "fenwick/bitl.hpp" 14 | 15 | #include "fenwick/hybrid.hpp" 16 | -------------------------------------------------------------------------------- /include/poppy/README.md: -------------------------------------------------------------------------------- 1 | Poppy 2 | ---- 3 | 4 | Library implemented by Efficient Computing at Carnegie Mellon, available [here](https://github.com/efficient/rankselect). 5 | 6 | The data structures are decribed in the paper *[Space-efficient, high-performance rank and select structures on uncompressed bit sequences](https://link.springer.com/chapter/10.1007/978-3-642-38527-8_15)* by Zhou, Andersen, and Kaminsky. 7 | 8 | The implementation uses PTSelect described in the paper *[A Fast x86 Implementation of Select](http://arxiv.org/abs/1706.00990)* by Pandey, Bender, and Johnson. 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/essentials"] 2 | path = external/essentials 3 | url = https://github.com/jermp/essentials.git 4 | [submodule "external/doctest"] 5 | path = external/doctest 6 | url = https://github.com/onqtam/doctest.git 7 | [submodule "external/cmd_line_parser"] 8 | path = external/cmd_line_parser 9 | url = https://github.com/jermp/cmd_line_parser.git 10 | [submodule "external/succinct"] 11 | path = external/succinct 12 | url = https://github.com/ot/succinct.git 13 | [submodule "external/sdsl-lite"] 14 | path = external/sdsl-lite 15 | url = https://github.com/simongog/sdsl-lite.git 16 | -------------------------------------------------------------------------------- /src/collect_results_mutable_bitmap.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | 4 | output_filename = sys.argv[1] 5 | 6 | types = [ 7 | "avx2_256_a", 8 | "avx512_256_a", 9 | "avx2_256_b", 10 | "avx512_256_b", 11 | "avx2_512_a", 12 | "avx512_512_a", 13 | "avx2_512_b", 14 | "avx512_512_b", 15 | "avx2_256_c", 16 | "avx512_256_c"] 17 | 18 | for t in types: 19 | os.system("./perf_mutable_bitmap " + t + " flip 0.3 2>> " + output_filename + ".flip.txt") 20 | os.system("./perf_mutable_bitmap " + t + " rank 0.3 2>> " + output_filename + ".rank.txt") 21 | os.system("./perf_mutable_bitmap " + t + " select 0.3 2>> " + output_filename + ".select.txt") 22 | -------------------------------------------------------------------------------- /test/test_segment_tree.cpp: -------------------------------------------------------------------------------- 1 | #include "test_common.hpp" 2 | #include "test_tree.hpp" 3 | 4 | template typename Tree> 5 | struct test { 6 | static void run() { 7 | const uint32_t n = sizes[i]; 8 | const uint32_t height = Tree<1>::height(n); 9 | test_tree>(n); 10 | test::run(); 11 | } 12 | }; 13 | 14 | template