home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / som / include / tpq.idl < prev    next >
Text File  |  1999-02-22  |  6KB  |  162 lines

  1. //#  @(#) 2.12 src/somuc/tpq.idl, somuc, som2.1 12/26/95 15:39:37 [7/30/96 14:50:08]
  2. //
  3. //   COMPONENT_NAME: somuc
  4. //
  5. //   ORIGINS: 82, 81, 27
  6. //
  7. //
  8. //    25H7912  (C)  COPYRIGHT International Business Machines Corp. 1992,1996,1996  
  9. //   All Rights Reserved
  10. //   Licensed Materials - Property of IBM
  11. //   US Government Users Restricted Rights - Use, duplication or
  12. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  13. //
  14. //   Copyright ⌐ 1988, 1989 Apple Computer, Inc. All rights reserved.
  15.  
  16. /*
  17.  * CLASS_NAME: somf_TPriorityQueue
  18.  *
  19.  * DESCRIPTION: A TPriorityQueue is a subclass of TCollection which keeps
  20.  *              the elements of the collection partially ordered based on
  21.  *              some ordering function.  Priority Queues are often used
  22.  *              when you must collect a set of records, then process the
  23.  *              largest, then collect more, the process the largest, etc.
  24.  *
  25.  */
  26.  
  27. #ifndef TPQ_idl
  28. #define TPQ_idl
  29.  
  30. #include "tcollect.idl"
  31. #include "morder.idl"
  32.  
  33. /* interface somf_MOrderableCollectible; */
  34.  
  35. interface somf_TPriorityQueue : somf_TCollection
  36. {
  37.  
  38.   const   long    kInitialPriorityQueueSize = 20;
  39.  
  40.   //#  friend class TPriorityQueueIterator;
  41.  
  42.   //# The following method is handled by the override of somInit.
  43.   //#  TPriorityQueue();
  44.  
  45.   somf_TPriorityQueue somfTPriorityQueueInitF(in somf_MOrderableCollectible::somf_MOrderableCompareFn testfn);
  46.   // Initialize a new TPriorityQueue
  47.   //#  TPriorityQueue(MOrderableCompareFn testfn);
  48.  
  49.   somf_TPriorityQueue somfTPriorityQueueInitP(in somf_TPriorityQueue q);
  50.   // Initialize a new TPriorityQueue
  51.   //#  TPriorityQueue(const TPriorityQueue&);
  52.  
  53.   //# The following method is handled by the override of somUninit.
  54.   //#  virtual ~TPriorityQueue();
  55.  
  56.   void somfAssign(in somf_TPriorityQueue source);
  57.   // Assign the instance of this equal to the instance of source.
  58.   //#  const TPriorityQueue& operator=(const TPriorityQueue&);
  59.  
  60.   void somfInsert(in somf_MOrderableCollectible obj);
  61.   // Insert obj in this
  62.   //#  virtual void Insert(MOrderableCollectible* obj);
  63.  
  64.   somf_MOrderableCollectible somfPop();
  65.   // Remove the object with the "highest" priority from the priority queue,
  66.   // and return it.
  67.   //#  virtual MOrderableCollectible*        Pop();
  68.  
  69.   somf_MOrderableCollectible somfPeek();
  70.   // Determine the object with the "highest" priority from the TPriorityQueue,
  71.   // but don't remove it.
  72.   //#  virtual MOrderableCollectible*        Peek() const;
  73.  
  74.   somf_MOrderableCollectible somfReplace(in somf_MOrderableCollectible obj);
  75.   // This method removes the object with the highest priority from the
  76.   // TPriorityQueue, then inserts obj into the TPriorityQueue.
  77.   //#  virtual MOrderableCollectible* Replace(MOrderableCollectible* obj);
  78.  
  79.   void somfChange(in somf_MOrderableCollectible obj);
  80.   // DO NOT USE THIS METHOD, it does nothing.
  81.   //#  virtual void Change(MOrderableCollectible* obj);
  82.  
  83.   //# The following methods are overriden below
  84.   //#  virtual MCollectible* Remove(const MCollectible& obj);
  85.   //#  virtual MCollectible* Add(MCollectible* obj);
  86.   //#  virtual void RemoveAll();
  87.   //#  virtual void DeleteAll();
  88.   //#  virtual long Count() const;
  89.   //#  virtual MCollectible* Member(const MCollectible& obj) const;
  90.   //#  virtual TIterator* CreateIterator() const;
  91.  
  92.   void somfSetEqualityComparisonFunction(in somf_MCollectible::somf_MCollectibleCompareFn fn);
  93.   // Set the equality comparison function being used by the priority queue.
  94.   //#  void SetEqualityComparisonFunction(MCollectibleCompareFn fn);
  95.  
  96.   somf_MCollectible::somf_MCollectibleCompareFn  somfGetEqualityComparisonFunction();
  97.   // Return the equality comparison function being used by the priority queue.
  98.   //#  MCollectibleCompareFn  GetEqualityComparisonFunction() const;
  99.  
  100.   //# The following streaming operators are not ported until the TStream
  101.   //# approach is resolved.
  102.   //#  virtual TStream& operator>>=(TStream& towhere) const;
  103.   //#  virtual TStream& operator<<=(TStream& towhere);
  104.   //#  MCollectibleDeclarationsMacro(TPriorityQueue);
  105.  
  106.  
  107.  
  108. #ifdef __SOMIDL__
  109.   implementation {
  110.  
  111.  
  112.     releaseorder: somfInsert, somfPop, somfPeek, somfReplace,
  113.           somfChange, somfSetEqualityComparisonFunction,
  114.           somfGetEqualityComparisonFunction,
  115.           somfDownHeap, somfUpHeap, somfGrowHeap, somfMakeNewTable,
  116.           somfCopyIn, somfAssign, somfTPriorityQueueInitF,
  117.           somfTPriorityQueueInitP;
  118.  
  119.  
  120.     //# Class Modifiers
  121.     majorversion = 2;
  122.     minorversion = 1;
  123.     filestem = tpq;
  124.     dllname = "somuc.dll";
  125.  
  126.  
  127.     passthru C_xh_after =  ""
  128. "#include <morder.xh>";
  129.  
  130.     passthru C_h_after =  ""
  131. "#include <morder.h>";
  132.  
  133.     //# Internal Instance Variables
  134.     somf_MOrderableCollectible* fTable;
  135.     long                      fCount;
  136.     long                      fCurrentSize;
  137.     somf_MOrderableCollectible::somf_MOrderableCompareFn    fSequencingFn;
  138.     somf_MCollectible::somf_MCollectibleCompareFn  fEqualityComparisonFn;
  139.     unsigned long             fSeed;
  140.  
  141.     //# Method Modifiers
  142.     somInit: override;
  143.     somUninit: override;
  144.     somfPeek: nomodify;
  145.     somfRemove: override;
  146.     somfAdd: override;
  147.     somfRemoveAll: override;
  148.     somfDeleteAll: override;
  149.     somfCount: override;
  150.     somfMember: override;
  151.     somfCreateIterator: override;
  152.     somfGetEqualityComparisonFunction: nomodify;
  153.     somfTPriorityQueueInitF: nooverride;
  154.     somfTPriorityQueueInitP: nooverride;
  155.  
  156.  
  157.   };
  158. #endif /* __SOMIDL__ */
  159. };
  160.  
  161. #endif  /* TPQ_idl */
  162.