set.hpp 70 KB

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