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

  1. //#  @(#) 2.12 src/somuc/tdict.idl, somuc, som2.1 12/26/95 15:36:47 [7/30/96 14:50:04]
  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_TDictionary
  18.  *
  19.  * DESCRIPTION: This class represents a collection of paired objects
  20.  *              (associations).  Because dictionaries are sometimes used
  21.  *              to represent a bijective mapping, functions for retrieving a
  22.  *              key given a value are provided along with the usual access
  23.  *              functions (however, this will probably be slow).
  24.  *
  25.  */
  26.  
  27. // This file was generated by the SOM Compiler.
  28. // FileName: TDict.id2.
  29. // Generated using:
  30. //     SOM Precompiler spc: 6.13
  31. //     SOM Emitter emitidl.dll: 6.18
  32. #ifndef TDict_idl
  33. #define TDict_idl
  34.  
  35. #include "tcollect.idl"
  36.  
  37. interface somf_THashTable;
  38.  
  39. interface somf_TDictionary : somf_TCollection
  40. {
  41.  
  42.   //#  friend class TDictionaryIterator;
  43.  
  44.   somf_TDictionary somfTDictionaryInitFLL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
  45.                        in long sizeHint,
  46.                        in long growthRate);
  47.  
  48.   // Initializes the new dictionary.
  49.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  50.  
  51.   somf_TDictionary somfTDictionaryInitFL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
  52.                       in long sizeHint);
  53.  
  54.   // Initializes the new dictionary.
  55.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  56.  
  57.   somf_TDictionary somfTDictionaryInitF(in somf_MCollectible::somf_MCollectibleCompareFn testfn);
  58.  
  59.   // Initializes the new dictionary.
  60.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  61.  
  62.   somf_TDictionary somfTDictionaryInitLLF(in long sizeHint,
  63.                        in long growthRate,
  64.                        in somf_MCollectible::somf_MCollectibleCompareFn testfn);
  65.  
  66.   // Initializes the new dictionary.
  67.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  68.  
  69.   somf_TDictionary somfTDictionaryInitLL(in long sizeHint,
  70.                       in long growthRate);
  71.  
  72.   // Initializes the new dictionary.
  73.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  74.  
  75.   somf_TDictionary somfTDictionaryInitL(in long sizeHint);
  76.  
  77.   // Initializes the new dictionary.
  78.   //#   TDictionary(MCollectibleCompareFn testfn, long sizeHint=kCollectionSizeHint, long growthRate = kCollectionSizeHint)
  79.  
  80.   somf_TDictionary somfTDictionaryInitD(in somf_TDictionary dictionary);
  81.  
  82.   // Initializes the new dictionary.
  83.   //#   TDictionary(const TDictionary&);
  84.  
  85.   void somfAssign(in somf_TDictionary source);
  86.  
  87.   // Assign the instance of this equal to the instance of source.
  88.   //#   const TDictionary&   operator=(const TDictionary&);
  89.  
  90.   void somfDeleteAllKeys();
  91.  
  92.   // Remove all of the entries in the dictionary.  Reset the count to be zero.
  93.   // Call the destructor on every key in the dictionary.
  94.   //#   virtual void     DeleteAllKeys()
  95.  
  96.   void somfDeleteAllValues();
  97.  
  98.   // Remove all of the entries in the dictionary.  Reset the count to be zero.
  99.   // Call the destructor on every value in the hash table.  If you have a value
  100.   // which appears more than once, you will be sorry you used this method because
  101.   // the utility classes will delete the same object more than once.  This
  102.   // is not good.
  103.   //#   virtual void     DeleteAllValues()
  104.  
  105.   somf_MCollectible somfValueAt(in somf_MCollectible key);
  106.  
  107.   // Return the value associated with the key.  Return SOMF_NIL if the key could not
  108.   // be found.
  109.   //#   virtual MCollectible*   ValueAt(const MCollectible& key) const;
  110.  
  111.   somf_MCollectible somfKeyAtMF(in somf_MCollectible val,
  112.                  in somf_MCollectible::somf_MCollectibleCompareFn testfn);
  113.  
  114.   // Return the first key found which has val as its value.  This involves a slow
  115.   // search.
  116.   //#    virtual MCollectible*   KeyAt(const MCollectible& val, MCollectibleCompareFn testfn = SOMF_NIL) const;
  117.  
  118.   somf_MCollectible somfKeyAtM(in somf_MCollectible val);
  119.  
  120.   // Return the first key found which has val as its value.  This involves a slow
  121.   // search. This method uses the same compare function as specified in
  122.   // the constructor.
  123.   //#    virtual MCollectible*   KeyAt(const MCollectible& val, MCollectibleCompareFn testfn = SOMF_NIL) const;
  124.  
  125.   somf_MCollectible somfDeleteKey(in somf_MCollectible key);
  126.  
  127.   // Delete the key from the key,value pair associated with key and remove the
  128.   // key,value pair from the dictionary.  Return the value that was removed
  129.   // as a result of this call.
  130.   //#   virtual MCollectible*   DeleteKey(MCollectible* key);
  131.  
  132.   somf_MCollectible somfAddKeyValuePairMMB(in somf_MCollectible key,
  133.                     in somf_MCollectible val,
  134.                     in boolean replace);
  135.  
  136.   // If replace = FALSE, then only add key,value pair to the table if there is not
  137.   // an existing key,value pair.  Otherwise, if replace=TRUE, add the key,value
  138.   // pair to the hash table.  Either way, return the key that existed (if any) in
  139.   // the hash table before this call.  Proper memory management may involve
  140.   // checking to see if the key returned is "the same" as the key passes in when
  141.   // replacing key,value pairs.
  142.   //#   virtual MCollectible*   AddKeyValuePair(const MCollectible* key, MCollectible* val, Boolean replace = TRUE);
  143.  
  144.   somf_MCollectible somfAddKeyValuePairMM(in somf_MCollectible key,
  145.                        in somf_MCollectible val);
  146.  
  147.   // Add the key,value pair to the hash table, and return the key that existed
  148.   // (if any) in the hash table before this call.  Proper memory management may
  149.   // involve checking to see if the key returned is "the same" as the key passes
  150.   // in when replacing key,value pairs.
  151.   //#   virtual MCollectible*   AddKeyValuePair(const MCollectible* key, MCollectible* val, Boolean replace = TRUE);
  152.  
  153.   void somfSetHashFunction(in somf_MCollectible::somf_MCollectibleHashFn fn);
  154.  
  155.   // Set the hash function to fn.  By default this is set to MCollectible's Hash
  156.   // (which is usually overridden in the objects you are adding to the hash
  157.   // table).  You can use any hash function that you like as long as it has the
  158.   // type signature of somf_MCollectibleHashFn.  Most of the time, you won't need to
  159.   // do this.
  160.   //#   virtual void     SetHashFunction(MCollectibleHashFn);
  161.  
  162.   somf_MCollectible::somf_MCollectibleHashFn somfGetHashFunction();
  163.  
  164.   // Return the hash function.
  165.   //#   virtual MCollectibleHashFn GetHashFunction() const;
  166.  
  167.   //#   override StreamOut;
  168.   //# // Stream stuff
  169.   //# //   virtual TStream&   operator>>=(TStream& towhere) const;
  170.   //#
  171.   //#   override StreamIn;
  172.   //# // Stream stuff
  173.   //# //   virtual TStream&   operator<<=(TStream& towhere);
  174.  
  175.   //#override somfClone;
  176.   //# There is no point in overriding somfClone, the code was fixed so it works
  177.   //# correctly.
  178.   //#   MCollectibleDeclarationsMacro(TDictionary);
  179.  
  180.   somf_THashTable somfCreateNewImplementationFLLL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
  181.                            in long tablesize,
  182.                            in long rate,
  183.                            in long threshold);
  184.  
  185.   // Create a new hash table for the dictionary.  Normally you won't have to do
  186.   // this.
  187.   //# protected:
  188.   //#   THashTable*     CreateNewImplementation(
  189.   //#                       MCollectibleCompareFn testfn = &MCollectible::IsSame,
  190.   //#                       long tablesize=kDefaultHashTableSize,
  191.   //#                       long rate=kDefaultGrowthRate,
  192.   //#                       long threshold=kDefaultRehashThreshold);
  193.  
  194.   somf_THashTable somfCreateNewImplementationF(in somf_MCollectible::somf_MCollectibleCompareFn testfn);
  195.  
  196.   // Create a new hash table for the dictionary.  Normally you won't have to do
  197.   // this.
  198.   //# protected:
  199.   //#   THashTable*     CreateNewImplementation(
  200.   //#                       MCollectibleCompareFn testfn = &MCollectible::IsSame,
  201.   //#                       long tablesize=kDefaultHashTableSize,
  202.   //#                       long rate=kDefaultGrowthRate,
  203.   //#                       long threshold=kDefaultRehashThreshold);
  204.  
  205.   somf_THashTable somfCreateNewImplementationFL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
  206.                          in long tablesize);
  207.  
  208.   // Create a new hash table for the dictionary.  Normally you won't have to do
  209.   // this.
  210.   //# protected:
  211.   //#   THashTable*     CreateNewImplementation(
  212.   //#                       MCollectibleCompareFn testfn = &MCollectible::IsSame,
  213.   //#                       long tablesize=kDefaultHashTableSize,
  214.   //#                       long rate=kDefaultGrowthRate,
  215.   //#                       long threshold=kDefaultRehashThreshold);
  216.  
  217.   somf_THashTable somfCreateNewImplementationFLL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
  218.                           in long tablesize,
  219.                           in long rate);
  220.  
  221.   // Create a new hash table for the dictionary.  Normally you won't have to do
  222.   // this.
  223.   //# protected:
  224.   //#   THashTable*     CreateNewImplementation(
  225.   //#                       MCollectibleCompareFn testfn = &MCollectible::IsSame,
  226.   //#                       long tablesize=kDefaultHashTableSize,
  227.   //#                       long rate=kDefaultGrowthRate,
  228.   //#                       long threshold=kDefaultRehashThreshold);
  229.  
  230.   somf_THashTable somfCopyImplementation();
  231.  
  232.   // Return a hash table that is a copy of the hash table in this.  Normally you
  233.   // won't have to do this.
  234.   //# protected:
  235.   //#   THashTable*     CopyImplementation() const;
  236.  
  237.  
  238.  
  239. #ifdef __SOMIDL__
  240.   implementation {
  241.  
  242.     releaseorder: somfDeleteAllKeys,somfDeleteAllValues,somfValueAt,somfKeyAtMF,
  243.           somfKeyAtM,somfDeleteKey,somfAddKeyValuePairMMB,
  244.           somfAddKeyValuePairMM,somfSetHashFunction,somfGetHashFunction,
  245.           somfCreateNewImplementationFLLL,somfCreateNewImplementationF,
  246.           somfCreateNewImplementationFL,somfCreateNewImplementationFLL,
  247.           somfCopyImplementation,somfAssign,somfTDictionaryInitFLL,
  248.           somfTDictionaryInitFL,somfTDictionaryInitF,
  249.           somfTDictionaryInitLLF,somfTDictionaryInitLL,
  250.           somfTDictionaryInitL,somfTDictionaryInitD;
  251.  
  252.     //# Class Modifiers
  253.     majorversion = 2;
  254.     minorversion = 1;
  255.     filestem = tdict;
  256.     dllname = "somuc.dll";
  257.  
  258.  
  259.     passthru C_xh_after =  ""
  260. ""
  261. "#include <mcollect.xh>"
  262. "#include <thash.xh>"
  263. "";
  264.  
  265.     passthru C_h_after =  ""
  266. ""
  267. "#include <mcollect.h>"
  268. "#include <thash.h>"
  269. "";
  270.  
  271.     //# Internal Instance Variables
  272.     somf_THashTable fImplementation;
  273.  
  274.     //# Method Modifiers
  275.     somInit: override;
  276.     somUninit: override;
  277.     somfCreateIterator: override;
  278.     somfRemove: override;
  279.     somfRemoveAll: override;
  280.     somfDeleteAll: override;
  281.     somfCount: override;
  282.     somfMember: override;
  283.     somfValueAt: nomodify;
  284.     somfKeyAtMF: nomodify;
  285.     somfKeyAtM: nomodify;
  286.     somfAdd: override;
  287.     somfGetHashFunction: nomodify;
  288.     somfCopyImplementation: nomodify;
  289.     somfTDictionaryInitFLL: nooverride;
  290.     somfTDictionaryInitFL: nooverride;
  291.     somfTDictionaryInitF: nooverride;
  292.     somfTDictionaryInitLLF: nooverride;
  293.     somfTDictionaryInitLL: nooverride;
  294.     somfTDictionaryInitL: nooverride;
  295.     somfTDictionaryInitD: nooverride;
  296.  
  297.     //# Data Modifiers
  298.  
  299.   };
  300. #endif /* __SOMIDL__ */
  301. };
  302.  
  303. #endif  /* TDict_idl */
  304.