aboutsummaryrefslogtreecommitdiff
path: root/src/set.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/set.h')
-rw-r--r--src/set.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/set.h b/src/set.h
index aec5781..d5593a2 100644
--- a/src/set.h
+++ b/src/set.h
@@ -16,6 +16,7 @@
16#include <utility> 16#include <utility>
17#include "bu/exceptionbase.h" 17#include "bu/exceptionbase.h"
18#include "bu/list.h" 18#include "bu/list.h"
19#include "bu/archive.h"
19 20
20#define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0)) 21#define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0))
21 22
@@ -763,6 +764,35 @@ namespace Bu
763 challoc ca; 764 challoc ca;
764 sizecalc szCalc; 765 sizecalc szCalc;
765 }; 766 };
767
768 template<typename key, typename b, typename c, typename d>
769 Archive &operator<<( Archive &ar, const Set<key, b, c, d> &h )
770 {
771 ar << h.getSize();
772 for( typename Set<key, b, c, d>::const_iterator i = h.begin(); i != h.end(); i++ )
773 {
774 ar << (*i);
775 }
776
777 return ar;
778 }
779
780 template<typename key, typename b, typename c, typename d>
781 Archive &operator>>( Archive &ar, Set<key, b, c, d> &h )
782 {
783 h.clear();
784 long nSize;
785 ar >> nSize;
786
787 for( long j = 0; j < nSize; j++ )
788 {
789 key v;
790 ar >> v;
791 h.insert( v );
792 }
793
794 return ar;
795 }
766} 796}
767 797
768#endif 798#endif