diff options
author | David <david@xagasoft.com> | 2007-06-18 20:45:45 +0000 |
---|---|---|
committer | David <david@xagasoft.com> | 2007-06-18 20:45:45 +0000 |
commit | 6f94639a3f5e20e1c635b2d8676086464d7cba2e (patch) | |
tree | 26d849636f58d5523c51776ad920781429a6df73 /src/list.h | |
parent | f58a0b3a1f657124076b96ba092e1f69e88af263 (diff) | |
download | libbu++-6f94639a3f5e20e1c635b2d8676086464d7cba2e.tar.gz libbu++-6f94639a3f5e20e1c635b2d8676086464d7cba2e.tar.bz2 libbu++-6f94639a3f5e20e1c635b2d8676086464d7cba2e.tar.xz libbu++-6f94639a3f5e20e1c635b2d8676086464d7cba2e.zip |
david - did more documenting
Diffstat (limited to 'src/list.h')
-rw-r--r-- | src/list.h | 92 |
1 files changed, 92 insertions, 0 deletions
@@ -115,6 +115,10 @@ namespace Bu | |||
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | /** | ||
119 | * Prepend a value to the list. | ||
120 | *@param v (const value_type &) The value to prepend. | ||
121 | */ | ||
118 | void prepend( const value &v ) | 122 | void prepend( const value &v ) |
119 | { | 123 | { |
120 | Link *pNew = la.allocate( 1 ); | 124 | Link *pNew = la.allocate( 1 ); |
@@ -136,6 +140,9 @@ namespace Bu | |||
136 | } | 140 | } |
137 | } | 141 | } |
138 | 142 | ||
143 | /** | ||
144 | * An iterator to iterate through your list. | ||
145 | */ | ||
139 | typedef struct iterator | 146 | typedef struct iterator |
140 | { | 147 | { |
141 | friend class List<value, valuealloc, linkalloc>; | 148 | friend class List<value, valuealloc, linkalloc>; |
@@ -152,36 +159,67 @@ namespace Bu | |||
152 | } | 159 | } |
153 | 160 | ||
154 | public: | 161 | public: |
162 | /** | ||
163 | * Equals comparison operator. | ||
164 | *@param oth (const iterator &) The iterator to compare to. | ||
165 | *@returns (bool) Are they equal? | ||
166 | */ | ||
155 | bool operator==( const iterator &oth ) const | 167 | bool operator==( const iterator &oth ) const |
156 | { | 168 | { |
157 | return ( pLink == oth.pLink ); | 169 | return ( pLink == oth.pLink ); |
158 | } | 170 | } |
159 | 171 | ||
172 | /** | ||
173 | * Equals comparison operator. | ||
174 | *@param pOth (const Link *) The link to compare to. | ||
175 | *@returns (bool) Are they equal? | ||
176 | */ | ||
160 | bool operator==( const Link *pOth ) const | 177 | bool operator==( const Link *pOth ) const |
161 | { | 178 | { |
162 | return ( pLink == pOth ); | 179 | return ( pLink == pOth ); |
163 | } | 180 | } |
164 | 181 | ||
182 | /** | ||
183 | * Not equals comparison operator. | ||
184 | *@param oth (const iterator &) The iterator to compare to. | ||
185 | *@returns (bool) Are they not equal? | ||
186 | */ | ||
165 | bool operator!=( const iterator &oth ) const | 187 | bool operator!=( const iterator &oth ) const |
166 | { | 188 | { |
167 | return ( pLink != oth.pLink ); | 189 | return ( pLink != oth.pLink ); |
168 | } | 190 | } |
169 | 191 | ||
192 | /** | ||
193 | * Not equals comparison operator. | ||
194 | *@param pOth (const Link *) The link to compare to. | ||
195 | *@returns (bool) Are they not equal? | ||
196 | */ | ||
170 | bool operator!=( const Link *pOth ) const | 197 | bool operator!=( const Link *pOth ) const |
171 | { | 198 | { |
172 | return ( pLink != pOth ); | 199 | return ( pLink != pOth ); |
173 | } | 200 | } |
174 | 201 | ||
202 | /** | ||
203 | * Dereference operator. | ||
204 | *@returns (value_type &) The value. | ||
205 | */ | ||
175 | value &operator*() | 206 | value &operator*() |
176 | { | 207 | { |
177 | return *(pLink->pValue); | 208 | return *(pLink->pValue); |
178 | } | 209 | } |
179 | 210 | ||
211 | /** | ||
212 | * Pointer access operator. | ||
213 | *@returns (value_type *) A pointer to the value. | ||
214 | */ | ||
180 | value *operator->() | 215 | value *operator->() |
181 | { | 216 | { |
182 | return pLink->pValue; | 217 | return pLink->pValue; |
183 | } | 218 | } |
184 | 219 | ||
220 | /** | ||
221 | * Increment operator. | ||
222 | */ | ||
185 | iterator &operator++() | 223 | iterator &operator++() |
186 | { | 224 | { |
187 | if( pLink != NULL ) | 225 | if( pLink != NULL ) |
@@ -189,6 +227,9 @@ namespace Bu | |||
189 | return *this; | 227 | return *this; |
190 | } | 228 | } |
191 | 229 | ||
230 | /** | ||
231 | * Decrement operator. | ||
232 | */ | ||
192 | iterator &operator--() | 233 | iterator &operator--() |
193 | { | 234 | { |
194 | if( pLink != NULL ) | 235 | if( pLink != NULL ) |
@@ -196,6 +237,9 @@ namespace Bu | |||
196 | return *this; | 237 | return *this; |
197 | } | 238 | } |
198 | 239 | ||
240 | /** | ||
241 | * Increment operator. | ||
242 | */ | ||
199 | iterator &operator++( int ) | 243 | iterator &operator++( int ) |
200 | { | 244 | { |
201 | if( pLink != NULL ) | 245 | if( pLink != NULL ) |
@@ -203,6 +247,9 @@ namespace Bu | |||
203 | return *this; | 247 | return *this; |
204 | } | 248 | } |
205 | 249 | ||
250 | /** | ||
251 | * Decrement operator. | ||
252 | */ | ||
206 | iterator &operator--( int ) | 253 | iterator &operator--( int ) |
207 | { | 254 | { |
208 | if( pLink != NULL ) | 255 | if( pLink != NULL ) |
@@ -210,6 +257,11 @@ namespace Bu | |||
210 | return *this; | 257 | return *this; |
211 | } | 258 | } |
212 | 259 | ||
260 | /** | ||
261 | * Assignment operator. | ||
262 | *@param oth (const iterator &) The other iterator to set this | ||
263 | * one to. | ||
264 | */ | ||
213 | iterator &operator=( const iterator &oth ) | 265 | iterator &operator=( const iterator &oth ) |
214 | { | 266 | { |
215 | pLink = oth.pLink; | 267 | pLink = oth.pLink; |
@@ -217,6 +269,9 @@ namespace Bu | |||
217 | } | 269 | } |
218 | }; | 270 | }; |
219 | 271 | ||
272 | /** | ||
273 | *@see iterator | ||
274 | */ | ||
220 | typedef struct const_iterator | 275 | typedef struct const_iterator |
221 | { | 276 | { |
222 | friend class List<value, valuealloc, linkalloc>; | 277 | friend class List<value, valuealloc, linkalloc>; |
@@ -309,21 +364,38 @@ namespace Bu | |||
309 | } | 364 | } |
310 | }; | 365 | }; |
311 | 366 | ||
367 | /** | ||
368 | * Get an iterator pointing to the first item in the list. | ||
369 | *@returns (iterator) | ||
370 | */ | ||
312 | iterator begin() | 371 | iterator begin() |
313 | { | 372 | { |
314 | return iterator( pFirst ); | 373 | return iterator( pFirst ); |
315 | } | 374 | } |
316 | 375 | ||
376 | /** | ||
377 | * Get a const iterator pointing to the first item in the list. | ||
378 | *@returns (const const_iterator) | ||
379 | */ | ||
317 | const const_iterator begin() const | 380 | const const_iterator begin() const |
318 | { | 381 | { |
319 | return const_iterator( pFirst ); | 382 | return const_iterator( pFirst ); |
320 | } | 383 | } |
321 | 384 | ||
385 | /** | ||
386 | * Get an iterator pointing to a place just past the last item in | ||
387 | * the list. | ||
388 | *@returns (const Link *) | ||
389 | */ | ||
322 | const Link *end() const | 390 | const Link *end() const |
323 | { | 391 | { |
324 | return NULL; | 392 | return NULL; |
325 | } | 393 | } |
326 | 394 | ||
395 | /** | ||
396 | * Erase an item from the list. | ||
397 | *@param i (iterator) The item to erase. | ||
398 | */ | ||
327 | void erase( iterator &i ) | 399 | void erase( iterator &i ) |
328 | { | 400 | { |
329 | Link *pCur = i.pLink; | 401 | Link *pCur = i.pLink; |
@@ -355,26 +427,46 @@ namespace Bu | |||
355 | } | 427 | } |
356 | } | 428 | } |
357 | 429 | ||
430 | /** | ||
431 | * Get the current size of the list. | ||
432 | *@returns (int) The current size of the list. | ||
433 | */ | ||
358 | int getSize() const | 434 | int getSize() const |
359 | { | 435 | { |
360 | return nSize; | 436 | return nSize; |
361 | } | 437 | } |
362 | 438 | ||
439 | /** | ||
440 | * Get the first item in the list. | ||
441 | *@returns (value_type &) The first item in the list. | ||
442 | */ | ||
363 | value &first() | 443 | value &first() |
364 | { | 444 | { |
365 | return *pFirst->pValue; | 445 | return *pFirst->pValue; |
366 | } | 446 | } |
367 | 447 | ||
448 | /** | ||
449 | * Get the first item in the list. | ||
450 | *@returns (const value_type &) The first item in the list. | ||
451 | */ | ||
368 | const value &first() const | 452 | const value &first() const |
369 | { | 453 | { |
370 | return *pFirst->pValue; | 454 | return *pFirst->pValue; |
371 | } | 455 | } |
372 | 456 | ||
457 | /** | ||
458 | * Get the last item in the list. | ||
459 | *@returns (value_type &) The last item in the list. | ||
460 | */ | ||
373 | value &last() | 461 | value &last() |
374 | { | 462 | { |
375 | return *pLast->pValue; | 463 | return *pLast->pValue; |
376 | } | 464 | } |
377 | 465 | ||
466 | /** | ||
467 | * Get the last item in the list. | ||
468 | *@returns (const value_type &) The last item in the list. | ||
469 | */ | ||
378 | const value &last() const | 470 | const value &last() const |
379 | { | 471 | { |
380 | return *pLast->pValue; | 472 | return *pLast->pValue; |