packages feed

language-Modula2-0.1: examples/Modula-2_Libraries/C.-Lins_Modula-2_Software_Component_Library/Vol4/hashing/bhash.def

DEFINITION MODULE BHash;
(*==============================================================
    Version  : 2.0 16 Sep 1990 C. Lins
    Compiler : Generic pc Modula-2
    Component: Hash Table - Sequential Bounded Managed Iterator
              Collision resolution using double hashing and
              Brent's Reorganization scheme

    REVISION HISTORY
    v1.00  13 May 1989  C. Lins:
        Initial Modula-2 implementation
    v1.01  30 Jun 1989  C. Lins:
       Eliminated separation of key and data.
    v1.02  21 Aug 1989  C. Lins:
       Added selector HashOf to return hashing function.
    v1.03  29 Aug 1989  C. Lins:
       Separate of key and data.
       Remove increment function from Create.

   v2.00  16 Sep 1990  C. Lins
     Created generic pc version
   (C) Copyright 1990 Charles A. Lins
==============================================================*)

FROM HashTypes IMPORT
   (*--type*) Exceptions, FoundProc, NotFoundProc,
              UpdateProc, LoopProc, AccessProc, HashFunction,
              States, Key, Data;

FROM ErrorHandling IMPORT
   (*--type*) HandlerProc;

FROM TypeManager IMPORT
   (*--type*) TypeID;

   (*-------------------------*)


CONST ModuleID = 10;

PROCEDURE TableError () : Exceptions               (*--out  *);

PROCEDURE SetHandler (    theError   : Exceptions  (*--in   *);
                         theHandler : HandlerProc  (*--in   *));

PROCEDURE GetHandler (    theError   : Exceptions  (*--in   *))
                                    : HandlerProc  (*--out  *);


TYPE  HashTable;
VAR NullTable : HashTable;


PROCEDURE Create   (    keyTypeID  : TypeID        (*--in   *);
                        dataTypeID : TypeID        (*--in   *);
                        theSize    : CARDINAL      (*--in   *);
                        hashFunc   : HashFunction  (*--in   *))
                                   : HashTable     (*--out  *);

PROCEDURE Destroy  (VAR theTable   : HashTable     (*--inout*));

PROCEDURE Clear    (    theTable   : HashTable     (*--inout*));

PROCEDURE Assign   (    theTable   : HashTable     (*--in   *);
                    VAR toTable    : HashTable     (*--inout*));

PROCEDURE Insert   (    theTable   : HashTable     (*--inout*);
                        theKey     : Key           (*--in   *);
                        theData    : Data          (*--in   *));

PROCEDURE Remove   (    theTable   : HashTable     (*--inout*);
                        theKey     : Key           (*--in   *);
                        notFound   : NotFoundProc  (*--in   *));

PROCEDURE Update   (    theTable   : HashTable     (*--inout*);
                        theKey     : Key           (*--in   *);
                        theData    : Data          (*--in   *);
                        updateEntry: UpdateProc    (*--in   *));


PROCEDURE IsDefined (    theTable  : HashTable     (*--in   *))
                                   : BOOLEAN       (*--out  *);

PROCEDURE IsEmpty  (    theTable   : HashTable     (*--in   *))
                                   : BOOLEAN       (*--out  *);

PROCEDURE KeyTypeOf (    theTable  : HashTable     (*--in   *))
                                   : TypeID        (*--out  *);

PROCEDURE DataTypeOf(    theTable  : HashTable     (*--in   *))
                                   : TypeID        (*--out  *);

PROCEDURE HashOf    (    theTable  : HashTable     (*--in   *))
                                   : HashFunction  (*--out  *);

PROCEDURE SizeOf    (    theTable  : HashTable     (*--in   *))
                                   : CARDINAL      (*--out  *);

PROCEDURE ExtentOf  (    theTable  : HashTable     (*--in   *))
                                   : CARDINAL      (*--out  *);

PROCEDURE IsPresent    (    theTable   : HashTable     (*--in   *);
                        theKey     : Key           (*--in   *);
                        found      : FoundProc     (*--in   *);
                        notFound   : NotFoundProc  (*--in   *));


PROCEDURE LoopOver (    theTable   : HashTable     (*--in   *);
                        process    : LoopProc      (*--in   *));

PROCEDURE Traverse (    theTable   : HashTable     (*--in   *);
                        process    : AccessProc    (*--in   *));

TYPE  IterateProc = PROCEDURE (CARDINAL, States, Key, Data);

PROCEDURE Iterate  (    theTable   : HashTable     (*--in   *);
                        process    : IterateProc   (*--in   *));

END BHash.