Spatial C++ Library
Generic Multi-Dimensional Containers and Spatial Operations
idle_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_IDLE_BOX_MULTISET_HPP
14 #define SPATIAL_IDLE_BOX_MULTISET_HPP
15 
16 #include <memory> // std::allocator
17 #include "function.hpp"
18 #include "bits/spatial_check_concept.hpp"
19 #include "bits/spatial_kdtree.hpp"
20 
21 namespace spatial
22 {
33  template<dimension_type Rank, typename Key,
34  typename Compare = bracket_less<Key>,
35  typename Alloc = std::allocator<Key> >
37  : public details::Kdtree<details::Static_rank<Rank>, const Key, const Key,
38  Compare, Alloc>
39  {
40  private:
41  typedef typename
43 
45  const Key, Compare, Alloc> base_type;
47 
48  public:
50 
51  explicit idle_box_multiset(const Compare& compare)
52  : base_type(details::Static_rank<Rank>(), compare)
53  { }
54 
55  idle_box_multiset(const Compare& compare, const Alloc& alloc)
56  : base_type(details::Static_rank<Rank>(), compare, alloc)
57  { }
58 
59  idle_box_multiset(const idle_box_multiset& other, bool balancing = false)
60  : base_type(other, balancing)
61  { }
62 
65  {
66  return static_cast<Self&>(base_type::operator=(other));
67  }
68  };
69 
82  template<typename Key, typename Compare, typename Alloc>
83  class idle_box_multiset<0, Key, Compare, Alloc>
84  : public details::Kdtree<details::Dynamic_rank, const Key, const Key,
85  Compare, Alloc>
86  {
87  private:
88  typedef details::Kdtree<details::Dynamic_rank, const Key,
89  const Key, Compare, Alloc> base_type;
91 
92  public:
93  idle_box_multiset() : base_type(details::Dynamic_rank(2)) { }
94 
96  : base_type(details::Dynamic_rank(dim))
97  { except::check_even_rank(dim); }
98 
99  idle_box_multiset(dimension_type dim, const Compare& compare)
100  : base_type(details::Dynamic_rank(dim), compare)
101  { except::check_even_rank(dim); }
102 
103  explicit idle_box_multiset(const Compare& compare)
104  : base_type(details::Dynamic_rank(2), compare)
105  { }
106 
107  idle_box_multiset(dimension_type dim, const Compare& compare,
108  const Alloc& alloc)
109  : base_type(details::Dynamic_rank(dim), compare, alloc)
110  { except::check_even_rank(dim); }
111 
112  idle_box_multiset(const Compare& compare, const Alloc& alloc)
113  : base_type(details::Dynamic_rank(2), compare, alloc)
114  { }
115 
116  idle_box_multiset(const idle_box_multiset& other, bool balancing = false)
117  : base_type(other, balancing)
118  { }
119 
122  {
123  return static_cast<Self&>(base_type::operator=(other));
124  }
125  };
126 
127 } // namespace spatial
128 
129 #endif // SPATIAL_IDLE_BOX_MULTISET_HPP
idle_box_multiset(dimension_type dim, const Compare &compare)
Non-associative containers that and store values in space that can be represented as boxes...
The dimension value is stored by a member of the object, but can be modified at run time...
idle_box_multiset(const Compare &compare, const Alloc &alloc)
idle_box_multiset(const Compare &compare)
idle_box_multiset(const Compare &compare, const Alloc &alloc)
idle_box_multiset< Rank, Key, Compare, Alloc > Self
idle_box_multiset(const idle_box_multiset &other, bool balancing=false)
void check_even_rank(dimension_type rank)
Checks that rank is not null and that it is a multiple of 2.
idle_box_multiset< 0, Key, Compare, Alloc > Self
details::Kdtree< details::Static_rank< Rank >, const Key, const Key, Compare, Alloc > base_type
idle_box_multiset(dimension_type dim, const Compare &compare, const Alloc &alloc)
std::size_t dimension_type
Defines the type for the dimension as being a size.
Definition: spatial.hpp:71
Specialization for spatial::idle_box_multiset with runtime rank support.
idle_box_multiset(const idle_box_multiset &other, bool balancing=false)
If B is true, spatial::enable_if has a public member typedef type, equal to Tp; otherwise, there is no member typedef.
The main namespace used in the library.
Definition: algorithm.hpp:23
details::Kdtree< details::Dynamic_rank, const Key, const Key, Compare, Alloc > base_type
enable_if_c<(Rank &1u)==0 >::type check_concept_dimension_is_even
Detailed implementation of the kd-tree.
Self & operator=(const Self &other)
Assignment of other into the tree, with deep copy.
idle_box_multiset & operator=(const idle_box_multiset &other)
idle_box_multiset & operator=(const idle_box_multiset &other)