pasta_bit_vector  1.0.1
Bit Vector with Compact and Fast Rank and Select Support
Loading...
Searching...
No Matches
find_l2_flat_with.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//! \addtogroup pasta_bit_vector_configuration
26//! \{
27
28/*!
29 * \brief Enum used to specify whether intrinsic functions should be used.
30 *
31 * Note that this does not necessarily mean that intrinsic functions are
32 * faster. Please refer to the benchmarks for real world practical results
33 * obtained in experiments.
34 */
35enum class FindL2FlatWith {
36 LINEAR_SEARCH,
37 BINARY_SEARCH,
38 INTRINSICS
39}; // enum class FindL2FlatWith
40
41/*! \brief Helper function indicating whether a linear search
42 * function should be used.
43 *
44 * \param find_with FindL2FlatWith indicating whether intrinsics
45 * should be used.
46 * \return \c true if intrinsics should be used and \c false otherwise.
47 */
48constexpr bool use_linear_search(FindL2FlatWith const find_with) {
49 return find_with == FindL2FlatWith::LINEAR_SEARCH;
50}
51
52/*! \brief Helper function indicating whether a binary search
53 * function should be used.
54 *
55 * \param find_with FindL2FlatWith indicating whether intrinsics
56 * should be used.
57 * \return \c true if intrinsics should be used and \c false otherwise.
58 */
59constexpr bool use_binary_search(FindL2FlatWith const find_with) {
60 return find_with == FindL2FlatWith::BINARY_SEARCH;
61}
62
63/*! \brief Helper function indicating whether intrinsic function should be
64 * used.
65 *
66 * \param find_with FindL2FlatWith indicating whether intrinsics
67 * should be used.
68 * \return \c true if intrinsics should be used and \c false otherwise.
69 */
70constexpr bool use_intrinsics(FindL2FlatWith const find_with) {
71#if defined(__x86_64__)
72 return find_with == FindL2FlatWith::INTRINSICS;
73#else
74 return false;
75#endif
76}
77
78//! \‍)
79
80} // namespace pasta
81
82/******************************************************************************/
constexpr bool use_intrinsics(FindL2FlatWith const find_with)
Helper function indicating whether intrinsic function should be used.
Definition find_l2_flat_with.hpp:70
constexpr bool use_linear_search(FindL2FlatWith const find_with)
Helper function indicating whether a linear search function should be used.
Definition find_l2_flat_with.hpp:48
FindL2FlatWith
Enum used to specify whether intrinsic functions should be used.
Definition find_l2_flat_with.hpp:35
constexpr bool use_binary_search(FindL2FlatWith const find_with)
Helper function indicating whether a binary search function should be used.
Definition find_l2_flat_with.hpp:59