list_t add more general search, change previose search name
This commit is contained in:
@@ -30,7 +30,8 @@
|
||||
void remove_all_list_in_##type(struct main_list_##type *var_list);\
|
||||
void increment_list_##type(struct main_list_##type * var_list);\
|
||||
void decrement_list_##type(struct main_list_##type * var_list);\
|
||||
struct list_##type * search_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int funcCmp(type, type));
|
||||
struct list_##type * search_first_occ_with_mov_from_curr_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type), void (*incr_or_decr_mov)(struct main_list_##type *));\
|
||||
struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type));\
|
||||
|
||||
|
||||
GENERATE_LIST_ALL(TYPE_CHAR)
|
||||
@@ -203,14 +204,17 @@ GENERATE_LIST_ALL(TYPE_PTR)
|
||||
var_list->current_list = (var_list->current_list)->preview;\
|
||||
--(var_list->current_index);\
|
||||
}\
|
||||
struct list_##type * search_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\
|
||||
for(move_current_to_begin_list_##type(var_list); var_list->current_list; increment_list_##type(var_list)){\
|
||||
struct list_##type * search_first_occ_with_mov_from_curr_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type), void (*incr_or_decr_mov)(struct main_list_##type *)){\
|
||||
for(; var_list->current_list; incr_or_decr_mov(var_list)){\
|
||||
if(0 == funcCmp(value, var_list->current_list->value))\
|
||||
return var_list->current_list;\
|
||||
}\
|
||||
return NULL;\
|
||||
}\
|
||||
|
||||
struct list_##type * search_first_occ_from_begin_in_list_##type(struct main_list_##type *var_list, type value, int (*funcCmp)(type, type)){\
|
||||
move_current_to_begin_list_##type(var_list);\
|
||||
return search_first_occ_with_mov_from_curr_in_list_##type(var_list, value, funcCmp, increment_list_##type);\
|
||||
}\
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user