Loading...
Searching...
No Matches
list.h File Reference
`#include <starpu_util.h>`

Go to the source code of this file.

## Macros

#define | LIST_INLINE
#define | struct
#define | LIST_CREATE_TYPE(ENAME, DECL)
#define | LIST_CREATE_TYPE_NOSTRUCT(ENAME, _prev, _next)
#define | STARPU_ASSERT_MULTILIST(expr)
#define | MULTILIST_CREATE_TYPE(ENAME, MEMBER)
#define | MULTILIST_CREATE_INLINES(TYPE, ENAME, MEMBER)

## Macro Definition Documentation

## LIST_INLINE

#define LIST_INLINE

Remarks
  list how-to ********************************************************* struct FOO { content);

- declares the following types:

  + for cells : struct FOO + for lists : struct FOO_list + for iterators : struct FOO

- declares the following inlines (all O(1) except stated otherwise, n is the number of elements) :

  * Create a cell struct FOO* FOO_new(void);

  * Suppress a cell void FOO_delete(struct FOO*);

  * Create a list (initially empty) struct FOO_list* FOO_list_new(void);

  * Initializes a list (initially empty) void FOO_list_init(struct FOO_list*);

  * Suppresses a liste void FOO_list_delete(struct FOO_list*);

  * Check whether a list is empty int FOO_list_empty(struct FOO_list*);

  * Remove a given cell from the list void FOO_list_erase(struct FOO_list*, struct FOO*);

  * Add a cell at the back of the list void FOO_list_push_back(struct FOO_list*, struct FOO*);

  * Add a cell at the front of the list void FOO_list_push_front(struct FOO_list*, struct FOO*);

  * Add a cell before a given cell of a list void FOO_list_insert_before(struct FOO_list*, struct FOO*new, struct FOO*);

  * Add a cell after a given cell of a list void FOO_list_insert_after(struct FOO_list*, struct FOO*new, struct FOO*);

  * Append the second list at the end of the first list struct FOO* FOO_list_push_list_back(struct FOO_list*, struct FOO_list*);

  * Prepend the first list at the beginning of the second list struct FOO* FOO_list_push_list_front(struct FOO_list*, struct FOO_list*);

  * Return and remove the node at the back of the list struct FOO* FOO_list_pop_back(struct FOO_list*);

  * Return and remove the node at the front of the list struct FOO* FOO_list_pop_front(struct FOO_list*);

  * Return the node at the back of the list struct FOO* FOO_list_back(struct FOO_list*);

  * Return the node at the front of the list struct FOO* FOO_list_front(struct FOO_list*);

  * Check that the list chaining is coherent (O(n)) int FOO_list_check(struct FOO_list*);

  * Return the first cell of the list (from the front) struct FOO* FOO_list_begin(struct FOO_list*);

  * Return the value to be tested at the end of the list (at the back) struct FOO* FOO_list_end(struct FOO_list*);

  * Return the next element of the list (from the front) struct FOO* FOO_list_next(struct FOO*)

  * Return the last element of the list (from the back) struct FOO* FOO_list_last(struct FOO_list*);

  * Return the value to be tested at the beginning of the list (at the fromt) struct FOO* FOO_list_alpha(struct FOO_list*);

  * Return the previous element of the list (from the back) struct FOO* FOO_list_prev(struct FOO*)

  * Return the size of the list in O(n) int FOO_list_size(struct FOO_list*)

  * Return the position of the cell in the list (indexed from 0) (O(n) on average) int FOO_list_member(struct FOO_list*, struct FOO*)

  * Test whether the cell is in the list (O(n) on average) int FOO_list_ismember(struct FOO_list*, struct FOO*)

********************************************************* Usage example:

- initially you'd have: struct my_struct { int a; int b; };
- to make a list of it, we replace the declaration above with: struct my_struct { int a; int b; ); which creates the struct my_struct and struct my_struct_list types.
- setting up an empty list: struct my_struct_list l; my_struct_list_init(&l);
- allocating an empty list: struct my_struct_list * l = my_struct_list_new();
- add a cell 'e' at the front of list 'l': struct my_struct * e = my_struct_new(); e->a = 0; e->b = 0; my_struct_list_push_front(&l, e);
- iterating over a list from the front: struct my_struct * i; for(i = my_struct_list_begin(&l); i != my_struct_list_end(&l); i = my_struct_list_next(i)) { printf("a=%d; b=%d\n", i->a, i->b); }
- iterating over a list from the back: struct my_struct * i; for(i = my_struct_list_last(&l); i != my_struct_list_alpha(&l); i = my_struct_list_prev(i)) { printf("a=%d; b=%d\n", i->a, i->b); } *********************************************************

## struct

#define struct

Generates a new type for list of elements

## LIST_CREATE_TYPE_NOSTRUCT

#define LIST_CREATE_TYPE_NOSTRUCT | ( |  | ENAME,
|  |  | _prev,
|  |  | _next
| ) |  |

The effective type declaration for lists