//
//   COMPONENT_NAME: somuc
//
//   ORIGINS: 82, 81, 27
//
//
//   10H9767, 10H9769  (C) COPYRIGHT International Business Machines Corp. 1992,1994
//   All Rights Reserved
//   Licensed Materials - Property of IBM
//   US Government Users Restricted Rights - Use, duplication or
//   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
//
//   Copyright © 1988, 1989 Apple Computer, Inc. All rights reserved.
/*
 * CLASS_NAME: somf_THashTable
 *
 * DESCRIPTION: Every Hash Table has a set of entries which associate a
 *              key to a value.  Hash tables provide for fast lookup of a
 *              value when given a key even if there are a large number of
 *              entries in the table.  Functions are provided for the usual
 *              things (insert, delete, etc.) as well as for controlling when
 *              rehashing will occur, and the growth of the table when a
 *              rehash occurs.
 *
 */
#ifndef THash_idl
#define THash_idl
#include "mcollect.idl"
interface THAssoc;
interface somf_THashTable : somf_MCollectible
{
  const long kDefaultHashTableSize = 23;
  const long kDefaultGrowthRate = 20;
  const long kDefaultRehashThreshold = 80;
  enum  ETableClassification { kUnchecked, kNormal, kFast };
  somf_THashTable somfTHashTableInitFLLL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
				      in long tablesize,
				      in long rate,
				      in long threshold);
  // Initializes the new hash table.
  somf_THashTable somfTHashTableInitFLL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
				     in long tablesize,
				     in long rate);
  // Initializes the new hash table.
  somf_THashTable somfTHashTableInitFL(in somf_MCollectible::somf_MCollectibleCompareFn testfn,
				    in long tablesize);
  // Initializes the new hash table.
  somf_THashTable somfTHashTableInitH(in somf_THashTable h);
  // Initializes the new hash table.
  void somfAssign(in somf_THashTable source);
  // Assign the instance of this equal to the instance of source.
  long somfCount();
  // Return the number of objects in this.
  somf_MCollectible somfRemove(in somf_MCollectible key);
  // Remove obj from this.  Return the object which was actually removed
  // (which if you are using an IsSame test function may not be the same
  // as the object passed in only "equal").
  somf_MCollectible somfDelete(in somf_MCollectible key);
  // Remove key from this and deallocate the storage that these objects might
  // have owned (that is, the destructor function is called for each object
  // in the collection).  Return the object which was actually removed (which
  // if you are using an IsSame test function may not be the same as the object
  // passed in only "equal").
  somf_MCollectible somfMember(in somf_MCollectible key);
  // Each object in this is compared to obj using the function testFn.  Return the
  // object for which testFn returned TRUE.  Return SOMF_NIL if not object was found.
  void somfRemoveAll();
  // Remove all of the objects from this.
  void somfDeleteAll();
  // Remove all of the objects from this and deallocate the storage that these
  // objects might have owned (that is, the destructor function is called
  // for each object in the collection).
  void somfDeleteAllKeys();
  // Remove all of the keys from this and deallocate the storage that these
  // objects might have owned (that is, the destructor function is called
  // for each object in the collection).
  void somfDeleteAllValues();
  // Remove all of the values from this and deallocate the storage that these
  // objects might have owned (that is, the destructor function is called
  // for each object in the collection).
  somf_MCollectible somfAddMMB(in somf_MCollectible key,
			    in somf_MCollectible value,
			    in boolean replace);
  // Add key and value to this.  If replace = TRUE, replace a copy if it already
  // exists.
  somf_MCollectible somfAddMM(in somf_MCollectible key,
			   in somf_MCollectible value);
  // Add key and value to this.  Replace a copy if it already exists.
  void somfGrow();
  // Grow the Hash Table
  somf_MCollectible somfRetrieve(in somf_MCollectible key);
  // Retrieve and return the value associated with key.
  void somfSetGrowthRate(in long rate);
  // Set the growth rate of the hash table.
  void somfSetRehashThreshold(in long threshold);
  // Set the rehash threshold of the hash table.
  long somfGetGrowthRate();
  // Return the growth rate of the hash table.
  long somfGetRehashThreshold();
  // Return the rehash threshold of the hash table.
  void somfSetHashFunction(in somf_MCollectible::somf_MCollectibleHashFn fn);
  // Set the hash function to fn.
  somf_MCollectible::somf_MCollectibleHashFn somfGetHashFunction();
  // Return the hash function.
#ifdef __SOMIDL__
  implementation {
    releaseorder: somfCount,somfRemove,somfDelete,somfMember,
		  somfRemoveAll,somfDeleteAll,somfDeleteAllKeys,
		  somfDeleteAllValues,somfAddMMB,somfAddMM,somfGrow,somfRetrieve,
		  somfSetGrowthRate,somfSetRehashThreshold,somfGetGrowthRate,
		  somfGetRehashThreshold,somfSetHashFunction,somfGetHashFunction,
		  somfFind,somfMakeNewTable,somfCopyIn,somfAssign,
		  somfTHashTableInitFLLL,somfTHashTableInitFLL,
		  somfTHashTableInitFL,somfTHashTableInitH;
    majorversion = 2;
    minorversion = 1;
    filestem = thash;
    dllname = "somuc.dll";
    long fTableSize;              // Actual physical size of the table
    long fSize;                   // Number of entries in the table
    long fGrowthRate;
    long fRehashThreshold;
    long fNextRehash;
    THAssoc fTable;
    somf_MCollectible::somf_MCollectibleCompareFn fTestfn;
    somf_MCollectible::somf_MCollectibleHashFn fHashfn;
    unsigned long fSeed;          // Count of operations on the table. Used by Iterator
    ETableClassification fFast;
    somInit: override;
    somUninit: override;
    somfCount: nooverride, nomodify;
    somfRemove: nooverride;
    somfDelete: nooverride;
    somfMember: nooverride, nomodify;
    somfRemoveAll: nooverride;
    somfDeleteAll: nooverride;
    somfDeleteAllKeys: nooverride;
    somfDeleteAllValues: nooverride;
    somfAddMMB: nooverride;
    somfAddMM: nooverride;
    somfGrow: nooverride;
    somfRetrieve: nooverride, nomodify;
    somfSetGrowthRate: nooverride;
    somfSetRehashThreshold: nooverride;
    somfGetGrowthRate: nooverride, nomodify;
    somfGetRehashThreshold: nooverride, nomodify;
    somfSetHashFunction: nooverride;
    somfGetHashFunction: nooverride, nomodify;
    somfTHashTableInitFLLL: nooverride;
    somfTHashTableInitFLL: nooverride;
    somfTHashTableInitFL: nooverride;
    somfTHashTableInitH: nooverride;
  };
#endif /* __SOMIDL__ */
};
#endif  /* THash_idl */
