]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/src/lfds710_list_addonly_singlylinked_unordered/lfds710_list_addonly_singlylinked_unordered_get.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / liblfds710 / src / lfds710_list_addonly_singlylinked_unordered / lfds710_list_addonly_singlylinked_unordered_get.c
1 /***** includes *****/
2 #include "lfds710_list_addonly_singlylinked_unordered_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 int lfds710_list_asu_get_by_key( struct lfds710_list_asu_state *lasus,
10                                  int (*key_compare_function)(void const *new_key, void const *existing_key),
11                                  void *key, 
12                                  struct lfds710_list_asu_element **lasue )
13 {
14   int
15     cr = !0,
16     rv = 1;
17
18   LFDS710_PAL_ASSERT( lasus != NULL );
19   LFDS710_PAL_ASSERT( key_compare_function != NULL );
20   // TRD : key can be NULL
21   LFDS710_PAL_ASSERT( lasue != NULL );
22
23   *lasue = NULL;
24
25   while( cr != 0 and LFDS710_LIST_ASU_GET_START_AND_THEN_NEXT(*lasus, *lasue) )
26     cr = key_compare_function( key, (*lasue)->key );
27
28   if( *lasue == NULL )
29     rv = 0;
30
31   return rv;
32 }
33