pasta::bit_vector  v1.0.0
Compact and Fast Rank and Select Data Structure for Bit Vectors
optimized_for.hpp
1/*******************************************************************************
2 * This file is part of pasta::bit_vector.
3 *
4 * Copyright (C) 2021 Florian Kurpicz <florian@kurpicz.org>
5 *
6 * pasta::bit_vector is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * pasta::bit_vector is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with pasta::bit_vector. If not, see <http://www.gnu.org/licenses/>.
18 *
19 ******************************************************************************/
20
21#pragma once
22
23namespace pasta {
24
25/*! \file */
26
27//! \addtogroup pasta_bit_vector_configuration
28//! \{
29
30/*!
31 * \brief Enum used to specify which queries the rank (and select) data
32 * structures should be optimized for.
33 *
34 * Throughout the rank and select data structures, we store information about
35 * the number of ones or zeros in 512 bit blocks. If we store the information
36 * for ones, the queries for zeros are more complicated and vice versa. This
37 * option allows to specify which query the data structure should be optimized
38 * for.
39 */
40enum class OptimizedFor {
41 //! It does not matter (both types are called equally often).
43 //! rank_1 and select_1 queries should be optimized.
45 //! rank_0 and select_9 queries should be optimized.
47}; // enum class OptimizedFor
48
49/*!
50 * \brief Helper function indicating if queries should be optimized for one
51 * queries or the caller does not care.
52 *
53 * \param optimized_for Parameter indicating for what type of queries
54 * the data structure should be optimized.
55 * \return \c true if the data structure should be optimized for one queries
56 * or the caller does not care for what queries the data structure is
57 * optimized for. `false` otherwise.
58 */
59constexpr bool optimize_one_or_dont_care(OptimizedFor const optimized_for) {
60 return ((optimized_for == OptimizedFor::DONT_CARE) ||
61 (optimized_for == OptimizedFor::ONE_QUERIES));
62}
63
64//! \}
65} // namespace pasta
66
67/******************************************************************************/
OptimizedFor
Enum used to specify which queries the rank (and select) data structures should be optimized for.
Definition: optimized_for.hpp:40
constexpr bool optimize_one_or_dont_care(OptimizedFor const optimized_for)
Helper function indicating if queries should be optimized for one queries or the caller does not care...
Definition: optimized_for.hpp:59
@ ZERO_QUERIES
rank_0 and select_9 queries should be optimized.
@ DONT_CARE
It does not matter (both types are called equally often).
@ ONE_QUERIES
rank_1 and select_1 queries should be optimized.