mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
hash.[ch]:
add Hash_NumElements to get the number of elements in the hash table qfplist.[ch]: add PL_A_NumObjects and PL_D_NumKeys, to get the number of objects or number of keys in the array or dictionary, respectively
This commit is contained in:
parent
85cd891d8c
commit
893d3ec290
4 changed files with 42 additions and 0 deletions
|
@ -139,6 +139,10 @@ unsigned long Hash_String (const char *str);
|
|||
*/
|
||||
unsigned long Hash_Buffer (const void *buf, int len);
|
||||
|
||||
/** return the number of elements in the table.
|
||||
*/
|
||||
size_t Hash_NumElements (hashtab_t *tab);
|
||||
|
||||
/** return a list of all elements in the table. it is the caller's
|
||||
responsibilty to free() the array. Null terminated.
|
||||
*/
|
||||
|
|
|
@ -157,6 +157,15 @@ plitem_t *PL_ObjectAtIndex (plitem_t *, int);
|
|||
*/
|
||||
plitem_t *PL_D_AllKeys (plitem_t *);
|
||||
|
||||
/**
|
||||
\brief Retrieve the number of keys in a dictionalry
|
||||
|
||||
\param dict The dictionary to get the number of keys of.
|
||||
|
||||
\return Returns the number of keys in the dictionary.
|
||||
*/
|
||||
int PL_D_NumKeys (plitem_t *);
|
||||
|
||||
/**
|
||||
\fn qboolean PL_D_AddObject (plitem_t *dict, plitem_t *key, plitem_t *value)
|
||||
|
||||
|
@ -182,6 +191,13 @@ qboolean PL_D_AddObject (plitem_t *, plitem_t *, plitem_t *);
|
|||
*/
|
||||
qboolean PL_A_AddObject (plitem_t *, plitem_t *);
|
||||
|
||||
/**
|
||||
\param array The array to get the number of objects in
|
||||
|
||||
\return number of objects in the array
|
||||
*/
|
||||
int PL_A_NumObjects (plitem_t *array);
|
||||
|
||||
/**
|
||||
\fn qboolean PL_A_InsertObjectAtIndex (plitem_t *array, plitem_t *item, int index)
|
||||
\param array The array to add the item to
|
||||
|
|
|
@ -415,6 +415,12 @@ Hash_Free (hashtab_t *tab, void *ele)
|
|||
tab->free_ele (ele, tab->user_data);
|
||||
}
|
||||
|
||||
size_t
|
||||
Hash_NumElements (hashtab_t *tab)
|
||||
{
|
||||
return tab->num_ele;
|
||||
}
|
||||
|
||||
void **
|
||||
Hash_GetList (hashtab_t *tab)
|
||||
{
|
||||
|
|
|
@ -179,6 +179,14 @@ PL_D_AllKeys (plitem_t *dict)
|
|||
return array;
|
||||
}
|
||||
|
||||
int
|
||||
PL_D_NumKeys (plitem_t *dict)
|
||||
{
|
||||
if (dict->type != QFDictionary)
|
||||
return 0;
|
||||
return Hash_NumElements ((hashtab_t *) dict->data);
|
||||
}
|
||||
|
||||
plitem_t *
|
||||
PL_ObjectAtIndex (plitem_t *array, int index)
|
||||
{
|
||||
|
@ -260,6 +268,14 @@ PL_A_AddObject (plitem_t *array, plitem_t *item)
|
|||
return PL_A_InsertObjectAtIndex (array, item, -1);
|
||||
}
|
||||
|
||||
int
|
||||
PL_A_NumObjects (plitem_t *array)
|
||||
{
|
||||
if (array->type != QFArray)
|
||||
return 0;
|
||||
return ((plarray_t *) array->data)->numvals;
|
||||
}
|
||||
|
||||
static qboolean
|
||||
PL_SkipSpace (pldata_t *pl)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue