Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
idle_box_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 
18 #ifndef SPATIAL_IDLE_BOX_MULTIMAP_HPP
19 #define SPATIAL_IDLE_BOX_MULTIMAP_HPP
20 
21 #include <memory> // std::allocator
22 #include <utility> // std::pair
23 #include "function.hpp"
24 #include "bits/spatial_check_concept.hpp"
25 #include "bits/spatial_kdtree.hpp"
26 
27 namespace spatial
28 {
29 
30  template<dimension_type Rank, typename Key, typename Mapped,
31  typename Compare = bracket_less<Key>,
32  typename Alloc = std::allocator<std::pair<const Key, Mapped> > >
34  : public details::Kdtree<details::Static_rank<Rank>, const Key,
35  std::pair<const Key, Mapped>, Compare, Alloc>
36  {
37  private:
38  typedef typename
40 
41  typedef details::Kdtree
42  <details::Static_rank<Rank>, const Key, std::pair<const Key, Mapped>,
43  Compare, Alloc> base_type;
45 
46  public:
47  typedef Mapped mapped_type;
48 
50 
51  explicit idle_box_multimap(const Compare& compare)
52  : base_type(details::Static_rank<Rank>(), compare)
53  { }
54 
55  idle_box_multimap(const Compare& compare, const Alloc& alloc)
56  : base_type(details::Static_rank<Rank>(), compare, alloc)
57  { }
58 
59  idle_box_multimap(const idle_box_multimap& other, bool balancing = false)
60  : base_type(other, balancing)
61  { }
62 
65  {
66  return static_cast<Self&>(base_type::operator=(other));
67  }
68  };
69 
83  template<typename Key, typename Mapped, typename Compare, typename Alloc>
84  class idle_box_multimap<0, Key, Mapped, Compare, Alloc>
85  : public details::Kdtree<details::Dynamic_rank, const Key,
86  std::pair<const Key, Mapped>, Compare, Alloc>
87  {
88  private:
89  typedef details::Kdtree<details::Dynamic_rank, const Key,
90  std::pair<const Key, Mapped>,
91  Compare, Alloc> base_type;
93 
94  public:
95  typedef Mapped mapped_type;
96 
97  idle_box_multimap() : base_type(details::Dynamic_rank(2)) { }
98 
100  : base_type(details::Dynamic_rank(dim))
101  { except::check_even_rank(dim); }
102 
103  idle_box_multimap(dimension_type dim, const Compare& compare)
104  : base_type(details::Dynamic_rank(dim), compare)
105  { except::check_even_rank(dim); }
106 
107  explicit idle_box_multimap(const Compare& compare)
108  : base_type(details::Dynamic_rank(2), compare)
109  { }
110 
111  idle_box_multimap(dimension_type dim, const Compare& compare,
112  const Alloc& alloc)
113  : base_type(details::Dynamic_rank(dim), compare, alloc)
114  { except::check_even_rank(dim); }
115 
116  idle_box_multimap(const Compare& compare, const Alloc& alloc)
117  : base_type(details::Dynamic_rank(2), compare, alloc)
118  { }
119 
120  idle_box_multimap(const idle_box_multimap& other, bool balancing = false)
121  : base_type(other, balancing)
122  { }
123 
126  {
127  return static_cast<Self&>(base_type::operator=(other));
128  }
129  };
130 
131 } // namespace spatial
132 
133 #endif // SPATIAL_IDLE_BOX_MULTIMAP_HPP
idle_box_multimap< Rank, Key, Mapped, Compare, Alloc > Self
idle_box_multimap< 0, Key, Mapped, Compare, Alloc > Self
details::Kdtree< details::Dynamic_rank, const Key, std::pair< const Key, Mapped >, Compare, Alloc > base_type
The dimension value is stored by a member of the object, but can be modified at run time...
idle_box_multimap(const Compare &compare, const Alloc &alloc)
idle_box_multimap(const idle_box_multimap &other, bool balancing=false)
idle_box_multimap(dimension_type dim, const Compare &compare, const Alloc &alloc)
void check_even_rank(dimension_type rank)
Checks that rank is not null and that it is a multiple of 2.
idle_box_multimap(const Compare &compare)
details::Kdtree< details::Static_rank< Rank >, const Key, std::pair< const Key, Mapped >, Compare, Alloc > base_type
idle_box_multimap(const Compare &compare, const Alloc &alloc)
Specialization for spatial::idle_box_multimap with runtime rank support.
enable_if_c<(Rank &1u)==0 >::type check_concept_dimension_is_even
idle_box_multimap & operator=(const idle_box_multimap &other)
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
If B is true, spatial::enable_if has a public member typedef type, equal to Tp; otherwise, there is no member typedef.
The dimension value is set by a template value, thus consuming no memory.
The main namespace used in the library.
Definition: algorithm.hpp:23
idle_box_multimap & operator=(const idle_box_multimap &other)
Detailed implementation of the kd-tree.
idle_box_multimap(dimension_type dim, const Compare &compare)
idle_box_multimap(const idle_box_multimap &other, bool balancing=false)