From 8c0b390617ea42af40d409bd1fbc541e63321239 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 13 Sep 2007 06:21:54 +0000 Subject: Sets now match Hashes better, and can be Archived. --- src/archive.h | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src/archive.h') 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 @@ #include #include "bu/hash.h" #include "bu/list.h" +#include "bu/set.h" namespace Bu { @@ -235,7 +236,36 @@ namespace Bu } return ar; - } + } + + template + Archive &operator<<( Archive &ar, Set &h ) + { + ar << h.getSize(); + for( typename Set::iterator i = h.begin(); i != h.end(); i++ ) + { + ar << (*i); + } + + return ar; + } + + template + Archive &operator>>( Archive &ar, Set &h ) + { + h.clear(); + uint32_t nSize; + ar >> nSize; + + for( uint32_t j = 0; j < nSize; j++ ) + { + value v; + ar >> v; + h.insert( v ); + } + + return ar; + } } #endif -- cgit v1.2.3