set.hpp 67 KB

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