summaryrefslogtreecommitdiff
path: root/src/hash.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hash.h')
-rw-r--r--src/hash.h56
1 files changed, 19 insertions, 37 deletions
diff --git a/src/hash.h b/src/hash.h
index 10c661f..09025ba 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -8,17 +8,11 @@
8#ifndef BU_HASH_H 8#ifndef BU_HASH_H
9#define BU_HASH_H 9#define BU_HASH_H
10 10
11#include <stddef.h>
12#include <string.h>
13#include <memory> 11#include <memory>
14#include <iostream>
15#include <list>
16#include <utility>
17#include "bu/exceptionbase.h" 12#include "bu/exceptionbase.h"
18#include "bu/list.h" 13#include "bu/list.h"
19#include "bu/util.h" 14#include "bu/util.h"
20//#include "archival.h" 15#include "archivebase.h"
21//#include "archive.h"
22 16
23#define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0)) 17#define bitsToBytes( n ) (n/32+(n%32>0 ? 1 : 0))
24 18
@@ -373,6 +367,11 @@ namespace Bu
373 return nFilled-nDeleted; 367 return nFilled-nDeleted;
374 } 368 }
375 369
370 bool isEmpty() const
371 {
372 return (nFilled-nDeleted) == 0;
373 }
374
376 /** 375 /**
377 * Get the number of items which have been deleted, but not yet 376 * Get the number of items which have been deleted, but not yet
378 * cleaned up. 377 * cleaned up.
@@ -1171,9 +1170,6 @@ namespace Bu
1171 template<> uint32_t __calcHashCode<char *>( char * const &k ); 1170 template<> uint32_t __calcHashCode<char *>( char * const &k );
1172 template<> bool __cmpHashKeys<char *>( char * const &a, char * const &b ); 1171 template<> bool __cmpHashKeys<char *>( char * const &a, char * const &b );
1173 1172
1174 template<> uint32_t __calcHashCode<std::string>( const std::string &k );
1175 template<> bool __cmpHashKeys<std::string>( const std::string &a, const std::string &b );
1176
1177 class Formatter; 1173 class Formatter;
1178 Formatter &operator<<( Formatter &rOut, char *sStr ); 1174 Formatter &operator<<( Formatter &rOut, char *sStr );
1179 Formatter &operator<<( Formatter &rOut, signed char c ); 1175 Formatter &operator<<( Formatter &rOut, signed char c );
@@ -1190,30 +1186,30 @@ namespace Bu
1190 f << '}'; 1186 f << '}';
1191 1187
1192 return f; 1188 return f;
1193 } 1189 }
1194 1190
1195 /* 1191 template<typename key, typename value, typename a, typename b,
1196 template<typename key, typename value> 1192 typename c, typename d>
1197 Archive &operator<<( Archive &ar, Hash<key,value> &h ) 1193 ArchiveBase &operator<<( ArchiveBase &ar, const Hash<key,value,a,b,c,d> &h )
1198 { 1194 {
1199 ar << h.size(); 1195 ar << h.getSize();
1200 for( typename Hash<key,value>::iterator i = h.begin(); i != h.end(); i++ ) 1196 for( typename Hash<key,value>::const_iterator i = h.begin(); i != h.end(); i++ )
1201 { 1197 {
1202 std::pair<key,value> p = *i; 1198 ar << (i.getKey()) << (i.getValue());
1203 ar << p.first << p.second;
1204 } 1199 }
1205 1200
1206 return ar; 1201 return ar;
1207 } 1202 }
1208 1203
1209 template<typename key, typename value> 1204 template<typename key, typename value, typename a, typename b,
1210 Archive &operator>>( Archive &ar, Hash<key,value> &h ) 1205 typename c, typename d>
1206 ArchiveBase &operator>>( ArchiveBase &ar, Hash<key,value,a,b,c,d> &h )
1211 { 1207 {
1212 h.clear(); 1208 h.clear();
1213 uint32_t nSize; 1209 long nSize;
1214 ar >> nSize; 1210 ar >> nSize;
1215 1211
1216 for( uint32_t j = 0; j < nSize; j++ ) 1212 for( long j = 0; j < nSize; j++ )
1217 { 1213 {
1218 key k; value v; 1214 key k; value v;
1219 ar >> k >> v; 1215 ar >> k >> v;
@@ -1221,21 +1217,7 @@ namespace Bu
1221 } 1217 }
1222 1218
1223 return ar; 1219 return ar;
1224 }*/ 1220 }
1225
1226 /*
1227 template<typename key, typename value>
1228 Serializer &operator&&( Serializer &ar, Hash<key,value> &h )
1229 {
1230 if( ar.isLoading() )
1231 {
1232 return ar >> h;
1233 }
1234 else
1235 {
1236 return ar << h;
1237 }
1238 }*/
1239} 1221}
1240 1222
1241#endif 1223#endif