mirror of
git://git.sv.nongnu.org/freetype/freetype2.git
synced 2026-01-19 04:52:09 +00:00
[base] Add iterators for FT_Hash.
* src/base/fthash.c (ft_hash_num_iterator, ft_hash_str_iterator): New functions. * include/freetype/internal/fthash.h: Updated.
This commit is contained in:
@@ -125,6 +125,17 @@ FT_BEGIN_HEADER
|
||||
ft_hash_num_lookup( FT_Int num,
|
||||
FT_Hash hash );
|
||||
|
||||
FT_Bool
|
||||
ft_hash_num_iterator( FT_UInt *idx,
|
||||
FT_Int *key,
|
||||
size_t *value,
|
||||
FT_Hash hash );
|
||||
|
||||
FT_Bool
|
||||
ft_hash_str_iterator( FT_UInt *idx,
|
||||
const char* *key,
|
||||
size_t *value,
|
||||
FT_Hash hash );
|
||||
|
||||
FT_END_HEADER
|
||||
|
||||
|
||||
@@ -335,4 +335,68 @@
|
||||
}
|
||||
|
||||
|
||||
FT_Bool
|
||||
ft_hash_num_iterator( FT_UInt *idx,
|
||||
FT_Int *key,
|
||||
size_t *value,
|
||||
FT_Hash hash )
|
||||
{
|
||||
FT_Hashnode nn = NULL;
|
||||
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( *idx >= hash->size )
|
||||
return 0;
|
||||
|
||||
nn = hash->table[*idx];
|
||||
if ( nn )
|
||||
break;
|
||||
|
||||
(*idx)++;
|
||||
}
|
||||
|
||||
if ( key )
|
||||
*key = nn->key.num;
|
||||
if ( value )
|
||||
*value = nn->data;
|
||||
|
||||
(*idx)++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
FT_Bool
|
||||
ft_hash_str_iterator( FT_UInt *idx,
|
||||
const char* *key,
|
||||
size_t *value,
|
||||
FT_Hash hash )
|
||||
{
|
||||
FT_Hashnode nn = NULL;
|
||||
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( *idx >= hash->size )
|
||||
return 0;
|
||||
|
||||
nn = hash->table[*idx];
|
||||
if ( nn )
|
||||
break;
|
||||
|
||||
(*idx)++;
|
||||
}
|
||||
|
||||
if ( key )
|
||||
*key = nn->key.str;
|
||||
if ( value )
|
||||
*value = nn->data;
|
||||
|
||||
(*idx)++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* END */
|
||||
|
||||
Reference in New Issue
Block a user