1#ifndef OSMIUM_INDEX_MAP_FLEX_MEM_HPP
2#define OSMIUM_INDEX_MAP_FLEX_MEM_HPP
45#define OSMIUM_HAS_INDEX_MAP_FLEX_MEM
60 template <
typename TId,
typename TValue>
113 static uint64_t
block(
const uint64_t
id)
noexcept {
117 static uint64_t
offset(
const uint64_t
id)
noexcept {
148 entry{id, osmium::index::empty_value<TValue>()});
150 return osmium::index::empty_value<TValue>();
162 return osmium::index::empty_value<TValue>();
186 std::size_t
size() const noexcept final {
199 void set(
const TId
id,
const TValue value)
final {
214 TValue
get(
const TId
id)
const final {
216 if (value == osmium::index::empty_value<TValue>()) {
256 std::pair<std::size_t, std::size_t>
stats() const noexcept {
257 std::size_t used_blocks = 0;
258 std::size_t empty_blocks = 0;
261 if (dense_block.empty()) {
268 return std::make_pair(used_blocks, empty_blocks);
279#ifdef OSMIUM_WANT_NODE_LOCATION_MAPS
Definition: location.hpp:271
Definition: flex_mem.hpp:61
static uint64_t block(const uint64_t id) noexcept
Definition: flex_mem.hpp:113
std::size_t size() const noexcept final
Definition: flex_mem.hpp:186
void switch_to_dense()
Definition: flex_mem.hpp:243
std::pair< std::size_t, std::size_t > stats() const noexcept
Definition: flex_mem.hpp:256
TValue get_sparse(const uint64_t id) const noexcept
Definition: flex_mem.hpp:145
@ min_dense_entries
Definition: flex_mem.hpp:76
std::size_t used_memory() const noexcept final
Definition: flex_mem.hpp:193
void sort() final
Definition: flex_mem.hpp:231
@ density_factor
Definition: flex_mem.hpp:85
static uint64_t offset(const uint64_t id) noexcept
Definition: flex_mem.hpp:117
void clear() final
Definition: flex_mem.hpp:222
bool is_dense() const noexcept
Definition: flex_mem.hpp:182
void set_sparse(const uint64_t id, const TValue value)
Definition: flex_mem.hpp:132
std::vector< entry > m_sparse_entries
Definition: flex_mem.hpp:103
void set(const TId id, const TValue value) final
Set the field with id to value.
Definition: flex_mem.hpp:199
void set_dense(const uint64_t id, const TValue value)
Definition: flex_mem.hpp:155
void assure_block(const uint64_t num)
Definition: flex_mem.hpp:123
@ block_size
Definition: flex_mem.hpp:70
FlexMem(bool use_dense=false)
Definition: flex_mem.hpp:178
TValue get_noexcept(const TId id) const noexcept final
Definition: flex_mem.hpp:207
uint64_t m_max_id
Definition: flex_mem.hpp:108
std::vector< std::vector< TValue > > m_dense_blocks
Definition: flex_mem.hpp:105
bool m_dense
Definition: flex_mem.hpp:111
TValue get_dense(const uint64_t id) const noexcept
Definition: flex_mem.hpp:160
@ bits
Definition: flex_mem.hpp:66
TValue get(const TId id) const final
Definition: flex_mem.hpp:214
#define REGISTER_MAP(id, value, klass, name)
Definition: map.hpp:287
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
uint64_t unsigned_object_id_type
Type for OSM object (node, way, or relation) IDs where we only allow positive IDs.
Definition: types.hpp:46
Definition: location.hpp:555
Definition: flex_mem.hpp:89
TValue value
Definition: flex_mem.hpp:91
entry(uint64_t i, TValue v)
Definition: flex_mem.hpp:93
uint64_t id
Definition: flex_mem.hpp:90
bool operator<(const entry other) const noexcept
Definition: flex_mem.hpp:98