/usr/include/sdsl/k2_treap_helper.hpp is in libsdsl-dev 2.0.3-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | /* sdsl - succinct data structures library
Copyright (C) 2014 Simon Gog
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/ .
*/
/*! \file k2_treap_helper.hpp
\brief k2_treap_helper.hpp contains helper functions and definitions for a k^2-treap implementation.
\author Simon Gog
*/
#ifndef INCLUDED_SDSL_K2_TREAP_HELPER
#define INCLUDED_SDSL_K2_TREAP_HELPER
#include "sdsl/vectors.hpp"
#include "sdsl/bits.hpp"
#include <tuple>
#include <algorithm>
#include <iterator>
#include <vector>
#include <complex>
#include <queue>
#include <array>
//! Namespace for the succinct data structure library.
namespace sdsl
{
namespace k2_treap_ns
{
// Precomputed value for fast k^2 treap operations
template<uint8_t t_k>
struct precomp {
static struct impl {
uint64_t exp[65];
impl()
{
exp[0] = 1;
for (uint8_t i=1; i<65; ++i) {
exp[i] = t_k * exp[i-1];
}
}
} data;
static uint64_t exp(uint8_t l)
{
return data.exp[l];
}
static uint64_t divexp(uint64_t x, uint8_t l)
{
return x/data.exp[l];
}
static uint64_t modexp(uint64_t x, uint8_t l)
{
return x%data.exp[l];
}
};
template<>
struct precomp<2> {
static uint64_t exp(uint8_t l)
{
return 1ULL<<l;
}
static uint64_t divexp(uint64_t x, uint8_t l)
{
return x>>l;
}
static uint64_t modexp(uint64_t x, uint8_t l)
{
return x & bits::lo_set[l];
}
};
template<>
struct precomp<4> {
static uint64_t exp(uint8_t l)
{
return 1ULL<<(2*l);
}
static uint64_t divexp(uint64_t x, uint8_t l)
{
return x>>(2*l);
}
static uint64_t modexp(uint64_t x, uint8_t l)
{
return x & bits::lo_set[2*l];
}
};
template<>
struct precomp<8> {
static uint64_t exp(uint8_t l)
{
return 1ULL<<(3*l);
}
static uint64_t divexp(uint64_t x, uint8_t l)
{
return x>>(3*l);
}
static uint64_t modexp(uint64_t x, uint8_t l)
{
return x & bits::lo_set[3*l];
}
};
template<>
struct precomp<16> {
static uint64_t exp(uint8_t l)
{
return 1ULL<<(4*l);
}
static uint64_t divexp(uint64_t x, uint8_t l)
{
return x>>(4*l);
}
static uint64_t modexp(uint64_t x, uint8_t l)
{
return x & bits::lo_set[4*l];
}
};
template<uint8_t t_k>
typename precomp<t_k>::impl precomp<t_k>::data;
typedef std::complex<uint64_t> t_p;
typedef t_p point_type;
typedef t_p range_type;
struct node_type {
uint8_t t; // level; size of node 1<<t
t_p p; // lower left corner
uint64_t idx; // index in bp
uint64_t max_v; // maximal value
t_p max_p; // maximal point
node_type() = default;
node_type(uint8_t _t, t_p _p, uint64_t _idx, uint64_t _max_v,
t_p _max_p) : t(_t), p(_p), idx(_idx), max_v(_max_v),
max_p(_max_p)
{}
node_type(node_type&&) = default;
node_type(const node_type&) = default;
node_type& operator=(node_type&&) = default;
node_type& operator=(const node_type&) = default;
bool operator<(const node_type& v) const
{
if (max_v != v.max_v) {
return max_v < v.max_v;
}
if (real(max_p) != real(v.max_p)) {
return real(max_p) > real(v.max_p);
}
return imag(max_p) > imag(v.max_p);
}
};
} // end namepsace k2_treap_ns
} // end nomespace sdsl
#endif
|