home *** CD-ROM | disk | FTP | other *** search
- //
- // MiscLinkedList.h -- an implementation of a doubly linked list
- // Written by Sean Luke Copyright (c) 1993, 1994 by Sean Luke.
- // Additional methods and editing by Don Yacktman.
- // Version 0.9. All rights reserved.
- //
- // This notice may not be removed from this source code.
- //
- // This object is included in the MiscKit by permission from the author
- // and its use is governed by the MiscKit license, found in the file
- // "LICENSE.rtf" in the MiscKit distribution. Please refer to that file
- // for a list of all applicable permissions and restrictions.
- //
-
- #import <misckit/misckit.h>
-
- @interface MiscLinkedList:Object <NXTransport>
-
- // implements a doubly-linked list. Uses the LinkedListNode object as the node
- // for the list.
-
- {
- id node_class;
- id current_node;
- id first_node;
- id last_node;
- int node_length;
- }
-
- - init;
- - initForClass: this_class; // uses this_class as the node to generate
- - free; // free nodes and the list, but not objects
- - freeObjects; // frees each node and object in the list
- - freeNodes; // frees each node in the list
-
- - goFirst; // returns first object or NULL
- - goLast;
- - goNext; // returns new current object or NULL
- - goPrevious;
-
- - (int) getLength; // 0 if empty
-
- - getNode; // returns the current MiscLinkedListNode
- // under normal circumstances you shouldn't
- // ever need to access this object.
- - getObject; // returns the current object or NULL
- - setObject:this_object; // returns the object
- - insertObjectAfter: this_object; // returns the object. Inserts After.
- // moves to the new node.
- - insertObjectBefore: this_object; // returns the object. Inserts Before.
- // if empty, inserts as first object.
- // moves to the new node.
- - deleteObject; // returns the object. Moves previous,
- // or first if already at first.
- - insertList: this_list; // insert one linked list into this one
- - insertListAtFront: this_list; // insert linked list at the front
- - appendList: this_list; // append linked list to this one
-
- - read: (NXTypedStream*) stream;
- - write: (NXTypedStream*) stream;
- //- awake;
-
- - swapWithNext;
- - swapWithPrevious;
- - moveToFirst;
- - moveToLast;
-
- - empty;
- - (BOOL)isEqual:anObject;
- - makeObjectsPerform:(SEL)aSelector;
- - makeObjectsPerform:(SEL)aSelector with:anObject;
- - replaceObject:anObject with:newObject; // return anObject
- - removeObject:anObject; // return anObject
- - addObjectIfAbsent:anObject; // appends it
-
- // these four are obvious:
- - removeLastObject;
- - lastObject;
- - removeFirstObject;
- - firstObject;
-
- - (unsigned int)count; // same as -getLength
- - addObject:anObject; // appends object to list
-
- @end