]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | ++++++++++++++++++++++++++++++++++ |
2 | |Boost| Pointer Container Library | |
3 | ++++++++++++++++++++++++++++++++++ | |
4 | ||
5 | .. |Boost| image:: boost.png | |
6 | ||
7 | Class ``ptr_deque`` | |
8 | -------------------- | |
9 | ||
10 | A ``ptr_deque<T>`` is a pointer container that uses an underlying ``std:deque<void*>`` | |
11 | to store the pointers. | |
12 | ||
13 | **Hierarchy:** | |
14 | ||
15 | - `reversible_ptr_container <reversible_ptr_container.html>`_ | |
16 | ||
17 | - `ptr_sequence_adapter <ptr_sequence_adapter.html>`_ | |
18 | ||
19 | - `ptr_vector <ptr_vector.html>`_ | |
20 | - `ptr_list <ptr_list.html>`_ | |
21 | - ``ptr_deque`` | |
22 | - `ptr_array <ptr_array.html>`_ | |
23 | ||
24 | **Navigate:** | |
25 | ||
26 | - `home <ptr_container.html>`_ | |
27 | - `reference <reference.html>`_ | |
28 | ||
29 | ||
30 | **Synopsis:** | |
31 | ||
32 | .. parsed-literal:: | |
33 | ||
34 | namespace boost | |
35 | { | |
36 | ||
37 | template | |
38 | < | |
39 | class T, | |
40 | class CloneAllocator = heap_clone_allocator | |
41 | class Allocator = std::allocator<void*> | |
42 | > | |
43 | class ptr_deque : public ptr_sequence_adapter | |
44 | < | |
45 | T, | |
46 | std::deque<void*,Allocator>, | |
47 | CloneAllocator | |
48 | > | |
49 | { | |
50 | ||
51 | public: // `element access`_ | |
52 | T& operator[]( size_type n ); | |
53 | const T& operator[]( size_type n ) const; | |
54 | T& at( size_type n ); | |
55 | const T& at( size_type n ) const; | |
56 | ||
57 | public: // modifiers_ | |
58 | void push_front( T* x ); | |
59 | template< class U > | |
60 | void push_front( std::auto_ptr<U> x ); | |
61 | auto_type pop_front(); | |
62 | ||
63 | public: // `pointer container requirements`_ | |
64 | auto_type replace( size_type idx, T* x ); | |
65 | template< class U > | |
66 | auto_type replace( size_type idx, std::auto_ptr<U> x ); | |
67 | bool is_null( size_type idx ) const; | |
68 | ||
69 | }; | |
70 | ||
71 | } // namespace 'boost' | |
72 | ||
73 | ||
74 | .. _`reversible_ptr_container`: reversible_ptr_container.html | |
75 | ||
76 | .. _`ptr_sequence_adapter`: ptr_sequence_adapter.html | |
77 | ||
78 | Semantics | |
79 | --------- | |
80 | ||
81 | .. _modifiers: | |
82 | ||
83 | Semantics: modifiers | |
84 | ^^^^^^^^^^^^^^^^^^^^ | |
85 | ||
86 | - ``void push_front( T* x );`` | |
87 | ||
88 | - Requirements: ``x != 0`` | |
89 | ||
90 | - Effects: Inserts the pointer into container and takes ownership of it | |
91 | ||
92 | - Throws: ``bad_pointer`` if ``x == 0`` | |
93 | ||
94 | - Exception safety: Strong guarantee | |
95 | ||
96 | - ``template< class U > void push_front( std::auto_ptr<U> x );`` | |
97 | ||
98 | - Effects: ``push_front( x.release() );`` | |
99 | ||
100 | .. | |
101 | - ``void push_front( const T& x );`` | |
102 | ||
103 | - Effects: push_front( allocate_clone( x ) ); | |
104 | ||
105 | - Exception safety: Strong guarantee | |
106 | ||
107 | - ``auto_type pop_front():`` | |
108 | ||
109 | - Requirements:``not empty()`` | |
110 | ||
111 | - Effects: Removes the first element in the container | |
112 | ||
113 | - Postconditions: ``size()`` is one less | |
114 | ||
115 | - Throws: ``bad_ptr_container_operation`` if ``empty() == true`` | |
116 | ||
117 | - Exception safety: Strong guarantee | |
118 | ||
119 | ||
120 | .. _`element access`: | |
121 | ||
122 | Semantics: element access | |
123 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
124 | ||
125 | - ``T& operator[]( size_type n );`` | |
126 | - ``const T& operator[]( size_type n ) const;`` | |
127 | ||
128 | - Requirements: ``n < size()`` | |
129 | ||
130 | - Effects: Returns a reference to the ``n``'th element | |
131 | ||
132 | - Throws: Nothing | |
133 | ||
134 | - ``T& at( size_type n );`` | |
135 | - ``const T& at( size_type n ) const;`` | |
136 | ||
137 | - Requirements: ``n < size()`` | |
138 | ||
139 | - Effects: Returns a reference to the ``n``'th element | |
140 | ||
141 | - Throws: ``bad_index`` if ``n >=size()`` | |
142 | ||
143 | ||
144 | .. _`pointer container requirements`: | |
145 | ||
146 | Semantics: pointer container requirements | |
147 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
148 | ||
149 | - ``auto_type replace( size_type idx, T* x );`` | |
150 | ||
151 | - Requirements: `` x != 0 and idx < size()`` | |
152 | ||
153 | - Effects: returns the object indexed by ``idx`` and replaces it with ``x``. | |
154 | ||
155 | - Throws: ``bad_index`` if ``idx >= size()`` and ``bad_pointer`` if ``x == 0``. | |
156 | ||
157 | - Exception safety: Strong guarantee | |
158 | ||
159 | - ``template< class U > auto_type replace( size_type idx, std::auto_ptr<U> x );`` | |
160 | ||
161 | - Effects: ``return replace( idx, x.release() );`` | |
162 | ||
163 | - ``bool is_null( size_type idx ) const;`` | |
164 | ||
165 | - Requirements: ``idx < size()`` | |
166 | ||
167 | - Effects: returns whether the pointer at index ``idx`` is null | |
168 | ||
169 | - Exception safety: Nothrow guarantee | |
170 | ||
171 | .. raw:: html | |
172 | ||
173 | <hr> | |
174 | ||
175 | :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__). | |
176 | ||
177 | __ http://www.boost.org/LICENSE_1_0.txt | |
178 | ||
179 |