set.hpp 68 KB

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