1#ifndef OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
2#define OSMIUM_INDEX_MULTIMAP_SPARSE_MEM_MULTIMAP_HPP
37#include <osmium/io/detail/read_write.hpp>
55 template <
typename TId,
typename TValue>
63 element_size =
sizeof(TId) +
sizeof(TValue) +
sizeof(
void*) * 4U
69 using iterator =
typename collection_type::iterator;
88 void set(
const TId
id,
const TValue value)
override {
92 std::pair<iterator, iterator>
get_all(
const TId
id) {
96 std::pair<const_iterator, const_iterator>
get_all(
const TId
id)
const {
100 void remove(
const TId
id,
const TValue value) {
101 std::pair<iterator, iterator> r =
get_all(
id);
102 for (
iterator it = r.first; it != r.second; ++it) {
103 if (it->second == value) {
135 std::vector<element_type> v;
138 v.emplace_back(element.first, element.second);
140 std::sort(v.begin(), v.end());
141 osmium::io::detail::reliable_write(fd,
reinterpret_cast<const char*
>(v.data()),
sizeof(
element_type) * v.size());
Definition: multimap.hpp:51
TValue value_type
The "value" type, usually a Location or size_t.
Definition: multimap.hpp:67
typename std::pair< TId, TValue > element_type
Definition: multimap.hpp:54
element_type * iterator
Definition: multimap.hpp:79
Definition: sparse_mem_multimap.hpp:56
size_t used_memory() const override
Definition: sparse_mem_multimap.hpp:122
iterator end()
Definition: sparse_mem_multimap.hpp:114
typename collection_type::const_iterator const_iterator
Definition: sparse_mem_multimap.hpp:70
@ element_size
Definition: sparse_mem_multimap.hpp:63
SparseMemMultimap()=default
typename std::multimap< const TId, TValue > collection_type
Definition: sparse_mem_multimap.hpp:68
void consolidate()
Definition: sparse_mem_multimap.hpp:130
void remove(const TId id, const TValue value)
Definition: sparse_mem_multimap.hpp:100
size_t size() const override
Definition: sparse_mem_multimap.hpp:118
collection_type m_elements
Definition: sparse_mem_multimap.hpp:76
void dump_as_list(const int fd) override
Definition: sparse_mem_multimap.hpp:134
iterator begin()
Definition: sparse_mem_multimap.hpp:110
void set(const TId id, const TValue value) override
Set the field with id to value.
Definition: sparse_mem_multimap.hpp:88
void unsorted_set(const TId id, const TValue value)
Definition: sparse_mem_multimap.hpp:84
std::pair< iterator, iterator > get_all(const TId id)
Definition: sparse_mem_multimap.hpp:92
std::pair< const_iterator, const_iterator > get_all(const TId id) const
Definition: sparse_mem_multimap.hpp:96
~SparseMemMultimap() noexcept=default
void clear() override
Definition: sparse_mem_multimap.hpp:126
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53