home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / DevTools / MachOViewer / Source / RCS / Queue.h,v < prev    next >
Encoding:
Text File  |  1994-05-23  |  2.7 KB  |  127 lines

  1. head     1.3;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ediger:1.3;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.3
  10. date     94.05.23.20.33.04;  author ediger;  state Exp;
  11. branches ;
  12. next     1.2;
  13.  
  14. 1.2
  15. date     94.05.15.18.55.28;  author ediger;  state Exp;
  16. branches ;
  17. next     1.1;
  18.  
  19. 1.1
  20. date     94.05.14.17.44.50;  author ediger;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @simple stack and/or queue object implemented via doubly linked lists
  27. @
  28.  
  29.  
  30. 1.3
  31. log
  32. @better comments
  33. @
  34. text
  35. @#ifndef _QUEUE_H
  36. #define _QUEUE_H
  37.  
  38. //H+
  39. // A first-in, first-out queue, or last-in, first-out stack.
  40. //
  41. // Holds a series of (void *)pointers for generality, but may require
  42. // casting to get the push: method to compile clean.
  43. //
  44. //    $Id: Queue.h,v 1.2 94/05/15 18:55:28 ediger Exp Locker: ediger $
  45. /*    $Log:    Queue.h,v $
  46.  * Revision 1.2  94/05/15  18:55:28  ediger
  47.  * remove a method namespace clash by changing -empty to -isEmpty.
  48.  * 
  49.  * Revision 1.1  94/05/14  17:44:50  ediger
  50.  * Initial revision
  51.  * 
  52.  */
  53. //H-
  54.  
  55. #import <objc/Object.h>
  56.  
  57. // Here's the data structure for the implementation: a doubly-linked list.
  58. // Elaborate struct tag to avoid name-space collisions.
  59. struct qs_internal_node {
  60.     struct qs_internal_node *prev;
  61.     struct qs_internal_node *next;
  62.     void                    *ptr;
  63. };
  64.  
  65. // It's possible that the ptr member should be a union of all
  66. // inherent Obj-C datatypes.  That would certainly ensure that
  67. // enough space is reserved for the stored data.  Doing the class
  68. // with that data would require "typed" pushes and pops, wouldn't it?
  69. // At least to avoid casting the data on pushes or pops.
  70.  
  71. @@interface Queue: Object
  72. {
  73.     struct qs_internal_node *head;
  74.     struct qs_internal_node *tail;
  75. }
  76.  
  77. - init;
  78. - push:(void *)something;  // put something on end of container
  79. -(void *)first;            // FIFO access to container
  80. -(void *)pop;              // LIFO access to container
  81. -(void *)head;             // peek at what's at the head of container
  82. -(void *)tail;             // peek at what's at the tail of container
  83. -(BOOL)isEmpty;            // check if container has something in it.
  84. - free;                    // deallocate implementation of container
  85.  
  86. @@end
  87.  
  88. #endif /* _QUEUE_H */
  89. @
  90.  
  91.  
  92. 1.2
  93. log
  94. @remove a method namespace clash by changing -empty to -isEmpty.
  95. @
  96. text
  97. @d10 1
  98. a10 1
  99. //    $Id: Queue.h,v 1.1 94/05/14 17:44:50 ediger Exp Locker: ediger $
  100. d12 3
  101. d23 2
  102. a24 2
  103. // here's the implementation: a doubly-linked list.
  104. // elaborate struct tag to avoid name-space collisions.
  105. d28 1
  106. a28 1
  107.     void        *ptr;
  108. d30 6
  109. @
  110.  
  111.  
  112. 1.1
  113. log
  114. @Initial revision
  115. @
  116. text
  117. @d10 5
  118. a14 2
  119. //    $Id$
  120. /*    $Log$
  121. d38 3
  122. a40 3
  123. -(void *)head;             // peek at what's on the head of container
  124. -(void *)tail;             // peek at what's on the tail of container
  125. -(BOOL)empty;              // check if container has something in it.
  126. @
  127.