set.hpp 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/container for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_CONTAINER_SET_HPP
  11. #define BOOST_CONTAINER_SET_HPP
  12. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #if defined(BOOST_HAS_PRAGMA_ONCE)
  16. # pragma once
  17. #endif
  18. #include <boost/container/detail/config_begin.hpp>
  19. #include <boost/container/detail/workaround.hpp>
  20. // container
  21. #include <boost/container/container_fwd.hpp>
  22. // container/detail
  23. #include <boost/container/detail/mpl.hpp>
  24. #include <boost/container/detail/tree.hpp>
  25. #include <boost/container/new_allocator.hpp> //new_allocator
  26. #include <boost/container/detail/algorithm.hpp>
  27. // intrusive/detail
  28. #include <boost/intrusive/detail/minimal_pair_header.hpp> //pair
  29. #include <boost/intrusive/detail/minimal_less_equal_header.hpp>//less, equal
  30. // move
  31. #include <boost/move/traits.hpp>
  32. #include <boost/move/utility_core.hpp>
  33. // move/detail
  34. #include <boost/move/detail/move_helpers.hpp>
  35. #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  36. #include <boost/move/detail/fwd_macros.hpp>
  37. #endif
  38. // std
  39. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  40. #include <initializer_list>
  41. #endif
  42. namespace boost {
  43. namespace container {
  44. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  45. //! A set is a kind of associative container that supports unique keys (contains at
  46. //! most one of each key value) and provides for fast retrieval of the keys themselves.
  47. //! Class set supports bidirectional iterators.
  48. //!
  49. //! A set satisfies all of the requirements of a container and of a reversible container
  50. //! , and of an associative container. A set also provides most operations described in
  51. //! for unique keys.
  52. //!
  53. //! \tparam Key is the type to be inserted in the set, which is also the key_type
  54. //! \tparam Compare is the comparison functor used to order keys
  55. //! \tparam Allocator is the allocator to be used to allocate memory for this container
  56. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  57. template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = void>
  58. #else
  59. template <class Key, class Compare, class Allocator, class Options>
  60. #endif
  61. class set
  62. ///@cond
  63. : public dtl::tree
  64. < Key, void, Compare, Allocator, Options>
  65. ///@endcond
  66. {
  67. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  68. private:
  69. BOOST_COPYABLE_AND_MOVABLE(set)
  70. typedef dtl::tree
  71. < Key, void, Compare, Allocator, Options> base_t;
  72. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  73. public:
  74. //////////////////////////////////////////////
  75. //
  76. // types
  77. //
  78. //////////////////////////////////////////////
  79. typedef Key key_type;
  80. typedef Key value_type;
  81. typedef Compare key_compare;
  82. typedef key_compare value_compare;
  83. typedef typename base_t::allocator_type allocator_type;
  84. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  85. typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
  86. typedef typename ::boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  87. typedef typename ::boost::container::allocator_traits<allocator_type>::reference reference;
  88. typedef typename ::boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  89. typedef typename ::boost::container::allocator_traits<allocator_type>::size_type size_type;
  90. typedef typename ::boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  91. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  92. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  93. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  94. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  95. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  96. typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type;
  97. typedef typename BOOST_CONTAINER_IMPDEF(base_t::insert_return_type) insert_return_type;
  98. //////////////////////////////////////////////
  99. //
  100. // construct/copy/destroy
  101. //
  102. //////////////////////////////////////////////
  103. //! <b>Effects</b>: Default constructs an empty set.
  104. //!
  105. //! <b>Complexity</b>: Constant.
  106. inline set()
  107. BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  108. dtl::is_nothrow_default_constructible<Compare>::value)
  109. : base_t()
  110. {}
  111. //! <b>Effects</b>: Constructs an empty set using the specified allocator object.
  112. //!
  113. //! <b>Complexity</b>: Constant.
  114. inline explicit set(const allocator_type& a)
  115. : base_t(a)
  116. {}
  117. //! <b>Effects</b>: Constructs an empty set using the specified comparison object.
  118. //!
  119. //! <b>Complexity</b>: Constant.
  120. inline explicit set(const Compare& comp)
  121. : base_t(comp)
  122. {}
  123. //! <b>Effects</b>: Constructs an empty set using the specified comparison object
  124. //! and allocator.
  125. //!
  126. //! <b>Complexity</b>: Constant.
  127. inline set(const Compare& comp, const allocator_type& a)
  128. : base_t(comp, a)
  129. {}
  130. //! <b>Effects</b>: Constructs an empty set using and
  131. //! inserts elements from the range [first ,last ).
  132. //!
  133. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  134. //! the predicate and otherwise N logN, where N is last - first.
  135. template <class InputIterator>
  136. inline set(InputIterator first, InputIterator last)
  137. : base_t(true, first, last)
  138. {}
  139. //! <b>Effects</b>: Constructs an empty set using the specified
  140. //! allocator, and inserts elements from the range [first ,last ).
  141. //!
  142. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  143. //! the predicate and otherwise N logN, where N is last - first.
  144. template <class InputIterator>
  145. inline set(InputIterator first, InputIterator last, const allocator_type& a)
  146. : base_t(true, first, last, key_compare(), a)
  147. {}
  148. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  149. //! inserts elements from the range [first ,last ).
  150. //!
  151. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  152. //! the predicate and otherwise N logN, where N is last - first.
  153. template <class InputIterator>
  154. inline set(InputIterator first, InputIterator last, const Compare& comp)
  155. : base_t(true, first, last, comp)
  156. {}
  157. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  158. //! allocator, and inserts elements from the range [first ,last ).
  159. //!
  160. //! <b>Complexity</b>: Linear in N if the range [first ,last ) is already sorted using
  161. //! the predicate and otherwise N logN, where N is last - first.
  162. template <class InputIterator>
  163. inline set(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  164. : base_t(true, first, last, comp, a)
  165. {}
  166. //! <b>Effects</b>: Constructs an empty set and
  167. //! inserts elements from the ordered unique range [first ,last). This function
  168. //! is more efficient than the normal range creation for ordered ranges.
  169. //!
  170. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  171. //! unique values.
  172. //!
  173. //! <b>Complexity</b>: Linear in N.
  174. //!
  175. //! <b>Note</b>: Non-standard extension.
  176. template <class InputIterator>
  177. inline set( ordered_unique_range_t, InputIterator first, InputIterator last)
  178. : base_t(ordered_range, first, last)
  179. {}
  180. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  181. //! inserts elements from the ordered unique range [first ,last). This function
  182. //! is more efficient than the normal range creation for ordered ranges.
  183. //!
  184. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  185. //! unique values.
  186. //!
  187. //! <b>Complexity</b>: Linear in N.
  188. //!
  189. //! <b>Note</b>: Non-standard extension.
  190. template <class InputIterator>
  191. inline set( ordered_unique_range_t, InputIterator first, InputIterator last, const Compare& comp )
  192. : base_t(ordered_range, first, last, comp)
  193. {}
  194. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  195. //! allocator, and inserts elements from the ordered unique range [first ,last). This function
  196. //! is more efficient than the normal range creation for ordered ranges.
  197. //!
  198. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  199. //! unique values.
  200. //!
  201. //! <b>Complexity</b>: Linear in N.
  202. //!
  203. //! <b>Note</b>: Non-standard extension.
  204. template <class InputIterator>
  205. inline set( ordered_unique_range_t, InputIterator first, InputIterator last
  206. , const Compare& comp, const allocator_type& a)
  207. : base_t(ordered_range, first, last, comp, a)
  208. {}
  209. //! <b>Effects</b>: Constructs an empty set using the specified allocator and
  210. //! inserts elements from the ordered unique range [first ,last). This function
  211. //! is more efficient than the normal range creation for ordered ranges.
  212. //!
  213. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate and must be
  214. //! unique values.
  215. //!
  216. //! <b>Complexity</b>: Linear in N.
  217. //!
  218. //! <b>Note</b>: Non-standard extension.
  219. template <class InputIterator>
  220. inline set(ordered_unique_range_t, InputIterator first, InputIterator last, const allocator_type& a)
  221. : base_t(ordered_range, first, last, Compare(), a)
  222. {}
  223. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  224. //! <b>Effects</b>: Constructs an empty set and
  225. //! inserts elements from the range [il.begin(), il.end()).
  226. //!
  227. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  228. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  229. inline set(std::initializer_list<value_type> il)
  230. : base_t(true, il.begin(), il.end())
  231. {}
  232. //! <b>Effects</b>: Constructs an empty set using the specified
  233. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  234. //!
  235. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  236. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  237. inline set(std::initializer_list<value_type> il, const allocator_type& a)
  238. : base_t(true, il.begin(), il.end(), Compare(), a)
  239. {}
  240. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  241. //! inserts elements from the range [il.begin(), il.end()).
  242. //!
  243. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  244. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  245. inline set(std::initializer_list<value_type> il, const Compare& comp )
  246. : base_t(true, il.begin(), il.end(), comp)
  247. {}
  248. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  249. //! allocator, and inserts elements from the range [il.begin(), il.end()).
  250. //!
  251. //! <b>Complexity</b>: Linear in N if the range [il.begin(), il.end()) is already sorted using
  252. //! the predicate and otherwise N logN, where N is il.begin() - il.end().
  253. inline set(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  254. : base_t(true, il.begin(), il.end(), comp, a)
  255. {}
  256. //! <b>Effects</b>: Constructs an empty set and
  257. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  258. //! is more efficient than the normal range creation for ordered ranges.
  259. //!
  260. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  261. //! unique values.
  262. //!
  263. //! <b>Complexity</b>: Linear in N.
  264. //!
  265. //! <b>Note</b>: Non-standard extension.
  266. inline set( ordered_unique_range_t, std::initializer_list<value_type> il)
  267. : base_t(ordered_range, il.begin(), il.end())
  268. {}
  269. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  270. //! inserts elements from the ordered unique range [il.begin(), il.end()). This function
  271. //! is more efficient than the normal range creation for ordered ranges.
  272. //!
  273. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  274. //! unique values.
  275. //!
  276. //! <b>Complexity</b>: Linear in N.
  277. //!
  278. //! <b>Note</b>: Non-standard extension.
  279. inline set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp)
  280. : base_t(ordered_range, il.begin(), il.end(), comp)
  281. {}
  282. //! <b>Effects</b>: Constructs an empty set using the specified comparison object and
  283. //! allocator, and inserts elements from the ordered unique range [il.begin(), il.end()). This function
  284. //! is more efficient than the normal range creation for ordered ranges.
  285. //!
  286. //! <b>Requires</b>: [il.begin(), il.end()) must be ordered according to the predicate and must be
  287. //! unique values.
  288. //!
  289. //! <b>Complexity</b>: Linear in N.
  290. //!
  291. //! <b>Note</b>: Non-standard extension.
  292. inline set( ordered_unique_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  293. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  294. {}
  295. #endif
  296. //! <b>Effects</b>: Copy constructs a set.
  297. //!
  298. //! <b>Complexity</b>: Linear in x.size().
  299. inline set(const set& x)
  300. : base_t(static_cast<const base_t&>(x))
  301. {}
  302. //! <b>Effects</b>: Move constructs a set. Constructs *this using x's resources.
  303. //!
  304. //! <b>Complexity</b>: Constant.
  305. //!
  306. //! <b>Postcondition</b>: x is emptied.
  307. inline set(BOOST_RV_REF(set) x)
  308. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  309. : base_t(BOOST_MOVE_BASE(base_t, x))
  310. {}
  311. //! <b>Effects</b>: Copy constructs a set using the specified allocator.
  312. //!
  313. //! <b>Complexity</b>: Linear in x.size().
  314. inline set(const set& x, const allocator_type &a)
  315. : base_t(static_cast<const base_t&>(x), a)
  316. {}
  317. //! <b>Effects</b>: Move constructs a set using the specified allocator.
  318. //! Constructs *this using x's resources.
  319. //!
  320. //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
  321. inline set(BOOST_RV_REF(set) x, const allocator_type &a)
  322. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  323. {}
  324. //! <b>Effects</b>: Makes *this a copy of x.
  325. //!
  326. //! <b>Complexity</b>: Linear in x.size().
  327. inline set& operator=(BOOST_COPY_ASSIGN_REF(set) x)
  328. { return static_cast<set&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  329. //! <b>Effects</b>: this->swap(x.get()).
  330. //!
  331. //! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
  332. //! is false and (allocation throws or value_type's move constructor throws)
  333. //!
  334. //! <b>Complexity</b>: Constant if allocator_traits_type::
  335. //! propagate_on_container_move_assignment is true or
  336. //! this->get>allocator() == x.get_allocator(). Linear otherwise.
  337. inline set& operator=(BOOST_RV_REF(set) x)
  338. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  339. allocator_traits_type::is_always_equal::value) &&
  340. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  341. { return static_cast<set&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  342. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  343. //! <b>Effects</b>: Copy all elements from il to *this.
  344. //!
  345. //! <b>Complexity</b>: Linear in il.size().
  346. set& operator=(std::initializer_list<value_type> il)
  347. {
  348. this->clear();
  349. insert(il.begin(), il.end());
  350. return *this;
  351. }
  352. #endif
  353. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  354. //! <b>Effects</b>: Returns a copy of the allocator that
  355. //! was passed to the object's constructor.
  356. //!
  357. //! <b>Complexity</b>: Constant.
  358. allocator_type get_allocator() const;
  359. //! <b>Effects</b>: Returns a reference to the internal allocator.
  360. //!
  361. //! <b>Throws</b>: Nothing
  362. //!
  363. //! <b>Complexity</b>: Constant.
  364. //!
  365. //! <b>Note</b>: Non-standard extension.
  366. stored_allocator_type &get_stored_allocator();
  367. //! <b>Effects</b>: Returns a reference to the internal allocator.
  368. //!
  369. //! <b>Throws</b>: Nothing
  370. //!
  371. //! <b>Complexity</b>: Constant.
  372. //!
  373. //! <b>Note</b>: Non-standard extension.
  374. const stored_allocator_type &get_stored_allocator() const;
  375. //! <b>Effects</b>: Returns an iterator to the first element contained in the container.
  376. //!
  377. //! <b>Throws</b>: Nothing.
  378. //!
  379. //! <b>Complexity</b>: Constant
  380. iterator begin();
  381. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  382. //!
  383. //! <b>Throws</b>: Nothing.
  384. //!
  385. //! <b>Complexity</b>: Constant.
  386. const_iterator begin() const;
  387. //! <b>Effects</b>: Returns a const_iterator to the first element contained in the container.
  388. //!
  389. //! <b>Throws</b>: Nothing.
  390. //!
  391. //! <b>Complexity</b>: Constant.
  392. const_iterator cbegin() const;
  393. //! <b>Effects</b>: Returns an iterator to the end of the container.
  394. //!
  395. //! <b>Throws</b>: Nothing.
  396. //!
  397. //! <b>Complexity</b>: Constant.
  398. iterator end();
  399. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  400. //!
  401. //! <b>Throws</b>: Nothing.
  402. //!
  403. //! <b>Complexity</b>: Constant.
  404. const_iterator end() const;
  405. //! <b>Effects</b>: Returns a const_iterator to the end of the container.
  406. //!
  407. //! <b>Throws</b>: Nothing.
  408. //!
  409. //! <b>Complexity</b>: Constant.
  410. const_iterator cend() const;
  411. //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
  412. //! of the reversed container.
  413. //!
  414. //! <b>Throws</b>: Nothing.
  415. //!
  416. //! <b>Complexity</b>: Constant.
  417. reverse_iterator rbegin();
  418. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  419. //! of the reversed container.
  420. //!
  421. //! <b>Throws</b>: Nothing.
  422. //!
  423. //! <b>Complexity</b>: Constant.
  424. const_reverse_iterator rbegin() const;
  425. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
  426. //! of the reversed container.
  427. //!
  428. //! <b>Throws</b>: Nothing.
  429. //!
  430. //! <b>Complexity</b>: Constant.
  431. const_reverse_iterator crbegin() const;
  432. //! <b>Effects</b>: Returns a reverse_iterator pointing to the end
  433. //! of the reversed container.
  434. //!
  435. //! <b>Throws</b>: Nothing.
  436. //!
  437. //! <b>Complexity</b>: Constant.
  438. reverse_iterator rend();
  439. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  440. //! of the reversed container.
  441. //!
  442. //! <b>Throws</b>: Nothing.
  443. //!
  444. //! <b>Complexity</b>: Constant.
  445. const_reverse_iterator rend() const;
  446. //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
  447. //! of the reversed container.
  448. //!
  449. //! <b>Throws</b>: Nothing.
  450. //!
  451. //! <b>Complexity</b>: Constant.
  452. const_reverse_iterator crend() const;
  453. //! <b>Effects</b>: Returns true if the container contains no elements.
  454. //!
  455. //! <b>Throws</b>: Nothing.
  456. //!
  457. //! <b>Complexity</b>: Constant.
  458. bool empty() const;
  459. //! <b>Effects</b>: Returns the number of the elements contained in the container.
  460. //!
  461. //! <b>Throws</b>: Nothing.
  462. //!
  463. //! <b>Complexity</b>: Constant.
  464. size_type size() const;
  465. //! <b>Effects</b>: Returns the largest possible size of the container.
  466. //!
  467. //! <b>Throws</b>: Nothing.
  468. //!
  469. //! <b>Complexity</b>: Constant.
  470. size_type max_size() const;
  471. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  472. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  473. //! <b>Effects</b>: Inserts an object x of type Key constructed with
  474. //! std::forward<Args>(args)... if and only if there is
  475. //! no element in the container with equivalent value.
  476. //! and returns the iterator pointing to the
  477. //! newly inserted element.
  478. //!
  479. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  480. //! if the insertion takes place, and the iterator component of the pair
  481. //! points to the element with key equivalent to the key of x.
  482. //!
  483. //! <b>Throws</b>: If memory allocation throws or
  484. //! Key's in-place constructor throws.
  485. //!
  486. //! <b>Complexity</b>: Logarithmic.
  487. template <class... Args>
  488. inline std::pair<iterator,bool> emplace(BOOST_FWD_REF(Args)... args)
  489. { return this->base_t::emplace_unique(boost::forward<Args>(args)...); }
  490. //! <b>Effects</b>: Inserts an object of type Key constructed with
  491. //! std::forward<Args>(args)... if and only if there is
  492. //! no element in the container with equivalent value.
  493. //! p is a hint pointing to where the insert
  494. //! should start to search.
  495. //!
  496. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  497. //!
  498. //! <b>Complexity</b>: Logarithmic.
  499. template <class... Args>
  500. inline iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  501. { return this->base_t::emplace_hint_unique(p, boost::forward<Args>(args)...); }
  502. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  503. #define BOOST_CONTAINER_SET_EMPLACE_CODE(N) \
  504. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  505. inline std::pair<iterator,bool> emplace(BOOST_MOVE_UREF##N)\
  506. { return this->base_t::emplace_unique(BOOST_MOVE_FWD##N); }\
  507. \
  508. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  509. inline iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  510. { return this->base_t::emplace_hint_unique(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  511. //
  512. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_SET_EMPLACE_CODE)
  513. #undef BOOST_CONTAINER_SET_EMPLACE_CODE
  514. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  515. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  516. //! <b>Effects</b>: Inserts x if and only if there is no element in the container
  517. //! with key equivalent to the key of x.
  518. //!
  519. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  520. //! if the insertion takes place, and the iterator component of the pair
  521. //! points to the element with key equivalent to the key of x.
  522. //!
  523. //! <b>Complexity</b>: Logarithmic.
  524. std::pair<iterator, bool> insert(const value_type &x);
  525. //! <b>Effects</b>: Move constructs a new value from x if and only if there is
  526. //! no element in the container with key equivalent to the key of x.
  527. //!
  528. //! <b>Returns</b>: The bool component of the returned pair is true if and only
  529. //! if the insertion takes place, and the iterator component of the pair
  530. //! points to the element with key equivalent to the key of x.
  531. //!
  532. //! <b>Complexity</b>: Logarithmic.
  533. std::pair<iterator, bool> insert(value_type &&x);
  534. #else
  535. private:
  536. typedef std::pair<iterator, bool> insert_return_pair;
  537. public:
  538. BOOST_MOVE_CONVERSION_AWARE_CATCH
  539. (insert, value_type, insert_return_pair, this->base_t::insert_unique_convertible)
  540. #endif
  541. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  542. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  543. //! no element in the container with key equivalent to the key of x.
  544. //! p is a hint pointing to where the insert should start to search.
  545. //!
  546. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  547. //! to the key of x.
  548. //!
  549. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  550. //! is inserted right before p.
  551. iterator insert(const_iterator p, const value_type &x);
  552. //! <b>Effects</b>: Inserts an element move constructed from x in the container.
  553. //! p is a hint pointing to where the insert should start to search.
  554. //!
  555. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  556. //!
  557. //! <b>Complexity</b>: Logarithmic.
  558. iterator insert(const_iterator p, value_type &&x);
  559. #else
  560. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG
  561. (insert, value_type, iterator, this->base_t::insert_unique_hint_convertible, const_iterator, const_iterator)
  562. #endif
  563. //! <b>Requires</b>: first, last are not iterators into *this.
  564. //!
  565. //! <b>Effects</b>: inserts each element from the range [first,last) if and only
  566. //! if there is no element with key equivalent to the key of that element.
  567. //!
  568. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  569. template <class InputIterator>
  570. inline void insert(InputIterator first, InputIterator last)
  571. { this->base_t::insert_unique_range(first, last); }
  572. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  573. //! <b>Effects</b>: inserts each element from the range [il.begin(),il.end()) if and only
  574. //! if there is no element with key equivalent to the key of that element.
  575. //!
  576. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
  577. inline void insert(std::initializer_list<value_type> il)
  578. { this->base_t::insert_unique_range(il.begin(), il.end()); }
  579. #endif
  580. //! @copydoc ::boost::container::map::insert(node_type&&)
  581. inline insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  582. { return this->base_t::insert_unique_node(boost::move(nh)); }
  583. //! @copydoc ::boost::container::map::insert(const_iterator, node_type&&)
  584. inline insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  585. { return this->base_t::insert_unique_node(hint, boost::move(nh)); }
  586. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  587. template<class C2>
  588. inline void merge(set<Key, C2, Allocator, Options>& source)
  589. {
  590. typedef dtl::tree
  591. <Key, void, C2, Allocator, Options> base2_t;
  592. this->base_t::merge_unique(static_cast<base2_t&>(source));
  593. }
  594. //! @copydoc ::boost::container::set::merge(set<Key, C2, Allocator, Options>&)
  595. template<class C2>
  596. inline void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  597. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  598. //! @copydoc ::boost::container::map::merge(multimap<Key, T, C2, Allocator, Options>&)
  599. template<class C2>
  600. inline void merge(multiset<Key, C2, Allocator, Options>& source)
  601. {
  602. typedef dtl::tree
  603. <Key, void, C2, Allocator, Options> base2_t;
  604. this->base_t::merge_unique(static_cast<base2_t&>(source));
  605. }
  606. //! @copydoc ::boost::container::set::merge(multiset<Key, C2, Allocator, Options>&)
  607. template<class C2>
  608. inline void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  609. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  610. //! <b>Effects</b>: If present, erases the element in the container with key equivalent to x.
  611. //!
  612. //! <b>Returns</b>: Returns the number of erased elements (0/1).
  613. //!
  614. //! <b>Complexity</b>: log(size()) + count(k)
  615. inline size_type erase(const key_type& x)
  616. { return this->base_t::erase_unique(x); }
  617. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  618. //! <b>Effects</b>: Erases the element pointed to by p.
  619. //!
  620. //! <b>Returns</b>: Returns an iterator pointing to the element immediately
  621. //! following q prior to the element being erased. If no such element exists,
  622. //! returns end().
  623. //!
  624. //! <b>Complexity</b>: Amortized constant time
  625. iterator erase(const_iterator p);
  626. //! <b>Effects</b>: Erases all the elements in the range [first, last).
  627. //!
  628. //! <b>Returns</b>: Returns last.
  629. //!
  630. //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
  631. iterator erase(const_iterator first, const_iterator last);
  632. //! @copydoc ::boost::container::map::extract(const_iterator)
  633. node_type extract(const_iterator p);
  634. //! @copydoc ::boost::container::map::extract(const key_type&)
  635. node_type extract(const key_type& x);
  636. //! <b>Effects</b>: Swaps the contents of *this and x.
  637. //!
  638. //! <b>Throws</b>: Nothing.
  639. //!
  640. //! <b>Complexity</b>: Constant.
  641. void swap(set& x)
  642. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  643. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  644. //! <b>Effects</b>: erase(begin(),end()).
  645. //!
  646. //! <b>Postcondition</b>: size() == 0.
  647. //!
  648. //! <b>Complexity</b>: linear in size().
  649. void clear();
  650. //! <b>Effects</b>: Returns the comparison object out
  651. //! of which a was constructed.
  652. //!
  653. //! <b>Complexity</b>: Constant.
  654. key_compare key_comp() const;
  655. //! <b>Effects</b>: Returns an object of value_compare constructed out
  656. //! of the comparison object.
  657. //!
  658. //! <b>Complexity</b>: Constant.
  659. value_compare value_comp() const;
  660. //! <b>Returns</b>: An iterator pointing to an element with the key
  661. //! equivalent to x, or end() if such an element is not found.
  662. //!
  663. //! <b>Complexity</b>: Logarithmic.
  664. iterator find(const key_type& x);
  665. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  666. //! equivalent to x, or end() if such an element is not found.
  667. //!
  668. //! <b>Complexity</b>: Logarithmic.
  669. const_iterator find(const key_type& x) const;
  670. //! <b>Requires</b>: This overload is available only if
  671. //! key_compare::is_transparent exists.
  672. //!
  673. //! <b>Returns</b>: An iterator pointing to an element with the key
  674. //! equivalent to x, or end() if such an element is not found.
  675. //!
  676. //! <b>Complexity</b>: Logarithmic.
  677. template<typename K>
  678. iterator find(const K& x);
  679. //! <b>Requires</b>: This overload is available only if
  680. //! key_compare::is_transparent exists.
  681. //!
  682. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  683. //! equivalent to x, or end() if such an element is not found.
  684. //!
  685. //! <b>Complexity</b>: Logarithmic.
  686. template<typename K>
  687. const_iterator find(const K& x) const;
  688. #else
  689. using base_t::erase;
  690. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  691. //! <b>Returns</b>: The number of elements with key equivalent to x.
  692. //!
  693. //! <b>Complexity</b>: log(size())+count(k)
  694. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  695. size_type count(const key_type& x) const
  696. { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); }
  697. //! <b>Requires</b>: This overload is available only if
  698. //! key_compare::is_transparent exists.
  699. //!
  700. //! <b>Returns</b>: The number of elements with key equivalent to x.
  701. //!
  702. //! <b>Complexity</b>: log(size())+count(k)
  703. template<typename K>
  704. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  705. size_type count(const K& x) const
  706. { return static_cast<size_type>(this->find(x) != this->cend()); }
  707. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  708. //! <b>Returns</b>: Returns true if there is an element with key
  709. //! equivalent to key in the container, otherwise false.
  710. //!
  711. //! <b>Complexity</b>: log(size()).
  712. bool contains(const key_type& x) const;
  713. //! <b>Requires</b>: This overload is available only if
  714. //! key_compare::is_transparent exists.
  715. //!
  716. //! <b>Returns</b>: Returns true if there is an element with key
  717. //! equivalent to key in the container, otherwise false.
  718. //!
  719. //! <b>Complexity</b>: log(size()).
  720. template<typename K>
  721. bool contains(const K& x) const;
  722. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  723. //! than x, or end() if such an element is not found.
  724. //!
  725. //! <b>Complexity</b>: Logarithmic
  726. iterator lower_bound(const key_type& x);
  727. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  728. //! less than x, or end() if such an element is not found.
  729. //!
  730. //! <b>Complexity</b>: Logarithmic
  731. const_iterator lower_bound(const key_type& x) const;
  732. //! <b>Requires</b>: This overload is available only if
  733. //! key_compare::is_transparent exists.
  734. //!
  735. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  736. //! than x, or end() if such an element is not found.
  737. //!
  738. //! <b>Complexity</b>: Logarithmic
  739. template<typename K>
  740. iterator lower_bound(const K& x);
  741. //! <b>Requires</b>: This overload is available only if
  742. //! key_compare::is_transparent exists.
  743. //!
  744. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  745. //! less than x, or end() if such an element is not found.
  746. //!
  747. //! <b>Complexity</b>: Logarithmic
  748. template<typename K>
  749. const_iterator lower_bound(const K& x) const;
  750. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  751. //! than x, or end() if such an element is not found.
  752. //!
  753. //! <b>Complexity</b>: Logarithmic
  754. iterator upper_bound(const key_type& x);
  755. //! <b>Returns</b>: A const iterator pointing to the first element with key
  756. //! greater than x, or end() if such an element is not found.
  757. //!
  758. //! <b>Complexity</b>: Logarithmic
  759. const_iterator upper_bound(const key_type& x) const;
  760. //! <b>Requires</b>: This overload is available only if
  761. //! key_compare::is_transparent exists.
  762. //!
  763. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  764. //! than x, or end() if such an element is not found.
  765. //!
  766. //! <b>Complexity</b>: Logarithmic
  767. template<typename K>
  768. iterator upper_bound(const K& x);
  769. //! <b>Requires</b>: This overload is available only if
  770. //! key_compare::is_transparent exists.
  771. //!
  772. //! <b>Returns</b>: A const iterator pointing to the first element with key
  773. //! greater than x, or end() if such an element is not found.
  774. //!
  775. //! <b>Complexity</b>: Logarithmic
  776. template<typename K>
  777. const_iterator upper_bound(const K& x) const;
  778. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  779. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  780. //!
  781. //! <b>Complexity</b>: Logarithmic
  782. inline std::pair<iterator,iterator> equal_range(const key_type& x)
  783. { return this->base_t::lower_bound_range(x); }
  784. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  785. //!
  786. //! <b>Complexity</b>: Logarithmic
  787. inline std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
  788. { return this->base_t::lower_bound_range(x); }
  789. //! <b>Requires</b>: This overload is available only if
  790. //! key_compare::is_transparent exists.
  791. //!
  792. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  793. //!
  794. //! <b>Complexity</b>: Logarithmic
  795. template<typename K>
  796. inline std::pair<iterator,iterator> equal_range(const K& x)
  797. { return this->base_t::lower_bound_range(x); }
  798. //! <b>Requires</b>: This overload is available only if
  799. //! key_compare::is_transparent exists.
  800. //!
  801. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  802. //!
  803. //! <b>Complexity</b>: Logarithmic
  804. template<typename K>
  805. inline std::pair<const_iterator,const_iterator> equal_range(const K& x) const
  806. { return this->base_t::lower_bound_range(x); }
  807. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  808. //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
  809. //!
  810. //! <b>Complexity</b>: Linear
  811. void rebalance();
  812. //! <b>Effects</b>: Returns true if x and y are equal
  813. //!
  814. //! <b>Complexity</b>: Linear to the number of elements in the container.
  815. friend bool operator==(const set& x, const set& y);
  816. //! <b>Effects</b>: Returns true if x and y are unequal
  817. //!
  818. //! <b>Complexity</b>: Linear to the number of elements in the container.
  819. friend bool operator!=(const set& x, const set& y);
  820. //! <b>Effects</b>: Returns true if x is less than y
  821. //!
  822. //! <b>Complexity</b>: Linear to the number of elements in the container.
  823. friend bool operator<(const set& x, const set& y);
  824. //! <b>Effects</b>: Returns true if x is greater than y
  825. //!
  826. //! <b>Complexity</b>: Linear to the number of elements in the container.
  827. friend bool operator>(const set& x, const set& y);
  828. //! <b>Effects</b>: Returns true if x is equal or less than y
  829. //!
  830. //! <b>Complexity</b>: Linear to the number of elements in the container.
  831. friend bool operator<=(const set& x, const set& y);
  832. //! <b>Effects</b>: Returns true if x is equal or greater than y
  833. //!
  834. //! <b>Complexity</b>: Linear to the number of elements in the container.
  835. friend bool operator>=(const set& x, const set& y);
  836. //! <b>Effects</b>: x.swap(y)
  837. //!
  838. //! <b>Complexity</b>: Constant.
  839. friend void swap(set& x, set& y)
  840. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  841. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  842. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  843. };
  844. //! <b>Effects</b>: Erases all elements that satisfy the predicate pred from the container c.
  845. //!
  846. //! <b>Complexity</b>: Linear.
  847. template <class K, class C, class A, class O, class Pred>
  848. inline typename set<K, C, A, O>::size_type erase_if(set<K, C, A, O>& c, Pred pred)
  849. {
  850. return container_erase_if(c, pred);
  851. }
  852. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  853. template <typename InputIterator>
  854. set(InputIterator, InputIterator) ->
  855. set< it_based_value_type_t<InputIterator> >;
  856. template < typename InputIterator, typename AllocatorOrCompare>
  857. set(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  858. set< it_based_value_type_t<InputIterator>
  859. , typename dtl::if_c< // Compare
  860. dtl::is_allocator<AllocatorOrCompare>::value
  861. , std::less<it_based_value_type_t<InputIterator>>
  862. , AllocatorOrCompare
  863. >::type
  864. , typename dtl::if_c< // Allocator
  865. dtl::is_allocator<AllocatorOrCompare>::value
  866. , AllocatorOrCompare
  867. , new_allocator<it_based_value_type_t<InputIterator>>
  868. >::type
  869. >;
  870. template < typename InputIterator, typename Compare, typename Allocator
  871. , typename = dtl::require_nonallocator_t<Compare>
  872. , typename = dtl::require_allocator_t<Allocator>>
  873. set(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  874. set< it_based_value_type_t<InputIterator>
  875. , Compare
  876. , Allocator>;
  877. template <typename InputIterator>
  878. set(ordered_unique_range_t, InputIterator, InputIterator) ->
  879. set< it_based_value_type_t<InputIterator>>;
  880. template < typename InputIterator, typename AllocatorOrCompare>
  881. set(ordered_unique_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  882. set< it_based_value_type_t<InputIterator>
  883. , typename dtl::if_c< // Compare
  884. dtl::is_allocator<AllocatorOrCompare>::value
  885. , std::less<it_based_value_type_t<InputIterator>>
  886. , AllocatorOrCompare
  887. >::type
  888. , typename dtl::if_c< // Allocator
  889. dtl::is_allocator<AllocatorOrCompare>::value
  890. , AllocatorOrCompare
  891. , new_allocator<it_based_value_type_t<InputIterator>>
  892. >::type
  893. >;
  894. template < typename InputIterator, typename Compare, typename Allocator
  895. , typename = dtl::require_nonallocator_t<Compare>
  896. , typename = dtl::require_allocator_t<Allocator>>
  897. set(ordered_unique_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  898. set< it_based_value_type_t<InputIterator>
  899. , Compare
  900. , Allocator>;
  901. #endif
  902. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  903. } //namespace container {
  904. //!has_trivial_destructor_after_move<> == true_type
  905. //!specialization for optimizations
  906. template <class Key, class Compare, class Allocator, class Options>
  907. struct has_trivial_destructor_after_move<boost::container::set<Key, Compare, Allocator, Options> >
  908. {
  909. typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
  910. BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  911. };
  912. namespace container {
  913. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  914. #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
  915. //! A multiset is a kind of associative container that supports equivalent keys
  916. //! (possibly contains multiple copies of the same key value) and provides for
  917. //! fast retrieval of the keys themselves. Class multiset supports bidirectional iterators.
  918. //!
  919. //! A multiset satisfies all of the requirements of a container and of a reversible
  920. //! container, and of an associative container). multiset also provides most operations
  921. //! described for duplicate keys.
  922. //!
  923. //! \tparam Key is the type to be inserted in the set, which is also the key_type
  924. //! \tparam Compare is the comparison functor used to order keys
  925. //! \tparam Allocator is the allocator to be used to allocate memory for this container
  926. //! \tparam Options is an packed option type generated using using boost::container::tree_assoc_options.
  927. template <class Key, class Compare = std::less<Key>, class Allocator = new_allocator<Key>, class Options = tree_assoc_defaults >
  928. #else
  929. template <class Key, class Compare, class Allocator, class Options>
  930. #endif
  931. class multiset
  932. /// @cond
  933. : public dtl::tree
  934. <Key, void, Compare, Allocator, Options>
  935. /// @endcond
  936. {
  937. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  938. private:
  939. BOOST_COPYABLE_AND_MOVABLE(multiset)
  940. typedef dtl::tree
  941. <Key, void, Compare, Allocator, Options> base_t;
  942. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  943. public:
  944. //////////////////////////////////////////////
  945. //
  946. // types
  947. //
  948. //////////////////////////////////////////////
  949. typedef Key key_type;
  950. typedef Key value_type;
  951. typedef Compare key_compare;
  952. typedef key_compare value_compare;
  953. typedef typename base_t::allocator_type allocator_type;
  954. typedef ::boost::container::allocator_traits<allocator_type> allocator_traits_type;
  955. typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
  956. typedef typename ::boost::container::allocator_traits<allocator_type>::const_pointer const_pointer;
  957. typedef typename ::boost::container::allocator_traits<allocator_type>::reference reference;
  958. typedef typename ::boost::container::allocator_traits<allocator_type>::const_reference const_reference;
  959. typedef typename ::boost::container::allocator_traits<allocator_type>::size_type size_type;
  960. typedef typename ::boost::container::allocator_traits<allocator_type>::difference_type difference_type;
  961. typedef typename BOOST_CONTAINER_IMPDEF(base_t::stored_allocator_type) stored_allocator_type;
  962. typedef typename BOOST_CONTAINER_IMPDEF(base_t::iterator) iterator;
  963. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_iterator) const_iterator;
  964. typedef typename BOOST_CONTAINER_IMPDEF(base_t::reverse_iterator) reverse_iterator;
  965. typedef typename BOOST_CONTAINER_IMPDEF(base_t::const_reverse_iterator) const_reverse_iterator;
  966. typedef typename BOOST_CONTAINER_IMPDEF(base_t::node_type) node_type;
  967. //////////////////////////////////////////////
  968. //
  969. // construct/copy/destroy
  970. //
  971. //////////////////////////////////////////////
  972. //! @copydoc ::boost::container::set::set()
  973. inline multiset()
  974. BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<allocator_type>::value &&
  975. dtl::is_nothrow_default_constructible<Compare>::value)
  976. : base_t()
  977. {}
  978. //! @copydoc ::boost::container::set::set(const allocator_type&)
  979. inline explicit multiset(const allocator_type& a)
  980. : base_t(a)
  981. {}
  982. //! @copydoc ::boost::container::set::set(const Compare&)
  983. inline explicit multiset(const Compare& comp)
  984. : base_t(comp)
  985. {}
  986. //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&)
  987. inline multiset(const Compare& comp, const allocator_type& a)
  988. : base_t(comp, a)
  989. {}
  990. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator)
  991. template <class InputIterator>
  992. inline multiset(InputIterator first, InputIterator last)
  993. : base_t(false, first, last)
  994. {}
  995. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const allocator_type&)
  996. template <class InputIterator>
  997. inline multiset(InputIterator first, InputIterator last, const allocator_type& a)
  998. : base_t(false, first, last, key_compare(), a)
  999. {}
  1000. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&)
  1001. template <class InputIterator>
  1002. inline multiset(InputIterator first, InputIterator last, const Compare& comp)
  1003. : base_t(false, first, last, comp)
  1004. {}
  1005. //! @copydoc ::boost::container::set::set(InputIterator, InputIterator, const Compare&, const allocator_type&)
  1006. template <class InputIterator>
  1007. inline multiset(InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  1008. : base_t(false, first, last, comp, a)
  1009. {}
  1010. //! <b>Effects</b>: Constructs an empty multiset and
  1011. //! and inserts elements from the ordered range [first ,last ). This function
  1012. //! is more efficient than the normal range creation for ordered ranges.
  1013. //!
  1014. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1015. //!
  1016. //! <b>Complexity</b>: Linear in N.
  1017. //!
  1018. //! <b>Note</b>: Non-standard extension.
  1019. template <class InputIterator>
  1020. inline multiset( ordered_range_t, InputIterator first, InputIterator last )
  1021. : base_t(ordered_range, first, last)
  1022. {}
  1023. //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
  1024. //! inserts elements from the ordered range [first ,last ). This function
  1025. //! is more efficient than the normal range creation for ordered ranges.
  1026. //!
  1027. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1028. //!
  1029. //! <b>Complexity</b>: Linear in N.
  1030. //!
  1031. //! <b>Note</b>: Non-standard extension.
  1032. template <class InputIterator>
  1033. inline multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp)
  1034. : base_t(ordered_range, first, last, comp)
  1035. {}
  1036. //! <b>Effects</b>: Constructs an empty multiset using the specified comparison object and
  1037. //! allocator, and inserts elements from the ordered range [first ,last ). This function
  1038. //! is more efficient than the normal range creation for ordered ranges.
  1039. //!
  1040. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1041. //!
  1042. //! <b>Complexity</b>: Linear in N.
  1043. //!
  1044. //! <b>Note</b>: Non-standard extension.
  1045. template <class InputIterator>
  1046. inline multiset( ordered_range_t, InputIterator first, InputIterator last, const Compare& comp, const allocator_type& a)
  1047. : base_t(ordered_range, first, last, comp, a)
  1048. {}
  1049. //! <b>Effects</b>: Constructs an empty multiset using the specified allocator and
  1050. //! inserts elements from the ordered range [first ,last ). This function
  1051. //! is more efficient than the normal range creation for ordered ranges.
  1052. //!
  1053. //! <b>Requires</b>: [first ,last) must be ordered according to the predicate.
  1054. //!
  1055. //! <b>Complexity</b>: Linear in N.
  1056. //!
  1057. //! <b>Note</b>: Non-standard extension.
  1058. template <class InputIterator>
  1059. inline multiset(ordered_range_t, InputIterator first, InputIterator last, const allocator_type &a)
  1060. : base_t(ordered_range, first, last, Compare(), a)
  1061. {}
  1062. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1063. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>)
  1064. inline multiset(std::initializer_list<value_type> il)
  1065. : base_t(false, il.begin(), il.end())
  1066. {}
  1067. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const allocator_type&)
  1068. inline multiset(std::initializer_list<value_type> il, const allocator_type& a)
  1069. : base_t(false, il.begin(), il.end(), Compare(), a)
  1070. {}
  1071. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&)
  1072. inline multiset(std::initializer_list<value_type> il, const Compare& comp)
  1073. : base_t(false, il.begin(), il.end(), comp)
  1074. {}
  1075. //! @copydoc ::boost::container::set::set(std::initializer_list<value_type>, const Compare&, const allocator_type&)
  1076. inline multiset(std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1077. : base_t(false, il.begin(), il.end(), comp, a)
  1078. {}
  1079. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>)
  1080. inline multiset(ordered_range_t, std::initializer_list<value_type> il)
  1081. : base_t(ordered_range, il.begin(), il.end())
  1082. {}
  1083. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&)
  1084. inline multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp)
  1085. : base_t(ordered_range, il.begin(), il.end(), comp)
  1086. {}
  1087. //! @copydoc ::boost::container::set::set(ordered_unique_range_t, std::initializer_list<value_type>, const Compare&, const allocator_type&)
  1088. inline multiset(ordered_range_t, std::initializer_list<value_type> il, const Compare& comp, const allocator_type& a)
  1089. : base_t(ordered_range, il.begin(), il.end(), comp, a)
  1090. {}
  1091. #endif
  1092. //! @copydoc ::boost::container::set::set(const set &)
  1093. inline multiset(const multiset& x)
  1094. : base_t(static_cast<const base_t&>(x))
  1095. {}
  1096. //! @copydoc ::boost::container::set::set(set &&)
  1097. inline multiset(BOOST_RV_REF(multiset) x)
  1098. BOOST_NOEXCEPT_IF(boost::container::dtl::is_nothrow_move_constructible<Compare>::value)
  1099. : base_t(BOOST_MOVE_BASE(base_t, x))
  1100. {}
  1101. //! @copydoc ::boost::container::set::set(const set &, const allocator_type &)
  1102. inline multiset(const multiset& x, const allocator_type &a)
  1103. : base_t(static_cast<const base_t&>(x), a)
  1104. {}
  1105. //! @copydoc ::boost::container::set::set(set &&, const allocator_type &)
  1106. inline multiset(BOOST_RV_REF(multiset) x, const allocator_type &a)
  1107. : base_t(BOOST_MOVE_BASE(base_t, x), a)
  1108. {}
  1109. //! @copydoc ::boost::container::set::operator=(const set &)
  1110. inline multiset& operator=(BOOST_COPY_ASSIGN_REF(multiset) x)
  1111. { return static_cast<multiset&>(this->base_t::operator=(static_cast<const base_t&>(x))); }
  1112. //! @copydoc ::boost::container::set::operator=(set &&)
  1113. inline multiset& operator=(BOOST_RV_REF(multiset) x)
  1114. BOOST_NOEXCEPT_IF( (allocator_traits_type::propagate_on_container_move_assignment::value ||
  1115. allocator_traits_type::is_always_equal::value) &&
  1116. boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
  1117. { return static_cast<multiset&>(this->base_t::operator=(BOOST_MOVE_BASE(base_t, x))); }
  1118. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1119. //! @copydoc ::boost::container::set::operator=(std::initializer_list<value_type>)
  1120. multiset& operator=(std::initializer_list<value_type> il)
  1121. {
  1122. this->clear();
  1123. insert(il.begin(), il.end());
  1124. return *this;
  1125. }
  1126. #endif
  1127. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1128. //! @copydoc ::boost::container::set::get_allocator()
  1129. allocator_type get_allocator() const;
  1130. //! @copydoc ::boost::container::set::get_stored_allocator()
  1131. stored_allocator_type &get_stored_allocator();
  1132. //! @copydoc ::boost::container::set::get_stored_allocator() const
  1133. const stored_allocator_type &get_stored_allocator() const;
  1134. //! @copydoc ::boost::container::set::begin()
  1135. iterator begin();
  1136. //! @copydoc ::boost::container::set::begin() const
  1137. const_iterator begin() const;
  1138. //! @copydoc ::boost::container::set::cbegin() const
  1139. const_iterator cbegin() const;
  1140. //! @copydoc ::boost::container::set::end()
  1141. iterator end() BOOST_NOEXCEPT_OR_NOTHROW;
  1142. //! @copydoc ::boost::container::set::end() const
  1143. const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW;
  1144. //! @copydoc ::boost::container::set::cend() const
  1145. const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1146. //! @copydoc ::boost::container::set::rbegin()
  1147. reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW;
  1148. //! @copydoc ::boost::container::set::rbegin() const
  1149. const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1150. //! @copydoc ::boost::container::set::crbegin() const
  1151. const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW;
  1152. //! @copydoc ::boost::container::set::rend()
  1153. reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW;
  1154. //! @copydoc ::boost::container::set::rend() const
  1155. const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1156. //! @copydoc ::boost::container::set::crend() const
  1157. const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW;
  1158. //! @copydoc ::boost::container::set::empty() const
  1159. bool empty() const;
  1160. //! @copydoc ::boost::container::set::size() const
  1161. size_type size() const;
  1162. //! @copydoc ::boost::container::set::max_size() const
  1163. size_type max_size() const;
  1164. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1165. #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1166. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1167. //! std::forward<Args>(args)... and returns the iterator pointing to the
  1168. //! newly inserted element.
  1169. //!
  1170. //! <b>Complexity</b>: Logarithmic.
  1171. template <class... Args>
  1172. inline iterator emplace(BOOST_FWD_REF(Args)... args)
  1173. { return this->base_t::emplace_equal(boost::forward<Args>(args)...); }
  1174. //! <b>Effects</b>: Inserts an object of type Key constructed with
  1175. //! std::forward<Args>(args)...
  1176. //!
  1177. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1178. //! to the key of x.
  1179. //!
  1180. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1181. //! is inserted right before p.
  1182. template <class... Args>
  1183. inline iterator emplace_hint(const_iterator p, BOOST_FWD_REF(Args)... args)
  1184. { return this->base_t::emplace_hint_equal(p, boost::forward<Args>(args)...); }
  1185. #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1186. #define BOOST_CONTAINER_MULTISET_EMPLACE_CODE(N) \
  1187. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1188. inline iterator emplace(BOOST_MOVE_UREF##N)\
  1189. { return this->base_t::emplace_equal(BOOST_MOVE_FWD##N); }\
  1190. \
  1191. BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
  1192. inline iterator emplace_hint(const_iterator hint BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
  1193. { return this->base_t::emplace_hint_equal(hint BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
  1194. //
  1195. BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_MULTISET_EMPLACE_CODE)
  1196. #undef BOOST_CONTAINER_MULTISET_EMPLACE_CODE
  1197. #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  1198. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1199. //! <b>Effects</b>: Inserts x and returns the iterator pointing to the
  1200. //! newly inserted element.
  1201. //!
  1202. //! <b>Complexity</b>: Logarithmic.
  1203. iterator insert(const value_type &x);
  1204. //! <b>Effects</b>: Inserts a copy of x in the container.
  1205. //!
  1206. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1207. //! to the key of x.
  1208. //!
  1209. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1210. //! is inserted right before p.
  1211. iterator insert(value_type &&x);
  1212. #else
  1213. BOOST_MOVE_CONVERSION_AWARE_CATCH(insert, value_type, iterator, this->base_t::insert_equal_convertible)
  1214. #endif
  1215. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1216. //! <b>Effects</b>: Inserts a copy of x in the container.
  1217. //! p is a hint pointing to where the insert should start to search.
  1218. //!
  1219. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1220. //! to the key of x.
  1221. //!
  1222. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1223. //! is inserted right before p.
  1224. iterator insert(const_iterator p, const value_type &x);
  1225. //! <b>Effects</b>: Inserts a value move constructed from x in the container.
  1226. //! p is a hint pointing to where the insert should start to search.
  1227. //!
  1228. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  1229. //! to the key of x.
  1230. //!
  1231. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  1232. //! is inserted right before p.
  1233. iterator insert(const_iterator p, value_type &&x);
  1234. #else
  1235. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG
  1236. (insert, value_type, iterator, this->base_t::insert_equal_hint_convertible, const_iterator, const_iterator)
  1237. #endif
  1238. //! <b>Requires</b>: first, last are not iterators into *this.
  1239. //!
  1240. //! <b>Effects</b>: inserts each element from the range [first,last) .
  1241. //!
  1242. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  1243. template <class InputIterator>
  1244. inline void insert(InputIterator first, InputIterator last)
  1245. { this->base_t::insert_equal_range(first, last); }
  1246. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1247. //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>)
  1248. inline void insert(std::initializer_list<value_type> il)
  1249. { this->base_t::insert_equal_range(il.begin(), il.end()); }
  1250. #endif
  1251. //! @copydoc ::boost::container::multimap::insert(node_type&&)
  1252. inline iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1253. { return this->base_t::insert_equal_node(boost::move(nh)); }
  1254. //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&)
  1255. inline iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1256. { return this->base_t::insert_equal_node(hint, boost::move(nh)); }
  1257. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1258. template<class C2>
  1259. inline void merge(multiset<Key, C2, Allocator, Options>& source)
  1260. {
  1261. typedef dtl::tree
  1262. <Key, void, C2, Allocator, Options> base2_t;
  1263. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1264. }
  1265. //! @copydoc ::boost::container::multiset::merge(multiset<Key, C2, Allocator, Options>&)
  1266. template<class C2>
  1267. inline void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1268. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  1269. //! @copydoc ::boost::container::multimap::merge(map<Key, T, C2, Allocator, Options>&)
  1270. template<class C2>
  1271. inline void merge(set<Key, C2, Allocator, Options>& source)
  1272. {
  1273. typedef dtl::tree
  1274. <Key, void, C2, Allocator, Options> base2_t;
  1275. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1276. }
  1277. //! @copydoc ::boost::container::multiset::merge(set<Key, C2, Allocator, Options>&)
  1278. template<class C2>
  1279. inline void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1280. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  1281. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1282. //! @copydoc ::boost::container::set::erase(const_iterator)
  1283. iterator erase(const_iterator p);
  1284. //! @copydoc ::boost::container::set::erase(const key_type&)
  1285. size_type erase(const key_type& x);
  1286. //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
  1287. iterator erase(const_iterator first, const_iterator last);
  1288. //! @copydoc ::boost::container::multimap::extract(const_iterator)
  1289. node_type extract(const_iterator p);
  1290. //! @copydoc ::boost::container::multimap::extract(const key_type&)
  1291. node_type extract(const key_type& x);
  1292. //! @copydoc ::boost::container::set::swap
  1293. void swap(multiset& x)
  1294. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1295. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1296. //! @copydoc ::boost::container::set::clear
  1297. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1298. //! @copydoc ::boost::container::set::key_comp
  1299. key_compare key_comp() const;
  1300. //! @copydoc ::boost::container::set::value_comp
  1301. value_compare value_comp() const;
  1302. //! @copydoc ::boost::container::set::find(const key_type& )
  1303. iterator find(const key_type& x);
  1304. //! @copydoc ::boost::container::set::find(const key_type& ) const
  1305. const_iterator find(const key_type& x) const;
  1306. //! @copydoc ::boost::container::set::find(const K& )
  1307. template<typename K>
  1308. iterator find(const K& x);
  1309. //! @copydoc ::boost::container::set::find(const K& )
  1310. template<typename K>
  1311. const_iterator find(const K& x) const;
  1312. //! @copydoc ::boost::container::set::count(const key_type& ) const
  1313. size_type count(const key_type& x) const;
  1314. //! @copydoc ::boost::container::set::count(const K& ) const
  1315. template<typename K>
  1316. size_type count(const K& x) const;
  1317. //! @copydoc ::boost::container::set::contains(const key_type& ) const
  1318. bool contains(const key_type& x) const;
  1319. //! @copydoc ::boost::container::set::contains(const K& ) const
  1320. template<typename K>
  1321. bool contains(const K& x) const;
  1322. //! @copydoc ::boost::container::set::lower_bound(const key_type& )
  1323. iterator lower_bound(const key_type& x);
  1324. //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const
  1325. const_iterator lower_bound(const key_type& x) const;
  1326. //! @copydoc ::boost::container::set::lower_bound(const K& )
  1327. template<typename K>
  1328. iterator lower_bound(const K& x);
  1329. //! @copydoc ::boost::container::set::lower_bound(const K& ) const
  1330. template<typename K>
  1331. const_iterator lower_bound(const K& x) const;
  1332. //! @copydoc ::boost::container::set::upper_bound(const key_type& )
  1333. iterator upper_bound(const key_type& x);
  1334. //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const
  1335. const_iterator upper_bound(const key_type& x) const;
  1336. //! @copydoc ::boost::container::set::upper_bound(const K& )
  1337. template<typename K>
  1338. iterator upper_bound(const K& x);
  1339. //! @copydoc ::boost::container::set::upper_bound(const K& ) const
  1340. template<typename K>
  1341. const_iterator upper_bound(const K& x) const;
  1342. //! @copydoc ::boost::container::set::equal_range(const key_type& ) const
  1343. std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
  1344. //! @copydoc ::boost::container::set::equal_range(const key_type& )
  1345. std::pair<iterator,iterator> equal_range(const key_type& x);
  1346. //! @copydoc ::boost::container::set::equal_range(const K& ) const
  1347. template<typename K>
  1348. std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
  1349. //! @copydoc ::boost::container::set::equal_range(const K& )
  1350. template<typename K>
  1351. std::pair<iterator,iterator> equal_range(const K& x);
  1352. //! @copydoc ::boost::container::set::rebalance()
  1353. void rebalance();
  1354. //! <b>Effects</b>: Returns true if x and y are equal
  1355. //!
  1356. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1357. friend bool operator==(const multiset& x, const multiset& y);
  1358. //! <b>Effects</b>: Returns true if x and y are unequal
  1359. //!
  1360. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1361. friend bool operator!=(const multiset& x, const multiset& y);
  1362. //! <b>Effects</b>: Returns true if x is less than y
  1363. //!
  1364. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1365. friend bool operator<(const multiset& x, const multiset& y);
  1366. //! <b>Effects</b>: Returns true if x is greater than y
  1367. //!
  1368. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1369. friend bool operator>(const multiset& x, const multiset& y);
  1370. //! <b>Effects</b>: Returns true if x is equal or less than y
  1371. //!
  1372. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1373. friend bool operator<=(const multiset& x, const multiset& y);
  1374. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1375. //!
  1376. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1377. friend bool operator>=(const multiset& x, const multiset& y);
  1378. //! <b>Effects</b>: x.swap(y)
  1379. //!
  1380. //! <b>Complexity</b>: Constant.
  1381. friend void swap(multiset& x, multiset& y)
  1382. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1383. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1384. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1385. };
  1386. //! <b>Effects</b>: Erases all elements that satisfy the predicate pred from the container c.
  1387. //!
  1388. //! <b>Complexity</b>: Linear.
  1389. template <class K, class C, class A, class O, class Pred>
  1390. inline typename multiset<K, C, A, O>::size_type erase_if(multiset<K, C, A, O>& c, Pred pred)
  1391. {
  1392. return container_erase_if(c, pred);
  1393. }
  1394. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1395. template <typename InputIterator>
  1396. multiset(InputIterator, InputIterator) ->
  1397. multiset< it_based_value_type_t<InputIterator> >;
  1398. template < typename InputIterator, typename AllocatorOrCompare>
  1399. multiset(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1400. multiset < it_based_value_type_t<InputIterator>
  1401. , typename dtl::if_c< // Compare
  1402. dtl::is_allocator<AllocatorOrCompare>::value
  1403. , std::less<it_based_value_type_t<InputIterator>>
  1404. , AllocatorOrCompare
  1405. >::type
  1406. , typename dtl::if_c< // Allocator
  1407. dtl::is_allocator<AllocatorOrCompare>::value
  1408. , AllocatorOrCompare
  1409. , new_allocator<it_based_value_type_t<InputIterator>>
  1410. >::type
  1411. >;
  1412. template < typename InputIterator, typename Compare, typename Allocator
  1413. , typename = dtl::require_nonallocator_t<Compare>
  1414. , typename = dtl::require_allocator_t<Allocator>>
  1415. multiset(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1416. multiset< it_based_value_type_t<InputIterator>
  1417. , Compare
  1418. , Allocator>;
  1419. template <typename InputIterator>
  1420. multiset(ordered_range_t, InputIterator, InputIterator) ->
  1421. multiset< it_based_value_type_t<InputIterator>>;
  1422. template < typename InputIterator, typename AllocatorOrCompare>
  1423. multiset(ordered_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1424. multiset < it_based_value_type_t<InputIterator>
  1425. , typename dtl::if_c< // Compare
  1426. dtl::is_allocator<AllocatorOrCompare>::value
  1427. , std::less<it_based_value_type_t<InputIterator>>
  1428. , AllocatorOrCompare
  1429. >::type
  1430. , typename dtl::if_c< // Allocator
  1431. dtl::is_allocator<AllocatorOrCompare>::value
  1432. , AllocatorOrCompare
  1433. , new_allocator<it_based_value_type_t<InputIterator>>
  1434. >::type
  1435. >;
  1436. template < typename InputIterator, typename Compare, typename Allocator
  1437. , typename = dtl::require_nonallocator_t<Compare>
  1438. , typename = dtl::require_allocator_t<Allocator>>
  1439. multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1440. multiset< it_based_value_type_t<InputIterator>
  1441. , Compare
  1442. , Allocator>;
  1443. #endif
  1444. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1445. } //namespace container {
  1446. //!has_trivial_destructor_after_move<> == true_type
  1447. //!specialization for optimizations
  1448. template <class Key, class Compare, class Allocator, class Options>
  1449. struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> >
  1450. {
  1451. typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
  1452. BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  1453. };
  1454. namespace container {
  1455. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1456. }}
  1457. #include <boost/container/detail/config_end.hpp>
  1458. #endif // BOOST_CONTAINER_SET_HPP