Libosmium  2.22.0
Fast and flexible C++ library for working with OpenStreetMap data
Loading...
Searching...
No Matches
multimap.hpp
Go to the documentation of this file.
1#ifndef OSMIUM_INDEX_MULTIMAP_HPP
2#define OSMIUM_INDEX_MULTIMAP_HPP
3
4/*
5
6This file is part of Osmium (https://osmcode.org/libosmium).
7
8Copyright 2013-2025 Jochen Topf <jochen@topf.org> and others (see README).
9
10Boost Software License - Version 1.0 - August 17th, 2003
11
12Permission is hereby granted, free of charge, to any person or organization
13obtaining a copy of the software and accompanying documentation covered by
14this license (the "Software") to use, reproduce, display, distribute,
15execute, and transmit the Software, and to prepare derivative works of the
16Software, and to permit third-parties to whom the Software is furnished to
17do so, all subject to the following:
18
19The copyright notices in the Software and this entire statement, including
20the above license grant, this restriction and the following disclaimer,
21must be included in all copies of the Software, in whole or in part, and
22all derivative works of the Software, unless such copies or derivative
23works are solely in the form of machine-executable object code generated by
24a source language processor.
25
26THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32DEALINGS IN THE SOFTWARE.
33
34*/
35
36#include <cstddef>
37#include <stdexcept>
38#include <type_traits>
39#include <utility>
40
41namespace osmium {
42
43 namespace index {
44
48 namespace multimap {
49
50 template <typename TId, typename TValue>
51 class Multimap {
52
53
54 using element_type = typename std::pair<TId, TValue>;
55
56 protected:
57
58 Multimap(Multimap&&) noexcept = default;
59 Multimap& operator=(Multimap&&) noexcept = default;
60
61 public:
62
64 using key_type = TId;
65
67 using value_type = TValue;
68
69 Multimap() = default;
70
71 Multimap(const Multimap&) = delete;
72 Multimap& operator=(const Multimap&) = delete;
73
74 virtual ~Multimap() noexcept = default;
75
77 virtual void set(const TId id, const TValue value) = 0;
78
80
81// virtual std::pair<iterator, iterator> get_all(const TId id) const = 0;
82
89 virtual size_t size() const = 0;
90
98 virtual size_t used_memory() const = 0;
99
104 virtual void clear() = 0;
105
110 virtual void sort() {
111 // default implementation is empty
112 }
113
114 virtual void dump_as_list(const int /*fd*/) {
115 throw std::runtime_error{"can't dump as list"};
116 }
117
118 }; // class Multimap
119
120 } // namespace multimap
121
122 } // namespace index
123
124} // namespace osmium
125
126#endif // OSMIUM_INDEX_MULTIMAP_HPP
virtual void dump_as_list(const int)
Definition multimap.hpp:114
Multimap(Multimap &&) noexcept=default
virtual void set(const unsigned_object_id_type id, const unsigned_object_id_type value)=0
typename std::pair< unsigned_object_id_type, unsigned_object_id_type > element_type
Definition multimap.hpp:54
Key-value containers with multiple values for an integer key.
Definition multimap.hpp:48
Indexing of OSM data, Locations, etc.
Definition id_set.hpp:51
Namespace for everything in the Osmium library.
Definition assembler.hpp:53