libSBML C API  libSBML 5.20.2 C API
Loading...
Searching...
No Matches
List.h File Reference

Simple, generic list utility class. More...

Include dependency graph for List.h:
This graph shows which files directly or indirectly include this file:

Macros

#define List_freeItems(list, free_item, type)
 @_tendcond_t
 

Typedefs

typedef void(* ListDeleteItemFunc) (void *item)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 
typedef int(* ListItemComparator) (const void *item1, const void *item2)
 _tA_t @_tsbmlconstant_t{_tListItemComparator_t,} _tis_t _ta_t _ttypedef_t _tfor_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tthat_t _tcompares_t _ttwo_t _tlist_t _titems_t.
 
typedef int(* ListItemPredicate) (const void *item)
 _tA_t @_tsbmlconstant_t{_tListItemPredicate_t,} _tis_t _ta_t _ttypedef_t _tfor_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tthat_t _ttakes_t _ta_t _tList_t _titem_t _tand_t _treturns_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t).
 

Functions

void List_add (List_t *lst, void *item)
 @_tendcond_t
 
unsigned int List_countIf (const List_t *lst, ListItemPredicate predicate)
 @_treturn_t _tthe_t _tnumber_t _tof_t _titems_t _tin_t _tthis_t _tList_t_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.
 
List_tList_create (void)
 _tCreates_t _ta_t _tnew_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.
 
void * List_find (const List_t *lst, const void *item1, ListItemComparator comparator)
 _tSearches_t _tthe_t _tList_t_t _tfor_t _tan_t _tentry_t _tthat_t _tmatches_t @_tp_t _titem1_t, _taccording_t _tto_t @_tp_t _tcomparator_t.
 
List_tList_findIf (const List_t *lst, ListItemPredicate predicate)
 _tCreate_t _tand_t _treturn_t _ta_t _tnew_t _tList_t_t _twith_t _tthe_t _tsubset_t _tof_t _titems_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.
 
void List_free (List_t *lst)
 @_tendcond_t
 
void * List_get (const List_t *lst, unsigned int n)
 _tReturns_t _tthe_t _tnth_t _titem_t _tin_t _tthis_t _tList_t_t.
 
void List_prepend (List_t *lst, void *item)
 _tAdds_t _titem_t _tto_t _tthe_t _tbeginning_t _tof_t _tthis_t _tList_t_t.
 
void * List_remove (List_t *lst, unsigned int n)
 _tRemoves_t _tthe_t _tnth_t _titem_t _tfrom_t _tthis_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.
 
unsigned int List_size (const List_t *lst)
 _tThe_t _tnumber_t _tof_t _telements_t _tin_t @_tp_t _tlst_t.
 
ListNode_t * ListNode_create (void *item)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 
void ListNode_free (ListNode_t *node)
 @_tcond_t _tdoxygenLibsbmlInternal_t
 

Detailed Description

Simple, generic list utility class.

Author
Ben Bornstein

Macro Definition Documentation

◆ List_freeItems

#define List_freeItems (   list,
  free_item,
  type 
)
Value:
{ \
unsigned int size = List_size(list); \
while (size--) free_item( (type *) List_remove(list, 0) ); \
}
void * List_remove(List_t *lst, unsigned int n)
_tRemoves_t _tthe_t _tnth_t _titem_t _tfrom_t _tthis_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer...
Definition List.cpp:553
unsigned int List_size(const List_t *lst)
_tThe_t _tnumber_t _tof_t _telements_t _tin_t @_tp_t _tlst_t.
Definition List.cpp:567

@_tendcond_t

@_tdef_t _tList_freeItems_t(_tlist_t, _tfree_item_t, _ttype_t) _tFrees_t _tthe_t _titems_t _tin_t _tthe_t _tgiven_t _tList_t.

_tIterates_t _tover_t _tthe_t _titems_t _tin_t _tthis_t _tList_t _tand_t _tfrees_t _teach_t _tone_t _tin_t _tturn_t _tby_t _tcalling_t _tthe_t _tpassed_t-_tin_t '_tvoid_t _tfree_item_t(_ttype_t *)' _tfunction_t.

_tThe_t _tList_t _titself_t _twill_t _tnot_t _tbe_t _tfreed_t _tand_t _tso_t _tmay_t _tbe_t _tre_t-_tused_t. _tTo_t _tfree_t _tthe_t _tList_t, _tuse_t _tthe_t _tdestructor_t.

