home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / MiscKit1.2.6 / Temp / DataStructures / PriorityQueue.h < prev    next >
Encoding:
Text File  |  1993-09-28  |  949 b   |  32 lines

  1. #import "Queue.h"
  2.  
  3. // (C) 1993 by Don Yacktman
  4.  
  5. // This object would be useful for sorting events in a simulator and
  6. // then send them in correct time order, or it could track important
  7. // objects "things to do" and then return them in order of priority.
  8. // I've used this in an RTL simulator to handle the event queue
  9. // dynamically, but there's plenty of other applications...
  10.  
  11. @protocol PrioritizedObject
  12.  
  13. // An object should follow this protocol if you're going to
  14. // add it to the priority queue.  Objects with lower return
  15. // values will exit the queue first.
  16.  
  17. - (unsigned int)sortKey;    // This should return a hash value, a
  18.                             // priority, timestamp or something
  19.                             // which tells the queue how to sort
  20.                             // the objects as it adds them.
  21. @end
  22.  
  23.  
  24. @interface PriorityQueue : Queue
  25. {
  26. }
  27.  
  28. // use -addObject: (from List) to add to the queue, and this to
  29. // remove from the queue.  Other List methods still apply.
  30. - removeNextObject;
  31.  
  32. @end