library/src/datastructures/BP-HashTable.cc
// returns the number of entries in a table
returns the number of entries in a table
returns the number of entries in a table
size_t BP_HashRegCountEntriesInTable
(
	P_BP_HASH_TABLE_KEYED_ENTRY table,
	BP_HASH_TABLE_COUNT_POLICY  count_policy
)
{
	if(!table)
		return 0;
	if(table->type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE)
		return 0;
	if(!table->data)
		return 0;
	size_t entry_n = 0;
	BP_HASH_ITER_OPEN( (P_BP_HTKE) table->data, tmp_entry)
	{
		switch(count_policy)
		{
			case BP_HASH_TABLE_COUNT_POLICY_COUNT_ONLY_DATA_ENTRIES:
				if(tmp_entry->type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE)
					entry_n++;
				break;
			case BP_HASH_TABLE_COUNT_POLICY_COUNT_ONLY_TABLE_ENTRIES:
				if(tmp_entry->type == BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE)
					entry_n++;
				break;
			case BP_HASH_TABLE_COUNT_POLICY_COUNT_ALL:
				entry_n++;
				break;
		}
	}
	BP_HASH_ITER_CLOSE;
	return entry_n;
}
size_t BP_HashRegCountEntriesInTable ( P_BP_HASH_TABLE_KEYED_ENTRY table , BP_HASH_TABLE_COUNT_POLICY count_policy ) { if ( ! table ) return 0 ; if ( table -> type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE ) return 0 ; if ( ! table -> data ) return 0 ; size_t entry_n = 0 ; BP_HASH_ITER_OPEN ( ( P_BP_HTKE ) table -> data , tmp_entry ) { switch ( count_policy ) { case BP_HASH_TABLE_COUNT_POLICY_COUNT_ONLY_DATA_ENTRIES : if ( tmp_entry -> type != BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE ) entry_n ++ ; break ; case BP_HASH_TABLE_COUNT_POLICY_COUNT_ONLY_TABLE_ENTRIES : if ( tmp_entry -> type == BP_HASH_TABLE_KEYED_ENTRY_TYPE_NAMED_HASH_TABLE ) entry_n ++ ; break ; case BP_HASH_TABLE_COUNT_POLICY_COUNT_ALL : entry_n ++ ; break ; } } BP_HASH_ITER_CLOSE ; return entry_n ; }
returns the number of entries in a table
returns the number of entries in a table
// run basic checks // count tables // switch on the count policy // count data entries // count table entries only // count all // return the entry count