X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fq.h;h=58e18c324aea6e26b5b2d154638359a030988847;hp=f6d597dac3c24bdaa9de992b59c40583e2f7cbeb;hb=f9777d63606840b68fc86df0a96ee1a79ab04e69;hpb=5ba24931ec3861ca5befcaae1502dd9105639b44 diff --git a/lib/q.h b/lib/q.h index f6d597d..58e18c3 100644 --- a/lib/q.h +++ b/lib/q.h @@ -73,6 +73,7 @@ typedef struct _type_t { extern type_t charptr_type; extern type_t stringstruct_type; extern type_t ptr_type; +extern type_t int_type; typedef struct _dictentry { void*key; @@ -132,6 +133,18 @@ typedef struct _trie { void*rollback; } trie_t; +/* move to front list structure */ +typedef struct _mtf_item { + const void*key; + int num; + struct _mtf_item*next; +} mtf_item_t; + +typedef struct _mtf { + mtf_item_t*first; + type_t*type; +} mtf_t; + char* strdup_n(const char*str, int size); char* allocprintf(const char*str, ...); @@ -139,6 +152,7 @@ float medianf(float*values, int n); unsigned int crc32_add_byte(unsigned int crc32, unsigned char b); unsigned int crc32_add_string(unsigned int crc32, const char*s); +unsigned int crc32_add_bytes(unsigned int checksum, const void*s, int len); void mem_init(mem_t*mem); int mem_put(mem_t*m, void*data, int length); @@ -212,7 +226,7 @@ void dict_destroy(dict_t*dict); #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) + for(v1##_e=(d)->slots[v1##_i]; v1##_e && (((v1=(t1)v1##_e->key)||1)&&((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); @@ -242,6 +256,10 @@ void trie_remember(trie_t*t); void trie_rollback(trie_t*t); void trie_dump(trie_t*t); +mtf_t* mtf_new(type_t*type); +void mtf_increase(mtf_t*m, const void*key); +void mtf_destroy(mtf_t*m); + array_t* array_new(); array_t* array_new2(type_t*type); void array_free(array_t*array);