iflList(3)
iflList, iflMultiList - simple doubly-linked list
Showing IRIX 6.5.30 (default release). Unchanged since IRIX 6.5.
NAME iflList, iflMultiList - simple doubly-linked list INHERITS FROM This is a base class. HEADER FILE #include <ifl/iflList.h> CLASS DESCRIPTION iflList provides a lightweight, fast, doubly-linked list template. Using iflList Derive from iflListItem to place objects of type itemType in an doubly- linked list (iflList<itemType>); for example to define a list element that can hold an x,y int pair you would write: class XY : public iflListItem { public: XY(int X, int Y) { x = X; y = Y; } int x, y; }; You could then use it with code like: XY foo(3,4); iflList<XY> list; list.append(&foo); ... iflListIter<XY> iter(list); XY* item; while (item = iter.next()) item->unlink(); If you need to place an object in two lists simulaneously you would write something like: class XY; class A : public iflListItem {}; class B : public iflListItem {}; class XY : public A, public B { public: XY(int X, int Y) { x = X; y = Y; } int x, y; }; and to operate on the "A" list of the XY elements: XY foo(3,4); iflMutliList<XY,A> list; list.append(&foo); ... iflMultiListIter<XY,A> iter(list); XY* xy; while (item = iter.next()) item->unlink(); CLASS MEMBER FUNCTION SUMMARY Constructors iflList<type>() iflMultiList<itemType,linkageType>() Editing void append(linkageType* item) void appendList(iflMultiList<itemType,linkageType>* list) void appendSubList(linkageType* bgn, linkageType* end) void clear() void insert(linkageType* item) void insertAfter(linkageType* item, linkageType* after) void insertBefore(linkageType* item, linkageType* before) void insertList(iflMultiList<itemType,linkageType>* list) void insertSubList(linkageType* bgn, linkageType* end) void unlink(linkageType* item) Query int isEmpty() const itemType* head() const itemType* tail() const itemType* getNext(const linkageType* item) const itemType* getPrev(const linkageType* item) const FUNCTION DESCRIPTIONS iflList() iflList<itemType>() Creates an iflMultiList of length zero (that is, empty list). The items will be of type itemType. Access to the next and prev pointers will also be through itemType. Use this form of the constructor with items that will be placed on only one type of list. iflMultiList() iflMultiList<itemType,linkageType>() Creates an iflMultiList of length zero (that is, empty list). The items will be of type itemType. Access to the next and prev pointers will be done through casts to type linkageType. This form of the contructor is useful when used with items that will be placed on more than one type of list. append() void append(linkageType* item) Appends item to the end of the list. appendList() void appendList(iflMultiList<itemType,linkageType>* list) Removes all of the items from list and appends them to the end of this list (in the same order that they were on the original list). appendSubList() void appendSubList(linkageType* bgn, linkageType* end) Removes all of the items between bgn and end, inclusive, from whatever list they are on and appends them to the end of this list (in the same order that they were on the original list). clear() void clear() Clears the list of all items. This is not usually a good idea, but is sometimes necessary to avoid an assertion failure on destruction. getNext() itemType* getNext(const linkageType* item) const Returns the item immediately following item or NULL if item is at the end of the list. getPrev() itemType* getPrev(const linkageType* item) const Returns the item immediately preceding item or NULL if item is at the beginning of the list. head() itemType* head() const Returns the item at the head of the list or NULL if the list is empty. insert() void insert(linkageType* item) Inserts item at the front of the list. insertAfter() void insertAfter(linkageType* item, linkageType* after) Inserts item immediately following the item indicated by after. insertBefore() void insertBefore(linkageType* item, linkageType* before) Inserts item immediately preceding the item indicated by before. insertList() void insertList(iflMultiList<itemType,linkageType>* list) Removes all of the items from list and prepends them to the front of this list (in the same order that they were on the original list). insertSubList() void insertSubList(linkageType* bgn, linkageType* end) Removes all of the items between bgn and end, inclusive, from whatever list they are on and prepends them to the front of this list (in the same order that they were on the original list). isEmpty() int isEmpty() const Returns TRUE if the list is empty, FALSE otherwise. tail() itemType* tail() const Returns the item at the tail of the list or NULL if the list is empty. unlink() void unlink(linkageType* item) Unlinks the item from the list. If item is not on the list, the result is undefined. SEE ALSO iflListItem, iflListIter, iflListIterRev