Fixes for ecore_hash_goto_first and ecore_hash_next

SVN revision: 12767
This commit is contained in:
werkt 2005-01-05 06:03:48 +00:00 committed by werkt
parent 91d0cd0555
commit 260ad16e93
2 changed files with 19 additions and 11 deletions

View File

@ -277,7 +277,6 @@ extern "C" {
int nodes; /* The number of nodes currently in the hash */
int index; /* The current index into the bucket table */
Ecore_Hash_Node *current; /* the current node in the current bucket */
Ecore_Compare_Cb compare; /* The function used to compare node values */
Ecore_Hash_Cb hash_func; /* The function used to compare node values */

View File

@ -207,18 +207,24 @@ void ecore_hash_destroy(Ecore_Hash *hash)
*/
Ecore_Hash_Node *ecore_hash_goto_first(Ecore_Hash *hash)
{
Ecore_Hash_Node *node = NULL;
CHECK_PARAM_POINTER_RETURN("hash", hash, FALSE);
hash->index = 0;
ECORE_READ_LOCK(hash);
if( hash->buckets[hash->index] )
ecore_list_goto_first( hash->buckets[hash->index] );
while( hash->index < ecore_prime_table[hash->index] &&
!hash->buckets[hash->index] )
hash->index++;
if( hash->index < ecore_prime_table[hash->index] )
node = ecore_list_goto_first( hash->buckets[hash->index] );
ECORE_READ_UNLOCK(hash);
return hash->current;
return node;
}
/**
@ -235,16 +241,19 @@ Ecore_Hash_Node *ecore_hash_next(Ecore_Hash *hash)
ECORE_READ_LOCK(hash);
if( hash->index < ecore_prime_table[hash->size] &&
hash->buckets[hash->index] ) {
while( hash->index < ecore_prime_table[hash->size] &&
!hash->buckets[hash->index] ) {
hash->index++;
if( hash->index < ecore_prime_table[hash->size] &&
hash->buckets[hash->index] )
ecore_list_goto_first( hash->buckets[hash->index] );
}
if( hash->index < ecore_prime_table[hash->size] ) {
node = ecore_list_next( hash->buckets[hash->index] );
if( !node ) {
hash->index++;
while( hash->index < ecore_prime_table[hash->size] &&
!hash->buckets[hash->index] )
hash->index++;
if( hash->index < ecore_prime_table[hash->size] )
node = ecore_list_goto_first( hash->buckets[hash->index] );
node = ecore_hash_next(hash);
}
}