aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-09-13 06:21:54 +0000
committerMike Buland <eichlan@xagasoft.com>2007-09-13 06:21:54 +0000
commit8c0b390617ea42af40d409bd1fbc541e63321239 (patch)
tree4912a3c3b503a4ee76c03b36ab02623ee230d0b8 /src
parentcc1d8bdc45fa626b514bdace0cd026fa83dc8400 (diff)
downloadlibbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.gz
libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.bz2
libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.tar.xz
libbu++-8c0b390617ea42af40d409bd1fbc541e63321239.zip
Sets now match Hashes better, and can be Archived.
Diffstat (limited to '')
-rw-r--r--src/archive.h32
-rw-r--r--src/set.h2
2 files changed, 32 insertions, 2 deletions
diff --git a/src/archive.h b/src/archive.h
index 24c3a67..b5477bb 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -8,6 +8,7 @@
8#include <list> 8#include <list>
9#include "bu/hash.h" 9#include "bu/hash.h"
10#include "bu/list.h" 10#include "bu/list.h"
11#include "bu/set.h"
11 12
12namespace Bu 13namespace Bu
13{ 14{
@@ -235,7 +236,36 @@ namespace Bu
235 } 236 }
236 237
237 return ar; 238 return ar;
238 } 239 }
240
241 template<typename value>
242 Archive &operator<<( Archive &ar, Set<value> &h )
243 {
244 ar << h.getSize();
245 for( typename Set<value>::iterator i = h.begin(); i != h.end(); i++ )
246 {
247 ar << (*i);
248 }
249
250 return ar;
251 }
252
253 template<typename value>
254 Archive &operator>>( Archive &ar, Set<value> &h )
255 {
256 h.clear();
257 uint32_t nSize;
258 ar >> nSize;
259
260 for( uint32_t j = 0; j < nSize; j++ )
261 {
262 value v;
263 ar >> v;
264 h.insert( v );
265 }
266
267 return ar;
268 }
239} 269}
240 270
241#endif 271#endif
diff --git a/src/set.h b/src/set.h
index 4788804..ce2c10a 100644
--- a/src/set.h
+++ b/src/set.h
@@ -162,7 +162,7 @@ namespace Bu
162 * Get the number of items stored in the hash table. 162 * Get the number of items stored in the hash table.
163 *@returns (uint32_t) The number of items stored in the hash table. 163 *@returns (uint32_t) The number of items stored in the hash table.
164 */ 164 */
165 uint32_t size() 165 uint32_t getSize()
166 { 166 {
167 return nFilled-nDeleted; 167 return nFilled-nDeleted;
168 } 168 }