Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
idle_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_IDLE_POINT_MULTIMAP_HPP
14 #define SPATIAL_IDLE_POINT_MULTIMAP_HPP
15 
16 #include <memory> // std::allocator
17 #include <utility> // std::pair
18 #include "function.hpp"
19 #include "bits/spatial_kdtree.hpp"
20 
21 namespace spatial
22 {
23 
28  template<dimension_type Rank, typename Key, typename Mapped,
29  typename Compare = bracket_less<Key>,
30  typename Alloc = std::allocator<std::pair<const Key, Mapped> > >
32  : details::Kdtree<details::Static_rank<Rank>, const Key,
33  std::pair<const Key, Mapped>, Compare, Alloc>
34  {
35  private:
37  std::pair<const Key, Mapped>, Compare,
38  Alloc> base_type;
39  typedef idle_point_multimap<Rank, Key, Mapped,
40  Compare, Alloc> Self;
41 
42  public:
43  typedef Mapped mapped_type;
44 
46 
47  explicit idle_point_multimap(const Compare& compare)
48  : base_type(details::Static_rank<Rank>(), compare)
49  { }
50 
51  idle_point_multimap(const Compare& compare, const Alloc& alloc)
52  : base_type(details::Static_rank<Rank>(), compare, alloc)
53  { }
54 
55  idle_point_multimap(const idle_point_multimap& other, bool balancing = false)
56  : base_type(other, balancing)
57  { }
58 
61  {
62  return static_cast<Self&>(base_type::operator=(other));
63  }
64  };
65 
70  template<typename Key, typename Mapped, typename Compare, typename Alloc>
71  struct idle_point_multimap<0, Key, Mapped, Compare, Alloc>
72  : details::Kdtree<details::Dynamic_rank, const Key,
73  std::pair<const Key, Mapped>, Compare, Alloc>
74  {
75  private:
76  typedef details::Kdtree<details::Dynamic_rank, const Key,
77  std::pair<const Key, Mapped>,
78  Compare, Alloc> base_type;
80 
81  public:
82  typedef Mapped mapped_type;
83 
85 
87  : base_type(details::Dynamic_rank(dim))
88  { except::check_rank(dim); }
89 
90  idle_point_multimap(dimension_type dim, const Compare& compare)
91  : base_type(details::Dynamic_rank(dim), compare)
92  { except::check_rank(dim); }
93 
94  explicit idle_point_multimap(const Compare& compare)
95  : base_type(compare)
96  { }
97 
98  idle_point_multimap(dimension_type dim, const Compare& compare,
99  const Alloc& alloc)
100  : base_type(details::Dynamic_rank(dim), compare, alloc)
101  { except::check_rank(dim); }
102 
103  idle_point_multimap(const Compare& compare, const Alloc& alloc)
104  : base_type(details::Dynamic_rank(), compare, alloc)
105  { }
106 
108  bool balancing = false)
109  : base_type(other, balancing)
110  { }
111 
114  {
115  return static_cast<Self&>(base_type::operator=(other));
116  }
117  };
118 
119 }
120 
121 #endif // SPATIAL_IDLE_POINT_MULTIMAP_HPP
When specified with a null dimension, the rank of the point_multimap can be determined at run time an...
The dimension value is stored by a member of the object, but can be modified at run time...
idle_point_multimap(const Compare &compare, const Alloc &alloc)
idle_point_multimap(dimension_type dim, const Compare &compare)
idle_point_multimap(const idle_point_multimap &other, bool balancing=false)
These containers are mapped containers and store values in space that can be represented as points...
idle_point_multimap & operator=(const idle_point_multimap &other)
idle_point_multimap(const Compare &compare)
idle_point_multimap(dimension_type dim, const Compare &compare, const Alloc &alloc)
idle_point_multimap< 0, Key, Mapped, Compare, Alloc > Self
void check_rank(dimension_type rank)
Checks that rank is not null.
idle_point_multimap< Rank, Key, Mapped, Compare, Alloc > Self
idle_point_multimap(const Compare &compare, const Alloc &alloc)
idle_point_multimap & operator=(const idle_point_multimap &other)
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
idle_point_multimap(const idle_point_multimap &other, bool balancing=false)
The main namespace used in the library.
Definition: algorithm.hpp:23
Detailed implementation of the kd-tree.
details::Kdtree< details::Dynamic_rank, const Key, std::pair< const Key, Mapped >, Compare, Alloc > base_type
details::Kdtree< details::Static_rank< Rank >, const Key, std::pair< const Key, Mapped >, Compare, Alloc > base_type