The Single Linked List and Array Base Classes



next up previous contents
Next: Classes derived from Up: 7.1.1 Architecture Previous: 7.1.1 Architecture

The Single Linked List and Array Base Classes

The base classes are made up of the single and double linked list classes, a generic array class and array classes for different data types like integers, reals, and object pointers. The VOOPS class definitions for these array classes are automatically generated using UNFUG. Thus, additional array classes can be added by simply appending the class name and the corresponding C type in an array class tuple definition file.gif

The array classes supersede the default New() method, since they need an additional length argument for allocating a new array object of the desired size. Dynamic arrays are supported through a method which appends an array element but reallocates the array to the double of its current size if the element to be appended would not fit into the array. These dynamic arrays are used during construction of the search-directed acyclic graph for the KIRKPATRICK point location method in unstructured grids. New grid elements are appended there dynamically to grid element arrays, since their final size is not known in advance.

An iteration method of the array classes iterates linearly over all array elements and executes a given callback function on each array element. These are used in various places throughout the GRS library, when scanning grid element arrays, attribute value arrays, or point list coordinate arrays. Methods which swap and move array elements are also available. These are necessary when sorting the element index entries of a specific point connectivity array of an unstructured grid, since only then a topologically correct scan through the elements surrounding a point is possible.

The single linked list class is used by GRS to keep a list of the attributes and grids it has in memory. Because PIF attributes can be defined on the same grid, GRS searches this linked list, if a grid is already kept in memory when an attribute is read for interpolation. If this is the case, GRS just needs to set the grid reference pointer of the attribute in question to the grid already pertinent in memory; if the grid is not in memory, then it will be read and inserted into the linked list.

The only member of the single linked list class is a generic pointer to the next object in the list. Methods for prepending, appending to and unhooking an element from a single linked list exist, as well as for finding the last element and the previous element with respect to a given element in the list. A looping method traverses the single linked list and executes a given callback function on each element. This is the method used by GRS to search through the linked list for grids already known.

The GRS class hierarchy defines also a double linked list class, although this class is not used by GRS itself presently. Therefore, no methods are defined on the class itself, it just inherits the single linked list methods. But since the definition of this class is easily accomplished and the double linked list is a useful data structure, it was incorporated in GRS to be prepared for further extensions without having to change the base class designs.



next up previous contents
Next: Classes derived from Up: 7.1.1 Architecture Previous: 7.1.1 Architecture



Martin Stiftinger
Tue Nov 29 19:41:50 MET 1994