aboutsummaryrefslogtreecommitdiff
path: root/src/list.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h62
1 files changed, 57 insertions, 5 deletions
diff --git a/src/list.h b/src/list.h
index c587c1a..d8c5a4a 100644
--- a/src/list.h
+++ b/src/list.h
@@ -178,11 +178,11 @@ namespace Bu
178 178
179 /** 179 /**
180 * Linked list template container. This class is similar to the stl list 180 * Linked list template container. This class is similar to the stl list
181 * class except for a few minor changes. First, it doesn't mimic a stack or 181 * class except for a few minor changes. First, when const, all
182 * queue, use the Stack or Queue clasess for that. Second, when const, all 182 * members are only accessable const. Second, erasing a location does not
183 * members are only accessable const. Third, erasing a location does not 183 * invalidate the iterator used, it simply points to the next valid
184 * invalidate the iterator, it simply points to the next valid location, or 184 * location, or end() if there are no more. Other iterators pointing to
185 * end() if there are no more. 185 * the deleted record will, of course, no longer be valid.
186 * 186 *
187 *@param value (typename) The type of data to store in your list 187 *@param value (typename) The type of data to store in your list
188 *@param valuealloc (typename) Memory Allocator for your value type 188 *@param valuealloc (typename) Memory Allocator for your value type
@@ -506,6 +506,32 @@ namespace Bu
506 return *this; 506 return *this;
507 } 507 }
508 508
509 iterator operator+( int iDelta )
510 {
511 iterator ret( *this );
512 for( int j = 0; j < iDelta; j++ )
513 {
514 if( ret.pLink == NULL )
515 throw Bu::ExceptionBase(
516 "Attempt to iterate past begining of list.");
517 ret.pLink = ret.pLink->pNext;
518 }
519 return ret;
520 }
521
522 iterator operator-( int iDelta )
523 {
524 iterator ret( *this );
525 for( int j = 0; j < iDelta; j++ )
526 {
527 if( ret.pLink == NULL )
528 throw Bu::ExceptionBase(
529 "Attempt to iterate past begining of list.");
530 ret.pLink = ret.pLink->pPrev;
531 }
532 return ret;
533 }
534
509 operator bool() 535 operator bool()
510 { 536 {
511 return pLink != NULL; 537 return pLink != NULL;
@@ -619,6 +645,32 @@ namespace Bu
619 return *this; 645 return *this;
620 } 646 }
621 647
648 const_iterator operator+( int iDelta )
649 {
650 const_iterator ret( *this );
651 for( int j = 0; j < iDelta; j++ )
652 {
653 if( ret.pLink == NULL )
654 throw Bu::ExceptionBase(
655 "Attempt to iterate past begining of list.");
656 ret.pLink = ret.pLink->pNext;
657 }
658 return ret;
659 }
660
661 const_iterator operator-( int iDelta )
662 {
663 const_iterator ret( *this );
664 for( int j = 0; j < iDelta; j++ )
665 {
666 if( ret.pLink == NULL )
667 throw Bu::ExceptionBase(
668 "Attempt to iterate past begining of list.");
669 ret.pLink = ret.pLink->pPrev;
670 }
671 return ret;
672 }
673
622 const_iterator &operator=( const iterator &oth ) 674 const_iterator &operator=( const iterator &oth )
623 { 675 {
624 pLink = oth.pLink; 676 pLink = oth.pLink;