Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
box_multiset.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_BOX_MULTISET_HPP
14 #define SPATIAL_BOX_MULTISET_HPP
15 
16 #include <memory> // std::allocator
17 #include "function.hpp"
18 #include "bits/spatial_check_concept.hpp"
19 #include "bits/spatial_relaxed_kdtree.hpp"
20 
21 namespace spatial
22 {
34  template<dimension_type Rank, typename Key,
35  typename Compare = bracket_less<Key>,
36  typename BalancingPolicy = loose_balancing,
37  typename Alloc = std::allocator<Key> >
39  : public details::Relaxed_kdtree<details::Static_rank<Rank>, const Key,
40  const Key, Compare, BalancingPolicy, Alloc>
41  {
42  private:
43  typedef typename
45 
47  <details::Static_rank<Rank>, const Key, const Key, Compare,
48  BalancingPolicy, Alloc> base_type;
50 
51  public:
53 
54  explicit box_multiset(const Compare& compare)
55  : base_type(details::Static_rank<Rank>(), compare)
56  { }
57 
58  box_multiset(const Compare& compare, const BalancingPolicy& balancing)
59  : base_type(details::Static_rank<Rank>(), compare, balancing)
60  { }
61 
62  box_multiset(const Compare& compare, const BalancingPolicy& balancing,
63  const Alloc& alloc)
64  : base_type(details::Static_rank<Rank>(), compare, balancing, alloc)
65  { }
66 
67  box_multiset(const box_multiset& other)
68  : base_type(other)
69  { }
70 
72  operator=(const box_multiset& other)
73  { return static_cast<Self&>(base_type::operator=(other)); }
74  };
75 
90  template<typename Key,
91  typename Compare,
92  typename BalancingPolicy,
93  typename Alloc>
94  class box_multiset<0, Key, Compare, BalancingPolicy, Alloc>
95  : public details::Relaxed_kdtree<details::Dynamic_rank, const Key,
96  const Key, Compare, BalancingPolicy, Alloc>
97  {
98  private:
100  const Key, const Key, Compare,
101  BalancingPolicy, Alloc> base_type;
103 
104  public:
105  box_multiset() : base_type(details::Dynamic_rank(2)) { }
106 
108  : base_type(details::Dynamic_rank(dim))
109  { except::check_even_rank(dim); }
110 
111  box_multiset(dimension_type dim, const Compare& compare)
112  : base_type(details::Dynamic_rank(dim), compare)
113  { except::check_even_rank(dim); }
114 
115  box_multiset(dimension_type dim, const Compare& compare,
116  const BalancingPolicy& policy)
117  : base_type(details::Dynamic_rank(dim), compare, policy)
118  { except::check_even_rank(dim); }
119 
120  box_multiset(dimension_type dim, const Compare& compare,
121  const BalancingPolicy& policy, const Alloc& alloc)
122  : base_type(details::Dynamic_rank(dim), compare, policy, alloc)
123  { except::check_even_rank(dim); }
124 
125  explicit box_multiset(const Compare& compare)
126  : base_type(details::Dynamic_rank(2), compare)
127  { }
128 
129  box_multiset(const Compare& compare, const BalancingPolicy& policy)
130  : base_type(details::Dynamic_rank(2), compare, policy)
131  { }
132 
133  box_multiset(const Compare& compare, const BalancingPolicy& policy,
134  const Alloc& alloc)
135  : base_type(details::Dynamic_rank(2), compare, policy, alloc)
136  { }
137 
139  : base_type(other)
140  { }
141 
142  box_multiset&
143  operator=(const box_multiset& other)
144  { return static_cast<Self&>(base_type::operator=(other)); }
145  };
146 
147 }
148 
149 #endif // SPATIAL_BOX_MULTISET_HPP
Relaxed_kdtree & operator=(const Relaxed_kdtree &other)
Assignment of other into the tree, with deep copy.
Detailed implementation of the kd-tree.
box_multiset(const box_multiset &other)
The dimension value is stored by a member of the object, but can be modified at run time...
details::Relaxed_kdtree< details::Dynamic_rank, const Key, const Key, Compare, BalancingPolicy, Alloc > base_type
These containers are not mapped containers and store values in space that can be represented as boxes...
box_multiset(const Compare &compare)
details::Relaxed_kdtree< details::Static_rank< Rank >, const Key, const Key, Compare, BalancingPolicy, Alloc > base_type
box_multiset(const Compare &compare, const BalancingPolicy &policy)
box_multiset(dimension_type dim, const Compare &compare, const BalancingPolicy &policy)
void check_even_rank(dimension_type rank)
Checks that rank is not null and that it is a multiple of 2.
box_multiset(dimension_type dim, const Compare &compare)
box_multiset & operator=(const box_multiset &other)
box_multiset(const Compare &compare, const BalancingPolicy &balancing)
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
Specialization for spatial::box_multiset with runtime rank support.
If B is true, spatial::enable_if has a public member typedef type, equal to Tp; otherwise, there is no member typedef.
box_multiset(dimension_type dim, const Compare &compare, const BalancingPolicy &policy, const Alloc &alloc)
The dimension value is set by a template value, thus consuming no memory.
The main namespace used in the library.
Definition: algorithm.hpp:23
box_multiset(const Compare &compare, const BalancingPolicy &policy, const Alloc &alloc)
box_multiset(const Compare &compare, const BalancingPolicy &balancing, const Alloc &alloc)
box_multiset< 0, Key, Compare, BalancingPolicy, Alloc > Self
enable_if_c<(Rank &1u)==0 >::type check_concept_dimension_is_even
box_multiset< Rank, Key, Compare, BalancingPolicy, Alloc > Self