qse/ase/awk/hash.h

56 lines
1.1 KiB
C
Raw Normal View History

2005-11-07 16:02:44 +00:00
/*
2006-01-30 14:34:47 +00:00
* $Id: hash.h,v 1.4 2006-01-30 14:34:47 bacon Exp $
2005-11-07 16:02:44 +00:00
*/
#ifndef _XP_AWK_HASH_H_
#define _XP_AWK_HASH_H_
2006-01-29 18:28:14 +00:00
#ifdef __STAND_ALONE
#include <xp/awk/sa.h>
#else
#include <xp/types.h>
#include <xp/macros.h>
#endif
typedef struct xp_awk_hash_t xp_awk_hash_t;
2006-01-30 13:25:26 +00:00
typedef struct xp_awk_pair_t xp_awk_pair_t;
2006-01-29 18:28:14 +00:00
2006-01-30 13:25:26 +00:00
struct xp_awk_pair_t
2006-01-29 18:28:14 +00:00
{
2006-01-30 14:34:47 +00:00
xp_char_t* key;
2006-01-29 18:28:14 +00:00
void* value;
2006-01-30 13:25:26 +00:00
xp_awk_pair_t* next;
2006-01-29 18:28:14 +00:00
};
struct xp_awk_hash_t
{
xp_size_t size;
xp_size_t capa;
2006-01-30 13:25:26 +00:00
xp_awk_pair_t** buck;
2006-01-30 14:34:47 +00:00
void (*free_value) (void*);
2006-01-29 18:28:14 +00:00
xp_bool_t __dynamic;
};
2005-11-07 16:02:44 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2006-01-30 14:34:47 +00:00
xp_awk_hash_t* xp_awk_hash_open (
xp_awk_hash_t* hash, xp_size_t capa, void (*free_value) (void*));
2006-01-30 13:25:26 +00:00
void xp_awk_hash_close (xp_awk_hash_t* hash);
void xp_awk_hash_clear (xp_awk_hash_t* hash);
2006-01-30 14:34:47 +00:00
xp_awk_pair_t* xp_awk_hash_get (xp_awk_hash_t* hash, xp_char_t* key);
xp_awk_pair_t* xp_awk_hash_put (xp_awk_hash_t* hash, xp_char_t* key, void* value);
xp_awk_pair_t* xp_awk_hash_set (xp_awk_hash_t* hash, xp_char_t* key, void* value);
2006-01-30 13:25:26 +00:00
2006-01-30 14:34:47 +00:00
int xp_awk_hash_remove (xp_awk_hash_t* hash, xp_char_t* key);
int xp_awk_hash_walk (xp_awk_hash_t* hash, int (*walker) (xp_awk_pair_t*));
2005-11-07 16:02:44 +00:00
#ifdef __cplusplus
}
#endif
#endif