Update Apple's list and hash utility routines to latest versions (John

Harper).
This commit is contained in:
Torrey Lyons 2004-09-17 21:57:26 +00:00
parent b56f4532d1
commit cedb9a8d62
3 changed files with 149 additions and 129 deletions

View File

@ -35,8 +35,8 @@
#include <assert.h>
struct x_hash_table_struct {
int bucket_index;
int total_keys;
unsigned int bucket_index;
unsigned int total_keys;
x_list **buckets;
x_hash_fun *hash_key;

View File

@ -167,6 +167,25 @@ X_PFX (list_nth) (x_list *lst, int n)
return lst;
}
X_EXTERN x_list *
X_PFX (list_pop) (x_list *lst, void **data_ret)
{
void *data = NULL;
if (lst != NULL)
{
x_list *tem = lst;
data = lst->data;
lst = lst->next;
X_PFX (list_free_1) (tem);
}
if (data_ret != NULL)
*data_ret = data;
return lst;
}
X_EXTERN x_list *
X_PFX (list_filter) (x_list *lst,
int (*pred) (void *item, void *data), void *data)

View File

@ -55,6 +55,7 @@ X_EXTERN x_list *X_PFX (list_prepend) (x_list *lst, void *data);
X_EXTERN x_list *X_PFX (list_append) (x_list *lst, void *data);
X_EXTERN x_list *X_PFX (list_remove) (x_list *lst, void *data);
X_EXTERN void X_PFX (list_free) (x_list *lst);
X_EXTERN x_list *X_PFX (list_pop) (x_list *lst, void **data_ret);
X_EXTERN x_list *X_PFX (list_copy) (x_list *lst);
X_EXTERN x_list *X_PFX (list_reverse) (x_list *lst);