diff options
Diffstat (limited to '')
-rw-r--r-- | src/hashtable.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/hashtable.cpp b/src/hashtable.cpp index 8a31f57..ea13236 100644 --- a/src/hashtable.cpp +++ b/src/hashtable.cpp | |||
@@ -241,6 +241,51 @@ const void *HashTable::get( const void *id, unsigned long int nSkip ) | |||
241 | return NULL; | 241 | return NULL; |
242 | } | 242 | } |
243 | 243 | ||
244 | const void *HashTable::getKey( const void *id, unsigned long int nSkip ) | ||
245 | { | ||
246 | unsigned long int nPos = hFunc->hash( id )%nTableSize; | ||
247 | |||
248 | for( unsigned long int j=0; j < 32; nPos = (nPos+(1<<j))%nTableSize, j++ ) | ||
249 | { | ||
250 | if( !isFilled( nPos ) ) return NULL; | ||
251 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | ||
252 | aTable[nPos].bDeleted == false ) | ||
253 | { | ||
254 | if( nSkip == 0 ) | ||
255 | { | ||
256 | return aTable[nPos].id; | ||
257 | } | ||
258 | else | ||
259 | { | ||
260 | nSkip--; | ||
261 | } | ||
262 | } | ||
263 | } | ||
264 | |||
265 | if( bAllowDupes ) | ||
266 | { | ||
267 | int nOldPos = nPos; | ||
268 | for( nPos++; nPos != nOldPos; nPos=(nPos+1)%nTableSize ) | ||
269 | { | ||
270 | if( !isFilled( nPos ) ) return NULL; | ||
271 | if( hFunc->cmpIDs( id, aTable[nPos].id ) && | ||
272 | aTable[nPos].bDeleted == false ) | ||
273 | { | ||
274 | if( nSkip == 0 ) | ||
275 | { | ||
276 | return aTable[nPos].id; | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | nSkip--; | ||
281 | } | ||
282 | } | ||
283 | } | ||
284 | } | ||
285 | |||
286 | return NULL; | ||
287 | } | ||
288 | |||
244 | void *HashTable::getFirstItemPos() | 289 | void *HashTable::getFirstItemPos() |
245 | { | 290 | { |
246 | HashPos *pos = new HashPos; | 291 | HashPos *pos = new HashPos; |