set.hpp 70 KB

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