/**********************************************************************
 * Copyright (c) 2005, 2007 Scapa Technologies Limited and others
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * $Id: hashtable.h,v 1.2 2007/04/06 01:15:26 jkubasta Exp $
 * 
 * Contributors: 
 * Scapa Technologies Limited - Initial API and implementation
 **********************************************************************/

#ifndef __HASHTABLE_H__
#define __HASHTABLE_H__

#include "system.h"

#ifdef __cplusplus
extern "C" {
#endif

//
// Hashtable collision list (user doesnt need to care about these - they're private)
//
typedef struct {
	long int hash;
	char* key;
	XINT64 value;
	void* next;
} Entry;

//
// Hashtable struct
//
typedef struct {
	Entry**	table;
	int table_len;
	int count;
	int threshold;
	XMutex mutex;

} HashTable;

BOOL containsKey(HashTable* table, char* key);
int tableKeysAsList(HashTable* table, char** list, int list_size);
HashTable* tableCreate();
void tableDelete(HashTable* hasht);
void tableClear(HashTable* hasht);
void tableFree(HashTable* hasht);		//frees all the entry values in a table
int tableSize(HashTable* hasht);
XINT64 tableGet(HashTable* hasht, char* key);
void tableRehash(HashTable* hasht);
void tableRemove(HashTable* hasht, char* key);
XINT64 tablePut(HashTable* hasht, char* key, XINT64 value);
long int getHash(char* key);

#ifdef __cplusplus
}
#endif
#endif
