Libosmium  2.7.1
Fast and flexible C++ library for working with OpenStreetMap data
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 (http://osmcode.org/libosmium).
7 
8 Copyright 2013-2016 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  Multimap(const Multimap&) = delete;
57  Multimap& operator=(const Multimap&) = delete;
58 
59  protected:
60 
61  Multimap(Multimap&&) = default;
62  Multimap& operator=(Multimap&&) = default;
63 
64  public:
65 
67  using key_type = TId;
68 
70  using value_type = TValue;
71 
72  Multimap() = default;
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  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 size_t size() const =0
virtual ~Multimap() noexcept=default
element_type * iterator
Definition: multimap.hpp:79
virtual void set(const TId id, const TValue value)=0
Set the field with id to value.
Multimap & operator=(const Multimap &)=delete
Namespace for everything in the Osmium library.
Definition: assembler.hpp:66
virtual void dump_as_list(const int)
Definition: multimap.hpp:114
Definition: multimap.hpp:51
virtual size_t used_memory() const =0
TValue value_type
The "value" type, usually a Location or size_t.
Definition: multimap.hpp:70
virtual void sort()
Definition: multimap.hpp:110
typename std::pair< TId, TValue > element_type
Definition: multimap.hpp:54
TId key_type
The "key" type, usually osmium::unsigned_object_id_type.
Definition: multimap.hpp:67