Data Structures | |
| struct | EGeList_t |
| List Node Structure. More... | |
| struct | integer_list_t |
| example of integer number lists structure based on embeded lists. More... | |
Files | |
| file | eg_elist.ex.c |
| file | eg_elist.h |
Defines | |
| #define | __EGeListAdd(__newpt, __prevpt, __nextpt) |
| Insert a __newpt __entry between two known consecutive entries. | |
| #define | __EGeListLink(__prevpt, __nextpt) |
| Given two nodes, link them as if they would follow one another in the list (used to delete points from a list). | |
| #define | __EGeListSplice(__list, __head) |
| move all elements in one list to the given location in a second list. Note that this function assumes that the list is represented by a pointer to an EGeList_t structure that act as a marker but that don't bellong to the list, and thus is not included in the joinded list. | |
| #define | __EL_DEBUG_ 100 |
| debug level for lists | |
| #define | EGeListAddAfter(__newpt, __head) __EGeListAdd(__newpt,__head,(__head)->next) |
| Insert a __newpt __entry after the given pointer. | |
| #define | EGeListAddBefore(__newpt, __tailpt) __EGeListAdd(__newpt,(__tailpt)->prev,__tailpt) |
| Insert a __newpt __entry before the given pointer. | |
| #define | EGeListDel(__entry) |
| Given a node, eliminate it from the list it bellongs. but don't change the internal data in the eliminated list (be carefull, if you will use it afterwards, then you MUST initialize it). If debugging is enabled, then whenever you delete, the connector is reseted to 0xffffffff. What you can count on is that the connector won't be NULL after deleting it from the list, but it's values may be lost if we are debugging. | |
| #define | EGeListInit(__lpt) |
| Initialize a given structure to point to itself (in circular fashion). | |
| #define | EGeListIsEmpty(__head) |
| test whether a list is empty (i.e. he is its own next pointer) | |
| #define | EGeListMoveAfter(__entry, __head) |
| Move an element from one list to another (deleting it from the original one). | |
| #define | EGeListMoveBefore(__entry, __tailpt) |
| Move an element from one list to another (deleting it from the original one). | |
| #define | EGeListReplace(__oldpt, __newpt) |
| Replace one __entry with another in a list. | |
| #define | EGeListSplice(__list, __head) ({if(!EGeListIsEmpty(__list)) __EGeListSplice(__list,__head);}) |
Typedefs | |
| typedef struct EGeList_t | EGeList_t |
| List Node Structure. | |
Functions | |
| int | main (void) |
| A simple example of using embeded lists. | |
Here we define the basic interface for a circular linked list where the list is embeded in some other structure. The ideas come from the Linux Kernel implementation of lists. This implementation is based on the philosophy of embeded structures.
| #define __EGeListAdd | ( | __newpt, | ||
| __prevpt, | ||||
| __nextpt | ||||
| ) |
({\
EGeList_t*const __EGeL_add_new = (__newpt);\
EGeList_t*const __EGeL_add_prev = (__prevpt);\
EGeList_t*const __EGeL_add_next = (__nextpt);\
__EGeL_add_next->prev = __EGeL_add_new;\
__EGeL_add_prev->next = __EGeL_add_new;\
__EGeL_add_new->next = __EGeL_add_next;\
__EGeL_add_new->prev = __EGeL_add_prev;\
__EGeL_add_new;})
Insert a __newpt __entry between two known consecutive entries.
| __newpt | pointer to the list node to insert. | |
| __prevpt | pointer to the node to preceed the __newpt node. | |
| __nextpt | pointer to the node to follow the __newpt node. |
Definition at line 93 of file eg_elist.h.
| #define __EGeListLink | ( | __prevpt, | ||
| __nextpt | ||||
| ) |
({\
EGeList_t* __EGeL_lnk_prev = (__prevpt);\
EGeList_t* __EGeL_lnk_next = (__nextpt);\
__EGeL_lnk_prev->next = __EGeL_lnk_next;\
__EGeL_lnk_next->prev = __EGeL_lnk_prev;\
0;})
Given two nodes, link them as if they would follow one another in the list (used to delete points from a list).
| __prevpt | pointer to the guy to be in first in the list. | |
| __nextpt | pointer to the guy to follow in the list. |
Definition at line 128 of file eg_elist.h.
| #define __EGeListSplice | ( | __list, | ||
| __head | ||||
| ) |
({\
EGeList_t* __EGeL_spl_list = (__list);\
EGeList_t* __EGeL_spl_first = __EGeL_spl_list->next;\
EGeList_t* __EGeL_spl_last = __EGeL_spl_list->prev;\
EGeList_t* __EGeL_spl_head = (__head);\
EGeList_t* __EGeL_spl_at = __EGeL_spl_head->next;\
__EGeL_spl_first->prev = __EGeL_spl_head;\
__EGeL_spl_head->next = __EGeL_spl_first;\
__EGeL_spl_last->next = __EGeL_spl_at;\
__EGeL_spl_at->prev = __EGeL_spl_last;\
0;})
move all elements in one list to the given location in a second list. Note that this function assumes that the list is represented by a pointer to an EGeList_t structure that act as a marker but that don't bellong to the list, and thus is not included in the joinded list.
| __list | marker to the list to be joined with the second. Note that the fields in list won't be reinitialized, so be carefull with that, because the fields are pointing to inconsistent data as it is, if you want to reutilize the list you must call EGeListInit before. | |
| __head | position from where the list will be spliced in. |
Definition at line 210 of file eg_elist.h.
| #define __EL_DEBUG_ 100 |
debug level for lists
Definition at line 59 of file eg_elist.h.
| #define EGeListAddAfter | ( | __newpt, | ||
| __head | ||||
| ) | __EGeListAdd(__newpt,__head,(__head)->next) |
Insert a __newpt __entry after the given pointer.
| __newpt | pointer to the __newpt list node to insert. | |
| __head | pointer from where the __newpt __entry will follow. |
Definition at line 109 of file eg_elist.h.
Referenced by EGalgMCcomputeT(), EGalgPRcomputeLabels(), EGalgPRglobalRelabel(), EGalgPRpush(), EGalgPRpushRelabel(), and main().
| #define EGeListAddBefore | ( | __newpt, | ||
| __tailpt | ||||
| ) | __EGeListAdd(__newpt,(__tailpt)->prev,__tailpt) |
Insert a __newpt __entry before the given pointer.
| __newpt | pointer to the __newpt list node to insert. | |
| __tailpt | pointer that will follow the __newpt __entry in the list. |
Definition at line 117 of file eg_elist.h.
Referenced by main().
| #define EGeListDel | ( | __entry | ) |
({\
EGeList_t *const __EGeL_del_entr = (__entry);\
__EGeListLink(__EGeL_del_entr->prev,__EGeL_del_entr->next);\
if(__EL_DEBUG_ <= DEBUG) \
(*__EGeL_del_entr) = (EGeList_t){(EGeList_t*)0xffffffffU,\
(EGeList_t*)0xffffffffU};\
__EGeL_del_entr;})
Given a node, eliminate it from the list it bellongs. but don't change the internal data in the eliminated list (be carefull, if you will use it afterwards, then you MUST initialize it). If debugging is enabled, then whenever you delete, the connector is reseted to 0xffffffff. What you can count on is that the connector won't be NULL after deleting it from the list, but it's values may be lost if we are debugging.
| __entry | __entry to eliminate from the list. |
Definition at line 144 of file eg_elist.h.
Referenced by EGalgMCcomputeT(), EGalgPRcomputeLabels(), EGalgPRnumb(), EGalgPRpreprocess(), EGalgPRpushRelabel(), and main().
| #define EGeListInit | ( | __lpt | ) |
Initialize a given structure to point to itself (in circular fashion).
| __lpt | pointer to the list to initialize. |
Definition at line 79 of file eg_elist.h.
Referenced by EGalgMCcomputeT(), EGalgPRcomputeLabels(), EGalgPRglobalRelabel(), EGalgPRminSTcut(), EGalgPRoptimalityTest(), and main().
| #define EGeListIsEmpty | ( | __head | ) |
test whether a list is empty (i.e. he is its own next pointer)
Definition at line 193 of file eg_elist.h.
Referenced by display_DG(), display_srkG(), display_UG(), EGalgMCcomputeT(), EGalgPRcomputeLabels(), EGalgPRmaxSTflow(), EGalgPRminSTcut(), and main().
| #define EGeListMoveAfter | ( | __entry, | ||
| __head | ||||
| ) |
({\
__EGeListLink((__entry)->prev,(__entry)->next);\
EGeListAddAfter(__entry,__head);})
Move an element from one list to another (deleting it from the original one).
| __entry | element to be removed from it's current list to a position after the given __head. | |
| __head | element to be before the moved element. |
Definition at line 176 of file eg_elist.h.
Referenced by EGalgPRpushRelabel().
| #define EGeListMoveBefore | ( | __entry, | ||
| __tailpt | ||||
| ) |
({\
__EGeListLink((__entry)->prev,(__entry)->next);\
EGeListAddBefore(__entry,__tailpt);})
Move an element from one list to another (deleting it from the original one).
| __entry | element to be removed from it's current list to a position before the given __tailpt. | |
| __tailpt | element to be after the moved element. |
Definition at line 187 of file eg_elist.h.
Referenced by main().
| #define EGeListReplace | ( | __oldpt, | ||
| __newpt | ||||
| ) |
({\
EGeList_t* __EGeL_rep_old = (__oldpt);\
EGeList_t* __EGeL_rep_new = (__newpt);\
__EGeL_rep_new->next = __EGeL_rep_old->next;\
__EGeL_rep_new->prev = __EGeL_rep_old->prev;\
__EGeL_rep_new->next->prev = __EGeL_rep_new;\
__EGeL_rep_new->prev->next = __EGeL_rep_new;\
__EGeL_rep_old;})
Replace one __entry with another in a list.
| __oldpt | __entry to be replaced, note that the pointers stored in next/prev won't be changed, this may possible lead to errors if the __entry is used afterwards without initialization. | |
| __newpt | __newpt __entry in the list. |
Definition at line 160 of file eg_elist.h.
Referenced by main().
| #define EGeListSplice | ( | __list, | ||
| __head | ||||
| ) | ({if(!EGeListIsEmpty(__list)) __EGeListSplice(__list,__head);}) |
List Node Structure.
| int main | ( | void | ) |
A simple example of using embeded lists.
Definition at line 40 of file eg_elist.ex.c.
References integer_list_t::cn, EGcontainerOf, EGeListAddBefore, EGeListDel, EGeListInit, EGeListIsEmpty, EGeListMoveBefore, EGeListReplace, EGeListSplice, EGlib_info(), EGlib_version(), EGrand(), EGrandInit(), EGsetLimits(), EGsigSet, g, integer_list_t::n, and EGeList_t::next.

1.7.1