/Src/Dependencies/Boost/libs/bimap/doc/reference/set_of.qbk

http://hadesmem.googlecode.com/ · text · 935 lines · 650 code · 285 blank · 0 comment · 0 complexity · e5b5a244dd6aea9f62da4c52143d0f77 MD5 · raw file

  1. [/license
  2. Boost.Bimap
  3. Copyright (c) 2006-2007 Matias Capeletto
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. ]
  8. [/ QuickBook Document version 1.4 ]
  9. [section set_of Reference]
  10. [section Header "boost/bimap/set_of.hpp" synopsis]
  11. namespace boost {
  12. namespace bimaps {
  13. template
  14. <
  15. class KeyType,
  16. class KeyCompare = std::less< KeyType >
  17. >
  18. struct set_of;
  19. template
  20. <
  21. class KeyCompare = std::less< _relation >
  22. >
  23. struct set_of_relation;
  24. } // namespace bimap
  25. } // namespace boost
  26. [endsect]
  27. [section Header "boost/bimap/multiset_of.hpp" synopsis]
  28. namespace boost {
  29. namespace bimaps {
  30. template
  31. <
  32. class KeyType,
  33. class KeyCompare = std::less< KeyType >
  34. >
  35. struct multiset_of;
  36. template
  37. <
  38. class KeyCompare = std::less< _relation >
  39. >
  40. struct multiset_of_relation;
  41. } // namespace bimap
  42. } // namespace boost
  43. [endsect]
  44. [section Collection type specifiers set_of and multiset_of]
  45. These collection type specifiers allow for insertion of sets disallowing or
  46. allowing duplicate elements, respectively. The syntaxes of `set_of` and
  47. `multiset_of` coincide, so they are described together.
  48. [endsect]
  49. [section \[multi\]set_of Views]
  50. A \[multi\]set_of set view is a std::\[multi\]set signature-compatible
  51. interface to the underlying heap of elements contained in a `bimap`.
  52. There are two variants: set_of, which does not allow duplicate elements
  53. (with respect to its associated comparison predicate) and multiset_of,
  54. which does accept those duplicates. The interface of these two variants
  55. is largely the same, so they are documented together with their
  56. differences explicitly noted where they exist.
  57. If you look the bimap from a side, you will use a map view, and if you
  58. look at it as a whole, you will be using a set view.
  59. namespace boost {
  60. namespace bimaps {
  61. namespace views {
  62. template< ``['-implementation defined parameter list-]`` >
  63. class ``['-implementation defined view name-]``
  64. {
  65. public:
  66. typedef ``['-unspecified-]`` key_type;
  67. typedef ``['-unspecified-]`` value_type;
  68. typedef ``['-unspecified-]`` key_compare;
  69. typedef ``['-unspecified-]`` value_compare;
  70. typedef ``['-unspecified-]`` allocator_type;
  71. typedef ``['-unspecified-]`` reference;
  72. typedef ``['-unspecified-]`` const_reference;
  73. typedef ``['-unspecified-]`` iterator;
  74. typedef ``['-unspecified-]`` const_iterator;
  75. typedef ``['-unspecified-]`` size_type;
  76. typedef ``['-unspecified-]`` difference_type;
  77. typedef ``['-unspecified-]`` pointer;
  78. typedef ``['-unspecified-]`` const_pointer;
  79. typedef ``['-unspecified-]`` reverse_iterator;
  80. typedef ``['-unspecified-]`` const_reverse_iterator;
  81. typedef ``['-unspecified-]`` info_type;
  82. this_type & operator=(const this_type & x);
  83. allocator_type get_allocator() const;
  84. // iterators
  85. iterator begin();
  86. const_iterator begin() const;
  87. iterator end();
  88. const_iterator end() const;
  89. reverse_iterator rbegin();
  90. const_reverse_iterator rbegin() const;
  91. reverse_iterator rend();
  92. const_reverse_iterator rend() const;
  93. // capacity
  94. bool empty() const;
  95. size_type size() const;
  96. size_type max_size() const;
  97. // modifiers
  98. std::pair<iterator,bool> ``[link reference_set_of_insert_value insert]``(const value_type & x);
  99. iterator ``[link reference_set_of_insert_iterator_value insert]``(iterator position, const value_type & x);
  100. template< class InputIterator>
  101. void ``[link reference_set_of_insert_iterator_iterator insert]``(InputIterator first, InputIterator last);
  102. iterator ``[link reference_set_of_erase_iterator erase]``(iterator position);
  103. template< class CompatibleKey >
  104. size_type ``[link reference_set_of_erase_key erase]``(const CompatibleKey & x);
  105. iterator ``[link reference_set_of_erase_iterator_iterator erase]``(iterator first, iterator last);
  106. bool ``[link reference_set_of_replace_iterator_value replace]``(iterator position, const value_type& x);
  107. // Only in map views
  108. // {
  109. template< class CompatibleKey >
  110. bool ``[link reference_set_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x);
  111. template< class CompatibleData >
  112. bool ``[link reference_set_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x);
  113. template< class KeyModifier >
  114. bool ``[link reference_set_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod);
  115. template< class DataModifier >
  116. bool ``[link reference_set_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod);
  117. // }
  118. void swap(this_type & x);
  119. void clear();
  120. // observers
  121. key_compare key_comp() const;
  122. value_compare value_comp() const;
  123. // set operations
  124. template< class CompatibleKey >
  125. iterator ``[link reference_set_of_find_key find]``(const CompatibleKey & x);
  126. template< class CompatibleKey >
  127. const_iterator ``[link reference_set_of_find_key find]``(const CompatibleKey & x) const;
  128. template< class CompatibleKey >
  129. size_type ``[link reference_set_of_count_key count]``(const CompatibleKey & x) const;
  130. template< class CompatibleKey >
  131. iterator ``[link reference_set_of_lower_bound_key lower_bound]``(const CompatibleKey & x);
  132. template< class CompatibleKey >
  133. const_iterator ``[link reference_set_of_lower_bound_key lower_bound]``(const CompatibleKey & x) const;
  134. template< class CompatibleKey >
  135. iterator ``[link reference_set_of_upper_bound_key upper_bound]``(const CompatibleKey & x);
  136. template< class CompatibleKey >
  137. const_iterator ``[link reference_set_of_upper_bound_key upper_bound]``(const CompatibleKey & x) const;
  138. template< class CompatibleKey >
  139. std::pair<iterator,iterator>
  140. ``[link reference_set_of_equal_range_key equal_range]``(const CompatibleKey & x);
  141. template< class CompatibleKey >
  142. std::pair<const_iterator,const_iterator>
  143. ``[link reference_set_of_equal_range_key equal_range]``(const CompatibleKey & x) const;
  144. // Only in maps views
  145. // {
  146. template< class LowerBounder, class UpperBounder>
  147. std::pair<iterator,iterator> ``[link reference_set_of_range_lower_upper range]``(
  148. LowerBounder lower, UpperBounder upper);
  149. template< class LowerBounder, class UpperBounder>
  150. std::pair<const_iterator,const_iterator> ``[link reference_set_of_range_lower_upper range]``(
  151. LowerBounder lower, UpperBounder upper) const;
  152. typedef ``['-unspecified-]`` data_type;
  153. // Only in for `set_of` collection type
  154. // {
  155. template< class CompatibleKey >
  156. const data_type & ``[link reference_set_of_at_key_const at]``(const CompatibleKey & k) const;
  157. // Only if the other collection type is mutable
  158. // {
  159. template< class CompatibleKey >
  160. data_type & ``[link reference_set_of_operator_bracket_key operator\[\]]``(const CompatibleKey & k);
  161. template< class CompatibleKey >
  162. data_type & ``[link reference_set_of_at_key at]``(const CompatibleKey & k);
  163. // }
  164. // Only if info_hook is used
  165. // {
  166. template< class CompatibleKey >
  167. info_type & ``[link reference_set_of_info_at_key info_at]``(const CompatibleKey & k);
  168. template< class CompatibleKey >
  169. const info_type & ``[link reference_set_of_info_at_key info_at]``(const CompatibleKey & k) const;
  170. // }
  171. // }
  172. // }
  173. };
  174. // view comparison
  175. bool operator==(const this_type & v1, const this_type & v2 );
  176. bool operator< (const this_type & v1, const this_type & v2 );
  177. bool operator!=(const this_type & v1, const this_type & v2 );
  178. bool operator> (const this_type & v1, const this_type & v2 );
  179. bool operator>=(const this_type & v1, const this_type & v2 );
  180. bool operator<=(const this_type & v1, const this_type & v2 );
  181. } // namespace views
  182. } // namespace bimap
  183. } // namespace boost
  184. [/ Functions that may be implemented some day
  185. template< class Modifier>
  186. bool ``[link reference_set_of_modify_iterator_modifier modify]``(iterator position, Modifier mod);
  187. template< class CompatibleKey, class CompatibleCompare >
  188. iterator find(const CompatibleKey & x,
  189. const CompatibleCompare & comp);
  190. template< class CompatibleKey, class CompatibleCompare >
  191. const_iterator find(const CompatibleKey & x,
  192. const CompatibleCompare & comp) const;
  193. template< class CompatibleKey, class CompatibleCompare >
  194. size_type count(const CompatibleKey & x,
  195. const CompatibleCompare & comp) const;
  196. template< class CompatibleKey, class CompatibleCompare >
  197. iterator lower_bound(const CompatibleKey & x,
  198. const CompatibleCompare & comp);
  199. template< class CompatibleKey, class CompatibleCompare >
  200. const_iterator lower_bound(const CompatibleKey & x,
  201. const CompatibleCompare & comp) const;
  202. template< class CompatibleKey, class CompatibleCompare >
  203. iterator upper_bound(const CompatibleKey & x,
  204. const CompatibleCompare & comp);
  205. template< class CompatibleKey, class CompatibleCompare >
  206. const_iterator upper_bound(const CompatibleKey & x,
  207. const CompatibleCompare & comp) const;
  208. template< class CompatibleKey, class CompatibleCompare >
  209. std::pair<iterator,iterator> equal_range(
  210. const CompatibleKey & x, const CompatibleCompare & comp);
  211. template< class CompatibleKey, class CompatibleCompare >
  212. std::pair<const_iterator,const_iterator> equal_range(
  213. const CompatibleKey & x, const CompatibleCompare & comp) const;
  214. ]
  215. In the case of a `bimap< {multi}set_of<Left>, ... >`
  216. In the set view:
  217. typedef signature-compatible with relation< Left, ... > key_type;
  218. typedef signature-compatible with relation< const Left, ... > value_type;
  219. In the left map view:
  220. typedef Left key_type;
  221. typedef ... data_type;
  222. typedef signature-compatible with std::pair< const Left, ... > value_type;
  223. In the right map view:
  224. typedef ... key_type;
  225. typedef Left data_type;
  226. typedef signature-compatible with std::pair< ... ,const Left > value_type;
  227. [#set_of_complexity_signature]
  228. [section Complexity signature]
  229. Here and in the descriptions of operations of this view, we adopt the
  230. scheme outlined in the [link complexity_signature_explanation complexity signature section].
  231. The complexity signature of \[multi\]set_of view is:
  232. * copying: `c(n) = n * log(n)`,
  233. * insertion: `i(n) = log(n)`,
  234. * hinted insertion: `h(n) = 1` (constant) if the hint element precedes the point of
  235. insertion, `h(n) = log(n)` otherwise,
  236. * deletion: `d(n) = 1` (amortized constant),
  237. * replacement: `r(n) = 1` (constant) if the element position does not change,
  238. `r(n) = log(n)` otherwise,
  239. * modifying: `m(n) = 1` (constant) if the element position does not change,
  240. `m(n) = log(n)` otherwise.
  241. [endsect]
  242. [section Instantiation types]
  243. Set views are instantiated internally to a `bimap`.
  244. Instantiations are dependent on the following types:
  245. * `Value` from the set specifier,
  246. * `Allocator` from `bimap`,
  247. * `Compare` from the set specifier.
  248. `Compare` is a __SGI_STRICT_WEAK_ORDERING__ on elements of `Value`.
  249. [endsect]
  250. [section Constructors, copy and assignment]
  251. Set views do not have public constructors or destructors.
  252. Assignment, on the other hand, is provided.
  253. this_type & operator=(const this_type & x);
  254. * [*Effects: ] `a = b;`
  255. where a and b are the `bimap` objects to which `*this` and x
  256. belong, respectively.
  257. * [*Returns: ] `*this`.
  258. [endsect]
  259. [section Modifiers]
  260. [#reference_set_of_insert_value]
  261. std::pair<iterator,bool> insert(const value_type & x);
  262. * [*Effects:] Inserts `x` into the `bimap` to which the set view belongs if
  263. * the set view is non-unique OR no other element with equivalent key exists,
  264. * AND insertion is allowed by the other set specifications the `bimap`.
  265. * [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if insertion
  266. took place. On successful insertion, `p.first` points to the element inserted;
  267. otherwise, `p.first` points to an element that caused the insertion to be banned.
  268. Note that more than one element can be causing insertion not to be allowed.
  269. * [link set_of_complexity_signature
  270. [*Complexity:]] O(I(n)).
  271. * [*Exception safety:] Strong.
  272. [#reference_set_of_insert_iterator_value]
  273. iterator insert(iterator position, const value_type & x);
  274. * [*Requires: ] `position` is a valid iterator of the view.
  275. * [*Effects: ] `position` is used as a hint to improve the efficiency of the operation. Inserts `x` into the `bimap` to which the view belongs if
  276. * the set view is non-unique OR no other element with equivalent key exists,
  277. * AND insertion is allowed by all other views of the `bimap`.
  278. * [*Returns:] On successful insertion, an iterator to the newly inserted
  279. element. Otherwise, an iterator to an element that caused the insertion to be
  280. banned. Note that more than one element can be causing insertion not to be allowed.
  281. * [link set_of_complexity_signature
  282. [*Complexity:]] O(H(n)).
  283. * [*Exception safety:] Strong.
  284. [#reference_set_of_insert_iterator_iterator]
  285. template< class InputIterator >
  286. void insert(InputIterator first, InputIterator last);
  287. * [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements of
  288. type `value_type` or a type convertible to value_type. `first` and `last` are not
  289. iterators into any view of the `bimap` to which this index
  290. belongs. `last` is reachable from `first`.
  291. * [*Effects: ]
  292. `iterator hint = end()`;
  293. `while( first != last ) hint = insert( hint, *first++ );`
  294. * [link set_of_complexity_signature
  295. [*Complexity:]] O(m*H(n+m)), where m is the number of elements in
  296. `[first, last)`.
  297. * [*Exception safety:] Basic.
  298. [#reference_set_of_erase_iterator]
  299. iterator erase(iterator position);
  300. * [*Requires: ] `position` is a valid dereferenceable iterator if the set view.
  301. * [*Effects:] Deletes the element pointed to by `position`.
  302. * [*Returns:] An iterator pointing to the element immediately following
  303. the one that was deleted, or `end()` if no such element exists.
  304. * [link set_of_complexity_signature
  305. [*Complexity:]] O(D(n)).
  306. * [*Exception safety:] nothrow.
  307. [#reference_set_of_erase_key]
  308. template< class CompatibleKey >
  309. size_type erase(const CompatibleKey & x);
  310. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  311. * [*Effects:] Deletes the elements with key equivalent to `x`.
  312. * [*Returns:] Number of elements deleted.
  313. * [link set_of_complexity_signature
  314. [*Complexity:]] O(log(n) + m*D(n)), where m is the number of elements deleted.
  315. * [*Exception safety:] Basic.
  316. [#reference_set_of_erase_iterator_iterator]
  317. iterator erase(iterator first, iterator last);
  318. * [*Requires: ] `[first,last)` is a valid range of the view.
  319. * [*Effects:] Deletes the elements in `[first,last)`.
  320. * [*Returns:] last.
  321. * [link set_of_complexity_signature
  322. [*Complexity:]] O(log(n) + m*D(n)), where m is the number of elements
  323. in `[first,last)`.
  324. * [*Exception safety:] nothrow.
  325. [#reference_set_of_replace_iterator_value]
  326. bool replace(iterator position, const value_type& x);
  327. * [*Requires: ] `position` is a valid dereferenceable iterator of the set view.
  328. * [*Effects:] Assigns the value `x` to the element pointed to by `position` into
  329. the `bimap` to which the set view belongs if, for the value `x`
  330. * the set view is non-unique OR no other element with equivalent key exists
  331. (except possibly `*position`),
  332. * AND replacing is allowed by all other views of the `bimap`.
  333. * [*Postconditions:] Validity of position is preserved in all cases.
  334. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  335. * [link set_of_complexity_signature
  336. [*Complexity:]] O(R(n)).
  337. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  338. operation, the `bimap` to which the set view belongs remains in
  339. its original state.
  340. [#reference_set_of_replace_key_iterator_key]
  341. template< class CompatibleKey >
  342. bool replace_key(iterator position, const CompatibleKey & x);
  343. * [*Requires: ] `position` is a valid dereferenceable iterator of the set view.
  344. `CompatibleKey` can be assigned to `key_type`.
  345. * [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed
  346. to by `position` into the `bimap` to which the set view belongs if,
  347. * the map view is non-unique OR no other element with equivalent key exists
  348. (except possibly `*position`),
  349. * AND replacing is allowed by all other views of the `bimap`.
  350. * [*Postconditions:] Validity of position is preserved in all cases.
  351. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  352. * [link set_of_complexity_signature
  353. [*Complexity:]] O(R(n)).
  354. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  355. operation, the `bimap` to which the set view belongs remains in
  356. its original state.
  357. [#reference_set_of_replace_data_iterator_data]
  358. template< class CompatibleData >
  359. bool replace_data(iterator position, const CompatibleData & x);
  360. * [*Requires: ] `position` is a valid dereferenceable iterator of the set view.
  361. `CompatibleKey` can be assigned to `data_type`.
  362. * [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed
  363. to by `position` into the `bimap` to which the set view belongs if,
  364. * the map view is non-unique OR no other element with equivalent key exists
  365. (except possibly `*position`),
  366. * AND replacing is allowed by all other views of the `bimap`.
  367. * [*Postconditions:] Validity of position is preserved in all cases.
  368. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  369. * [link set_of_complexity_signature
  370. [*Complexity:]] O(R(n)).
  371. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  372. operation, the `bimap` to which the set view belongs remains in
  373. its original state.
  374. [#reference_set_of_modify_key_iterator_modifier]
  375. template< class KeyModifier >
  376. bool modify_key(iterator position, KeyModifier mod);
  377. * [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of
  378. type: `key_type&`; `position` is a valid dereferenceable iterator of the view.
  379. * [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and
  380. rearranges `*position` into all the views of the `bimap`.
  381. If the rearrangement fails, the element is erased.
  382. Rearrangement is successful if
  383. * the map view is non-unique OR no other element with equivalent key exists,
  384. * AND rearrangement is allowed by all other views of the `bimap`.
  385. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  386. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  387. * [link set_of_complexity_signature
  388. [*Complexity:]] O(M(n)).
  389. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  390. operation (except possibly mod), then the element pointed to by position is erased.
  391. * [*Note:] Only provided for map views.
  392. [#reference_set_of_modify_data_iterator_modifier]
  393. template< class DataModifier >
  394. bool modify_data(iterator position, DataModifier mod);
  395. * [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of
  396. type: `data_type&`; `position` is a valid dereferenceable iterator of the view.
  397. * [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and
  398. rearranges `*position` into all the views of the `bimap`.
  399. If the rearrangement fails, the element is erased.
  400. Rearrangement is successful if
  401. * the oppositte map view is non-unique OR no other element with equivalent key in that
  402. view exists,
  403. * AND rearrangement is allowed by all other views of the `bimap`.
  404. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  405. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  406. * [link set_of_complexity_signature
  407. [*Complexity:]] O(M(n)).
  408. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  409. operation (except possibly mod), then the element pointed to by position is erased.
  410. * [*Note:] Only provided for map views.
  411. [/
  412. [#reference_set_of_modify_iterator_modifier]
  413. template< class Modifier >
  414. bool modify(iterator position, Modifier mod);
  415. * [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of
  416. type: `first_type&` and `second_type&` for ['Map View] or `left_type&` and `right_type&`
  417. ['Set View]; `position` is a valid dereferenceable iterator of the view.
  418. * [*Effects:] Calls `mod(e.first,e.second)` for ['Map View] or Calls `mod(e.left,e.right)`
  419. for ['Set View] where e is the element pointed to by position and rearranges `*position`
  420. into all the views of the `bimap`.
  421. If the rearrangement fails, the element is erased.
  422. Rearrangement is successful if
  423. * the view is non-unique OR no other element with equivalent key exists,
  424. * AND rearrangement is allowed by all other views of the `bimap`.
  425. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  426. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  427. * [link set_of_complexity_signature
  428. [*Complexity:]] O(M(n)).
  429. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  430. operation (except possibly mod), then the element pointed to by position is erased.
  431. ]
  432. [endsect]
  433. [section Set operations]
  434. `[multi]set_of` views provide the full lookup functionality required by
  435. __SGI_SORTED_ASSOCIATIVE_CONTAINER__ and __SGI_UNIQUE_ASSOCIATIVE_CONTAINER__,
  436. namely `find`, `count`, `lower_bound`, `upper_bound` and `equal_range`.
  437. Additionally, these member functions are templatized to allow for non-standard
  438. arguments, so extending the types of search operations allowed.
  439. [/
  440. The kinds of arguments permissible when invoking the lookup member functions
  441. are defined by the following concept.
  442. Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type `Key`. A pair of
  443. types `(CompatibleKey, CompatibleCompare)` is said to be a ['compatible extension]
  444. of Compare if
  445. * `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(Key, CompatibleKey)`,
  446. * `CompatibleCompare` is a __SGI_BINARY_PREDICATE__ over `(CompatibleKey, Key)`,
  447. * if `c_comp(ck,k1)` then `!c_comp(k1,ck)`,
  448. * if `!c_comp(ck,k1)` and `!comp(k1,k2)` then `!c_comp(ck,k2)`,
  449. * if `!c_comp(k1,ck)` and `!comp(k2,k1)` then `!c_comp(k2,ck)`,
  450. for every `c_comp` of type `CompatibleCompare`, `comp` of type `Compare`, `ck` of type
  451. `CompatibleKey` and `k1`, `k2` of type `Key`.
  452. ]
  453. A type `CompatibleKey` is said to be a ['compatible key] of `Compare`
  454. if `(CompatibleKey, Compare)` is a compatible extension of `Compare`. This implies
  455. that `Compare`, as well as being a strict weak ordering, accepts arguments of type
  456. `CompatibleKey`, which usually means it has several overloads of `operator()`.
  457. [/
  458. In the context of a compatible extension or a compatible key, the expressions
  459. "equivalent", "less than" and "greater than" take on their obvious interpretations.
  460. ]
  461. [#reference_set_of_find_key]
  462. template< class CompatibleKey >
  463. iterator find(const CompatibleKey & x);
  464. template< class CompatibleKey >
  465. const_iterator find(const CompatibleKey & x) const;
  466. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  467. * [*Effects:] Returns a pointer to an element whose key is equivalent to `x`, or
  468. `end()` if such an element does not exist.
  469. * [*Complexity:] O(log(n)).
  470. [/
  471. template< class CompatibleKey, class CompatibleCompare >
  472. iterator find(const CompatibleKey & x,
  473. const CompatibleCompare & comp);
  474. template< class CompatibleKey, class CompatibleCompare >
  475. const_iterator find(const CompatibleKey & x,
  476. const CompatibleCompare & comp) const;
  477. * [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of
  478. `key_compare.`
  479. * [*Effects:] Returns a pointer to an element whose key is
  480. equivalent to `x`, or `end()` if such an element does not exist.
  481. * [*Complexity:] O(log(n)).
  482. ]
  483. [#reference_set_of_count_key]
  484. template< class CompatibleKey >
  485. size_type count(const key_type & x) const;
  486. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  487. * [*Effects:] Returns the number of elements with key equivalent to `x`.
  488. * [*Complexity:] O(log(n) + count(x)).
  489. [/
  490. template< class CompatibleKey, class CompatibleCompare >
  491. size_type count(const CompatibleKey & x,
  492. const CompatibleCompare & comp) const;
  493. * [*Requires: ] `(CompatibleKey, CompatibleCompare)` is a compatible extension of
  494. `key_compare.`
  495. * [*Effects:] Returns the number of elements with key equivalent to `x`.
  496. * [*Complexity:] O(log(n) + count(x)).
  497. ]
  498. [#reference_set_of_lower_bound_key]
  499. template< class CompatibleKey >
  500. iterator lower_bound(const key_type & x);
  501. template< class CompatibleKey >
  502. const_iterator lower_bound(const key_type & x) const;
  503. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  504. * [*Effects:] Returns an iterator pointing to the first element with key not
  505. less than `x`, or `end()` if such an element does not exist.
  506. * [*Complexity:] O(log(n)).
  507. [#reference_set_of_upper_bound_key]
  508. template< class CompatibleKey >
  509. iterator upper_bound(const key_type & x);
  510. template< class CompatibleKey >
  511. const_iterator upper_bound(const key_type & x) const;
  512. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  513. * [*Effects:] Returns an iterator pointing to the first element with key greater
  514. than `x`, or `end()` if such an element does not exist.
  515. * [*Complexity:] O(log(n)).
  516. [#reference_set_of_equal_range_key]
  517. template< class CompatibleKey >
  518. std::pair<iterator,iterator>
  519. equal_range(const key_type & x);
  520. template< class CompatibleKey >
  521. std::pair<const_iterator,const_iterator>
  522. equal_range(const key_type & x) const;
  523. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  524. * [*Effects:] Equivalent to `make_pair(lower_bound(x),upper_bound(x))`.
  525. * [*Complexity:] O(log(n)).
  526. [endsect]
  527. [section Range operations]
  528. The member function range is not defined for sorted associative
  529. containers, but `[multi]set_of` map views provide it as a convenient utility.
  530. A range or interval is defined by two conditions for the lower and upper
  531. bounds, which are modelled after the following concepts.
  532. Consider a __SGI_STRICT_WEAK_ORDERING__ `Compare` over values of type Key.
  533. A type `LowerBounder` is said to be a lower bounder of `Compare` if
  534. * `LowerBounder` is a `Predicate` over `Key`,
  535. * if `lower(k1)` and `!comp(k2,k1)` then `lower(k2)`,
  536. for every `lower` of type `LowerBounder`, `comp` of type `Compare`, and `k1`, `k2`
  537. of type `Key`.
  538. Similarly, an upper bounder is a type `UpperBounder` such that
  539. * `UpperBounder` is a `Predicate` over `Key`,
  540. * if `upper(k1)` and `!comp(k1,k2)` then `upper(k2)`,
  541. for every `upper` of type `UpperBounder`, `comp` of type `Compare`, and `k1`, `k2`
  542. of type `Key`.
  543. [#reference_set_of_range_lower_upper]
  544. template< class LowerBounder, class UpperBounder>
  545. std::pair<const_iterator,const_iterator> range(
  546. LowerBounder lower, UpperBounder upper) const;
  547. * [*Requires: ] `LowerBounder` and `UpperBounder` are a lower and upper bounder of
  548. `key_compare`, respectively.
  549. * [*Effects:] Returns a pair of iterators pointing to
  550. the beginning and one past the end of the subsequence of elements satisfying
  551. lower and upper simultaneously. If no such elements exist, the iterators both
  552. point to the first element satisfying lower, or else are equal to `end()` if this
  553. latter element does not exist.
  554. * [*Complexity:] O(log(n)).
  555. * [*Variants:] In place of lower or upper (or both), the singular value
  556. `boost::bimap::unbounded` can be provided. This acts as a predicate which
  557. all values of type `key_type` satisfy.
  558. * [*Note:] Only provided for map views.
  559. [endsect]
  560. [section at(), info_at() and operator\[\] - set_of only]
  561. [#reference_set_of_at_key_const]
  562. template< class CompatibleKey >
  563. const data_type & at(const CompatibleKey & k) const;
  564. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  565. * [*Effects:] Returns the `data_type` reference that is associated with `k`, or
  566. throws `std::out_of_range` if such key does not exist.
  567. * [*Complexity:] O(log(n)).
  568. * [*Note:] Only provided when `set_of` is used.
  569. The symmetry of bimap imposes some constraints on `operator[]` and the
  570. non constant version of at() that are not found in `std::maps`.
  571. Tey are only provided if the other collection type is mutable
  572. (`list_of`, `vector_of` and `unconstrained_set_of`).
  573. [#reference_set_of_operator_bracket_key]
  574. template< class CompatibleKey >
  575. data_type & operator[](const CompatibleKey & k);
  576. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  577. * [*Effects: ] `return insert(value_type(k,data_type()))->second;`
  578. * [*Complexity:] O(log(n)).
  579. * [*Note:] Only provided when `set_of` is used and the other collection
  580. type is mutable.
  581. [#reference_set_of_at_key]
  582. template< class CompatibleKey >
  583. data_type & at(const CompatibleKey & k);
  584. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  585. * [*Effects: ] Returns the `data_type` reference that is associated with `k`, or
  586. throws `std::out_of_range` if such key does not exist.
  587. * [*Complexity:] O(log(n)).
  588. * [*Note:] Only provided when `set_of` is used and the other collection
  589. type is mutable.
  590. [/
  591. The symmetry of bimap imposes some constraints on `operator[]` that are
  592. not found in `std::maps`. If other views are unique,
  593. `bimap::duplicate_value` is thrown whenever an assignment is attempted to
  594. a value that is already a key in these views. As for
  595. `bimap::value_not_found`, this exception is thrown while trying to access
  596. a non-existent key: this behaviour differs from that of `std::map`, which
  597. automatically assigns a default value to non-existent keys referred to
  598. by `operator[]`.
  599. const data_type & operator[](const typename key_type & k) const;
  600. * [*Effects:] Returns the `data_type` reference that is associated with `k`, or
  601. throws `bimap::value_not_found` if such an element does not exist.
  602. * [*Complexity:] O(log(n)).
  603. ``['-unspecified data_type proxy-]`` operator[](const typename key_type & k);
  604. * [*Effects:] Returns a proxy to a `data_type` associated with `k` and the
  605. bimap. The proxy behaves as a reference to the `data_type` object. If this
  606. proxy is read and `k` was not in the bimap, the bimap::value_not_found is
  607. thrown. If it is written then `bimap::duplicate_value` is thrown if the
  608. assignment is not allowed by one of the other views of the `bimap`.
  609. * [link set_of_complexity_signature
  610. [*Complexity:]] If the assignment operator of the proxy is not used, then
  611. the order is O(log(n)). If it is used, the order is O(I(n)) if `k` was not
  612. in the bimap and O(R(n)) if it existed in the bimap.
  613. ]
  614. [#reference_set_of_info_at_key]
  615. template< class CompatibleKey >
  616. info_type & info_at(const CompatibleKey & k);
  617. template< class CompatibleKey >
  618. const info_type & info_at(const CompatibleKey & k) const;
  619. * [*Requires: ] `CompatibleKey` is a compatible key of `key_compare`.
  620. * [*Effects:] Returns the `info_type` reference that is associated with `k`, or
  621. throws `std::out_of_range` if such key does not exist.
  622. * [*Complexity:] O(log(n)).
  623. * [*Note:] Only provided when `set_of` and `info_hook` are used
  624. [endsect]
  625. [section Serialization]
  626. Views cannot be serialized on their own, but only as part of the `bimap`
  627. into which they are embedded. In describing the additional preconditions and guarantees
  628. associated to `[multi]set_of` views with respect to serialization of their embedding containers,
  629. we use the concepts defined in the `bimap` serialization section.
  630. [blurb [*Operation:] saving of a `bimap` m to an output archive (XML archive) ar.]
  631. * [*Requires:] No additional requirements to those imposed by the container.
  632. [blurb [*Operation:] loading of a `bimap` m' from an input archive (XML archive) ar.]
  633. * [*Requires:] In addition to the general requirements, `value_comp()` must be
  634. serialization-compatible with `m.get<i>().value_comp()`, where i is the position
  635. of the ordered view in the container.
  636. * [*Postconditions:] On successful loading, each of the elements of `[begin(), end())`
  637. is a restored copy of the corresponding element in `[m.get<i>().begin(), m.get<i>().end())`.
  638. [blurb [*Operation:] saving of an iterator or `const_iterator` it to an output archive
  639. (XML archive) ar.]
  640. * [*Requires: ] `it` is a valid iterator of the view. The associated `bimap`
  641. has been previously saved.
  642. [blurb [*Operation:] loading of an `iterator` or `const_iterator` `it`' from an input archive (
  643. XML archive) ar.]
  644. * [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is the
  645. restored copy of `*it`, otherwise `it`'` == end()`.
  646. * [*Note:] It is allowed that it be a `const_iterator` and the restored `it`' an iterator,
  647. or viceversa.
  648. [endsect]
  649. [endsect]
  650. [endsect]