ptr_deque.rst 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ++++++++++++++++++++++++++++++++++
  2. |Boost| Pointer Container Library
  3. ++++++++++++++++++++++++++++++++++
  4. .. |Boost| image:: boost.png
  5. Class ``ptr_deque``
  6. --------------------
  7. A ``ptr_deque<T>`` is a pointer container that uses an underlying ``std:deque<void*>``
  8. to store the pointers.
  9. **Hierarchy:**
  10. - `reversible_ptr_container <reversible_ptr_container.html>`_
  11. - `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
  12. - `ptr_vector <ptr_vector.html>`_
  13. - `ptr_list <ptr_list.html>`_
  14. - ``ptr_deque``
  15. - `ptr_array <ptr_array.html>`_
  16. **Navigate:**
  17. - `home <ptr_container.html>`_
  18. - `reference <reference.html>`_
  19. **Synopsis:**
  20. .. parsed-literal::
  21. namespace boost
  22. {
  23. template
  24. <
  25. class T,
  26. class CloneAllocator = heap_clone_allocator
  27. class Allocator = std::allocator<void*>
  28. >
  29. class ptr_deque : public ptr_sequence_adapter
  30. <
  31. T,
  32. std::deque<void*,Allocator>,
  33. CloneAllocator
  34. >
  35. {
  36. public: // `element access`_
  37. T& operator[]( size_type n );
  38. const T& operator[]( size_type n ) const;
  39. T& at( size_type n );
  40. const T& at( size_type n ) const;
  41. public: // modifiers_
  42. void push_front( T* x );
  43. template< class U >
  44. void push_front( compatible-smart-ptr<U> x );
  45. auto_type pop_front();
  46. public: // `pointer container requirements`_
  47. auto_type replace( size_type idx, T* x );
  48. template< class U >
  49. auto_type replace( size_type idx, compatible-smart-ptr<U> x );
  50. bool is_null( size_type idx ) const;
  51. };
  52. } // namespace 'boost'
  53. .. _`reversible_ptr_container`: reversible_ptr_container.html
  54. .. _`ptr_sequence_adapter`: ptr_sequence_adapter.html
  55. Semantics
  56. ---------
  57. .. _modifiers:
  58. Semantics: modifiers
  59. ^^^^^^^^^^^^^^^^^^^^
  60. - ``void push_front( T* x );``
  61. - Requirements: ``x != 0``
  62. - Effects: Inserts the pointer into container and takes ownership of it
  63. - Throws: ``bad_pointer`` if ``x == 0``
  64. - Exception safety: Strong guarantee
  65. - ``template< class U > void push_front( compatible-smart-ptr<U> x );``
  66. - Effects: ``push_front( x.release() );``
  67. ..
  68. - ``void push_front( const T& x );``
  69. - Effects: push_front( allocate_clone( x ) );
  70. - Exception safety: Strong guarantee
  71. - ``auto_type pop_front():``
  72. - Requirements:``not empty()``
  73. - Effects: Removes the first element in the container
  74. - Postconditions: ``size()`` is one less
  75. - Throws: ``bad_ptr_container_operation`` if ``empty() == true``
  76. - Exception safety: Strong guarantee
  77. .. _`element access`:
  78. Semantics: element access
  79. ^^^^^^^^^^^^^^^^^^^^^^^^^
  80. - ``T& operator[]( size_type n );``
  81. - ``const T& operator[]( size_type n ) const;``
  82. - Requirements: ``n < size()``
  83. - Effects: Returns a reference to the ``n``'th element
  84. - Throws: Nothing
  85. - ``T& at( size_type n );``
  86. - ``const T& at( size_type n ) const;``
  87. - Requirements: ``n < size()``
  88. - Effects: Returns a reference to the ``n``'th element
  89. - Throws: ``bad_index`` if ``n >=size()``
  90. .. _`pointer container requirements`:
  91. Semantics: pointer container requirements
  92. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  93. - ``auto_type replace( size_type idx, T* x );``
  94. - Requirements: `` x != 0 and idx < size()``
  95. - Effects: returns the object indexed by ``idx`` and replaces it with ``x``.
  96. - Throws: ``bad_index`` if ``idx >= size()`` and ``bad_pointer`` if ``x == 0``.
  97. - Exception safety: Strong guarantee
  98. - ``template< class U > auto_type replace( size_type idx, compatible-smart-ptr<U> x );``
  99. - Effects: ``return replace( idx, x.release() );``
  100. - ``bool is_null( size_type idx ) const;``
  101. - Requirements: ``idx < size()``
  102. - Effects: returns whether the pointer at index ``idx`` is null
  103. - Exception safety: Nothrow guarantee
  104. .. raw:: html
  105. <hr>
  106. :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
  107. __ http://www.boost.org/LICENSE_1_0.txt