home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / iikbhsh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  10.8 KB  |  468 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #ifndef _IIKBHSH_H
  19. #define _IIKBHSH_H
  20.  
  21. #include <iiakb.h>
  22. #include <stddef.h>
  23.  
  24.  
  25. #pragma info (nocls, nocnd, nocns, nocnv, noext, nognr, novft)
  26. #pragma pack (4)
  27.  
  28. #pragma SOMAsDefault (off)
  29.  
  30. struct IAKeyBagAsHshTableNodeImpl {
  31.  
  32.   IAKeyBagAsHshTableNodeImpl*
  33.            ivNext;
  34.  
  35.            IAKeyBagAsHshTableNodeImpl
  36.                             ();
  37.  
  38. };
  39.  
  40. template <class Element>
  41. struct IKeyBagAsHshTableNodeImpl :
  42.   public IAKeyBagAsHshTableNodeImpl {
  43.  
  44.   Element  ivElement;
  45.  
  46.            IKeyBagAsHshTableNodeImpl
  47.                             (Element const&);
  48.  
  49.           ~IKeyBagAsHshTableNodeImpl
  50.                             ();
  51.  
  52.  
  53. };
  54.  
  55. #pragma SOMAsDefault (pop)
  56. #pragma SOMAsDefault (off)
  57.  
  58. class IKeyBagAsHshTableCursorImpl : public ICursorImpl {
  59.  
  60.   typedef  ICursorImpl Inherited;
  61.  
  62.   typedef  IKeyBagAsHshTableCursorImpl Self;
  63.  
  64. public:
  65.  
  66.            IKeyBagAsHshTableCursorImpl
  67.                             (IACollectionImpl const&);
  68.  
  69.            IKeyBagAsHshTableCursorImpl
  70.                             (IKeyBagAsHshTableCursorImpl const&);
  71.  
  72.           ~IKeyBagAsHshTableCursorImpl
  73.                             ();
  74.  
  75.   ICursorImpl*
  76.            Clone            () const;
  77.  
  78.   void     Copy             (ICursorImpl const&);
  79.  
  80.   void     Invalidate       ();
  81.  
  82.   IBoolean IsInBetween      () const;
  83.  
  84.   IBoolean IsValid          () const;
  85.  
  86.   void     operator=        (IKeyBagAsHshTableCursorImpl const&);
  87.  
  88.   IBoolean operator==       (ICursorImpl const&) const;
  89.  
  90. protected:
  91.  
  92. private:
  93.  
  94.   IAKeyBagAsHshTableNodeImpl*
  95.            ivNode;
  96.  
  97.   INumber  ivBucket;
  98.  
  99.   friend
  100.   class    IKeyBagAsHshTableImpl;
  101.  
  102.  
  103. };
  104.  
  105.  
  106. template <class Base>
  107. class IKeySetOnKeyBagImpl;
  108.  
  109. class IAKeyBagAsHshTableOps;
  110.  
  111. class IKeyBagAsHshTableImpl : public IAKeyBagImpl {
  112.  
  113.   typedef  IAKeyBagImpl Inherited;
  114.  
  115.   typedef  IKeyBagAsHshTableImpl Self;
  116.  
  117.   typedef  IAKeyBagAsHshTableNodeImpl Node;
  118.  
  119. public:
  120.  
  121.   typedef  IAKeyBagAsHshTableOps Ops;
  122.  
  123.   typedef  IKeyBagAsHshTableCursorImpl Cursor;
  124.  
  125.   typedef  IKeyBagAsHshTableCursorImpl MngCursor;
  126.  
  127.            IKeyBagAsHshTableImpl
  128.                             (Ops&, INumber);
  129.  
  130.            IKeyBagAsHshTableImpl
  131.                             (Ops&, IKeyBagAsHshTableImpl const&);
  132.  
  133.           ~IKeyBagAsHshTableImpl
  134.                             ();
  135.  
  136.   IBoolean Add              (void const* element, ICursorImpl&);
  137.  
  138.   void     AddAllFrom       (IACollectionImpl const&);
  139.  
  140.   IBoolean AddOrReplaceElementWithKey
  141.                             (void const*, ICursorImpl&);
  142.  
  143.   IBoolean AllElementsDo    (IApplFunc, void*);
  144.  
  145.   void*    Any              () const;
  146.  
  147.   IBoolean CheckCursor      (ICursorImpl const&) const;
  148.  
  149.   IBoolean CheckReplacement (ICursorImpl const&, void const*) const;
  150.  
  151.   char const*
  152.            ClassName        () const;
  153.  
  154.   IACollectionImpl*
  155.            Clone            () const;
  156.  
  157.   IBoolean ContainsAllKeysFrom
  158.                             (IACollectionImpl const&) const;
  159.  
  160.   IBoolean ContainsElementWithKey
  161.                             (void const*) const;
  162.  
  163.   void     Copy             (IACollectionImpl const&);
  164.  
  165.   Cursor*  CreateCursor     () const;
  166.  
  167.   MngCursor*
  168.            CreateMngCursor  () const;
  169.  
  170.   void*    ElementAt        (ICursorImpl const&) const;
  171.  
  172.   void*    ElementWithKey   (void const*) const;
  173.  
  174.   IBoolean IsBounded        () const;
  175.  
  176.   IBoolean IsConsistent     () const;
  177.  
  178.   IBoolean IsEmpty          () const;
  179.  
  180.   IBoolean IsFull           () const;
  181.  
  182.   void*    Key              (void const*) const;
  183.  
  184.   IBoolean LocateElementWithKey
  185.                             (void const*, ICursorImpl&) const;
  186.  
  187.   IBoolean LocateNextElementWithKey
  188.                             (void const*, ICursorImpl&) const;
  189.  
  190.   IBoolean LocateOrAddElementWithKey
  191.                             (void const*, ICursorImpl&);
  192.  
  193.   INumber  NumberOfDifferentKeys
  194.                             () const;
  195.  
  196.   INumber  NumberOfElements () const;
  197.  
  198.   INumber  NumberOfElementsWithKey
  199.                             (void const*) const;
  200.  
  201.   INumber  RemoveAll        ();
  202.  
  203.   INumber  RemoveAll        (IPredFunc, void*);
  204.  
  205.   INumber  RemoveAllElementsWithKey
  206.                             (void const*);
  207.  
  208.   void     RemoveAt         (ICursorImpl&);
  209.  
  210.   IBoolean RemoveElementWithKey
  211.                             (void const*);
  212.  
  213.   void     ReplaceAt        (ICursorImpl const&, void const*);
  214.  
  215.   IBoolean ReplaceElementWithKey
  216.                             (void const*, ICursorImpl&);
  217.  
  218.   IBoolean SetToFirst       (ICursorImpl&) const;
  219.  
  220.   IBoolean SetToNext        (ICursorImpl&) const;
  221.  
  222.   IBoolean SetToNextWithDifferentKey
  223.                             (ICursorImpl&) const;
  224.  
  225.   void     operator=        (IKeyBagAsHshTableImpl const&);
  226.  
  227.   TStream& operator<<=      (TStream&);
  228.  
  229.   TStream& operator>>=      (TStream&) const;
  230.  
  231. protected:
  232.  
  233.   void     Assign           (void*, void const*) const;
  234.  
  235.   void*    CreateNode       (void const*) const;
  236.  
  237.   void*    CreateNodes      (INumber) const;
  238.  
  239.   void     DeleteNode       (void*) const;
  240.  
  241.   void     DeleteNodes      (void*) const;
  242.  
  243.   IBoolean EqualKeys        (void const*, void const*,
  244.                              IArgType) const;
  245.  
  246.   unsigned long
  247.            HashKey          (void const*, unsigned long,
  248.                              IArgType) const;
  249.  
  250.   void*    StreamIn         (TStream&) const;
  251.  
  252.   void     StreamOut        (void const*, TStream&) const;
  253.  
  254. private:
  255.  
  256.   enum { kOriginalVersion };
  257.  
  258.   static
  259.   char const*
  260.            cvClassName;
  261.  
  262.   MngCursor*
  263.            ivMngCursors;
  264.  
  265.   Node**   ivTable;
  266.  
  267.   INumber  ivNumberOfBuckets;
  268.  
  269.   INumber  ivNumberOfElements;
  270.  
  271.   static
  272.   INumber& BucketOf         (ICursorImpl const&);
  273.  
  274.   void     CopyFrom         (IKeyBagAsHshTableImpl const&);
  275.  
  276.   void*    ElementOf        (Node const*) const;
  277.  
  278.   void     GrowBy           (INumber);
  279.  
  280.   static
  281.   INumber  FindNearestPrime (INumber);
  282.  
  283.   void     Initialize       (INumber);
  284.  
  285.   static
  286.   IBoolean IsInBetween      (ICursorImpl const&);
  287.  
  288.   static
  289.   INumber& NextBucketOf     (ICursorImpl const&);
  290.  
  291.   static
  292.   Node*&   NextNodeOf       (ICursorImpl const&);
  293.  
  294.   static
  295.   Node*&   NodeOf           (ICursorImpl const&);
  296.  
  297.  
  298.   static
  299.   Ops&     OpsOf            (IKeyBagAsHshTableImpl const&);
  300.  
  301.   void     SetInBetween     (MngCursor&) const;
  302.  
  303.   friend
  304.   class    IKeyBagAsHshTableMngCursorImpl;
  305.  
  306.   friend
  307.   class    IKeySetOnKeyBagImpl <Self>;
  308.  
  309.  
  310. };
  311.  
  312. class IAKeyBagAsHshTableOps {
  313. public:
  314.  
  315.   virtual ~IAKeyBagAsHshTableOps
  316.                              ();
  317.  
  318.   virtual
  319.   void     Assign           (void*, void const*) const = 0;
  320.  
  321.   virtual
  322.   IACollectionImpl*
  323.            Clone            () const = 0;
  324.  
  325.   virtual
  326.   void*    CreateNode       (void const*) const = 0;
  327.  
  328.   virtual
  329.   void*    CreateNodes      (INumber) const = 0;
  330.  
  331.   virtual
  332.   void     DeleteNode       (void*) const = 0;
  333.  
  334.   virtual
  335.   void     DeleteNodes      (void*) const = 0;
  336.  
  337.   virtual
  338.   IBoolean EqualKeys        (void const*, void const*,
  339.                              IArgType) const = 0;
  340.  
  341.   virtual
  342.   unsigned long
  343.            HashKey          (void const*, unsigned long,
  344.                              IArgType) const = 0;
  345.  
  346.   virtual
  347.   void*    Key              (void const*) const = 0;
  348.  
  349.   virtual
  350.   void*    StreamIn         (TStream&) const = 0;
  351.  
  352.   virtual
  353.   void     StreamOut        (void const*, TStream&) const = 0;
  354.  
  355.   virtual
  356.   TStream& operator<<=      (TStream&) = 0;
  357.  
  358.   virtual
  359.   TStream& operator>>=      (TStream&) const = 0;
  360.  
  361. protected:
  362.  
  363.            IAKeyBagAsHshTableOps
  364.                             (IBoolean);
  365.  
  366. private:
  367.  
  368.   IBoolean ivContainsDTSObjects;
  369.  
  370.   friend
  371.   class    IKeyBagAsHshTableImpl;
  372.  
  373.  
  374. };
  375.  
  376. template <class Element, class _Key,
  377.           class ElementOps, class Implementation>
  378. class IKeyBagAsHshTableOps : public IAKeyBagAsHshTableOps {
  379.  
  380.   typedef  IAKeyBagAsHshTableOps Inherited;
  381.  
  382.   typedef  IKeyBagAsHshTableOps
  383.             <Element, _Key, ElementOps, Implementation> Self;
  384.  
  385.   typedef  IKeyBagAsHshTableNodeImpl <Element> Node;
  386.  
  387. public:
  388.  
  389.   typedef  Implementation ImplType;
  390.  
  391.   typedef  Element ElementType;
  392.  
  393.   typedef  _Key KeyType;
  394.  
  395.            IKeyBagAsHshTableOps
  396.                             (INumber);
  397.  
  398.            IKeyBagAsHshTableOps
  399.                             (INumber, void*);
  400.  
  401.            IKeyBagAsHshTableOps
  402.                             (IKeyBagAsHshTableOps
  403.                               <Element, _Key,
  404.                                ElementOps, Implementation> const&);
  405.  
  406.           ~IKeyBagAsHshTableOps
  407.                             ();
  408.  
  409.   void     Assign           (void*, void const*) const;
  410.  
  411.   IACollectionImpl*
  412.            Clone            () const;
  413.  
  414.   void*    CreateNode       (void const*) const;
  415.  
  416.   void*    CreateNodes      (INumber) const;
  417.  
  418.   void     DeleteNode       (void*) const;
  419.  
  420.   void     DeleteNodes      (void*) const;
  421.  
  422.   IBoolean EqualKeys        (void const*, void const*,
  423.                              IArgType) const;
  424.  
  425.   unsigned long
  426.            HashKey          (void const*, unsigned long,
  427.                              IArgType) const;
  428.  
  429.   void*    Key              (void const*) const;
  430.  
  431.   void*    StreamIn         (TStream&) const;
  432.  
  433.   void     StreamOut        (void const*, TStream&) const;
  434.  
  435.   TStream& operator<<=      (TStream&);
  436.  
  437.   TStream& operator>>=      (TStream&) const;
  438.  
  439.            operator Implementation*
  440.                             ();
  441.  
  442.  
  443. protected:
  444.  
  445. private:
  446.  
  447.   ElementOps
  448.            ivElementOps;
  449.  
  450.   Implementation
  451.            ivImpl;
  452.  
  453.  
  454. };
  455.  
  456. #pragma SOMAsDefault (pop)
  457.  
  458. #include <iikbhsh.inl>
  459.  
  460. #if ! defined (__TEMPINC__)
  461. #include <iikbhsh.c>
  462. #endif
  463.  
  464. #pragma info (restore)
  465. #pragma pack ()
  466.  
  467. #endif
  468.