packages feed

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

DEFINITION MODULE LHash;
(*==============================================================
    Version  : 2.0 16 Sep 1990 C. Lins
    Compiler : Generic pc Modula-2
    Component: Hash Table - Sequential Unbounded Managed Iterator
              Linear hashing

    REVISION HISTORY
    v1.00  23 Apr 1989  C. Lins:
        Initial Modula-2 implementation
    v1.01  30 Jun 1989  C. Lins:
        Removed separation of key and data.
    v1.02  12 Aug 1989  C. Lins:
        Change table to VAR parameter in Insert, Remove, Update.
    v1.03  13 Aug 1989  C. Lins:
        Changed active iteration mechanism to match that for
       Direct Chaining.
    v1.04  21 Aug 1989  C. Lins:
       Added HashOf selector.
    v1.05  29 Aug 1989  C. Lins:
       Separate key and data.

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

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

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

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

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


CONST ModuleID = 9;

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   *);
                        minLoadFact: REAL          (*--in   *);
                        maxLoadFact: REAL          (*--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  HashTableEntry;
TYPE  IterateProc = PROCEDURE (CARDINAL, States, HashTableEntry);

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

PROCEDURE IsNull   (    theEntry   : HashTableEntry(*--in   *))
                                   : BOOLEAN       (*--out  *);

PROCEDURE KeyOf    (    theEntry   : HashTableEntry(*--in   *))
                                   : Key           (*--out  *);

PROCEDURE DataOf   (    theEntry   : HashTableEntry(*--in   *))
                                   : Data          (*--out  *);

PROCEDURE NextOf   (    theEntry   : HashTableEntry(*--in   *))
                                   : HashTableEntry(*--out  *);

END LHash.