summaryrefslogtreecommitdiff
path: root/src/set.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
committerMike Buland <eichlan@xagasoft.com>2009-11-12 17:05:30 +0000
commit509d136e9adb60c56369565b9545e613cac3678e (patch)
treef118d676edeae2d5e17f48b32b180d4761b60520 /src/set.h
parent3166bd631a093f42ea44a4b0f4d914cf51518bd4 (diff)
downloadlibbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.gz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.bz2
libbu++-509d136e9adb60c56369565b9545e613cac3678e.tar.xz
libbu++-509d136e9adb60c56369565b9545e613cac3678e.zip
I've started my campaign to clean up all of the header files in libbu++ as far
as includes go. This required a little bit of reworking as far as archive goes, but I've been planning on changing it aronud for a bit anyway. The final result here is that you may need to add some more includes in your own code, libbu++ doesn't include as many random things you didn't ask for anymore, most of these seem to be bu/hash.h, unistd.h, and time.h. Also, any Archive functions and operators should use ArchiveBase when they can instead of Archive, archivebase.h is a much lighterweight include that will be used everywhere in core that it can be, there are a few classes that actually want a specific archiver to be used, they will use it (such as the nids storage class). So far, except for adding header files, nothing has changed in functionality, and no other code changes should be required, although the above mentioned archive changeover is reccomended.
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