From 6119b465b19e9be095971a33c63b0fa9a0e8a224 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 24 Sep 2008 05:52:36 +0000 Subject: Wow, I realized that the Bu::Array class wasn't finished, and went ahead and wrote it, it's pretty feature complete, index, append, iterators. You can't delete anything yet, exactly, but that's tricky in an array anyway, basically you just want to be able to remove elements from the end, and that's halfway there. Also, fixed some documentation and minor issues in Bu::Set, and made the Bu::Archive include fewer other classes while still defining archive oprators for them. I think I may yet move those into the headers for the classes that are being stored instead, makes a little more sense. I also would like to move the Exception classes out of the exceptions.h file and into the appropriate class' files'. There still should probably be a couple of general ones in there, or maybe just in exceptionbase.h, we'll see. --- src/archive.h | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'src/archive.h') 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 @@ #include #include "bu/hash.h" #include "bu/list.h" -#include "bu/set.h" +//#include "bu/set.h" #include "bu/util.h" namespace Bu @@ -298,11 +298,12 @@ namespace Bu return ar; } - template - Archive &operator<<( Archive &ar, Set &h ) + template class Array; + template + Archive &operator<<( Archive &ar, Array &h ) { ar << h.getSize(); - for( typename Set::iterator i = h.begin(); i != h.end(); i++ ) + for( typename Array::iterator i = h.begin(); i != h.end(); i++ ) { ar << (*i); } @@ -310,17 +311,47 @@ namespace Bu return ar; } - template - Archive &operator>>( Archive &ar, Set &h ) + template + Archive &operator>>(Archive &ar, Array &h ) { h.clear(); long nSize; ar >> nSize; - + + h.setCapacity( nSize ); for( long j = 0; j < nSize; j++ ) { value v; ar >> v; + h.append( v ); + } + return ar; + } + + template class Set; + 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(); + long nSize; + ar >> nSize; + + for( long j = 0; j < nSize; j++ ) + { + key v; + ar >> v; h.insert( v ); } -- cgit v1.2.3