libFirm
plist.h File Reference

Simple, non circular, double linked pointer list. Created because the properties of the standard circular list were not very well suited for the interference graph implementation. This list uses an obstack and a free-list to efficiently manage its elements. More...

#include <stddef.h>
#include "obst.h"
#include "../begin.h"
#include "../end.h"

Go to the source code of this file.

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

Functions

plist_t * plist_new (void)
 Creates a new pointer list and initializes it.
plist_t * plist_obstack_new (struct obstack *obst)
 Creates a new pointer list and initializes it.
void plist_free (plist_t *list)
 Frees the passed pointer list.
void plist_insert_back (plist_t *list, void *value)
 Inserts an element at the back of a pointer list.
void plist_insert_front (plist_t *list, void *value)
 Inserts an element at the front of a pointer list.
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.
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.
int plist_has_value (plist_t *list, void *value)
 Checks if list has an element with the given data pointer.
plist_element_t * plist_find_value (plist_t *list, void *value)
 Tries to find list element associated to the given data pointer.
void plist_erase (plist_t *list, plist_element_t *element)
 Erases the specified element from the pointer list.
void plist_clear (plist_t *list)
 Erases all elements from the specified pointer list.

Detailed Description

Simple, non circular, double linked pointer list. Created because the properties of the standard circular list were not very well suited for the interference graph implementation. This list uses an obstack and a free-list to efficiently manage its elements.

Author
Kimon Hoffmann
Date
14.07.2005

Definition in file plist.h.

Macro Definition Documentation

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

Convenience macro to iterate over a plist.

Definition at line 234 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 104 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 211 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 220 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 228 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 193 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 202 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 176 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 184 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.