axl main logo
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Modules Pages
axlPointer axl_list_lookup ( axlList list,
axlLookupFunc  func,
axlPointer  data 
)

Allows to perform a linear lookup on the list provided, givin a function that is used to now the object to return due to the lookup.

The function can also be used as a foreach function. The following example shows how to launch the function and perform a tasks on the lookup function:

1 // perform the lookup
2 return axl_list_lookup (list, __find_item, name);
3 
4 // the lookup function
5 axl_bool __find_item (axlPointer _element, axlPointer data)
6 {
7  SomeItem * element = _element;
8  char * name = data;
9 
10  // check the name
11  if (axl_cmp (element->name, name))
12  return axl_true;
13 
14  // it is not the element
15  return axl_false;
16 }

In the case you create a list to hold string values, you can use axl_list_find_string as lookup function predefined to perform the search.

Parameters
listThe list where the lookup will be performed.
funcThe function to use to perform the lookup.
dataUser defined data that will be passed to the func provided.
Returns
A pointer to the object found or NULL if no item was found.

References axl_return_val_if_fail.

Referenced by axl_dtd_get_attr(), and axl_dtd_get_element().