/*
    HashList.h, Copyright  (c) by George Fankhauser,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public Licence.
 
    A full copy of the GNU GPL is provided in the file COPYING found in the 
    development root of Topsy.
*/
/*
	
	File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Topsy/HashList.h,v $
 	Author(s):             George Fankhauser
 	Affiliation:           ETH Zuerich, TIK
 	Version:               $Revision: 2922 $
 	Creation Date:         
 	Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $      by: $Author: baderma $
*/

#ifndef _HASHLIST_H_
#define _HASHLIST_H_

#include "Topsy.h"
#include "MMHeapMemory.h"


#define HASHLISTSIZE 	17 /* the 7th prime */
#define HASHERROR 	 0
#define HASHOK 		 1
#define HASHNOTFOUND 	 2
#define HASHDUPLICATEKEY 3

typedef struct HashListElementDesc_t
{
  void* item;
  unsigned long int key;
  struct HashListElementDesc_t* next;
}
HashListElementDesc;

typedef HashListElementDesc* HashListElement;

typedef struct HashList_t
{
  HashListElement table[HASHLISTSIZE];
}
HashListDesc;

typedef HashListDesc* HashList;


HashList hashListNew(void);
Error hashListAdd(HashList list, void* data, unsigned long int key);
Error hashListGet(HashList list, void** data, unsigned long int key);
Error hashListRemove(HashList list, unsigned long int key);


#endif
