Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
point_multimap.hpp
1 // -*- C++ -*-
2 //
3 // Copyright Sylvain Bougerel 2009 - 2013.
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See accompanying file COPYING or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 
13 #ifndef SPATIAL_POINT_MULTIMAP_HPP
14 #define SPATIAL_POINT_MULTIMAP_HPP
15 
16 #include <memory> // std::allocator
17 #include <utility> // std::pair
18 #include "function.hpp"
19 #include "bits/spatial_relaxed_kdtree.hpp"
20 
21 namespace spatial
22 {
27  template<dimension_type Rank, typename Key, typename Mapped,
28  typename Compare = bracket_less<Key>,
29  typename BalancingPolicy = loose_balancing,
30  typename Alloc = std::allocator<std::pair<const Key, Mapped> > >
32  : details::Relaxed_kdtree<details::Static_rank<Rank>, const Key,
33  std::pair<const Key, Mapped>, Compare,
34  BalancingPolicy, Alloc>
35  {
36  private:
38  <details::Static_rank<Rank>, const Key, std::pair<const Key, Mapped>,
39  Compare, BalancingPolicy, Alloc> base_type;
40  typedef point_multimap<Rank, Key, Mapped, Compare,
41  BalancingPolicy, Alloc> Self;
42 
43  public:
44  typedef Mapped mapped_type;
45 
47 
48  explicit point_multimap(const Compare& compare)
49  : base_type(details::Static_rank<Rank>(), compare)
50  { }
51 
52  point_multimap(const Compare& compare, const BalancingPolicy& balancing)
53  : base_type(details::Static_rank<Rank>(), compare, balancing)
54  { }
55 
56  point_multimap(const Compare& compare, const BalancingPolicy& balancing,
57  const Alloc& alloc)
58  : base_type(details::Static_rank<Rank>(), compare, balancing, alloc)
59  { }
60 
62  : base_type(other)
63  { }
64 
66  operator=(const point_multimap& other)
67  { return static_cast<Self&>(base_type::operator=(other)); }
68  };
69 
74  template<typename Key, typename Mapped, typename Compare,
75  typename BalancingPolicy, typename Alloc>
76  struct point_multimap<0, Key, Mapped, Compare, BalancingPolicy, Alloc>
77  : details::Relaxed_kdtree<details::Dynamic_rank, const Key,
78  std::pair<const Key, Mapped>, Compare,
79  BalancingPolicy, Alloc>
80  {
81  private:
83  <details::Dynamic_rank, const Key, std::pair<const Key, Mapped>,
84  Compare, BalancingPolicy, Alloc> base_type;
87 
88  public:
89  typedef Mapped mapped_type;
90 
92 
94  : base_type(details::Dynamic_rank(dim))
95  { except::check_rank(dim); }
96 
97  point_multimap(dimension_type dim, const Compare& compare)
98  : base_type(details::Dynamic_rank(dim), compare)
99  { except::check_rank(dim); }
100 
101  point_multimap(dimension_type dim, const Compare& compare,
102  const BalancingPolicy& policy)
103  : base_type(details::Dynamic_rank(dim), compare, policy)
104  { except::check_rank(dim); }
105 
106  point_multimap(dimension_type dim, const Compare& compare,
107  const BalancingPolicy& policy, const Alloc& alloc)
108  : base_type(details::Dynamic_rank(dim), compare, policy, alloc)
109  { except::check_rank(dim); }
110 
111  explicit point_multimap(const Compare& compare)
112  : base_type(details::Dynamic_rank(), compare)
113  { }
114 
115  point_multimap(const Compare& compare, const BalancingPolicy& policy)
116  : base_type(details::Dynamic_rank(), compare, policy)
117  { }
118 
119  point_multimap(const Compare& compare, const BalancingPolicy& policy,
120  const Alloc& alloc)
121  : base_type(details::Dynamic_rank(), compare, policy, alloc)
122  { }
123 
125  : base_type(other)
126  { }
127 
129  operator=(const point_multimap& other)
130  { return static_cast<Self&>(base_type::operator=(other)); }
131  };
132 }
133 
134 #endif // SPATIAL_POINT_MULTIMAP_HPP
point_multimap(const Compare &compare, const BalancingPolicy &policy)
point_multimap(dimension_type dim, const Compare &compare, const BalancingPolicy &policy, const Alloc &alloc)
Detailed implementation of the kd-tree.
The dimension value is stored by a member of the object, but can be modified at run time...
point_multimap(const Compare &compare, const BalancingPolicy &balancing, const Alloc &alloc)
details::Relaxed_kdtree< details::Dynamic_rank, const Key, std::pair< const Key, Mapped >, Compare, BalancingPolicy, Alloc > base_type
point_multimap(const Compare &compare, const BalancingPolicy &policy, const Alloc &alloc)
point_multimap< 0, Key, Mapped, Compare, BalancingPolicy, Alloc > Self
details::Relaxed_kdtree< details::Static_rank< Rank >, const Key, std::pair< const Key, Mapped >, Compare, BalancingPolicy, Alloc > base_type
void check_rank(dimension_type rank)
Checks that rank is not null.
point_multimap & operator=(const point_multimap &other)
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
point_multimap(const point_multimap &other)
The dimension value is set by a template value, thus consuming no memory.
The main namespace used in the library.
Definition: algorithm.hpp:23
point_multimap(dimension_type dim, const Compare &compare, const BalancingPolicy &policy)
point_multimap< Rank, Key, Mapped, Compare, BalancingPolicy, Alloc > Self
These containers are mapped containers and store values in space that can be represented as points...
point_multimap(const Compare &compare, const BalancingPolicy &balancing)
When specified with a null dimension, the rank of the point_multimap can be determined at run time an...
point_multimap(const Compare &compare)