_tWhile_t _tthe_t _tfunction_t _tprototype_t _tcannot_t _tbe_t _texpressed_t _tprecisely_t _tin_t _tC_t _tsyntax_t, _tit_t _tis_t _troughly_t: @_tcode_t _tList_freeItems_t(_tList_t_t *_tlst_t, _tvoid_t (*_tfree_item_t)(_ttype_t *), _ttype_t) @_tendcode_t _twhere_t @_tc_t _ttype_t _tis_t _ta_t _tC_t _ttype_t _tresolved_t _tat_t _tcompile_t _ttime_t.

_tBelieve_t _tit_t _tor_t _tnot_t, _tdefining_t _tList_freeItems_t() _tas_t _ta_t _tmacro_t _tis_t _tactually_t _tmore_t _ttype_t _tsafe_t _tthan_t _tcan_t _tbe_t _tacheived_t _twith_t _tstraight_t _tC_t. _tThat_t _tis_t, _tin_t _tC_t, _tthe_t _tfree_item_t() _tfunction_t _twould_t _tneed_t _tto_t _ttake_t _ta_t _tvoid_t _tpointer_t _targument_t, _trequiring_t _tany_t _ttype_t _tsafe_t _tXXX_free_t() _tfunctions_t _tto_t _tbe_t _tre_t-_twritten_t _tto_t _tbe_t _tless_t _tsafe_t.

_tAs_t _twith_t _tall_t _tline_t-_tcontinuation_t _tmacros_t, _tcompile_t-_ttime_t _terrors_t _twill_t _tstill_t _treport_t _tthe_t _tcorrect_t _tline_t _tnumber_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

Examples
printRegisteredPackages.c.

Typedef Documentation

◆ ListDeleteItemFunc

typedef void(* ListDeleteItemFunc) (void *item)

@_tcond_t _tdoxygenLibsbmlInternal_t

_tA_t @_tsbmlconstant_t{_tListDeleteItemFunc_t,} _tis_t _ta_t _ttypedef_t _tfor_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tthat_t _ttakes_t _ta_t _tList_t _titem_t _tand_t _tdeletes_t / _tfrees_t _tit_t _tas_t _tapropriate_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

◆ ListItemComparator

typedef int(* ListItemComparator) (const void *item1, const void *item2)

_tA_t @_tsbmlconstant_t{_tListItemComparator_t,} _tis_t _ta_t _ttypedef_t _tfor_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tthat_t _tcompares_t _ttwo_t _tlist_t _titems_t.

_tThe_t _treturn_t _tvalue_t _tsemantics_t _tare_t _tthe_t _tsame_t _tas_t _tfor_t _tthe_t _tC_t _tlibrary_t _tfunction_t @_tc_t _tstrcmp_t: <_tul_t> <_tli_t> -_t1_t: @_tp_t _titem1_t < @_tp_t _titem2_t <_tli_t> _t0_t: @_tp_t _titem1_t == @_tp_t _titem2_t <_tli_t> _t1_t: @_tp_t _titem1_t > @_tp_t _titem2_t </_tul_t> @_tsee_t _tList_find_t()

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

◆ ListItemPredicate

typedef int(* ListItemPredicate) (const void *item)

_tA_t @_tsbmlconstant_t{_tListItemPredicate_t,} _tis_t _ta_t _ttypedef_t _tfor_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tthat_t _ttakes_t _ta_t _tList_t _titem_t _tand_t _treturns_t @_tc_t _t1_t (_ttrue_t) _tor_t @_tc_t _t0_t (_tfalse_t).

@_tsee_t _tList_countIf_t()

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

Function Documentation

◆ List_add()

void List_add ( List_t lst,
void *  item 
)

@_tendcond_t

_tAdds_t _ta_t _tpointer_t _tto_t @_tp_t _titem_t _tto_t _tthe_t _tend_t _tof_t _tthis_t _tList_t_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _titem_t _tthe_t _titem_t _tto_t _tadd_t _tto_t _tthe_t _tend_t _tof_t _tthe_t _tlist_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

◆ List_countIf()

unsigned int List_countIf ( const List_t lst,
ListItemPredicate  predicate 
)

@_treturn_t _tthe_t _tnumber_t _tof_t _titems_t _tin_t _tthis_t _tList_t_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.

_tThe_t _ttypedef_t _tfor_t @_tsbmlconstant_t{_tListItemPredicate_t,} _tis_t:

_tint_t (*_tListItemPredicate_t) (_tconst_t _tvoid_t *_titem_t);

_twhere_t _ta_t _treturn_t _tvalue_t _tof_t @_tc_t _t1_t _trepresents_t _ttrue_t _tand_t @_tc_t _t0_t _trepresents_t _tfalse_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _tpredicate_t _tthe_t _tpredicate_t _tto_t _ttest_t _tthe_t _telements_t _tof_t _tthe_t _tlist_t _tagainst_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

@_treturn_t _tthe_t _tnumber_t _tof_t _titems_t _tin_t _tthis_t _tList_t_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.

