aboutsummaryrefslogtreecommitdiff
path: root/src/list.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/list.h42
1 files changed, 29 insertions, 13 deletions
diff --git a/src/list.h b/src/list.h
index d711a2e..d06bc9e 100644
--- a/src/list.h
+++ b/src/list.h
@@ -239,10 +239,12 @@ namespace Bu
239 core->clear(); 239 core->clear();
240 } 240 }
241 241
242 void enqueue( const value &v ) 242 MyType &enqueue( const value &v )
243 { 243 {
244 _hardCopy(); 244 _hardCopy();
245 append( v ); 245 append( v );
246
247 return *this;
246 } 248 }
247 249
248 value dequeue() 250 value dequeue()
@@ -259,13 +261,15 @@ namespace Bu
259 * Append a value to the list. 261 * Append a value to the list.
260 *@param v (const value_type &) The value to append. 262 *@param v (const value_type &) The value to append.
261 */ 263 */
262 void append( const value &v ) 264 MyType &append( const value &v )
263 { 265 {
264 _hardCopy(); 266 _hardCopy();
265 core->append( v ); 267 core->append( v );
268
269 return *this;
266 } 270 }
267 271
268 void append( const MyType &rSrc ) 272 MyType &append( const MyType &rSrc )
269 { 273 {
270 _hardCopy(); 274 _hardCopy();
271 for( typename MyType::const_iterator i = rSrc.begin(); 275 for( typename MyType::const_iterator i = rSrc.begin();
@@ -273,23 +277,27 @@ namespace Bu
273 { 277 {
274 core->append( *i ); 278 core->append( *i );
275 } 279 }
280
281 return *this;
276 } 282 }
277 283
278 /** 284 /**
279 * Prepend a value to the list. 285 * Prepend a value to the list.
280 *@param v (const value_type &) The value to prepend. 286 *@param v (const value_type &) The value to prepend.
281 */ 287 */
282 void prepend( const value &v ) 288 MyType &prepend( const value &v )
283 { 289 {
284 _hardCopy(); 290 _hardCopy();
285 core->prepend( v ); 291 core->prepend( v );
292
293 return *this;
286 } 294 }
287 295
288 /** 296 /**
289 * Prepend another list to the front of this one. This will prepend 297 * Prepend another list to the front of this one. This will prepend
290 * the rSrc list in reverse order...I may fix that later. 298 * the rSrc list in reverse order...I may fix that later.
291 */ 299 */
292 void prepend( const MyType &rSrc ) 300 MyType &prepend( const MyType &rSrc )
293 { 301 {
294 _hardCopy(); 302 _hardCopy();
295 for( typename MyType::const_iterator i = rSrc.begin(); 303 for( typename MyType::const_iterator i = rSrc.begin();
@@ -297,13 +305,17 @@ namespace Bu
297 { 305 {
298 core->prepend( *i ); 306 core->prepend( *i );
299 } 307 }
308
309 return *this;
300 } 310 }
301 311
302 void insert( MyType::iterator &i, const value &v ) 312 MyType &insert( MyType::iterator &i, const value &v )
303 { 313 {
304 _hardCopy(); 314 _hardCopy();
305 315
306 core->insert( i.pLink, v ); 316 core->insert( i.pLink, v );
317
318 return *this;
307 } 319 }
308 320
309 /** 321 /**
@@ -313,14 +325,14 @@ namespace Bu
313 * List all items will be sorted. To use this, the value type must 325 * List all items will be sorted. To use this, the value type must
314 * support the > operator. 326 * support the > operator.
315 */ 327 */
316 void insertSorted( const value &v ) 328 MyType &insertSorted( const value &v )
317 { 329 {
318 _hardCopy(); 330 _hardCopy();
319 if( core->pFirst == NULL ) 331 if( core->pFirst == NULL )
320 { 332 {
321 // Empty list 333 // Empty list
322 core->append( v ); 334 core->append( v );
323 return; 335 return *this;
324 } 336 }
325 else 337 else
326 { 338 {
@@ -330,13 +342,13 @@ namespace Bu
330 if( !core->cmp( v, *(pCur->pValue)) ) 342 if( !core->cmp( v, *(pCur->pValue)) )
331 { 343 {
332 core->insert( pCur, v ); 344 core->insert( pCur, v );
333 return; 345 return *this;
334 } 346 }
335 pCur = pCur->pNext; 347 pCur = pCur->pNext;
336 if( pCur == NULL ) 348 if( pCur == NULL )
337 { 349 {
338 core->append( v ); 350 core->append( v );
339 return; 351 return *this;
340 } 352 }
341 } 353 }
342 } 354 }
@@ -641,26 +653,30 @@ namespace Bu
641 * Erase an item from the list. 653 * Erase an item from the list.
642 *@param i (iterator) The item to erase. 654 *@param i (iterator) The item to erase.
643 */ 655 */
644 void erase( iterator i ) 656 MyType &erase( iterator i )
645 { 657 {
646 _hardCopy(); 658 _hardCopy();
647 core->erase( i.pLink ); 659 core->erase( i.pLink );
660
661 return *this;
648 } 662 }
649 663
650 /** 664 /**
651 * Erase an item from the list if you already know the item. 665 * Erase an item from the list if you already know the item.
652 *@param v The item to find and erase. 666 *@param v The item to find and erase.
653 */ 667 */
654 void erase( const value &v ) 668 MyType &erase( const value &v )
655 { 669 {
656 for( const_iterator i = begin(); i != end(); i++ ) 670 for( const_iterator i = begin(); i != end(); i++ )
657 { 671 {
658 if( (*i) == v ) 672 if( (*i) == v )
659 { 673 {
660 erase( i ); 674 erase( i );
661 return; 675 return *this;
662 } 676 }
663 } 677 }
678
679 return *this;
664 } 680 }
665 681
666 /** 682 /**