home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscLinkedList.h < prev    next >
Encoding:
Text File  |  1995-07-21  |  2.8 KB  |  89 lines

  1. //
  2. //    MiscLinkedList.h -- an implementation of a doubly linked list
  3. //        Written by Sean Luke Copyright (c) 1993, 1994 by Sean Luke.
  4. //        Additional methods and editing by Don Yacktman.
  5. //                Version 0.9.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15. #import <misckit/misckit.h>
  16.  
  17. @interface MiscLinkedList:Object <NXTransport>
  18.  
  19. // implements a doubly-linked list.  Uses the LinkedListNode object as the node
  20. // for the list.
  21.  
  22. {
  23.     id node_class;
  24.     id current_node;
  25.     id first_node;
  26.     id last_node;
  27.     int node_length;
  28. }
  29.  
  30. - init;
  31. - initForClass: this_class;            // uses this_class as the node to generate
  32. - free;                                // free nodes and the list, but not objects
  33. - freeObjects;                        // frees each node and object in the list
  34. - freeNodes;                        // frees each node in the list
  35.  
  36. - goFirst;                            // returns first object or NULL
  37. - goLast;
  38. - goNext;                            // returns new current object or NULL
  39. - goPrevious;
  40.  
  41. - (int) getLength;                    // 0 if empty
  42.  
  43. - getNode;                            // returns the current MiscLinkedListNode
  44.                                     // under normal circumstances you shouldn't
  45.                                     // ever need to access this object.
  46. - getObject;                        // returns the current object or NULL
  47. - setObject:this_object;             // returns the object
  48. - insertObjectAfter:  this_object;    // returns the object.  Inserts After.
  49.                                     // moves to the new node.
  50. - insertObjectBefore: this_object;    // returns the object.  Inserts Before.
  51.                                     // if empty, inserts as first object.
  52.                                     // moves to the new node.
  53. - deleteObject;                        // returns the object.  Moves previous,
  54.                                     // or first if already at first.
  55.  
  56. // The next three will work for MiscLinkedList *or* List objects!
  57. // They determine which class they are dealing with and adapt as necessary.
  58. - insertList: this_list;            // insert one list into this one
  59. - insertListAtFront: this_list;        // insert list at the front
  60. - appendList: this_list;            // append list to this one
  61.                                 
  62. - read: (NXTypedStream*) stream;
  63. - write: (NXTypedStream*) stream;
  64. //- awake;
  65.  
  66. - swapWithNext;
  67. - swapWithPrevious;
  68. - moveToFirst;
  69. - moveToLast;
  70.  
  71. - empty;
  72. - (BOOL)isEqual:anObject;
  73. - makeObjectsPerform:(SEL)aSelector;
  74. - makeObjectsPerform:(SEL)aSelector with:anObject;
  75. - replaceObject:anObject with:newObject; // return anObject
  76. - removeObject:anObject; // return anObject
  77. - addObjectIfAbsent:anObject; // appends it
  78.  
  79. // these four are obvious:
  80. - removeLastObject;
  81. - lastObject;
  82. - removeFirstObject;
  83. - firstObject;
  84.  
  85. - (unsigned int)count; // same as -getLength
  86. - addObject:anObject; // appends object to list
  87.  
  88. @end
  89.