◆ List_create()

List_t * List_create ( void  )

_tCreates_t _ta_t _tnew_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.

_tThe_t _tpointer_t _tthat_t _tis_t _treturned_t _tby_t _tthis_t _tfunction_t _tis_t _towned_t _tby_t _tthe_t _tcaller_t, _twho_t _tis_t _tresponsible_t _tfor_t _tdeleting_t _tit_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tCreates_t _ta_t _tnew_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

◆ List_find()

void * List_find ( const List_t lst,
const void *  item1,
ListItemComparator  comparator 
)

_tSearches_t _tthe_t _tList_t_t _tfor_t _tan_t _tentry_t _tthat_t _tmatches_t @_tp_t _titem1_t, _taccording_t _tto_t @_tp_t _tcomparator_t.

_tThe_t @_tsbmlconstant_t{_tListItemComparator_t,} _tis_t _ta_t _tpointer_t _tto_t _ta_t _tfunction_t _tused_t _tto_t _tfind_t _ta_t _tmatching_t _tentry_t. _tThe_t _ttypedef_t _tfor_t @_tsbmlconstant_t{_tListItemComparator_t,} _tis_t:

_tint_t (*_tListItemComparator_t) (_tvoid_t *_titem1_t, _tvoid_t *_titem2_t);

_tThe_t _treturn_t _tvalue_t _tsemantics_t _tare_t _tthe_t _tsame_t _tas_t _tfor_t _tstrcmp_t: <_tul_t> <_tli_t> -_t1_t _titem1_t < _titem2_t, <_tli_t> _t0_t _titem1_t == _titem_t _t2_t <_tli_t> _t1_t _titem1_t > _titem2_t </_tul_t>

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _titem1_t _tthe_t _titem_t _tto_t _tlook_t _tfor_t. @_tparam_t _tcomparator_t _tthe_t _tpointer_t _tto_t _tthe_t _tfunction_t _tused_t _tto_t _tfind_t _tthe_t _titem_t.

@_treturn_t _tthe_t _tfirst_t _toccurrence_t _tof_t _tan_t _tentry_t _tmatching_t @_tp_t _titem1_t _tin_t _tthis_t _tList_t_t _tor_t @_tc_t _tNULL_t _tif_t _titem_t _twas_t _tnot_t _tfound_t.

_tThe_t _tpointer_t _tthat_t _tis_t _treturned_t _tby_t _tthis_t _tfunction_t _tis_t _tnot_t _towned_t _tby_t _tthe_t _tcaller_t, _tbut_t _tmay_t _tbe_t _tqueried_t _tand_t _tmodified_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tSearches_t _tthe_t _tList_t_t _tfor_t _tan_t _tentry_t _tthat_t _tmatches_t @_tp_t _titem1_t, _taccording_t _tto_t @_tp_t _tcomparator_t.

◆ List_findIf()

List_t * List_findIf ( const List_t lst,
ListItemPredicate  predicate 
)

_tCreate_t _tand_t _treturn_t _ta_t _tnew_t _tList_t_t _twith_t _tthe_t _tsubset_t _tof_t _titems_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.

_tThe_t _treturned_t _tlist_t _tmay_t _tbe_t _tempty_t.

_tThe_t _tcaller_t _towns_t _tthe_t _treturned_t _tlist_t (_tbut_t _tnot_t _tits_t _tconstituent_t _titems_t) _tand_t _tis_t _tresponsible_t _tfor_t _tfreeing_t _tit_t _twith_t _tList_free_t().

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _tpredicate_t _tthe_t _tpredicate_t _tto_t _ttest_t _tthe_t _telements_t _tof_t _tthe_t _tlist_t _tagainst_t.

@_treturn_t _ta_t _tnew_t _tList_t_t _tcontaining_t (_tpointers_t _tto_t) _tall_t _titems_t _tin_t _tthis_t _tList_t_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _twas_t _ttrue_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tCreate_t _tand_t _treturn_t _ta_t _tnew_t _tList_t_t _twith_t _tthe_t _tsubset_t _tof_t _titems_t _tfor_t _twhich_t <_tcode_t>_tpredicate_t(_titem_t)</_tcode_t> _treturns_t _ttrue_t.

◆ List_free()

void List_free ( List_t lst)

@_tendcond_t

_tFrees_t _tthe_t _tgiven_t _tList_t_t.

_tThis_t _tfunction_t _tdoes_t _tnot_t _tfree_t _tList_t_t _titems_t. _tIt_t _tfrees_t _tonly_t _tthe_t _tList_t_t _tstructure_t _tand_t _tits_t _tconstituent_t _tinternal_t _tstructures_t (_tif_t _tany_t).

