associative_ptr_container.rst 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. ++++++++++++++++++++++++++++++++++
  2. |Boost| Pointer Container Library
  3. ++++++++++++++++++++++++++++++++++
  4. .. |Boost| image:: boost.png
  5. Class ``associative_ptr_container``
  6. -------------------------------------
  7. This section describes all the common operations for all associative
  8. pointer containers (in addition to ``reversible_ptr_container``).
  9. **Hierarchy:**
  10. - `reversible_ptr_container <reversible_ptr_container.html>`_
  11. - ``associative_ptr_container``
  12. - `ptr_set_adapter <ptr_set_adapter.html>`_
  13. - `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
  14. - `ptr_map_adapter <ptr_map_adapter.html>`_
  15. - `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
  16. - `ptr_set <ptr_set.html>`_
  17. - `ptr_multi_set <ptr_multiset.html>`_
  18. - `ptr_map <ptr_map.html>`_
  19. - `ptr_multimap <ptr_multimap.html>`_
  20. **See also:**
  21. - `iterator_range <http://www.boost.org/libs/range/doc/utility_class.html#iter_range>`_
  22. **Navigate:**
  23. - `home <ptr_container.html>`_
  24. - `reference <reference.html>`_
  25. **Synopsis:**
  26. .. parsed-literal::
  27. namespace boost
  28. {
  29. template
  30. <
  31. class Key,
  32. class CloneAllocator = heap_clone_allocator
  33. >
  34. class associative_ptr_container
  35. {
  36. public: // typedefs_
  37. typedef ... key_type;
  38. typedef ... key_compare;
  39. typedef ... value_compare;
  40. public: // `observers`_
  41. key_compare key_comp() const;
  42. value_compare value_comp() const;
  43. public: // `modifiers`_
  44. template< typename InputIterator >
  45. void insert( InputIterator first, InputIterator last );
  46. template< class InputRange >
  47. void insert( const InputRange& r );
  48. void erase( iterator position );
  49. size_type erase( const key_type& x );
  50. template< class Range >
  51. void erase( const Range& r );
  52. void erase( iterator first, iterator last );
  53. public: // `algorithms`_
  54. iterator find( const key_type& x );
  55. const_iterator find( const key_type& x ) const;
  56. size_type count( const key_type& x ) const;
  57. iterator lower_bound( const key_type& x );
  58. const_iterator lower_bound( const key_type& x ) const;
  59. iterator upper_bound( const key_type& x );
  60. const_iterator upper_bound( const key_type& x ) const;
  61. iterator_range<iterator> equal_range( const key_type& x );
  62. iterator_range<const_iterator> equal_range( const key_type& x ) const;
  63. }; // class 'associative_ptr_container'
  64. } // namespace 'boost'
  65. Semantics
  66. ---------
  67. .. _typedefs:
  68. Semantics: typedefs
  69. ^^^^^^^^^^^^^^^^^^^
  70. - ``typedef ... key_type;``
  71. - if we are dealing with a map, then simply the key type
  72. - if we are dealing with a set, then the *indirected* key type, that is,
  73. given ``ptr_set<T>``, ``key_type*`` will be ``T*``.
  74. - ``typedef ... key_compare;``
  75. - comparison object type that determines the order of elements in the container
  76. - ``typedef ... value_compare;``
  77. - comparison object type that determines the order of elements in the container
  78. - if we are dealing with a map, then this comparison simply forwards to the ``key_compare`` comparison operation
  79. .. _`observers`:
  80. Semantics: observers
  81. ^^^^^^^^^^^^^^^^^^^^
  82. - ``key_compare key_comp() const;``
  83. - ``value_compare value_comp() const;``
  84. - returns copies of objects used to determine the order of elements
  85. .. _`modifiers`:
  86. Semantics: modifiers
  87. ^^^^^^^^^^^^^^^^^^^^
  88. - ``template< typename InputIterator >
  89. void insert( InputIterator first, InputIterator last );``
  90. - Requirements: ``[first,last)`` is a valid range
  91. - Effects: Inserts a cloned range
  92. - Exception safety: Basic guarantee
  93. - ``template< class InputRange >
  94. void insert( const InputRange& r );``
  95. - Effects: ``insert( boost::begin(r), boost::end(r) );``
  96. - ``void erase( iterator position );``
  97. - Requirements: ``position`` is a valid iterator from the container
  98. - Effects: Removes the element defined by ``position``.
  99. - Throws: Nothing
  100. - ``size_type erase( const key_type& x );``
  101. - Effects: Removes all the elements in the container with a key equivalent to ``x`` and returns the number of erased elements.
  102. - Throws: Nothing
  103. - ``void erase( iterator first, iterator last );``
  104. - Requirements: ``[first,last)`` is a valid range
  105. - Effects: Removes the range of elements defined by ``[first,last)``.
  106. - Throws: Nothing
  107. - ``template< class Range > void erase( const Range& r );``
  108. - Effects: ``erase( boost::begin(r), boost::end(r) );``
  109. .. _`algorithms`:
  110. Semantics: algorithms
  111. ^^^^^^^^^^^^^^^^^^^^^
  112. - ``iterator find( const Key& x );``
  113. - ``const_iterator find( const Key& x ) const;``
  114. - Effects: Searches for the key and returns ``end()`` on failure.
  115. - Complexity: Logarithmic
  116. - ``size_type count( const Key& x ) const;``
  117. - Effects: Counts the elements with a key equivalent to ``x``
  118. - Complexity: Logarithmic
  119. - ``iterator lower_bound( const Key& x );``
  120. - ``const_iterator lower_bound( const Key& x ) const;``
  121. - Effects: Returns an iterator pointing to the first element with a key not less than ``x``
  122. - Complexity: Logarithmic
  123. - ``iterator upper_bound( const Key& x );``
  124. - ``const_iterator upper_bound( const Key& x ) const;``
  125. - Effects: Returns an iterator pointing to the first element with a key greater than ``x``
  126. - Complexity: Logarithmic
  127. - ``iterator_range<iterator> equal_range( const Key& x );``
  128. - ``iterator_range<const_iterator> equal_range( const Key& x ) const;``
  129. - Effects: ``return boost::make_iterator_range( lower_bound( x ), upper_bound( x ) );``
  130. - Complexity: Logarithmic
  131. ..
  132. - ``reference at( const key_type& key );``
  133. - ``const_reference at( const key_type& key ) const;``
  134. - Requirements: the key exists
  135. - Effects: returns the object with key ``key``
  136. - Throws: ``bad_ptr_container_operation`` if the key does not exist
  137. .. _`pointer container requirements`:
  138. .. raw:: html
  139. <hr>
  140. :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
  141. __ http://www.boost.org/LICENSE_1_0.txt