libFirm
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
pointer lists (deprecated)

Data Structures

struct  plist_t
 The plist data type. More...
 
struct  plist_element_t
 An element in the pointer list. More...
 

Macros

#define plist_count(list)   ((list)->element_count)
 Returns the number of elements in a pointer list. More...
 
#define plist_first(list)   ((list)->first_element)
 Returns the first element of a pointer list. More...
 
#define plist_last(list)   ((list)->last_element)
 Returns the last element of a pointer list. More...
 
#define plist_element_has_next(element)   ((element)->next != NULL)
 Checks whether a pointer list element has a successor or not. More...
 
#define plist_element_has_prev(element)   ((element)->prev != NULL)
 Checks whether a pointer list element has a predecessor or not. More...
 
#define plist_element_get_next(element)   ((element)->next)
 Gets the successor of the passed list element. More...
 
#define plist_element_get_prev(element)   ((element)->prev)
 Gets the predecessor of the passed list element. More...
 
#define plist_element_get_value(element)   ((element)->data)
 Gets the value stored in the passed list element. More...
 
#define foreach_plist(list, el)   for (plist_element_t *el = plist_first(list); el; el = plist_element_get_next(el))
 Convenience macro to iterate over a plist. More...
 

Functions

plist_t * plist_new (void)
 Creates a new pointer list and initializes it. More...
 
plist_t * plist_obstack_new (struct obstack *obst)
 Creates a new pointer list and initializes it. More...
 
void plist_free (plist_t *list)
 Frees the passed pointer list. More...
 
void plist_insert_back (plist_t *list, void *value)
 Inserts an element at the back of a pointer list. More...
 
void plist_insert_front (plist_t *list, void *value)
 Inserts an element at the front of a pointer list. More...
 
void plist_insert_before (plist_t *list, plist_element_t *element, void *value)
 Inserts an element into a pointer list before the specified element, which must be non null. More...
 
void plist_insert_after (plist_t *list, plist_element_t *element, void *value)
 Inserts an element into a pointer list after the specified element, which must be non null. More...
 
int plist_has_value (plist_t *list, void *value)
 Checks if list has an element with the given data pointer. More...
 
plist_element_t * plist_find_value (plist_t *list, void *value)
 Tries to find list element associated to the given data pointer. More...
 
void plist_erase (plist_t *list, plist_element_t *element)
 Erases the specified element from the pointer list. More...
 
void plist_clear (plist_t *list)
 Erases all elements from the specified pointer list. More...
 

Detailed Description


Data Structure Documentation

struct plist

The plist data type.

Definition at line 36 of file plist.h.

Data Fields
int element_count Current number of elements in the list.
plist_element_t * first_element First element in the list.
plist_element_t * first_free_element First element in the free list.

Please note that the free list is a single linked list and all back references are invalid.

unsigned foreign_obstack: 1 Set to 1 if plist uses a foreign obstack.
plist_element_t * last_element Last element in the list.
struct obstack * obst The obstack used for all allocations.
struct plist_element

An element in the pointer list.

Definition at line 63 of file plist.h.

Data Fields
void * data element data
plist_element_t * next next element in double linked list
plist_element_t * prev previous element in double linked list

Macro Definition Documentation

#define foreach_plist (   list,
  el 
)    for (plist_element_t *el = plist_first(list); el; el = plist_element_get_next(el))

Convenience macro to iterate over a plist.

Definition at line 225 of file plist.h.

#define plist_count (   list)    ((list)->element_count)

Returns the number of elements in a pointer list.

Parameters
listthe pointer list
Returns
The number of elements in a pointer list.

Definition at line 95 of file plist.h.

#define plist_element_get_next (   element)    ((element)->next)

Gets the successor of the passed list element.

Parameters
elementthe list element to return the successor of.
Returns
The successor of element or NULL if element is the last element in the sequence.

Definition at line 202 of file plist.h.

#define plist_element_get_prev (   element)    ((element)->prev)

Gets the predecessor of the passed list element.

Parameters
elementthe list element to return the predecessor of.
Returns
The predecessor of element or NULL if element is the last element in the sequence.

Definition at line 211 of file plist.h.

#define plist_element_get_value (   element)    ((element)->data)

Gets the value stored in the passed list element.

Parameters
elementthe list element to return the value of.
Returns
The value stored in element.

Definition at line 219 of file plist.h.

#define plist_element_has_next (   element)    ((element)->next != NULL)

Checks whether a pointer list element has a successor or not.

Parameters
elementthe list element that should be queried for existence of a successor.
Returns
TRUE if element has a successor, otherwise FALSE.

Definition at line 184 of file plist.h.

#define plist_element_has_prev (   element)    ((element)->prev != NULL)

Checks whether a pointer list element has a predecessor or not.

Parameters
elementthe list element that should be queried for existence of a predecessor.
Returns
TRUE if element has a successor, otherwise FALSE.

Definition at line 193 of file plist.h.

#define plist_first (   list)    ((list)->first_element)

Returns the first element of a pointer list.

Parameters
listthe pointer list to iterate
Returns
a pointer to the element or NULL if the list is empty

Definition at line 167 of file plist.h.

#define plist_last (   list)    ((list)->last_element)

Returns the last element of a pointer list.

Parameters
listthe pointer list to iterate
Returns
a pointer to the element or NULL if the list is empty

Definition at line 175 of file plist.h.

Function Documentation

void plist_clear ( plist_t *  list)

Erases all elements from the specified pointer list.

Parameters
listthe pointer list that should be cleared.
void plist_erase ( plist_t *  list,
plist_element_t *  element 
)

Erases the specified element from the pointer list.

Parameters
listthe pointer list from which the element should be erased.
elementthe list element to erase. This element must be a part of list.
plist_element_t* plist_find_value ( plist_t *  list,
void *  value 
)

Tries to find list element associated to the given data pointer.

Parameters
listthe list to check
valuethe data pointer to look for
Returns
The first list element associated to data pointer if found, NULL otherwise
void plist_free ( plist_t *  list)

Frees the passed pointer list.

After a call to this function all references to the list and any of its elements are invalid.

int plist_has_value ( plist_t *  list,
void *  value 
)

Checks if list has an element with the given data pointer.

Parameters
listthe list to check
valuethe data pointer to look for
Returns
1 if element with data pointer found, 0 otherwise
void plist_insert_after ( plist_t *  list,
plist_element_t *  element,
void *  value 
)

Inserts an element into a pointer list after the specified element, which must be non null.

Parameters
listthe pointer list to insert the new element into.
elementthe list element after which the new element should be inserted. This element must be a part of list.
valuethe element value to insert.
void plist_insert_back ( plist_t *  list,
void *  value 
)

Inserts an element at the back of a pointer list.

Parameters
listthe pointer list to append the new element to.
valuethe element value to append.
void plist_insert_before ( plist_t *  list,
plist_element_t *  element,
void *  value 
)

Inserts an element into a pointer list before the specified element, which must be non null.

Parameters
listthe pointer list to insert the new element into.
elementthe list element before which the new element should be inserted. This element must be a part of list.
valuethe element value to insert.
void plist_insert_front ( plist_t *  list,
void *  value 
)

Inserts an element at the front of a pointer list.

Parameters
listthe pointer list to prepend the new element to.
valuethe element value to prepend.
plist_t* plist_new ( void  )

Creates a new pointer list and initializes it.

Returns
The newly created pointer list.
plist_t* plist_obstack_new ( struct obstack *  obst)

Creates a new pointer list and initializes it.

Uses the given obstack instead of creating one.

Parameters
obstThe obstack to use
Returns
The newly created pointer list.