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
6 This file is part of Osmium (https://osmcode.org/libosmium).
7
8 Copyright 2013-2025 Jochen Topf <jochen@topf.org> and others (see README).
9
10 Boost Software License - Version 1.0 - August 17th, 2003
11
12 Permission is hereby granted, free of charge, to any person or organization
13 obtaining a copy of the software and accompanying documentation covered by
14 this license (the "Software") to use, reproduce, display, distribute,
15 execute, and transmit the Software, and to prepare derivative works of the
16 Software, and to permit third-parties to whom the Software is furnished to
17 do so, all subject to the following:
18
19 The copyright notices in the Software and this entire statement, including
20 the above license grant, this restriction and the following disclaimer,
21 must be included in all copies of the Software, in whole or in part, and
22 all derivative works of the Software, unless such copies or derivative
23 works are solely in the form of machine-executable object code generated by
24 a source language processor.
25
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
29 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
30 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
31 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS IN THE SOFTWARE.
33
34*/
35
36#include <cstddef>
37#include <stdexcept>
38#include <type_traits>
39#include <utility>
40
41 namespace 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
79 using iterator = element_type*;
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
osmium::index::multimap::Multimap
Definition multimap.hpp:51
osmium::index::multimap::Multimap::key_type
TId key_type
The "key" type, usually osmium::unsigned_object_id_type.
Definition multimap.hpp:64
osmium::index::multimap::Multimap::used_memory
virtual size_t used_memory() const =0
osmium::index::multimap::Multimap::dump_as_list
virtual void dump_as_list(const int)
Definition multimap.hpp:114
osmium::index::multimap::Multimap::value_type
TValue value_type
The "value" type, usually a Location or size_t.
Definition multimap.hpp:67
osmium::index::multimap::Multimap::clear
virtual void clear()=0
osmium::index::multimap::Multimap::Multimap
Multimap(Multimap &&) noexcept=default
osmium::index::multimap::Multimap::set
virtual void set(const TId id, const TValue value)=0
Set the field with id to value.
osmium::index::multimap::Multimap::sort
virtual void sort()
Definition multimap.hpp:110
osmium::index::multimap::Multimap::size
virtual size_t size() const =0
osmium::index::multimap::Multimap::element_type
typename std::pair< TId, TValue > element_type
Definition multimap.hpp:54
osmium::index::multimap::Multimap::iterator
element_type * iterator
Definition multimap.hpp:79
osmium
Namespace for everything in the Osmium library.
Definition assembler.hpp:53