summaryrefslogtreecommitdiff
path: root/src/list.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-01-24 00:59:12 +0000
committerMike Buland <eichlan@xagasoft.com>2009-01-24 00:59:12 +0000
commitdfd5f8696787d18ae688b662040289f84b667fdd (patch)
tree6307e987456088304383c4552551e2995aec16d3 /src/list.h
parentb53b359c8d5079c996e47abafdf76781c4b1afc0 (diff)
downloadlibbu++-dfd5f8696787d18ae688b662040289f84b667fdd.tar.gz
libbu++-dfd5f8696787d18ae688b662040289f84b667fdd.tar.bz2
libbu++-dfd5f8696787d18ae688b662040289f84b667fdd.tar.xz
libbu++-dfd5f8696787d18ae688b662040289f84b667fdd.zip
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.
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h34
1 files changed, 34 insertions, 0 deletions
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
82 return *this; 82 return *this;
83 } 83 }
84 84
85 MyType &operator+=( const value &v )
86 {
87 append( v );
88 return *this;
89 }
90
91 MyType &operator+=( const MyType &src )
92 {
93 append( src );
94 return *this;
95 }
96
85 /** 97 /**
86 * Clear the data from the list. 98 * Clear the data from the list.
87 */ 99 */
@@ -142,6 +154,15 @@ namespace Bu
142 } 154 }
143 } 155 }
144 156
157 void append( const MyType &rSrc )
158 {
159 for( typename MyType::const_iterator i = rSrc.begin();
160 i != rSrc.end(); i++ )
161 {
162 append( *i );
163 }
164 }
165
145 /** 166 /**
146 * Prepend a value to the list. 167 * Prepend a value to the list.
147 *@param v (const value_type &) The value to prepend. 168 *@param v (const value_type &) The value to prepend.
@@ -168,6 +189,19 @@ namespace Bu
168 } 189 }
169 190
170 /** 191 /**
192 * Prepend another list to the front of this one. This will prepend
193 * the rSrc list in reverse order...I may fix that later.
194 */
195 void prepend( const MyType &rSrc )
196 {
197 for( typename MyType::const_iterator i = rSrc.begin();
198 i != rSrc.end(); i++ )
199 {
200 prepend( *i );
201 }
202 }
203
204 /**
171 * Insert a new item in sort order by searching for the first item that 205 * Insert a new item in sort order by searching for the first item that
172 * is larger and inserting this before it, or at the end if none are 206 * is larger and inserting this before it, or at the end if none are
173 * larger. If this is the only function used to insert data in the 207 * larger. If this is the only function used to insert data in the