set.hpp 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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
  538. (insert, value_type, insert_return_pair, this->base_t::insert_unique_convertible)
  539. #endif
  540. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  541. //! <b>Effects</b>: Inserts a copy of x in the container if and only if there is
  542. //! no element in the container with key equivalent to the key of x.
  543. //! p is a hint pointing to where the insert should start to search.
  544. //!
  545. //! <b>Returns</b>: An iterator pointing to the element with key equivalent
  546. //! to the key of x.
  547. //!
  548. //! <b>Complexity</b>: Logarithmic in general, but amortized constant if t
  549. //! is inserted right before p.
  550. iterator insert(const_iterator p, const value_type &x);
  551. //! <b>Effects</b>: Inserts an element move constructed from x in the container.
  552. //! p is a hint pointing to where the insert should start to search.
  553. //!
  554. //! <b>Returns</b>: An iterator pointing to the element with key equivalent to the key of x.
  555. //!
  556. //! <b>Complexity</b>: Logarithmic.
  557. iterator insert(const_iterator p, value_type &&x);
  558. #else
  559. BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG
  560. (insert, value_type, iterator, this->base_t::insert_unique_hint_convertible, const_iterator, const_iterator)
  561. #endif
  562. //! <b>Requires</b>: first, last are not iterators into *this.
  563. //!
  564. //! <b>Effects</b>: inserts each element from the range [first,last) if and only
  565. //! if there is no element with key equivalent to the key of that element.
  566. //!
  567. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  568. template <class InputIterator>
  569. inline void insert(InputIterator first, InputIterator last)
  570. { this->base_t::insert_unique_range(first, last); }
  571. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  572. //! <b>Effects</b>: inserts each element from the range [il.begin(),il.end()) if and only
  573. //! if there is no element with key equivalent to the key of that element.
  574. //!
  575. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from il.begin() to il.end())
  576. inline void insert(std::initializer_list<value_type> il)
  577. { this->base_t::insert_unique_range(il.begin(), il.end()); }
  578. #endif
  579. //! @copydoc ::boost::container::map::insert(node_type&&)
  580. inline insert_return_type insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  581. { return this->base_t::insert_unique_node(boost::move(nh)); }
  582. //! @copydoc ::boost::container::map::insert(const_iterator, node_type&&)
  583. inline insert_return_type insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  584. { return this->base_t::insert_unique_node(hint, boost::move(nh)); }
  585. //! @copydoc ::boost::container::map::merge(map<Key, T, C2, Allocator, Options>&)
  586. template<class C2>
  587. inline void merge(set<Key, C2, Allocator, Options>& source)
  588. {
  589. typedef dtl::tree
  590. <Key, void, C2, Allocator, Options> base2_t;
  591. this->base_t::merge_unique(static_cast<base2_t&>(source));
  592. }
  593. //! @copydoc ::boost::container::set::merge(set<Key, C2, Allocator, Options>&)
  594. template<class C2>
  595. inline void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  596. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  597. //! @copydoc ::boost::container::map::merge(multimap<Key, T, C2, Allocator, Options>&)
  598. template<class C2>
  599. inline void merge(multiset<Key, C2, Allocator, Options>& source)
  600. {
  601. typedef dtl::tree
  602. <Key, void, C2, Allocator, Options> base2_t;
  603. this->base_t::merge_unique(static_cast<base2_t&>(source));
  604. }
  605. //! @copydoc ::boost::container::set::merge(multiset<Key, C2, Allocator, Options>&)
  606. template<class C2>
  607. inline void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  608. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  609. //! <b>Effects</b>: If present, erases the element in the container with key equivalent to x.
  610. //!
  611. //! <b>Returns</b>: Returns the number of erased elements (0/1).
  612. //!
  613. //! <b>Complexity</b>: log(size()) + count(k)
  614. inline size_type erase(const key_type& x)
  615. { return this->base_t::erase_unique(x); }
  616. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  617. //! <b>Effects</b>: Erases the element pointed to by p.
  618. //!
  619. //! <b>Returns</b>: Returns an iterator pointing to the element immediately
  620. //! following q prior to the element being erased. If no such element exists,
  621. //! returns end().
  622. //!
  623. //! <b>Complexity</b>: Amortized constant time
  624. iterator erase(const_iterator p);
  625. //! <b>Effects</b>: Erases all the elements in the range [first, last).
  626. //!
  627. //! <b>Returns</b>: Returns last.
  628. //!
  629. //! <b>Complexity</b>: log(size())+N where N is the distance from first to last.
  630. iterator erase(const_iterator first, const_iterator last);
  631. //! @copydoc ::boost::container::map::extract(const_iterator)
  632. node_type extract(const_iterator p);
  633. //! @copydoc ::boost::container::map::extract(const key_type&)
  634. node_type extract(const key_type& x);
  635. //! <b>Effects</b>: Swaps the contents of *this and x.
  636. //!
  637. //! <b>Throws</b>: Nothing.
  638. //!
  639. //! <b>Complexity</b>: Constant.
  640. void swap(set& x)
  641. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  642. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  643. //! <b>Effects</b>: erase(begin(),end()).
  644. //!
  645. //! <b>Postcondition</b>: size() == 0.
  646. //!
  647. //! <b>Complexity</b>: linear in size().
  648. void clear();
  649. //! <b>Effects</b>: Returns the comparison object out
  650. //! of which a was constructed.
  651. //!
  652. //! <b>Complexity</b>: Constant.
  653. key_compare key_comp() const;
  654. //! <b>Effects</b>: Returns an object of value_compare constructed out
  655. //! of the comparison object.
  656. //!
  657. //! <b>Complexity</b>: Constant.
  658. value_compare value_comp() const;
  659. //! <b>Returns</b>: An iterator pointing to an element with the key
  660. //! equivalent to x, or end() if such an element is not found.
  661. //!
  662. //! <b>Complexity</b>: Logarithmic.
  663. iterator find(const key_type& x);
  664. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  665. //! equivalent to x, or end() if such an element is not found.
  666. //!
  667. //! <b>Complexity</b>: Logarithmic.
  668. const_iterator find(const key_type& x) const;
  669. //! <b>Requires</b>: This overload is available only if
  670. //! key_compare::is_transparent exists.
  671. //!
  672. //! <b>Returns</b>: An iterator pointing to an element with the key
  673. //! equivalent to x, or end() if such an element is not found.
  674. //!
  675. //! <b>Complexity</b>: Logarithmic.
  676. template<typename K>
  677. iterator find(const K& x);
  678. //! <b>Requires</b>: This overload is available only if
  679. //! key_compare::is_transparent exists.
  680. //!
  681. //! <b>Returns</b>: A const_iterator pointing to an element with the key
  682. //! equivalent to x, or end() if such an element is not found.
  683. //!
  684. //! <b>Complexity</b>: Logarithmic.
  685. template<typename K>
  686. const_iterator find(const K& x) const;
  687. #else
  688. using base_t::erase;
  689. #endif // #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  690. //! <b>Returns</b>: The number of elements with key equivalent to x.
  691. //!
  692. //! <b>Complexity</b>: log(size())+count(k)
  693. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  694. size_type count(const key_type& x) const
  695. { return static_cast<size_type>(this->base_t::find(x) != this->base_t::cend()); }
  696. //! <b>Requires</b>: This overload is available only if
  697. //! key_compare::is_transparent exists.
  698. //!
  699. //! <b>Returns</b>: The number of elements with key equivalent to x.
  700. //!
  701. //! <b>Complexity</b>: log(size())+count(k)
  702. template<typename K>
  703. BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
  704. size_type count(const K& x) const
  705. { return static_cast<size_type>(this->find(x) != this->cend()); }
  706. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  707. //! <b>Returns</b>: Returns true if there is an element with key
  708. //! equivalent to key in the container, otherwise false.
  709. //!
  710. //! <b>Complexity</b>: log(size()).
  711. bool contains(const key_type& x) const;
  712. //! <b>Requires</b>: This overload is available only if
  713. //! key_compare::is_transparent exists.
  714. //!
  715. //! <b>Returns</b>: Returns true if there is an element with key
  716. //! equivalent to key in the container, otherwise false.
  717. //!
  718. //! <b>Complexity</b>: log(size()).
  719. template<typename K>
  720. bool contains(const K& x) const;
  721. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  722. //! than x, or end() if such an element is not found.
  723. //!
  724. //! <b>Complexity</b>: Logarithmic
  725. iterator lower_bound(const key_type& x);
  726. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  727. //! less than x, or end() if such an element is not found.
  728. //!
  729. //! <b>Complexity</b>: Logarithmic
  730. const_iterator lower_bound(const key_type& x) const;
  731. //! <b>Requires</b>: This overload is available only if
  732. //! key_compare::is_transparent exists.
  733. //!
  734. //! <b>Returns</b>: An iterator pointing to the first element with key not less
  735. //! than x, or end() if such an element is not found.
  736. //!
  737. //! <b>Complexity</b>: Logarithmic
  738. template<typename K>
  739. iterator lower_bound(const K& x);
  740. //! <b>Requires</b>: This overload is available only if
  741. //! key_compare::is_transparent exists.
  742. //!
  743. //! <b>Returns</b>: A const iterator pointing to the first element with key not
  744. //! less than x, or end() if such an element is not found.
  745. //!
  746. //! <b>Complexity</b>: Logarithmic
  747. template<typename K>
  748. const_iterator lower_bound(const K& x) const;
  749. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  750. //! than x, or end() if such an element is not found.
  751. //!
  752. //! <b>Complexity</b>: Logarithmic
  753. iterator upper_bound(const key_type& x);
  754. //! <b>Returns</b>: A const iterator pointing to the first element with key
  755. //! greater than x, or end() if such an element is not found.
  756. //!
  757. //! <b>Complexity</b>: Logarithmic
  758. const_iterator upper_bound(const key_type& x) const;
  759. //! <b>Requires</b>: This overload is available only if
  760. //! key_compare::is_transparent exists.
  761. //!
  762. //! <b>Returns</b>: An iterator pointing to the first element with key greater
  763. //! than x, or end() if such an element is not found.
  764. //!
  765. //! <b>Complexity</b>: Logarithmic
  766. template<typename K>
  767. iterator upper_bound(const K& x);
  768. //! <b>Requires</b>: This overload is available only if
  769. //! key_compare::is_transparent exists.
  770. //!
  771. //! <b>Returns</b>: A const iterator pointing to the first element with key
  772. //! greater than x, or end() if such an element is not found.
  773. //!
  774. //! <b>Complexity</b>: Logarithmic
  775. template<typename K>
  776. const_iterator upper_bound(const K& x) const;
  777. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  778. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  779. //!
  780. //! <b>Complexity</b>: Logarithmic
  781. inline std::pair<iterator,iterator> equal_range(const key_type& x)
  782. { return this->base_t::lower_bound_range(x); }
  783. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  784. //!
  785. //! <b>Complexity</b>: Logarithmic
  786. inline std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const
  787. { return this->base_t::lower_bound_range(x); }
  788. //! <b>Requires</b>: This overload is available only if
  789. //! key_compare::is_transparent exists.
  790. //!
  791. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  792. //!
  793. //! <b>Complexity</b>: Logarithmic
  794. template<typename K>
  795. inline std::pair<iterator,iterator> equal_range(const K& x)
  796. { return this->base_t::lower_bound_range(x); }
  797. //! <b>Requires</b>: This overload is available only if
  798. //! key_compare::is_transparent exists.
  799. //!
  800. //! <b>Effects</b>: Equivalent to std::make_pair(this->lower_bound(k), this->upper_bound(k)).
  801. //!
  802. //! <b>Complexity</b>: Logarithmic
  803. template<typename K>
  804. inline std::pair<const_iterator,const_iterator> equal_range(const K& x) const
  805. { return this->base_t::lower_bound_range(x); }
  806. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  807. //! <b>Effects</b>: Rebalances the tree. It's a no-op for Red-Black and AVL trees.
  808. //!
  809. //! <b>Complexity</b>: Linear
  810. void rebalance();
  811. //! <b>Effects</b>: Returns true if x and y are equal
  812. //!
  813. //! <b>Complexity</b>: Linear to the number of elements in the container.
  814. friend bool operator==(const set& x, const set& y);
  815. //! <b>Effects</b>: Returns true if x and y are unequal
  816. //!
  817. //! <b>Complexity</b>: Linear to the number of elements in the container.
  818. friend bool operator!=(const set& x, const set& y);
  819. //! <b>Effects</b>: Returns true if x is less than y
  820. //!
  821. //! <b>Complexity</b>: Linear to the number of elements in the container.
  822. friend bool operator<(const set& x, const set& y);
  823. //! <b>Effects</b>: Returns true if x is greater than y
  824. //!
  825. //! <b>Complexity</b>: Linear to the number of elements in the container.
  826. friend bool operator>(const set& x, const set& y);
  827. //! <b>Effects</b>: Returns true if x is equal or less than y
  828. //!
  829. //! <b>Complexity</b>: Linear to the number of elements in the container.
  830. friend bool operator<=(const set& x, const set& y);
  831. //! <b>Effects</b>: Returns true if x is equal or greater than y
  832. //!
  833. //! <b>Complexity</b>: Linear to the number of elements in the container.
  834. friend bool operator>=(const set& x, const set& y);
  835. //! <b>Effects</b>: x.swap(y)
  836. //!
  837. //! <b>Complexity</b>: Constant.
  838. friend void swap(set& x, set& y)
  839. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  840. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  841. #endif //#if defined(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. inline 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. inline explicit multiset(const allocator_type& a)
  971. : base_t(a)
  972. {}
  973. //! @copydoc ::boost::container::set::set(const Compare&)
  974. inline explicit multiset(const Compare& comp)
  975. : base_t(comp)
  976. {}
  977. //! @copydoc ::boost::container::set::set(const Compare&, const allocator_type&)
  978. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline multiset(const multiset& x)
  1085. : base_t(static_cast<const base_t&>(x))
  1086. {}
  1087. //! @copydoc ::boost::container::set::set(set &&)
  1088. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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. inline 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->base_t::insert_equal_convertible)
  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
  1227. (insert, value_type, iterator, this->base_t::insert_equal_hint_convertible, const_iterator, const_iterator)
  1228. #endif
  1229. //! <b>Requires</b>: first, last are not iterators into *this.
  1230. //!
  1231. //! <b>Effects</b>: inserts each element from the range [first,last) .
  1232. //!
  1233. //! <b>Complexity</b>: At most N log(size()+N) (N is the distance from first to last)
  1234. template <class InputIterator>
  1235. inline void insert(InputIterator first, InputIterator last)
  1236. { this->base_t::insert_equal_range(first, last); }
  1237. #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
  1238. //! @copydoc ::boost::container::set::insert(std::initializer_list<value_type>)
  1239. inline void insert(std::initializer_list<value_type> il)
  1240. { this->base_t::insert_equal_range(il.begin(), il.end()); }
  1241. #endif
  1242. //! @copydoc ::boost::container::multimap::insert(node_type&&)
  1243. inline iterator insert(BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1244. { return this->base_t::insert_equal_node(boost::move(nh)); }
  1245. //! @copydoc ::boost::container::multimap::insert(const_iterator, node_type&&)
  1246. inline iterator insert(const_iterator hint, BOOST_RV_REF_BEG_IF_CXX11 node_type BOOST_RV_REF_END_IF_CXX11 nh)
  1247. { return this->base_t::insert_equal_node(hint, boost::move(nh)); }
  1248. //! @copydoc ::boost::container::multimap::merge(multimap<Key, T, C2, Allocator, Options>&)
  1249. template<class C2>
  1250. inline void merge(multiset<Key, C2, Allocator, Options>& source)
  1251. {
  1252. typedef dtl::tree
  1253. <Key, void, C2, Allocator, Options> base2_t;
  1254. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1255. }
  1256. //! @copydoc ::boost::container::multiset::merge(multiset<Key, C2, Allocator, Options>&)
  1257. template<class C2>
  1258. inline void merge(BOOST_RV_REF_BEG multiset<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1259. { return this->merge(static_cast<multiset<Key, C2, Allocator, Options>&>(source)); }
  1260. //! @copydoc ::boost::container::multimap::merge(map<Key, T, C2, Allocator, Options>&)
  1261. template<class C2>
  1262. inline void merge(set<Key, C2, Allocator, Options>& source)
  1263. {
  1264. typedef dtl::tree
  1265. <Key, void, C2, Allocator, Options> base2_t;
  1266. this->base_t::merge_equal(static_cast<base2_t&>(source));
  1267. }
  1268. //! @copydoc ::boost::container::multiset::merge(set<Key, C2, Allocator, Options>&)
  1269. template<class C2>
  1270. inline void merge(BOOST_RV_REF_BEG set<Key, C2, Allocator, Options> BOOST_RV_REF_END source)
  1271. { return this->merge(static_cast<set<Key, C2, Allocator, Options>&>(source)); }
  1272. #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1273. //! @copydoc ::boost::container::set::erase(const_iterator)
  1274. iterator erase(const_iterator p);
  1275. //! @copydoc ::boost::container::set::erase(const key_type&)
  1276. size_type erase(const key_type& x);
  1277. //! @copydoc ::boost::container::set::erase(const_iterator,const_iterator)
  1278. iterator erase(const_iterator first, const_iterator last);
  1279. //! @copydoc ::boost::container::multimap::extract(const_iterator)
  1280. node_type extract(const_iterator p);
  1281. //! @copydoc ::boost::container::multimap::extract(const key_type&)
  1282. node_type extract(const key_type& x);
  1283. //! @copydoc ::boost::container::set::swap
  1284. void swap(multiset& x)
  1285. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1286. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1287. //! @copydoc ::boost::container::set::clear
  1288. void clear() BOOST_NOEXCEPT_OR_NOTHROW;
  1289. //! @copydoc ::boost::container::set::key_comp
  1290. key_compare key_comp() const;
  1291. //! @copydoc ::boost::container::set::value_comp
  1292. value_compare value_comp() const;
  1293. //! @copydoc ::boost::container::set::find(const key_type& )
  1294. iterator find(const key_type& x);
  1295. //! @copydoc ::boost::container::set::find(const key_type& ) const
  1296. const_iterator find(const key_type& x) const;
  1297. //! @copydoc ::boost::container::set::find(const K& )
  1298. template<typename K>
  1299. iterator find(const K& x);
  1300. //! @copydoc ::boost::container::set::find(const K& )
  1301. template<typename K>
  1302. const_iterator find(const K& x) const;
  1303. //! @copydoc ::boost::container::set::count(const key_type& ) const
  1304. size_type count(const key_type& x) const;
  1305. //! @copydoc ::boost::container::set::count(const K& ) const
  1306. template<typename K>
  1307. size_type count(const K& x) const;
  1308. //! @copydoc ::boost::container::set::contains(const key_type& ) const
  1309. bool contains(const key_type& x) const;
  1310. //! @copydoc ::boost::container::set::contains(const K& ) const
  1311. template<typename K>
  1312. bool contains(const K& x) const;
  1313. //! @copydoc ::boost::container::set::lower_bound(const key_type& )
  1314. iterator lower_bound(const key_type& x);
  1315. //! @copydoc ::boost::container::set::lower_bound(const key_type& ) const
  1316. const_iterator lower_bound(const key_type& x) const;
  1317. //! @copydoc ::boost::container::set::lower_bound(const K& )
  1318. template<typename K>
  1319. iterator lower_bound(const K& x);
  1320. //! @copydoc ::boost::container::set::lower_bound(const K& ) const
  1321. template<typename K>
  1322. const_iterator lower_bound(const K& x) const;
  1323. //! @copydoc ::boost::container::set::upper_bound(const key_type& )
  1324. iterator upper_bound(const key_type& x);
  1325. //! @copydoc ::boost::container::set::upper_bound(const key_type& ) const
  1326. const_iterator upper_bound(const key_type& x) const;
  1327. //! @copydoc ::boost::container::set::upper_bound(const K& )
  1328. template<typename K>
  1329. iterator upper_bound(const K& x);
  1330. //! @copydoc ::boost::container::set::upper_bound(const K& ) const
  1331. template<typename K>
  1332. const_iterator upper_bound(const K& x) const;
  1333. //! @copydoc ::boost::container::set::equal_range(const key_type& ) const
  1334. std::pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
  1335. //! @copydoc ::boost::container::set::equal_range(const key_type& )
  1336. std::pair<iterator,iterator> equal_range(const key_type& x);
  1337. //! @copydoc ::boost::container::set::equal_range(const K& ) const
  1338. template<typename K>
  1339. std::pair<const_iterator, const_iterator> equal_range(const K& x) const;
  1340. //! @copydoc ::boost::container::set::equal_range(const K& )
  1341. template<typename K>
  1342. std::pair<iterator,iterator> equal_range(const K& x);
  1343. //! @copydoc ::boost::container::set::rebalance()
  1344. void rebalance();
  1345. //! <b>Effects</b>: Returns true if x and y are equal
  1346. //!
  1347. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1348. friend bool operator==(const multiset& x, const multiset& y);
  1349. //! <b>Effects</b>: Returns true if x and y are unequal
  1350. //!
  1351. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1352. friend bool operator!=(const multiset& x, const multiset& y);
  1353. //! <b>Effects</b>: Returns true if x is less than y
  1354. //!
  1355. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1356. friend bool operator<(const multiset& x, const multiset& y);
  1357. //! <b>Effects</b>: Returns true if x is greater than y
  1358. //!
  1359. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1360. friend bool operator>(const multiset& x, const multiset& y);
  1361. //! <b>Effects</b>: Returns true if x is equal or less than y
  1362. //!
  1363. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1364. friend bool operator<=(const multiset& x, const multiset& y);
  1365. //! <b>Effects</b>: Returns true if x is equal or greater than y
  1366. //!
  1367. //! <b>Complexity</b>: Linear to the number of elements in the container.
  1368. friend bool operator>=(const multiset& x, const multiset& y);
  1369. //! <b>Effects</b>: x.swap(y)
  1370. //!
  1371. //! <b>Complexity</b>: Constant.
  1372. friend void swap(multiset& x, multiset& y)
  1373. BOOST_NOEXCEPT_IF( allocator_traits_type::is_always_equal::value
  1374. && boost::container::dtl::is_nothrow_swappable<Compare>::value );
  1375. #endif //#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
  1376. };
  1377. #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
  1378. template <typename InputIterator>
  1379. multiset(InputIterator, InputIterator) ->
  1380. multiset< it_based_value_type_t<InputIterator> >;
  1381. template < typename InputIterator, typename AllocatorOrCompare>
  1382. multiset(InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1383. multiset < it_based_value_type_t<InputIterator>
  1384. , typename dtl::if_c< // Compare
  1385. dtl::is_allocator<AllocatorOrCompare>::value
  1386. , std::less<it_based_value_type_t<InputIterator>>
  1387. , AllocatorOrCompare
  1388. >::type
  1389. , typename dtl::if_c< // Allocator
  1390. dtl::is_allocator<AllocatorOrCompare>::value
  1391. , AllocatorOrCompare
  1392. , new_allocator<it_based_value_type_t<InputIterator>>
  1393. >::type
  1394. >;
  1395. template < typename InputIterator, typename Compare, typename Allocator
  1396. , typename = dtl::require_nonallocator_t<Compare>
  1397. , typename = dtl::require_allocator_t<Allocator>>
  1398. multiset(InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1399. multiset< it_based_value_type_t<InputIterator>
  1400. , Compare
  1401. , Allocator>;
  1402. template <typename InputIterator>
  1403. multiset(ordered_range_t, InputIterator, InputIterator) ->
  1404. multiset< it_based_value_type_t<InputIterator>>;
  1405. template < typename InputIterator, typename AllocatorOrCompare>
  1406. multiset(ordered_range_t, InputIterator, InputIterator, AllocatorOrCompare const&) ->
  1407. multiset < it_based_value_type_t<InputIterator>
  1408. , typename dtl::if_c< // Compare
  1409. dtl::is_allocator<AllocatorOrCompare>::value
  1410. , std::less<it_based_value_type_t<InputIterator>>
  1411. , AllocatorOrCompare
  1412. >::type
  1413. , typename dtl::if_c< // Allocator
  1414. dtl::is_allocator<AllocatorOrCompare>::value
  1415. , AllocatorOrCompare
  1416. , new_allocator<it_based_value_type_t<InputIterator>>
  1417. >::type
  1418. >;
  1419. template < typename InputIterator, typename Compare, typename Allocator
  1420. , typename = dtl::require_nonallocator_t<Compare>
  1421. , typename = dtl::require_allocator_t<Allocator>>
  1422. multiset(ordered_range_t, InputIterator, InputIterator, Compare const&, Allocator const&) ->
  1423. multiset< it_based_value_type_t<InputIterator>
  1424. , Compare
  1425. , Allocator>;
  1426. #endif
  1427. #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1428. } //namespace container {
  1429. //!has_trivial_destructor_after_move<> == true_type
  1430. //!specialization for optimizations
  1431. template <class Key, class Compare, class Allocator, class Options>
  1432. struct has_trivial_destructor_after_move<boost::container::multiset<Key, Compare, Allocator, Options> >
  1433. {
  1434. typedef ::boost::container::dtl::tree<Key, void, Compare, Allocator, Options> tree;
  1435. static const bool value = ::boost::has_trivial_destructor_after_move<tree>::value;
  1436. };
  1437. namespace container {
  1438. #endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
  1439. }}
  1440. #include <boost/container/detail/config_end.hpp>
  1441. #endif // BOOST_CONTAINER_SET_HPP