]> rtime.felk.cvut.cz Git - ulut.git/commitdiff
Use pointer to constant key type in GSA and GAVL custom types.
authorppisa <ppisa>
Fri, 19 Dec 2008 19:57:26 +0000 (19:57 +0000)
committerppisa <ppisa>
Fri, 19 Dec 2008 19:57:26 +0000 (19:57 +0000)
The wish to allow use of constant references to key asked
by Michal Sojka for uLUt use in Frescor project.

ulut/ul_gavl.h
ulut/ul_gavlcust.h
ulut/ul_gavlflesint.h
ulut/ul_gsa.h
ulut/ul_gsacust.h

index 7593a8e90a3a658caa3bf62a372627ca62d5a5ea..5ce7f531725d2649a92eb054b7215ab4fa4e84b7 100644 (file)
@@ -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);\
index df5d3f71d040f44c653ddc80aca0c7316de60be7..2a46a6cfc2fde1b2bb9afbca4a9fe0fbfbba3b4d 100644 (file)
@@ -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){\
index 7733d4090db0a41eb88ce1f6611d3a6326653597..83a94031984041525e9b38d8fa85f2a1f8859e2a 100644 (file)
@@ -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){\
index 0573616aad72677f57dc4a8174621e020961a3a8..aecb94f4fea7b1e4578acd87924a4c0f4550931f 100644 (file)
@@ -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;\
index 655735fed17ac92b881bb5bc027006e0268cb211..68826a8fae0f4ddc2e9a1a355b98fefe1e32bd23 100644 (file)
@@ -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;\