next up previous contents index
Next: Basic List Methods and Up: Utility Classes Previous: Utility Classes

Linked Lists

 

The class G_List implements a doubly linked list of arbitrary objects. The G_LIST instance is the list header, it only contains pointers to the first and the last node of the list. The data, pointers to the objects, is store in G_NODE structures:

 
typedef struct G_Node {
  struct G_Node *next;   /* next node */
  struct G_Node *prev;   /* previous node */
  void *obj;             /* object at this node */
} G_NODE;

#CLASS G_List : Root {
  char *type;
  G_NODE *head;   /* first element */
  G_NODE *tail;   /* last element */
  G_NODE *iter;   /* current element for iteration functons */
  G_NODE **iter_stack;                    /* stack for nested loops */
  int number_of_iter, max_number_of_iter; /* stack properties       */ 
};
You will not need to access any of the structures directly, doing so can cause incompatibility with further versions of GRAPE.

We decided to use structures for the nodes instead of instances because it is much more efficient. For the same reason all operations which work on single nodes are implemented as functions instead of methods.

G_Lists are used for several internal GRAPE lists, for example all information about classes, methods and items in a project is stored in this way.





SFB 256 Universität Bonn and IAM Universität Freiburg

Copyright © by the Sonderforschungsbereich 256 at the Institut für Angewandte Mathematik, Universität Bonn.