summaryrefslogtreecommitdiff
path: root/src/archive.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/archive.h')
-rw-r--r--src/archive.h45
1 files changed, 38 insertions, 7 deletions
diff --git a/src/archive.h b/src/archive.h
index 1d57724..519b2a7 100644
--- a/src/archive.h
+++ b/src/archive.h
@@ -13,7 +13,7 @@
13#include <list> 13#include <list>
14#include "bu/hash.h" 14#include "bu/hash.h"
15#include "bu/list.h" 15#include "bu/list.h"
16#include "bu/set.h" 16//#include "bu/set.h"
17#include "bu/util.h" 17#include "bu/util.h"
18 18
19namespace Bu 19namespace Bu
@@ -298,11 +298,12 @@ namespace Bu
298 return ar; 298 return ar;
299 } 299 }
300 300
301 template<typename value> 301 template<typename value, int inc, typename valuealloc> class Array;
302 Archive &operator<<( Archive &ar, Set<value> &h ) 302 template<typename value, int inc, typename valuealloc>
303 Archive &operator<<( Archive &ar, Array<value, inc, valuealloc> &h )
303 { 304 {
304 ar << h.getSize(); 305 ar << h.getSize();
305 for( typename Set<value>::iterator i = h.begin(); i != h.end(); i++ ) 306 for( typename Array<value, inc, valuealloc>::iterator i = h.begin(); i != h.end(); i++ )
306 { 307 {
307 ar << (*i); 308 ar << (*i);
308 } 309 }
@@ -310,17 +311,47 @@ namespace Bu
310 return ar; 311 return ar;
311 } 312 }
312 313
313 template<typename value> 314 template<typename value, int inc, typename valuealloc>
314 Archive &operator>>( Archive &ar, Set<value> &h ) 315 Archive &operator>>(Archive &ar, Array<value, inc, valuealloc> &h )
315 { 316 {
316 h.clear(); 317 h.clear();
317 long nSize; 318 long nSize;
318 ar >> nSize; 319 ar >> nSize;
319 320
321 h.setCapacity( nSize );
320 for( long j = 0; j < nSize; j++ ) 322 for( long j = 0; j < nSize; j++ )
321 { 323 {
322 value v; 324 value v;
323 ar >> v; 325 ar >> v;
326 h.append( v );
327 }
328 return ar;
329 }
330
331 template<typename key, typename b, typename c, typename d> class Set;
332 template<typename key, typename b, typename c, typename d>
333 Archive &operator<<( Archive &ar, Set<key, b, c, d> &h )
334 {
335 ar << h.getSize();
336 for( typename Set<key, b, c, d>::iterator i = h.begin(); i != h.end(); i++ )
337 {
338 ar << (*i);
339 }
340
341 return ar;
342 }
343
344 template<typename key, typename b, typename c, typename d>
345 Archive &operator>>( Archive &ar, Set<key, b, c, d> &h )
346 {
347 h.clear();
348 long nSize;
349 ar >> nSize;
350
351 for( long j = 0; j < nSize; j++ )
352 {
353 key v;
354 ar >> v;
324 h.insert( v ); 355 h.insert( v );
325 } 356 }
326 357