src/hashing/hash_table.h
/**
 * Get the next element.
 * Returns NULL if there is no next element.
 */
Get the next element.
Returns NULL if there is no next element.
Get the next element . Returns NULL if there is no next element .
inline void* hash_table_iterator_next(HashTableIterator* it) {
	while (it->bucket_index < it->hash_table->bucket_count)
		if (it->hash_table->buckets[it->bucket_index] != NULL) {
			while (it->chain_index < it->hash_table->chain_sizes[it->bucket_index]) {
				if (it->hash_table->buckets[it->bucket_index][it->chain_index] != NULL) {
					return it->hash_table->buckets[it->bucket_index][it->chain_index++];
				}
				else {
					++it->chain_index;
				}
			}
			++it->bucket_index;
			it->chain_index = 0;
		}
		else {
			++it->bucket_index;
		}
	return NULL;
}
inline void * hash_table_iterator_next ( HashTableIterator * it ) { while ( it -> bucket_index < it -> hash_table -> bucket_count ) if ( it -> hash_table -> buckets [ it -> bucket_index ] != NULL ) { while ( it -> chain_index < it -> hash_table -> chain_sizes [ it -> bucket_index ] ) { if ( it -> hash_table -> buckets [ it -> bucket_index ] [ it -> chain_index ] != NULL ) { return it -> hash_table -> buckets [ it -> bucket_index ] [ it -> chain_index ++ ] ; } else { ++ it -> chain_index ; } } ++ it -> bucket_index ; it -> chain_index = 0 ; } else { ++ it -> bucket_index ; } return NULL ; }
Get the next element.
Get the next element .
// found a non-NULL chain element // a NULL-element (indicates a removed element) // traversed all elements of this chain, go to the next one // a NULL-bucket (indicates a not yet used bucket) // No non-NULL bucket element und no non-NULL chain element found