reman3/Rayman_X/cpa/tempgrp/ldt/Inc/Hash.h

75 lines
2.5 KiB
C

/*------------------------------------------------------------------------------
FILE : Hash.h
CREATED : 98/05/12
AUTHOR : Catalin Cocos
CONTENTS: variable size hash table
------------------------------------------------------------------------------*/
#ifndef __LDT_HASH__
#define __LDT_HASH__
#include "DynArray.h"
/*
* To export code.
*/
#undef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else /* CPA_WANTS_IMPORT */
#define CPA_EXPORT
#endif /* CPA_WANTS_IMPORT */
/*------------------------------------------------------------------------------
TYPES
------------------------------------------------------------------------------*/
typedef struct LDT_tdst_DSHash_ LDT_tdst_DSHash;
struct LDT_tdst_DSHash_
{
int (* pfnDispersion ) (void*); /* the dispersion function */
void (* pfnDelete ) (void*); /* the element deletion function */
LDT_tdst_DSArray* pData; /* the vector */
};
/*------------------------------------------------------------------------------
FUNCTIONS
------------------------------------------------------------------------------*/
/*creation, initialization, deletion
--------------------------------------*/
CPA_EXPORT LDT_tdst_DSHash* LDT_DSHs_new(int (* _pfnDispersion ) (void*),
int (* _pfnCompare) (const void**, const void** ),
void (* _pfnDelete) (void*) ); /* creates a new hash */
CPA_EXPORT int LDT_DSHs_Init(LDT_tdst_DSHash*,
int (* _pfnDispersion ) (void*),
int (* _pfnCompare)(const void**, const void** ),
void (* _pfnDelete) (void*) ); /* initializes an existing hash */
CPA_EXPORT void LDT_DSHs_delete( LDT_tdst_DSHash*, int ); /* deletes an existing array*/
CPA_EXPORT void LDT_DSHs_SetGranularity( LDT_tdst_DSHash*, int); /* sets the dynamic aray elements granularity */
/* Clean up
-------------*/
CPA_EXPORT void LDT_DSHs_FreeExtra( LDT_tdst_DSHash* ); /* frees the unused memory */
CPA_EXPORT void LDT_DSHs_RemoveAll( LDT_tdst_DSHash*, int ); /* removes all elements */
CPA_EXPORT void LDT_DSHs_Close( LDT_tdst_DSHash*, int ); /* clears the hash memory */
/* Accessing elements
-----------------------*/
CPA_EXPORT void* LDT_DSHs_GetEqOf( LDT_tdst_DSHash*, void* ); /* gets the hash element matching the parameter*/
CPA_EXPORT void* LDT_DSHs_RemoveEqOf( LDT_tdst_DSHash*, void* ); /* removes the hash element matching the parameter*/
CPA_EXPORT void* LDT_DSHs_Insert( LDT_tdst_DSHash*, void*, int ); /* inserts the element in the hash table*/
#endif