From dfd5f8696787d18ae688b662040289f84b667fdd Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 24 Jan 2009 00:59:12 +0000 Subject: Added some append and prepend functions and operators to Bu::List, now you can append one list to another and the like. Also, wow, I found a bug that's been around for ages, I guess we don't copy hash tables often. The interesting thing is that it actually worked, it copied but it would include any data that had been deleted in the old hash table but not reclaimed yet and insert it as new data. Usually the key had been completely destroyed (like with a string) so it came out as keyed to blank string. So in cases like that, all deleted keys would collapse into one deleted key in the new hash table. --- src/list.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/list.h') diff --git a/src/list.h b/src/list.h index 8c5e94e..d16e606 100644 --- a/src/list.h +++ b/src/list.h @@ -82,6 +82,18 @@ namespace Bu return *this; } + MyType &operator+=( const value &v ) + { + append( v ); + return *this; + } + + MyType &operator+=( const MyType &src ) + { + append( src ); + return *this; + } + /** * Clear the data from the list. */ @@ -142,6 +154,15 @@ namespace Bu } } + void append( const MyType &rSrc ) + { + for( typename MyType::const_iterator i = rSrc.begin(); + i != rSrc.end(); i++ ) + { + append( *i ); + } + } + /** * Prepend a value to the list. *@param v (const value_type &) The value to prepend. @@ -167,6 +188,19 @@ namespace Bu } } + /** + * Prepend another list to the front of this one. This will prepend + * the rSrc list in reverse order...I may fix that later. + */ + void prepend( const MyType &rSrc ) + { + for( typename MyType::const_iterator i = rSrc.begin(); + i != rSrc.end(); i++ ) + { + prepend( *i ); + } + } + /** * Insert a new item in sort order by searching for the first item that * is larger and inserting this before it, or at the end if none are -- cgit v1.2.3