Chris@16
|
1 //
|
Chris@16
|
2 // Boost.Pointer Container
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright Thorsten Ottosen 2003-2005. Use, modification and
|
Chris@16
|
5 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
6 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8 //
|
Chris@16
|
9 // For more information, see http://www.boost.org/libs/ptr_container/
|
Chris@16
|
10 //
|
Chris@16
|
11
|
Chris@16
|
12 #ifndef BOOST_PTR_CONTAINER_PTR_SET_HPP
|
Chris@16
|
13 #define BOOST_PTR_CONTAINER_PTR_SET_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
Chris@16
|
16 # pragma once
|
Chris@16
|
17 #endif
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/ptr_container/indirect_fun.hpp>
|
Chris@16
|
20 #include <boost/ptr_container/ptr_set_adapter.hpp>
|
Chris@16
|
21 #include <set>
|
Chris@16
|
22
|
Chris@16
|
23 namespace boost
|
Chris@16
|
24 {
|
Chris@16
|
25
|
Chris@16
|
26 template
|
Chris@16
|
27 <
|
Chris@16
|
28 class Key,
|
Chris@16
|
29 class Compare = std::less<Key>,
|
Chris@16
|
30 class CloneAllocator = heap_clone_allocator,
|
Chris@16
|
31 class Allocator = std::allocator<void*>
|
Chris@16
|
32 >
|
Chris@16
|
33 class ptr_set :
|
Chris@16
|
34 public ptr_set_adapter< Key,
|
Chris@16
|
35 std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
|
Chris@16
|
36 CloneAllocator, true >
|
Chris@16
|
37 {
|
Chris@16
|
38 typedef ptr_set_adapter< Key, std::set<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
|
Chris@16
|
39 CloneAllocator, true >
|
Chris@16
|
40 base_type;
|
Chris@16
|
41
|
Chris@16
|
42 typedef ptr_set<Key,Compare,CloneAllocator,Allocator> this_type;
|
Chris@16
|
43
|
Chris@16
|
44 public:
|
Chris@16
|
45 ptr_set()
|
Chris@16
|
46 { }
|
Chris@16
|
47
|
Chris@16
|
48 explicit ptr_set( const Compare& comp,
|
Chris@16
|
49 const Allocator& a = Allocator() )
|
Chris@16
|
50 : base_type( comp, a )
|
Chris@16
|
51 { }
|
Chris@16
|
52
|
Chris@16
|
53 template< typename InputIterator >
|
Chris@16
|
54 ptr_set( InputIterator first, InputIterator last )
|
Chris@16
|
55 : base_type( first, last )
|
Chris@16
|
56 { }
|
Chris@16
|
57
|
Chris@16
|
58 template< typename InputIterator >
|
Chris@16
|
59 ptr_set( InputIterator first, InputIterator last,
|
Chris@16
|
60 const Compare& comp,
|
Chris@16
|
61 const Allocator& a = Allocator() )
|
Chris@16
|
62 : base_type( first, last, comp, a )
|
Chris@16
|
63 { }
|
Chris@16
|
64
|
Chris@16
|
65 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_set,
|
Chris@16
|
66 base_type,
|
Chris@16
|
67 this_type )
|
Chris@16
|
68
|
Chris@16
|
69 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_set, base_type )
|
Chris@16
|
70
|
Chris@16
|
71 };
|
Chris@16
|
72
|
Chris@16
|
73
|
Chris@16
|
74
|
Chris@16
|
75 template
|
Chris@16
|
76 <
|
Chris@16
|
77 class Key,
|
Chris@16
|
78 class Compare = std::less<Key>,
|
Chris@16
|
79 class CloneAllocator = heap_clone_allocator,
|
Chris@16
|
80 class Allocator = std::allocator<void*>
|
Chris@16
|
81 >
|
Chris@16
|
82 class ptr_multiset :
|
Chris@16
|
83 public ptr_multiset_adapter< Key,
|
Chris@16
|
84 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
|
Chris@16
|
85 CloneAllocator, true >
|
Chris@16
|
86 {
|
Chris@16
|
87 typedef ptr_multiset_adapter< Key,
|
Chris@16
|
88 std::multiset<void*,void_ptr_indirect_fun<Compare,Key>,Allocator>,
|
Chris@16
|
89 CloneAllocator, true >
|
Chris@16
|
90 base_type;
|
Chris@16
|
91 typedef ptr_multiset<Key,Compare,CloneAllocator,Allocator> this_type;
|
Chris@16
|
92
|
Chris@16
|
93 public:
|
Chris@16
|
94 ptr_multiset()
|
Chris@16
|
95 { }
|
Chris@16
|
96
|
Chris@16
|
97 explicit ptr_multiset( const Compare& comp,
|
Chris@16
|
98 const Allocator& a = Allocator() )
|
Chris@16
|
99 : base_type( comp, a )
|
Chris@16
|
100 { }
|
Chris@16
|
101
|
Chris@16
|
102 template< typename InputIterator >
|
Chris@16
|
103 ptr_multiset( InputIterator first, InputIterator last )
|
Chris@16
|
104 : base_type( first, last )
|
Chris@16
|
105 { }
|
Chris@16
|
106
|
Chris@16
|
107 template< typename InputIterator >
|
Chris@16
|
108 ptr_multiset( InputIterator first, InputIterator last,
|
Chris@16
|
109 const Compare& comp,
|
Chris@16
|
110 const Allocator& a = Allocator() )
|
Chris@16
|
111 : base_type( first, last, comp, a )
|
Chris@16
|
112 { }
|
Chris@16
|
113
|
Chris@16
|
114 BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_multiset,
|
Chris@16
|
115 base_type,
|
Chris@16
|
116 this_type )
|
Chris@16
|
117
|
Chris@16
|
118 BOOST_PTR_CONTAINER_DEFINE_COPY_CONSTRUCTORS( ptr_multiset,
|
Chris@16
|
119 base_type )
|
Chris@16
|
120
|
Chris@16
|
121 };
|
Chris@16
|
122
|
Chris@16
|
123 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
124 // clonability
|
Chris@16
|
125
|
Chris@16
|
126 template< typename K, typename C, typename CA, typename A >
|
Chris@16
|
127 inline ptr_set<K,C,CA,A>* new_clone( const ptr_set<K,C,CA,A>& r )
|
Chris@16
|
128 {
|
Chris@16
|
129 return r.clone().release();
|
Chris@16
|
130 }
|
Chris@16
|
131
|
Chris@16
|
132 template< typename K, typename C, typename CA, typename A >
|
Chris@16
|
133 inline ptr_multiset<K,C,CA,A>* new_clone( const ptr_multiset<K,C,CA,A>& r )
|
Chris@16
|
134 {
|
Chris@16
|
135 return r.clone().release();
|
Chris@16
|
136 }
|
Chris@16
|
137
|
Chris@16
|
138 /////////////////////////////////////////////////////////////////////////
|
Chris@16
|
139 // swap
|
Chris@16
|
140
|
Chris@16
|
141 template< typename K, typename C, typename CA, typename A >
|
Chris@16
|
142 inline void swap( ptr_set<K,C,CA,A>& l, ptr_set<K,C,CA,A>& r )
|
Chris@16
|
143 {
|
Chris@16
|
144 l.swap(r);
|
Chris@16
|
145 }
|
Chris@16
|
146
|
Chris@16
|
147 template< typename K, typename C, typename CA, typename A >
|
Chris@16
|
148 inline void swap( ptr_multiset<K,C,CA,A>& l, ptr_multiset<K,C,CA,A>& r )
|
Chris@16
|
149 {
|
Chris@16
|
150 l.swap(r);
|
Chris@16
|
151 }
|
Chris@16
|
152
|
Chris@16
|
153 }
|
Chris@16
|
154
|
Chris@16
|
155 #endif
|