diff options
author | David <david@xagasoft.com> | 2006-08-30 00:34:28 +0000 |
---|---|---|
committer | David <david@xagasoft.com> | 2006-08-30 00:34:28 +0000 |
commit | b797d7a7c4481c20b26ecf6ce7ef77e4782534bb (patch) | |
tree | c16d8138d6e025ed2ba0f133cef0bd9c2c322638 /src/hashtable.cpp | |
parent | 5ff43b1a4abd06a47a996b817846567f8d1bc615 (diff) | |
download | libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.gz libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.bz2 libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.tar.xz libbu++-b797d7a7c4481c20b26ecf6ce7ef77e4782534bb.zip |
david - creepy forgot to commit hashtable stuff... also fixed something in md5... it was using uninitialized data...
Diffstat (limited to 'src/hashtable.cpp')
-rw-r--r-- | src/hashtable.cpp | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/src/hashtable.cpp b/src/hashtable.cpp index ea13236..37c3149 100644 --- a/src/hashtable.cpp +++ b/src/hashtable.cpp | |||
@@ -203,16 +203,18 @@ const void *HashTable::get( const void *id, unsigned long int nSkip ) | |||
203 | for( unsigned long int j=0; j < 32; nPos = (nPos+(1<<j))%nTableSize, j++ ) | 203 | for( unsigned long int j=0; j < 32; nPos = (nPos+(1<<j))%nTableSize, j++ ) |
204 | { | 204 | { |
205 | if( !isFilled( nPos ) ) return NULL; | 205 | if( !isFilled( nPos ) ) return NULL; |
206 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | 206 | if( aTable[nPos].bDeleted == false ) |
207 | aTable[nPos].bDeleted == false ) | ||
208 | { | 207 | { |
209 | if( nSkip == 0 ) | 208 | if( hFunc->cmpIDs( id, aTable[nPos].id ) ) |
210 | { | ||
211 | return aTable[nPos].data; | ||
212 | } | ||
213 | else | ||
214 | { | 209 | { |
215 | nSkip--; | 210 | if( nSkip == 0 ) |
211 | { | ||
212 | return aTable[nPos].data; | ||
213 | } | ||
214 | else | ||
215 | { | ||
216 | nSkip--; | ||
217 | } | ||
216 | } | 218 | } |
217 | } | 219 | } |
218 | } | 220 | } |
@@ -223,16 +225,18 @@ const void *HashTable::get( const void *id, unsigned long int nSkip ) | |||
223 | for( nPos++; nPos != nOldPos; nPos=(nPos+1)%nTableSize ) | 225 | for( nPos++; nPos != nOldPos; nPos=(nPos+1)%nTableSize ) |
224 | { | 226 | { |
225 | if( !isFilled( nPos ) ) return NULL; | 227 | if( !isFilled( nPos ) ) return NULL; |
226 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | 228 | if( aTable[nPos].bDeleted == false ) |
227 | aTable[nPos].bDeleted == false ) | ||
228 | { | 229 | { |
229 | if( nSkip == 0 ) | 230 | if( hFunc->cmpIDs( id, aTable[nPos].id ) ) |
230 | { | 231 | { |
231 | return aTable[nPos].data; | 232 | if( nSkip == 0 ) |
232 | } | 233 | { |
233 | else | 234 | return aTable[nPos].data; |
234 | { | 235 | } |
235 | nSkip--; | 236 | else |
237 | { | ||
238 | nSkip--; | ||
239 | } | ||
236 | } | 240 | } |
237 | } | 241 | } |
238 | } | 242 | } |
@@ -248,16 +252,18 @@ const void *HashTable::getKey( const void *id, unsigned long int nSkip ) | |||
248 | for( unsigned long int j=0; j < 32; nPos = (nPos+(1<<j))%nTableSize, j++ ) | 252 | for( unsigned long int j=0; j < 32; nPos = (nPos+(1<<j))%nTableSize, j++ ) |
249 | { | 253 | { |
250 | if( !isFilled( nPos ) ) return NULL; | 254 | if( !isFilled( nPos ) ) return NULL; |
251 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | 255 | if( aTable[nPos].bDeleted == false ) |
252 | aTable[nPos].bDeleted == false ) | ||
253 | { | 256 | { |
254 | if( nSkip == 0 ) | 257 | if( hFunc->cmpIDs( id, aTable[nPos].id ) ) |
255 | { | ||
256 | return aTable[nPos].id; | ||
257 | } | ||
258 | else | ||
259 | { | 258 | { |
260 | nSkip--; | 259 | if( nSkip == 0 ) |
260 | { | ||
261 | return aTable[nPos].id; | ||
262 | } | ||
263 | else | ||
264 | { | ||
265 | nSkip--; | ||
266 | } | ||
261 | } | 267 | } |
262 | } | 268 | } |
263 | } | 269 | } |
@@ -268,16 +274,18 @@ const void *HashTable::getKey( const void *id, unsigned long int nSkip ) | |||
268 | for( nPos++; nPos != nOldPos; nPos=(nPos+1)%nTableSize ) | 274 | for( nPos++; nPos != nOldPos; nPos=(nPos+1)%nTableSize ) |
269 | { | 275 | { |
270 | if( !isFilled( nPos ) ) return NULL; | 276 | if( !isFilled( nPos ) ) return NULL; |
271 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | 277 | if( aTable[nPos].bDeleted == false ) |
272 | aTable[nPos].bDeleted == false ) | ||
273 | { | 278 | { |
274 | if( nSkip == 0 ) | 279 | if( hFunc->cmpIDs( id, aTable[nPos].id ) ) |
275 | { | 280 | { |
276 | return aTable[nPos].id; | 281 | if( nSkip == 0 ) |
277 | } | 282 | { |
278 | else | 283 | return aTable[nPos].id; |
279 | { | 284 | } |
280 | nSkip--; | 285 | else |
286 | { | ||
287 | nSkip--; | ||
288 | } | ||
281 | } | 289 | } |
282 | } | 290 | } |
283 | } | 291 | } |