X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fq.h;h=db55cd676b0040d290457ff99fbd67a598078ae2;hb=6b14c68239f98b818a7aacacc49bb7a16bfa7812;hp=942bf286a0a3e6163247c8c75aa27a99da48fb74;hpb=ddf646ca8e7a6f30ed99c144b46483199cfb8e8f;p=swftools.git diff --git a/lib/q.h b/lib/q.h index 942bf28..db55cd6 100644 --- a/lib/q.h +++ b/lib/q.h @@ -120,6 +120,12 @@ typedef struct _heap int(*compare)(const void *, const void *); } heap_t; +typedef struct _trie { + struct _trie*row[256]; + unsigned char*rest; +} trie_t; + + char* strdup_n(const char*str, int size); unsigned int crc32_add_byte(unsigned int crc32, unsigned char b); @@ -168,6 +174,7 @@ void stringarray_destroy(stringarray_t*sa); dict_t*dict_new(); dict_t*dict_new2(type_t*type); void dict_init(dict_t*dict, int size); +void dict_init2(dict_t*dict, type_t*type, int size); dictentry_t*dict_put(dict_t*h, const void*key, void* data); void dict_put2(dict_t*h, const char*s, void*data); int dict_count(dict_t*h); @@ -184,6 +191,9 @@ void dict_free_all(dict_t*h, char free_keys, void (*free_data_function)(void*)); void dict_clear(dict_t*h); void dict_destroy_shallow(dict_t*dict); void dict_destroy(dict_t*dict); +#define DICT_ITERATE_DATA(d,t,v) int v##_i;dictentry_t*v##_e;t v;for(v##_i=0;v##_i<(d)->hashsize;v##_i++) for(v##_e=(d)->slots[v##_i]; v##_e && ((v=(t)v##_e->data)||1); v##_e=v##_e->next) +#define DICT_ITERATE_KEY(d,t,v) int v##_i;dictentry_t*v##_e;t v;for(v##_i=0;v##_i<(d)->hashsize;v##_i++) for(v##_e=(d)->slots[v##_i];v##_e && ((v=(t)v##_e->key)||1);v##_e=v##_e->next) +#define DICT_ITERATE_ITEMS(d,t1,v1,t2,v2) int v1##_i;dictentry_t*v1##_e;t1 v1;t2 v2;for(v1##_i=0;v1##_i<(d)->hashsize;v1##_i++) for(v1##_e=(d)->slots[v1##_i]; v1##_e && (((v1=(t1)v1##_e->key)&&(v2=(t2)v1##_e->data))||1); v1##_e=v1##_e->next) void map_init(map_t*map); void map_put(map_t*map, string_t t1, string_t t2); @@ -201,6 +211,10 @@ void* heap_chopmax(heap_t*h); void heap_dump(heap_t*h, FILE*fi); void** heap_flatten(heap_t*h); +void trie_put(trie_t**t, unsigned const char*id); +char trie_remove(trie_t*t, unsigned const char*id); +int trie_lookup(trie_t*t, unsigned const char*id); + array_t* array_new(); array_t* array_new2(type_t*type); void array_free(array_t*array);