ptr_set_adapter.rst 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. ++++++++++++++++++++++++++++++++++
  2. |Boost| Pointer Container Library
  3. ++++++++++++++++++++++++++++++++++
  4. .. |Boost| image:: boost.png
  5. Class ``ptr_set_adapter``
  6. -------------------------
  7. This class is used to build custom pointer containers with
  8. an underlying set-like container. The interface of the class is an extension
  9. of the interface from ``associative_ptr_container``.
  10. **Hierarchy:**
  11. - `reversible_ptr_container <reversible_ptr_container.html>`_
  12. - `associative_ptr_container <associative_ptr_container.html>`_
  13. - ``ptr_set_adapter``
  14. - `ptr_multiset_adapter <ptr_multiset_adapter.html>`_
  15. - `ptr_map_adapter <ptr_map_adapter.html>`_
  16. - `ptr_multi_map_adapter <ptr_multimap_adapter.html>`_
  17. - `ptr_set <ptr_set.html>`_
  18. - `ptr_multi_set <ptr_multiset.html>`_
  19. - `ptr_map <ptr_map.html>`_
  20. - `ptr_multimap <ptr_multimap.html>`_
  21. **Navigate:**
  22. - `home <ptr_container.html>`_
  23. - `reference <reference.html>`_
  24. .. _reversible_ptr_container: reversible_ptr_container.html
  25. .. _associative_ptr_container: associative_ptr_container.html
  26. .. _ptr_set: ptr_set.html
  27. **Synopsis:**
  28. .. parsed-literal::
  29. namespace boost
  30. {
  31. template
  32. <
  33. class Key,
  34. class VoidPtrSet,
  35. class CloneAllocator = heap_clone_allocator
  36. >
  37. class ptr_set_adapter
  38. {
  39. public: // `modifiers`_
  40. std::pair<iterator,bool> insert( Key* x );
  41. template< class Key2 >
  42. std::pair<iterator,bool> insert( compatible-smart-ptr<Key2> x );
  43. public: // `pointer container requirements`_
  44. bool transfer( iterator object, ptr_set_adapter& from );
  45. size_type transfer( iterator first, iterator last, ptr_set_adapter& from );
  46. template< class Range >
  47. size_type transfer( const Range& r, ptr_set_adapter& from );
  48. size_type transfer( ptr_set_adapter& from );
  49. }; // class 'ptr_set_adapter'
  50. } // namespace 'boost'
  51. Semantics
  52. ---------
  53. .. _`modifiers`:
  54. Semantics: modifiers
  55. ^^^^^^^^^^^^^^^^^^^^
  56. - ``std::pair<iterator,bool> insert( key_type* x );``
  57. - Requirements: ``x != 0``
  58. - Effects: Takes ownership of ``x`` and insert it if there is no equivalent of it already. The ``bool`` part of the return value indicates insertion and the iterator points to the element with key ``x``.
  59. - Throws: bad_pointer if ``x == 0``
  60. - Exception safety: Strong guarantee
  61. - ``template< class Key2 > std::pair<iterator,bool> insert( compatible-smart-ptr<Key2> x );``
  62. - Effects: ``return insert( x.release() );``
  63. ..
  64. - ``std::pair<iterator,bool> insert( const key_type& x );``
  65. - Effects: ``return insert( allocate_clone( x ) );``
  66. - Exception safety: Strong guarantee
  67. .. _`pointer container requirements`:
  68. Semantics: pointer container requirements
  69. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  70. - ``bool transfer( iterator object, ptr_set_adapter& from );``
  71. - Requirements: ``not from.empty()``
  72. - Effects: Inserts the object defined by ``object`` into the container and remove it from ``from``
  73. iff no equivalent object exists.
  74. - Returns: whether the object was transfered
  75. - Exception safety: Strong guarantee
  76. - ``void transfer( iterator first, iterator last, ptr__set_adapter& from );``
  77. - Requirements: ``not from.empty()``
  78. - Effects: Inserts the objects defined by the range ``[first,last)`` into the container and remove it from ``from``.
  79. An object is only transferred if no equivalent object exists.
  80. - Returns: the number of transfered objects
  81. - Exception safety: Basic guarantee
  82. - ``template< class Range > void transfer( const Range& r, ptr_set_adapter& from );``
  83. - Effects: ``return transfer( boost::begin(r), boost::end(r), from );``
  84. - ``size_type transfer( ptr_set_adapter& from );``
  85. - Effects: ``return transfer( from.begin(), from.end(), from );``.
  86. .. raw:: html
  87. <hr>
  88. :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
  89. __ http://www.boost.org/LICENSE_1_0.txt