vector_of.qbk 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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 vector_of Reference]
  10. [section Header "boost/bimap/vector_of.hpp" synopsis]
  11. namespace boost {
  12. namespace bimaps {
  13. template< class KeyType >
  14. struct vector_of;
  15. struct vector_of_relation;
  16. } // namespace bimap
  17. } // namespace boost
  18. [endsect]
  19. [section vector_of views]
  20. vector_of views are free-order sequences with constant time positional
  21. access and random access iterators. Elements in a vector_of view are by
  22. default sorted according to their order of insertion: this means that new elements
  23. inserted through a different view of the `bimap` are appended to
  24. the end of the vector_of view; additionally, facilities are provided for
  25. further rearrangement of the elements. The public interface of vector_of views
  26. includes that of list_of views, with differences in the complexity
  27. of the operations, plus extra operations for positional access
  28. (`operator[]` and `at()`) and for capacity handling. Validity of iterators and
  29. references to elements is preserved in all operations, regardless of the
  30. capacity status.
  31. As is the case with list_of views, vector_of views have the following
  32. limitations with respect to STL sequence containers:
  33. * vector_of views
  34. are not __SGI_ASSIGNABLE__ (like any other view.)
  35. * Insertions into a vector_of view may fail due to clashings with other views.
  36. This alters the semantics of the operations provided with respect to their analogues
  37. in STL sequence containers.
  38. * Elements in a vector_of view are not mutable, and can only be changed by
  39. means of replace and modify member functions.
  40. Having these restrictions into account, vector of views are models of
  41. __SGI_RANDOM_ACCESS_CONTAINER__ and __SGI_BACK_INSERTION_SEQUENCE__. Although these views
  42. do not model __SGI_FRONT_INSERTION_SEQUENCE__, because front insertion and deletion
  43. take linear time, front operations are nonetheless provided to match the interface
  44. of list_of views. We only describe those types and operations that are either
  45. not present in the concepts modeled or do not exactly conform to the requirements
  46. for these types of containers.
  47. namespace boost {
  48. namespace bimaps {
  49. namespace views {
  50. template< ``['-implementation defined parameter list-]`` >
  51. class ``['-implementation defined view name-]``
  52. {
  53. public:
  54. // types
  55. typedef ``['-unspecified-]`` value_type;
  56. typedef ``['-unspecified-]`` allocator_type;
  57. typedef ``['-unspecified-]`` reference;
  58. typedef ``['-unspecified-]`` const_reference;
  59. typedef ``['-unspecified-]`` iterator;
  60. typedef ``['-unspecified-]`` const_iterator;
  61. typedef ``['-unspecified-]`` size_type;
  62. typedef ``['-unspecified-]`` difference_type;
  63. typedef ``['-unspecified-]`` pointer;
  64. typedef ``['-unspecified-]`` const_pointer;
  65. typedef ``['-unspecified-]`` reverse_iterator;
  66. typedef ``['-unspecified-]`` const_reverse_iterator;
  67. typedef ``['-unspecified-]`` info_type;
  68. // construct / copy / destroy
  69. this_type & operator=(this_type & x);
  70. template< class InputIterator >
  71. void ``[link reference_vector_of_assign_iterator_iterator assign]``(InputIterator first, InputIterator last);
  72. void ``[link reference_vector_of_assign_size_value assign]``(size_type n, const value_type & value);
  73. allocator_type get_allocator() const;
  74. // iterators
  75. iterator begin();
  76. const_iterator begin() const;
  77. iterator end();
  78. const_iterator end() const;
  79. reverse_iterator rbegin();
  80. const_reverse_iterator rbegin() const;
  81. reverse_iterator rend();
  82. const_reverse_iterator rend() const;
  83. // capacity
  84. bool empty() const;
  85. size_type size() const;
  86. size_type max_size() const;
  87. size_type ``[link reference_vector_of_capacity capacity]``() const;
  88. void ``[link reference_vector_of_reserve_size reserve]``(size_type m);
  89. void ``[link reference_vector_of_resize_size_value resize]``(size_type n, const value_type & x = value_type());
  90. // access
  91. const_reference operator[](size_type n) const;
  92. const_reference at(size_type n) const;
  93. const_reference front() const;
  94. const_reference back() const;
  95. // modifiers
  96. std::pair<iterator,bool> ``[link reference_vector_of_push_front_value push_front]``(const value_type & x);
  97. void pop_front();
  98. std::pair<iterator,bool> ``[link reference_vector_of_push_back_value push_back]``(const value_type & x);
  99. void pop_back();
  100. std::pair<iterator,bool> ``[link reference_vector_of_insert_iterator_value insert]``(iterator position, const value_type & x);
  101. void ``[link reference_vector_of_insert_iterator_size_value insert]``(iterator position, size_type m, const value_type & x);
  102. template< class InputIterator>
  103. void ``[link reference_vector_of_insert_iterator_iterator_iterator insert]``(iterator position, InputIterator first, InputIterator last);
  104. iterator ``[link reference_vector_of_erase_iterator erase]``(iterator position);
  105. iterator ``[link reference_vector_of_erase_iterator_iterator erase]``(iterator first, iterator last);
  106. bool ``[link reference_vector_of_replace_iterator_value replace]``(iterator position, const value_type & x);
  107. // Only in map views
  108. // {
  109. typedef ``['-unspecified-]`` key_type;
  110. typedef ``['-unspecified-]`` mapped_type;
  111. typedef ``['-unspecified-]`` data_type; // Equal to mapped_type
  112. template< class CompatibleKey >
  113. bool ``[link reference_vector_of_replace_key_iterator_key replace_key]``(iterator position, const CompatibleKey & x);
  114. template< class CompatibleData >
  115. bool ``[link reference_vector_of_replace_data_iterator_data replace_data]``(iterator position, const CompatibleData & x);
  116. template< class KeyModifier >
  117. bool ``[link reference_vector_of_modify_key_iterator_modifier modify_key]``(iterator position, KeyModifier mod);
  118. template< class DataModifier >
  119. bool ``[link reference_vector_of_modify_data_iterator_modifier modify_data]``(iterator position, DataModifier mod);
  120. // }
  121. void clear();
  122. // list operations
  123. void ``[link reference_vector_of_splice_iterator_this splice]``(iterator position, this_type & x);
  124. void ``[link reference_vector_of_splice_iterator_this_iterator splice]``(iterator position, this_type & x, iterator i);
  125. void ``[link reference_vector_of_splice_iterator_this_iterator_iterator splice]``(
  126. iterator position, this_type & x, iterator first, iterator last);
  127. void ``[link reference_vector_of_remove_value remove]``(const value_type & value);
  128. template< class Predicate >
  129. void ``[link reference_vector_of_remove_if_predicate remove_if]``(Predicate pred);
  130. void ``[link reference_vector_of_unique unique]``();
  131. template< class BinaryPredicate >
  132. void ``[link reference_vector_of_unique_predicate unique]``(BinaryPredicate binary_pred);
  133. void ``[link reference_vector_of_merge_this merge]``(this_type & x);
  134. template< typename Compare >
  135. void ``[link reference_vector_of_merge_this_compare merge]``(this_type & x, Compare comp);
  136. void ``[link reference_vector_of_sort sort]``();
  137. template< typename Compare >
  138. void ``[link reference_vector_of_sort_compare sort]``(Compare comp);
  139. void ``[link reference_vector_of_reverse reverse]``();
  140. // rearrange operations
  141. void ``[link reference_vector_of_relocate_iterator_iterator relocate]``(iterator position, iterator i);
  142. void ``[link reference_vector_of_relocate_iterator_iterator_iterator relocate]``(iterator position, iterator first, iterator last);
  143. };
  144. // view comparison
  145. bool operator==(const this_type & v1, const this_type & v2 );
  146. bool operator< (const this_type & v1, const this_type & v2 );
  147. bool operator!=(const this_type & v1, const this_type & v2 );
  148. bool operator> (const this_type & v1, const this_type & v2 );
  149. bool operator>=(const this_type & v1, const this_type & v2 );
  150. bool operator<=(const this_type & v1, const this_type & v2 );
  151. } // namespace views
  152. } // namespace bimap
  153. } // namespace boost
  154. In the case of a `bimap< vector_of<Left>, ... >`
  155. In the set view:
  156. typedef signature-compatible with relation< Left, ... > key_type;
  157. typedef signature-compatible with relation< Left, ... > value_type;
  158. In the left map view:
  159. typedef Left key_type;
  160. typedef ... mapped_type;
  161. typedef signature-compatible with std::pair< Left, ... > value_type;
  162. In the right map view:
  163. typedef ... key_type;
  164. typedef Left mapped_type;
  165. typedef signature-compatible with std::pair< ... , Left > value_type;
  166. [#vector_of_complexity_signature]
  167. [section Complexity signature]
  168. Here and in the descriptions of operations of `vector_of` views, we adopt
  169. the scheme outlined in the
  170. [link complexity_signature_explanation complexity signature section].
  171. The complexity signature of `vector_of` view is:
  172. * copying: `c(n) = n * log(n)`,
  173. * insertion: `i(n) = 1` (amortized constant),
  174. * hinted insertion: `h(n) = 1` (amortized constant),
  175. * deletion: `d(n) = m`, where m is the distance from the deleted element to the
  176. end of the sequence,
  177. * replacement: `r(n) = 1` (constant),
  178. * modifying: `m(n) = 1` (constant).
  179. The following expressions are also used as a convenience for writing down some
  180. of the complexity formulas:
  181. [blurb
  182. `shl(a,b) = a+b` if a is nonzero, 0 otherwise.
  183. `rel(a,b,c) =` if `a<b`, `c-a`, else `a-b`,
  184. ]
  185. (`shl` and `rel` stand for ['shift left] and ['relocate], respectively.)
  186. [endsect]
  187. [section Instantiation types]
  188. `vector_of` views are instantiated internally to `bimap` and specified
  189. by means of the collection type specifiers and the bimap itself.
  190. Instantiations are dependent on the following types:
  191. * `Value` from `vector_of`,
  192. * `Allocator` from `bimap`,
  193. [endsect]
  194. [section Constructors, copy and assignment]
  195. As explained in the views concepts section,
  196. views do not have public constructors or destructors.
  197. Assignment, on the other hand, is provided.
  198. this_type & operator=(const this_type & x);
  199. * [*Effects: ] `a=b;`
  200. where a and b are the `bimap` objects to which `*this` and
  201. `x` belong, respectively.
  202. * [*Returns: ] `*this`.
  203. [#reference_vector_of_assign_iterator_iterator]
  204. template< class InputIterator >
  205. void assign(InputIterator first, InputIterator last);
  206. * [*Requires: ] `InputIterator` is a model of __SGI_INPUT_ITERATOR__ over elements
  207. of type `value_type` or a type convertible to `value_type`. `first` and `last` are
  208. not iterators into any view of the `bimap` to which this
  209. view belongs. `last` is reachable from `first`.
  210. * [*Effects: ] `clear(); insert(end(),first,last);`
  211. [#reference_vector_of_assign_size_value]
  212. void assign(size_type n, const value_type & value);
  213. * [*Effects: ] `clear(); for(size_type i = 0; i < n; ++n) push_back(v);`
  214. [endsect]
  215. [section Capacity operations]
  216. [#reference_vector_of_capacity]
  217. size_type capacity() const;
  218. * [*Returns:] The total number of elements `c` such that, when `size() < c`,
  219. back insertions happen in constant time (the general case as described by
  220. i(n) is ['amortized] constant time.)
  221. * [*Note:] Validity of iterators and references to elements is preserved
  222. in all insertions, regardless of the capacity status.
  223. [#reference_vector_of_reserve_size]
  224. void reserve(size_type m);
  225. * [*Effects:] If the previous value of `capacity()` was greater than or equal
  226. to `m`, nothing is done; otherwise, the internal capacity is changed so that
  227. `capacity()>=m`.
  228. * [*Complexity:] If the capacity is not changed, constant; otherwise O(n).
  229. * [*Exception safety:] If the capacity is not changed, nothrow; otherwise, strong.
  230. [#reference_vector_of_resize_size_value]
  231. void resize(size_type n, const value_type & x = value_type());
  232. * [*Effects: ] `if( n > size() ) insert(end(), n-size(), x);`
  233. `else if( n<size() ) erase(begin()+n,end());`
  234. * [*Note:] If an expansion is requested, the size of the view is not guaranteed
  235. to be n after this operation (other views may ban insertions.)
  236. [endsect]
  237. [section Modifiers]
  238. [#reference_vector_of_push_front_value]
  239. std::pair<iterator,bool> push_front(const value_type & x);
  240. * [*Effects:] Inserts x at the beginning of the sequence if no other view
  241. of the `bimap` bans the insertion.
  242. * [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only if
  243. insertion took place. On successful insertion, `p.first` points to the element
  244. inserted; otherwise, `p.first` points to an element that caused the insertion
  245. to be banned. Note that more than one element can be causing insertion not
  246. to be allowed.
  247. * [link vector_of_complexity_signature [*Complexity:]] O(n+I(n)).
  248. * [*Exception safety:] Strong.
  249. [#reference_vector_of_push_back_value]
  250. std::pair<iterator,bool> push_back(const value_type & x);
  251. * [*Effects:] Inserts `x` at the end of the sequence if no other view of
  252. the `bimap` bans the insertion.
  253. * [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only
  254. if insertion took place. On successful insertion, `p.first` points to the
  255. element inserted; otherwise, `p.first` points to an element that caused
  256. the insertion to be banned. Note that more than one element can be
  257. causing insertion not to be allowed.
  258. * [link vector_of_complexity_signature [*Complexity:]] O(I(n)).
  259. * [*Exception safety:] Strong.
  260. [#reference_vector_of_insert_iterator_value]
  261. std::pair<iterator,bool> insert(iterator position, const value_type & x);
  262. * [*Requires: ] `position` is a valid iterator of the view.
  263. * [*Effects:] Inserts `x` before position if insertion is allowed by all
  264. other views of the `bimap`.
  265. * [*Returns:] The return value is a pair `p`. `p.second` is `true` if and only
  266. if insertion took place. On successful insertion, `p.first` points to the
  267. element inserted; otherwise, `p.first` points to an element that caused the
  268. insertion to be banned. Note that more than one element can be causing
  269. insertion not to be allowed.
  270. * [link vector_of_complexity_signature [*Complexity:]] O(shl(end()-position,1) + I(n)).
  271. * [*Exception safety:] Strong.
  272. [#reference_vector_of_insert_iterator_size_value]
  273. void insert(iterator position, size_type m, const value_type & x);
  274. * [*Requires: ] `position` is a valid iterator of the view.
  275. * [*Effects: ] `for(size_type i = 0; i < m; ++i) insert(position, x);`
  276. * [link vector_of_complexity_signature
  277. [*Complexity:]] O(shl(end()-position,m) + m*I(n+m)).
  278. [#reference_vector_of_insert_iterator_iterator_iterator]
  279. template< class InputIterator >
  280. void insert(iterator position, InputIterator first, InputIterator last);
  281. * [*Requires: ] `position` is a valid iterator of the view. `InputIterator`
  282. is a model of __SGI_INPUT_ITERATOR__ over elements of type `value_type` or a type
  283. convertible to `value_type`. `first` and `last` are not iterators into any view
  284. of the `bimap` to which this view belongs. `last` is reachable
  285. from `first`.
  286. * [*Effects: ] `while(first!=last)insert(position,*first++);`
  287. * [link vector_of_complexity_signature
  288. [*Complexity:]] O(shl(end()-position,m) + m*I(n+m)), where m is the number
  289. of elements in `[first,last)`.
  290. * [*Exception safety:] Basic.
  291. [#reference_vector_of_erase_iterator]
  292. iterator erase(iterator position);
  293. * [*Requires: ] `position` is a valid dereferenceable iterator of the view.
  294. * [*Effects:] Deletes the element pointed to by `position`.
  295. * [*Returns:] An iterator pointing to the element immediately following the
  296. one that was deleted, or `end()` if no such element exists.
  297. * [link vector_of_complexity_signature [*Complexity:]] O(D(n)).
  298. * [*Exception safety:] nothrow.
  299. [#reference_vector_of_erase_iterator_iterator]
  300. iterator erase(iterator first, iterator last);
  301. * [*Requires: ] `[first,last)` is a valid range of the view.
  302. * [*Effects:] Deletes the elements in `[first,last)`.
  303. * [*Returns:] last.
  304. * [link vector_of_complexity_signature
  305. [*Complexity:]] O(m*D(n)), where m is the number of elements in `[first,last)`.
  306. * [*Exception safety:] nothrow.
  307. [#reference_vector_of_replace_iterator_value]
  308. bool replace(iterator position, const value_type & x);
  309. * [*Requires: ] `position` is a valid dereferenceable iterator of the view.
  310. * [*Effects:] Assigns the value x to the element pointed to by position into
  311. the `bimap` to which the view belongs if replacing is allowed
  312. by all other views of the `bimap`.
  313. * [*Postconditions:] Validity of position is preserved in all cases.
  314. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  315. * [link vector_of_complexity_signature
  316. [*Complexity:]] O(R(n)).
  317. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  318. operation the `bimap` to which the view belongs remains in its
  319. original state.
  320. [#reference_vector_of_replace_key_iterator_key]
  321. template< class CompatibleKey >
  322. bool replace_key(iterator position, const CompatibleKey & x);
  323. * [*Requires: ] `position` is a valid dereferenceable iterator of the set view.
  324. `CompatibleKey` can be assigned to `key_type`.
  325. * [*Effects:] Assigns the value `x` to `e.first`, where `e` is the element pointed
  326. to by `position` into the `bimap` to which the set view belongs if replacing is allowed by
  327. all other views of the `bimap`.
  328. * [*Postconditions:] Validity of position is preserved in all cases.
  329. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  330. * [link vector_of_complexity_signature
  331. [*Complexity:]] O(R(n)).
  332. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  333. operation, the `bimap` to which the set view belongs remains in
  334. its original state.
  335. [#reference_vector_of_replace_data_iterator_data]
  336. template< class CompatibleData >
  337. bool replace_data(iterator position, const CompatibleData & x);
  338. * [*Requires: ] `position` is a valid dereferenceable iterator of the set view.
  339. `CompatibleKey` can be assigned to `mapped_type`.
  340. * [*Effects:] Assigns the value `x` to `e.second`, where `e` is the element pointed
  341. to by `position` into the `bimap` to which the set view belongs if replacing is allowed by
  342. all other views of the `bimap`.
  343. * [*Postconditions:] Validity of position is preserved in all cases.
  344. * [*Returns: ] `true` if the replacement took place, `false` otherwise.
  345. * [link vector_of_complexity_signature
  346. [*Complexity:]] O(R(n)).
  347. * [*Exception safety:] Strong. If an exception is thrown by some user-provided
  348. operation, the `bimap` to which the set view belongs remains in
  349. its original state.
  350. [#reference_vector_of_modify_key_iterator_modifier]
  351. template< class KeyModifier >
  352. bool modify_key(iterator position, KeyModifier mod);
  353. * [*Requires: ] `KeyModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of
  354. type: `key_type&`; `position` is a valid dereferenceable iterator of the view.
  355. * [*Effects:] Calls `mod(e.first)` where e is the element pointed to by position and
  356. rearranges `*position` into all the views of the `bimap`.
  357. If the rearrangement fails, the element is erased.
  358. It is successful if the rearrangement is allowed by all other views of the `bimap`.
  359. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  360. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  361. * [link vector_of_complexity_signature
  362. [*Complexity:]] O(M(n)).
  363. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  364. operation (except possibly mod), then the element pointed to by position is erased.
  365. * [*Note:] Only provided for map views.
  366. [#reference_vector_of_modify_data_iterator_modifier]
  367. template< class DataModifier >
  368. bool modify_data(iterator position, DataModifier mod);
  369. * [*Requires: ] `DataModifier` is a model of __SGI_UNARY_FUNCTION__ accepting arguments of
  370. type: `mapped_type&`; `position` is a valid dereferenceable iterator of the view.
  371. * [*Effects:] Calls `mod(e.second)` where e is the element pointed to by position and
  372. rearranges `*position` into all the views of the `bimap`.
  373. If the rearrangement fails, the element is erased.
  374. It is successful if the rearrangement is allowed by all other views of the `bimap`.
  375. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  376. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  377. * [link vector_of_complexity_signature
  378. [*Complexity:]] O(M(n)).
  379. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  380. operation (except possibly mod), then the element pointed to by position is erased.
  381. * [*Note:] Only provided for map views.
  382. [/
  383. [#reference_vector_of_modify_iterator_modifier]
  384. template< class Modifier >
  385. bool modify(iterator position, Modifier mod);
  386. * [*Requires: ] `Modifier` is a model of __SGI_BINARY_FUNCTION__ accepting arguments of
  387. type: `first_type&` and `second_type&` for ['Map View] or `left_type&` and `right_type&`
  388. for ['Set View]; `position` is a valid dereferenceable iterator of the view.
  389. * [*Effects:] Calls `mod(e.first,e.second)` for ['Map View:] or calls `mod(e.left,e.right)`
  390. for ['Set View] where e is the element pointed to by `position` and
  391. rearranges `*position` into all the views of the `bimap`.
  392. Rearrangement on `vector_of` views does not change the position of the
  393. element with respect to the view; rearrangement on other views may or
  394. might not suceed. If the rearrangement fails, the element is erased.
  395. * [*Postconditions:] Validity of `position` is preserved if the operation succeeds.
  396. * [*Returns: ] `true` if the operation succeeded, `false` otherwise.
  397. * [link vector_of_complexity_signature [*Complexity:]] O(M(n)).
  398. * [*Exception safety:] Basic. If an exception is thrown by some user-provided
  399. operation (except possibly `mod`), then the element pointed to by position
  400. is erased.
  401. ]
  402. [endsect]
  403. [section List operations]
  404. `vector_of` views replicate the interface of `list_of` views, which
  405. in turn includes the list operations provided by `std::list`. The syntax and
  406. behavior of these operations exactly matches those of `list_of` views, but
  407. the associated complexity bounds differ in general.
  408. [#reference_vector_of_splice_iterator_this]
  409. void splice(iterator position, this_type & x);
  410. * [*Requires: ] `position` is a valid iterator of the view. `&x!=this`.
  411. * [*Effects:] Inserts the contents of `x` before position, in the same order
  412. as they were in `x`. Those elements successfully inserted are erased from `x`.
  413. * [link vector_of_complexity_signature
  414. [*Complexity:]] O(shl(end()-position,x.size()) + x.size()*I(n+x.size()) + x.size()*D(x.size())).
  415. * [*Exception safety:] Basic.
  416. [#reference_vector_of_splice_iterator_this_iterator]
  417. void splice(iterator position, this_type & x,iterator i);
  418. * [*Requires: ] `position` is a valid iterator of the view. `i` is a valid
  419. dereferenceable iterator `x`.
  420. * [*Effects:] Inserts the element pointed to by `i` before `position`: if
  421. insertion is successful, the element is erased from `x`. In the special
  422. case `&x==this`, no copy or deletion is performed, and the operation is
  423. always successful. If `position==i`, no operation is performed.
  424. * [*Postconditions:] If `&x==this`, no iterator or reference is invalidated.
  425. * [link vector_of_complexity_signature
  426. [*Complexity:]] If `&x==this`, O(rel(position,i,i+1));
  427. otherwise O(shl(end()-position,1) + I(n) + D(n)).
  428. * [*Exception safety:] If `&x==this`, nothrow; otherwise, strong.
  429. [#reference_vector_of_splice_iterator_this_iterator_iterator]
  430. void splice(iterator position, this_type & x, iterator first, iterator last);
  431. * [*Requires: ] `position` is a valid iterator of the view. `first` and
  432. `last` are valid iterators of `x`. `last` is reachable from `first`. `position` is
  433. not in the range `[first,last)`.
  434. * [*Effects:] For each element in the range `[first,last)`, insertion is
  435. tried before `position`; if the operation is successful, the element is
  436. erased from `x`. In the special case `&x==this`, no copy or deletion is
  437. performed, and insertions are always successful.
  438. * [*Postconditions:] If `&x==this`, no iterator or reference is invalidated.
  439. * [link vector_of_complexity_signature
  440. [*Complexity:]] If `&x==this`, O(rel(position,first,last));
  441. otherwise O(shl(end()-position,m) + m*I(n+m) + m*D(x.size()))
  442. where m is the number of elements in `[first,last)`.
  443. * [*Exception safety:] If `&x==this`, nothrow; otherwise, basic.
  444. [#reference_vector_of_remove_value]
  445. void remove(const value_type & value);
  446. * [*Effects:] Erases all elements of the view which compare equal to `value`.
  447. * [link vector_of_complexity_signature
  448. [*Complexity:]] O(n + m*D(n)), where m is the number of elements erased.
  449. * [*Exception safety:] Basic.
  450. [#reference_vector_of_remove_if_predicate]
  451. template< class Predicate >
  452. void remove_if(Predicate pred);
  453. * [*Effects:] Erases all elements `x` of the view for which `pred(x)` holds.
  454. * [link vector_of_complexity_signature
  455. [*Complexity:]] O(n + m*D(n)), where m is the number of elements erased.
  456. * [*Exception safety:] Basic.
  457. [#reference_vector_of_unique]
  458. void unique();
  459. * [*Effects:] Eliminates all but the first element from every consecutive
  460. group of equal elements referred to by the iterator `i` in the range
  461. `[first+1,last)` for which `*i==*(i-1)`.
  462. * [link vector_of_complexity_signature
  463. [*Complexity:]] O(n + m*D(n)), where m is the number of elements erased.
  464. * [*Exception safety:] Basic.
  465. [#reference_vector_of_unique_predicate]
  466. template< class BinaryPredicate >
  467. void unique(BinaryPredicate binary_pred);
  468. * [*Effects:] Eliminates all but the first element from every consecutive
  469. group of elements referred to by the iterator i in the range `[first+1,last)`
  470. for which `binary_pred(*i, *(i-1))` holds.
  471. * [link vector_of_complexity_signature
  472. [*Complexity:]] O(n + m*D(n)), where m is the number of elements erased.
  473. * [*Exception safety:] Basic.
  474. [#reference_vector_of_merge_this]
  475. void merge(this_type & x);
  476. * [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over
  477. `value_type`. Both the view and `x` are sorted according to `std::less<value_type>`.
  478. * [*Effects:] Attempts to insert every element of x into the corresponding
  479. position of the view (according to the order). Elements successfully
  480. inserted are erased from `x`. The resulting sequence is stable, i.e. equivalent
  481. elements of either container preserve their relative position. In the special
  482. case `&x==this`, no operation is performed.
  483. * [*Postconditions:] Elements in the view and remaining elements in `x` are
  484. sorted. Validity of iterators to the view and of non-erased elements of `x`
  485. references is preserved.
  486. * [link vector_of_complexity_signature
  487. [*Complexity:]] If `&x==this`, constant;
  488. otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())).
  489. * [*Exception safety:] If `&x==this`, nothrow; otherwise, basic.
  490. [#reference_vector_of_merge_this_compare]
  491. template< class Compare >
  492. void merge(this_type & x, Compare comp);
  493. * [*Requires: ] `Compare` is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`.
  494. Both the view and `x` are sorted according to comp.
  495. * [*Effects:] Attempts to insert every element of `x` into the corresponding
  496. position of the view (according to `comp`). Elements successfully inserted
  497. are erased from `x`. The resulting sequence is stable, i.e. equivalent
  498. elements of either container preserve their relative position. In the
  499. special case `&x==this`, no operation is performed.
  500. * [*Postconditions:] Elements in the view and remaining elements in `x` are
  501. sorted according to `comp`. Validity of iterators to the view and of
  502. non-erased elements of `x` references is preserved.
  503. * [link vector_of_complexity_signature
  504. [*Complexity:]] If `&x==this`, constant;
  505. otherwise O(n + x.size()*I(n+x.size()) + x.size()*D(x.size())).
  506. * [*Exception safety:] If `&x==this`, nothrow; otherwise, basic.
  507. [#reference_vector_of_sort]
  508. void sort();
  509. * [*Requires: ] `std::less<value_type>` is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`.
  510. * [*Effects:] Sorts the view according to `std::less<value_type>`.
  511. The sorting is stable, i.e. equivalent elements preserve their relative position.
  512. * [*Postconditions:] Validity of iterators and references is preserved.
  513. * [*Complexity:] O(n*log(n)).
  514. * [*Exception safety:] Basic.
  515. [#reference_vector_of_sort_compare]
  516. template< class Compare >
  517. void sort(Compare comp);
  518. * [*Requires:] Compare is a __SGI_STRICT_WEAK_ORDERING__ over `value_type`.
  519. * [*Effects:] Sorts the view according to `comp`. The sorting is stable, i.e.
  520. equivalent elements preserve their relative position.
  521. * [*Postconditions:] Validity of iterators and references is preserved.
  522. * [*Complexity:] O(n*log(n)).
  523. * [*Exception safety:] Basic.
  524. [#reference_vector_of_reverse]
  525. void reverse();
  526. * [*Effects:] Reverses the order of the elements in the view.
  527. * [*Postconditions:] Validity of iterators and references is preserved.
  528. * [*Complexity:] O(n).
  529. * [*Exception safety:] nothrow.
  530. [endsect]
  531. [section Rearrange operations]
  532. These operations, without counterpart in `std::list` (although splice provides
  533. partially overlapping functionality), perform individual and global repositioning
  534. of elements inside the index.
  535. [#reference_vector_of_relocate_iterator_iterator]
  536. void relocate(iterator position, iterator i);
  537. * [*Requires: ] `position` is a valid iterator of the view. `i` is a valid
  538. dereferenceable iterator of the view.
  539. * [*Effects:] Inserts the element pointed to by `i` before `position`.
  540. If `position==i`, no operation is performed.
  541. * [*Postconditions:] No iterator or reference is invalidated.
  542. * [*Complexity:] Constant.
  543. * [*Exception safety:] nothrow.
  544. [#reference_vector_of_relocate_iterator_iterator_iterator]
  545. void relocate(iterator position, iterator first, iterator last);
  546. * [*Requires: ] `position` is a valid iterator of the view. `first` and `last` are
  547. valid iterators of the view. `last` is reachable from `first`. `position` is not
  548. in the range `[first,last)`.
  549. * [*Effects:] The range of elements `[first,last)` is repositioned just before
  550. `position`.
  551. * [*Postconditions:] No iterator or reference is invalidated.
  552. * [*Complexity:] Constant.
  553. * [*Exception safety:] nothrow.
  554. [endsect]
  555. [section Serialization]
  556. Views cannot be serialized on their own, but only as part of the `bimap`
  557. into which they are embedded. In describing the additional preconditions and guarantees
  558. associated to `vector_of` views with respect to serialization of their embedding
  559. containers, we use the concepts defined in the `bimap` serialization section.
  560. [blurb [*Operation:] saving of a `bimap` b to an output archive (XML archive) ar.]
  561. * [*Requires:] No additional requirements to those imposed by the container.
  562. [blurb [*Operation:] loading of a `bimap` b' from an input archive (XML archive) ar.]
  563. * [*Requires:] No additional requirements to those imposed by the container.
  564. * [*Postconditions:] On successful loading, each of the elements of `[begin(), end())` is a
  565. restored copy of the corresponding element in `[m.get<i>().begin(), m.get<i>().end())`,
  566. where `i` is the position of the `vector_of` view in the container.
  567. [blurb [*Operation:] saving of an `iterator` or `const_iterator` `it` to an output archive (XML archive) ar.]
  568. * [*Requires: ] `it` is a valid iterator of the view. The associated `bimap`
  569. has been previously saved.
  570. [blurb [*Operation:] loading of an `iterator` or `const_iterator` `it`' from an input archive (XML archive) ar.]
  571. * [*Postconditions:] On successful loading, if it was dereferenceable then `*it`' is the
  572. restored copy of `*it`, otherwise `it`'`==end()`.
  573. * [*Note:] It is allowed that it be a `const_iterator` and the restored `it`' an `iterator`,
  574. or viceversa.
  575. [endsect]
  576. [endsect]
  577. [endsect]