From: ppisa Date: Fri, 19 Dec 2008 19:57:26 +0000 (+0000) Subject: Use pointer to constant key type in GSA and GAVL custom types. X-Git-Tag: ul_drv-0.8.0-release~27 X-Git-Url: https://rtime.felk.cvut.cz/gitweb/ulut.git/commitdiff_plain/a82c504bd4be557f440b7e15e2e8120faefe2af3 Use pointer to constant key type in GSA and GAVL custom types. The wish to allow use of constant references to key asked by Michal Sojka for uLUt use in Frescor project. --- diff --git a/ulut/ul_gavl.h b/ulut/ul_gavl.h index 7593a8e..5ce7f53 100644 --- a/ulut/ul_gavl.h +++ b/ulut/ul_gavl.h @@ -424,10 +424,10 @@ cust_prefix##_node2key(const cust_root_t *root, gavl_node_t *node)\ { return &(cust_prefix##_node2item(root, node)->cust_item_key);}\ \ void cust_prefix##_init_root_field(cust_root_t *root);\ -int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep);\ -cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key);\ -cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key);\ -cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key);\ +int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep);\ +cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key);\ +cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key);\ +cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key);\ int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\ int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\ int cust_prefix##_delete(cust_root_t *root, cust_item_t *item);\ diff --git a/ulut/ul_gavlcust.h b/ulut/ul_gavlcust.h index df5d3f7..2a46a6c 100644 --- a/ulut/ul_gavlcust.h +++ b/ulut/ul_gavlcust.h @@ -60,7 +60,7 @@ void cust_prefix##_init_root_field(cust_root_t *root)\ root->cust_root_node=NULL;\ }\ \ -int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep)\ +int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep)\ {\ int cmp=1;\ gavl_node_t *n, *p;\ @@ -81,7 +81,7 @@ int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_nod return cmp;\ }\ \ -cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key)\ {\ gavl_node_t *node;\ if(cust_prefix##_search_node(root, key, &node))\ @@ -89,12 +89,12 @@ cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\ return cust_prefix##_node2item(root,node);\ }\ \ -cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key)\ {\ return cust_prefix##_find(root, key);\ }\ \ -cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key)\ {\ gavl_node_t *node;\ if(cust_prefix##_search_node(root, key, &node)<=0){\ diff --git a/ulut/ul_gavlflesint.h b/ulut/ul_gavlflesint.h index 7733d40..83a9403 100644 --- a/ulut/ul_gavlflesint.h +++ b/ulut/ul_gavlflesint.h @@ -44,10 +44,10 @@ cust_prefix##_node2key(const cust_root_t *root, gavl_node_t *node)\ { return &(cust_prefix##_node2item(root, node)->cust_item_key);}\ \ void cust_prefix##_init_root_field(cust_root_t *root);\ -int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep);\ -cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key);\ -cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key);\ -cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key);\ +int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep);\ +cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key);\ +cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key);\ +cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key);\ int cust_prefix##_insert(cust_root_t *root, cust_item_t *item);\ cust_item_t *cust_prefix##_cut_first(cust_root_t *root);\ int cust_prefix##_delete_node(cust_root_t *root, gavl_node_t *node);\ @@ -136,7 +136,7 @@ void cust_prefix##_init_root_field(cust_root_t *root)\ root->cust_root_field.count=0;\ }\ \ -int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep, int mode)\ +int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep, int mode)\ {\ int cmp=1;\ gavl_node_t *n, *p;\ @@ -174,12 +174,12 @@ int cust_prefix##_search_node4(const cust_root_t *root, cust_key_t *key, gavl_no return cmp;\ }\ \ -int cust_prefix##_search_node(const cust_root_t *root, cust_key_t *key, gavl_node_t **nodep)\ +int cust_prefix##_search_node(const cust_root_t *root, cust_key_t const *key, gavl_node_t **nodep)\ {\ return cust_prefix##_search_node4(root, key, nodep, 0);\ }\ \ -cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t const *key)\ {\ gavl_node_t *node;\ if(cust_prefix##_search_node4(root, key, &node, 0))\ @@ -187,7 +187,7 @@ cust_item_t *cust_prefix##_find(const cust_root_t *root, cust_key_t *key)\ return cust_prefix##_node2item(root,node);\ }\ \ -cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t const *key)\ {\ gavl_node_t *n;\ if(cust_prefix##_search_node4(root, key, &n, GAVL_FFIRST))\ @@ -195,7 +195,7 @@ cust_item_t *cust_prefix##_find_first(const cust_root_t *root, cust_key_t *key)\ return cust_prefix##_node2item(root,n);\ }\ \ -cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t *key)\ +cust_item_t *cust_prefix##_find_after(const cust_root_t *root, cust_key_t const *key)\ {\ gavl_node_t *node;\ if(cust_prefix##_search_node4(root, key, &node, GAVL_FAFTER)<=0){\ diff --git a/ulut/ul_gsa.h b/ulut/ul_gsa.h index 0573616..aecb94f 100644 --- a/ulut/ul_gsa.h +++ b/ulut/ul_gsa.h @@ -167,7 +167,7 @@ static inline cust_key_t *\ cust_prefix##_indx2key(const cust_array_t *array, unsigned indx)\ { return &(cust_prefix##_indx2item(array, indx)->cust_item_key);}\ \ -int cust_prefix##_bsearch_indx(const cust_array_t *array, const cust_key_t *key, int mode, unsigned *indxp);\ +int cust_prefix##_bsearch_indx(const cust_array_t *array, cust_key_t const *key, int mode, unsigned *indxp);\ \ static inline cust_item_t *\ cust_prefix##_at(const cust_array_t *array, unsigned indx)\ @@ -176,7 +176,7 @@ cust_prefix##_at(const cust_array_t *array, unsigned indx)\ }\ \ static inline cust_item_t *\ -cust_prefix##_find(const cust_array_t *array, cust_key_t *key)\ +cust_prefix##_find(const cust_array_t *array, cust_key_t const *key)\ {\ unsigned indx;\ if(!cust_prefix##_bsearch_indx(array, key, 0, &indx)) return NULL;\ @@ -184,7 +184,7 @@ cust_prefix##_find(const cust_array_t *array, cust_key_t *key)\ }\ \ static inline cust_item_t *\ -cust_prefix##_find_first(const cust_array_t *array, cust_key_t *key)\ +cust_prefix##_find_first(const cust_array_t *array, cust_key_t const *key)\ {\ unsigned indx;\ if(!cust_prefix##_bsearch_indx(array, key, GSA_FFIRST, &indx)) return NULL;\ @@ -192,7 +192,7 @@ cust_prefix##_find_first(const cust_array_t *array, cust_key_t *key)\ }\ \ static inline unsigned \ -cust_prefix##_find_first_indx(const cust_array_t *array, cust_key_t *key)\ +cust_prefix##_find_first_indx(const cust_array_t *array, cust_key_t const *key)\ {\ unsigned indx;\ if(!cust_prefix##_bsearch_indx(array, key, GSA_FFIRST, &indx)) return -1;\ @@ -200,7 +200,7 @@ cust_prefix##_find_first_indx(const cust_array_t *array, cust_key_t *key)\ }\ \ static inline cust_item_t *\ -cust_prefix##_find_after(const cust_array_t *array, cust_key_t *key)\ +cust_prefix##_find_after(const cust_array_t *array, cust_key_t const *key)\ {\ unsigned indx;\ if(!cust_prefix##_bsearch_indx(array, key, GSA_FAFTER, &indx)) return NULL;\ @@ -208,7 +208,7 @@ cust_prefix##_find_after(const cust_array_t *array, cust_key_t *key)\ }\ \ static inline unsigned \ -cust_prefix##_find_after_indx(const cust_array_t *array, cust_key_t *key)\ +cust_prefix##_find_after_indx(const cust_array_t *array, cust_key_t const *key)\ {\ unsigned indx;\ cust_prefix##_bsearch_indx(array, key, GSA_FAFTER, &indx);\ @@ -295,21 +295,21 @@ cust_prefix##_is_end_it(cust_prefix##_it_t *it)\ }\ \ static inline int \ -cust_prefix##_find_it(cust_array_t *container, cust_key_t *key, cust_prefix##_it_t *it)\ +cust_prefix##_find_it(cust_array_t *container, cust_key_t const *key, cust_prefix##_it_t *it)\ {\ it->container=container;\ return (it->indx=cust_prefix##_find_first_indx(container, key))!=(unsigned)-1;\ }\ \ static inline int \ -cust_prefix##_find_first_it(cust_array_t *container, cust_key_t *key, cust_prefix##_it_t *it)\ +cust_prefix##_find_first_it(cust_array_t *container, cust_key_t const *key, cust_prefix##_it_t *it)\ {\ it->container=container;\ return (it->indx=cust_prefix##_find_first_indx(container, key))!=(unsigned)-1;\ }\ \ static inline int \ -cust_prefix##_find_after_it(cust_array_t *container, cust_key_t *key, cust_prefix##_it_t *it)\ +cust_prefix##_find_after_it(cust_array_t *container, cust_key_t const *key, cust_prefix##_it_t *it)\ {\ it->container=container;\ return (it->indx=cust_prefix##_find_after_indx(container, key))!=(unsigned)-1;\ diff --git a/ulut/ul_gsacust.h b/ulut/ul_gsacust.h index 655735f..68826a8 100644 --- a/ulut/ul_gsacust.h +++ b/ulut/ul_gsacust.h @@ -35,7 +35,7 @@ extern "C" { cust_array_field, cust_item_key, cust_cmp_fnc, cust_ins_fl) \ \ int \ -cust_prefix##_bsearch_indx(const cust_array_t *array, const cust_key_t *key, \ +cust_prefix##_bsearch_indx(const cust_array_t *array, cust_key_t const *key, \ int mode, unsigned *indx) \ {\ unsigned a, b, c;\