2007-05-02 01:07:00 +00:00
|
|
|
/*
|
2007-07-29 23:42:00 +00:00
|
|
|
* $Id: map.h,v 1.7 2007/07/25 07:00:09 bacon Exp $
|
2007-05-02 01:07:00 +00:00
|
|
|
*
|
|
|
|
* {License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASE_AWK_MAP_H_
|
|
|
|
#define _ASE_AWK_MAP_H_
|
|
|
|
|
|
|
|
#ifndef _ASE_AWK_AWK_H_
|
|
|
|
#error Include <ase/awk/awk.h> first
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*typedef struct ase_awk_map_t ase_awk_map_t;*/
|
|
|
|
typedef struct ase_awk_pair_t ase_awk_pair_t;
|
|
|
|
|
|
|
|
struct ase_awk_pair_t
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ase_char_t* ptr;
|
|
|
|
ase_size_t len;
|
|
|
|
} key;
|
|
|
|
|
|
|
|
void* val;
|
|
|
|
ase_awk_pair_t* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ase_awk_map_t
|
|
|
|
{
|
|
|
|
void* owner;
|
|
|
|
ase_size_t size;
|
|
|
|
ase_size_t capa;
|
2007-07-29 23:42:00 +00:00
|
|
|
unsigned int factor;
|
|
|
|
ase_size_t threshold;
|
2007-05-02 01:07:00 +00:00
|
|
|
ase_awk_pair_t** buck;
|
|
|
|
void (*freeval) (void*,void*);
|
|
|
|
ase_awk_t* awk;
|
|
|
|
};
|
|
|
|
|
2007-05-06 19:44:00 +00:00
|
|
|
#define ASE_AWK_PAIR_KEYPTR(p) ((p)->key.ptr)
|
|
|
|
#define ASE_AWK_PAIR_KEYLEN(p) ((p)->key.len)
|
|
|
|
#define ASE_AWK_PAIR_VAL(p) ((p)->val)
|
|
|
|
#define ASE_AWK_PAIR_LNK(p) ((p)->next)
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ase_awk_map_t* ase_awk_map_open (
|
2007-07-29 23:42:00 +00:00
|
|
|
void* owner, ase_size_t capa, unsigned int factor,
|
2007-05-02 01:07:00 +00:00
|
|
|
void(*freeval)(void*,void*), ase_awk_t* awk);
|
|
|
|
|
|
|
|
void ase_awk_map_close (ase_awk_map_t* map);
|
|
|
|
|
|
|
|
void ase_awk_map_clear (ase_awk_map_t* map);
|
|
|
|
|
|
|
|
ase_size_t ase_awk_map_getsize (ase_awk_map_t* map);
|
|
|
|
|
|
|
|
ase_awk_pair_t* ase_awk_map_get (
|
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen);
|
|
|
|
|
|
|
|
ase_awk_pair_t* ase_awk_map_put (
|
2007-05-07 01:05:00 +00:00
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen,
|
|
|
|
void* val);
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
int ase_awk_map_putx (
|
2007-05-07 01:05:00 +00:00
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen,
|
2007-05-02 01:07:00 +00:00
|
|
|
void* val, ase_awk_pair_t** px);
|
|
|
|
|
|
|
|
ase_awk_pair_t* ase_awk_map_set (
|
2007-05-07 01:05:00 +00:00
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen,
|
|
|
|
void* val);
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
ase_awk_pair_t* ase_awk_map_getpair (
|
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen,
|
|
|
|
void** val);
|
|
|
|
|
|
|
|
ase_awk_pair_t* ase_awk_map_setpair (
|
|
|
|
ase_awk_map_t* map, ase_awk_pair_t* pair, void* val);
|
|
|
|
|
|
|
|
int ase_awk_map_remove (
|
2007-05-07 01:05:00 +00:00
|
|
|
ase_awk_map_t* map, const ase_char_t* keyptr, ase_size_t keylen);
|
2007-05-02 01:07:00 +00:00
|
|
|
|
|
|
|
int ase_awk_map_walk (ase_awk_map_t* map,
|
|
|
|
int (*walker)(ase_awk_pair_t*,void*), void* arg);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|