src/stdlib/hashtab.c
/*================================
 * next_hashtab -- Advance hash table iterator
 * If not finished, set pointers and return TRUE
 * If no more entries, return FALSE
 *==============================*/
- Advance hash table iterator
If not finished, set pointers and return TRUE
If no more entries, return FALSE
- Advance hash table iterator If not finished set pointers and return TRUE If no more entries return FALSE
BOOLEAN
next_hashtab (HASHTAB_ITER tabit, CNSTRING *pkey, HVALUE *pval)
{
	HASHTAB tab=0;
	ASSERT(tabit);
	ASSERT(tabit->magic == hashtab_iter_magic);
	if (!tabit->hashtab) return FALSE;
	tab = tabit->hashtab;
	if (tabit->index == -1 || tab->count == 0)
		return FALSE;
	if (tabit->enext) {
		tabit->enext = tabit->enext->enext;
		if (tabit->enext)
			goto returnit;
		++tabit->index;
	}
	for ( ; tabit->index < tab->maxhash; ++tabit->index) {
			tabit->enext = tab->entries[tabit->index];
			if (tabit->enext)
				goto returnit;
	}
	tabit->index = -1;
	tabit->enext = 0;
	return FALSE;
returnit:
	*pkey = tabit->enext->ekey;
	*pval = tabit->enext->val;
	return TRUE;
}
BOOLEAN next_hashtab ( HASHTAB_ITER tabit , CNSTRING * pkey , HVALUE * pval ) { HASHTAB tab = 0 ; ASSERT ( tabit ) ; ASSERT ( tabit -> magic == hashtab_iter_magic ) ; if ( ! tabit -> hashtab ) return FALSE ; tab = tabit -> hashtab ; if ( tabit -> index == -1 || tab -> count == 0 ) return FALSE ; if ( tabit -> enext ) { tabit -> enext = tabit -> enext -> enext ; if ( tabit -> enext ) goto returnit ; ++ tabit -> index ; } for ( ; tabit -> index < tab -> maxhash ; ++ tabit -> index ) { tabit -> enext = tab -> entries [ tabit -> index ] ; if ( tabit -> enext ) goto returnit ; } tabit -> index = -1 ; tabit -> enext = 0 ; return FALSE ; returnit : * pkey = tabit -> enext -> ekey ; * pval = tabit -> enext -> val ; return TRUE ; }
next_hashtab -- Advance hash table iterator
 If not finished, set pointers and return TRUE
 If no more entries, return FALSE
next_hashtab -- Advance hash table iterator If not finished set pointers and return TRUE If no more entries return FALSE
/* continue current hash chain */ /* find next populated hash chain */ /* finished (ran out of hash chains) */ /* found entry */