_tPresumably_t, _tyou_t _teither_t _ti_t) _thave_t _tpointers_t _tto_t _tthe_t _tindividual_t _tlist_t _titems_t _telsewhere_t _tin_t _tyour_t _tprogram_t _tand_t _tyou_t _twant_t _tto_t _tkeep_t _tthem_t _taround_t _tfor_t _tawhile_t _tlonger_t _tor_t _tii_t) _tthe_t _tlist_t _thas_t _tno_t _titems_t ( _tList_size_t() == @_tc_t _t0_t ). _tIf_t _tneither_t _tare_t _ttrue_t, _ttry_t _tList_freeItems_t() _tinstead_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

◆ List_get()

void * List_get ( const List_t lst,
unsigned int  n 
)

_tReturns_t _tthe_t _tnth_t _titem_t _tin_t _tthis_t _tList_t_t.

_tIf_t _tn_t > _tList_size_t() _treturns_t _tNULL_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _tn_t _tthe_t _tindex_t _tof_t _tthe_t _titem_t _tto_t _tfind_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tReturns_t _tthe_t _tnth_t _titem_t _tin_t _tthis_t _tList_t_t.

◆ List_prepend()

void List_prepend ( List_t lst,
void *  item 
)

_tAdds_t _titem_t _tto_t _tthe_t _tbeginning_t _tof_t _tthis_t _tList_t_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _titem_t _tthe_t _titem_t _tto_t _tadd_t _tto_t _tthe_t _tlist_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tAdds_t _titem_t _tto_t _tthe_t _tbeginning_t _tof_t _tthis_t _tList_t_t.

◆ List_remove()

void * List_remove ( List_t lst,
unsigned int  n 
)

_tRemoves_t _tthe_t _tnth_t _titem_t _tfrom_t _tthis_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.

_tIf_t _tn_t > _tList_size_t() _treturns_t _tNULL_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t. @_tparam_t _tn_t _tthe_t _tindex_t _tof_t _tthe_t _titem_t _tto_t _tremove_t.

_tUnlike_t _tother_t '_tremove_t' _tfunctions_t _tin_t _tlibsbml_t, _tthe_t _tcaller_t _tdoes_t _tnot_t _town_t _tthe_t _treturned_t _titem_t: _tit_t _tcontinues_t _tto_t _tbe_t _towned_t _tby_t _twhoever_t _towned_t _tit_t _tbefore_t _tbeing_t _tput_t _ton_t _tthe_t _tList_t_t. _tIt_t _tmay_t _tbe_t _tqueried_t _tor_t _tchanged_t _tby_t _tthe_t _tcaller_t, _tlike_t _tother_t _telements_t _tof_t _tthe_t _tList_t_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tRemoves_t _tthe_t _tnth_t _titem_t _tfrom_t _tthis_t _tList_t_t _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tit_t.

◆ List_size()

unsigned int List_size ( const List_t lst)

_tThe_t _tnumber_t _tof_t _telements_t _tin_t @_tp_t _tlst_t.

@_tparam_t _tlst_t _tthe_t _tList_t_t _tstructure_t.

@_treturn_t _tthe_t _tnumber_t _tof_t _telements_t _tin_t _tthe_t _tgiven_t _tList_t_t.

@_tif_t _tconly_t @_tmemberof_t _tList_t_t @_tendif_t

_tThe_t _tnumber_t _tof_t _telements_t _tin_t @_tp_t _tlst_t.

◆ ListNode_create()

ListNode_t * ListNode_create ( void *  item)

@_tcond_t _tdoxygenLibsbmlInternal_t

_tCreates_t _ta_t _tnew_t _tListNode_t_t (_twith_t @_tp_t _titem_t) _tand_t _treturns_t _ta_t _tpointer_t _tto_t _tthe_t _tnode_t.

@_tparam_t _titem_t _tthe_t _titem_t _tto_t _tcreate_t _ta_t _tListNode_t_t _tfor_t.

_tThe_t _tpointer_t _tthat_t _tis_t _treturned_t _tby_t _tthis_t _tfunction_t _tis_t _towned_t _tby_t _tthe_t _tcaller_t, _twho_t _tis_t _tresponsible_t _tfor_t _tdeleting_t _tit_t.

@_tif_t _tconly_t @_tmemberof_t _tListNode_t_t @_tendif_t

◆ ListNode_free()

void ListNode_free ( ListNode_t *  node)

@_tcond_t _tdoxygenLibsbmlInternal_t

_tFrees_t _tthe_t _tgiven_t _tListNode_t_t.

@_tparam_t _tnode_t _tthe_t _tListNode_t_t _tstructure_t.

@_tmemberof_t _tListNode_t_t