home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Headers / misckit / MiscLinkedList.h < prev    next >
Encoding:
Text File  |  1994-03-23  |  2.6 KB  |  85 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. - insertList: this_list;            // insert one linked list into this one
  56. - insertListAtFront: this_list;        // insert linked list at the front
  57. - appendList: this_list;            // append linked list to this one
  58.                                 
  59. - read: (NXTypedStream*) stream;
  60. - write: (NXTypedStream*) stream;
  61. //- awake;
  62.  
  63. - swapWithNext;
  64. - swapWithPrevious;
  65. - moveToFirst;
  66. - moveToLast;
  67.  
  68. - empty;
  69. - (BOOL)isEqual:anObject;
  70. - makeObjectsPerform:(SEL)aSelector;
  71. - makeObjectsPerform:(SEL)aSelector with:anObject;
  72. - replaceObject:anObject with:newObject; // return anObject
  73. - removeObject:anObject; // return anObject
  74. - addObjectIfAbsent:anObject; // appends it
  75.  
  76. // these four are obvious:
  77. - removeLastObject;
  78. - lastObject;
  79. - removeFirstObject;
  80. - firstObject;
  81.  
  82. - (unsigned int)count; // same as -getLength
  83. - addObject:anObject; // appends object to list
  84.  
  85. @end