Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

hashtable.h File Reference

Hash Table functions. More...

Go to the source code of this file.

Data Structures

struct  _PmBucket
 A bucket in a hash table. More...

struct  _PmHashTable
 A hash table. More...


Typedefs

typedef _PmHashTable PmHashTable
 Hash table.

typedef _PmBucket PmBucket
 Bucket.


Functions

PmHashTablepmNewHashTable (int(*compare)(const void *key1, const void *key2), unsigned short(*hashkey)(PmHashTable *table, const void *key), void(*freeData)(void *data))
 Creates a new hash table.

void pmDestroyHashTable (PmHashTable *table)
 Destroys a hash table.

char pmHashTableAdd (PmHashTable *table, void *key, void *data)
 Adds a key and its associated data to a hash table.

char pmHashTableRemove (PmHashTable *table, void *key)
 Removes a key and its associated data from a hash table.

void * pmHashTableGet (PmHashTable *table, void *key)
 Returns the data with the specified key.


Detailed Description

Hash Table functions.

Id:
hashtable.h,v 1.3 2002/05/30 06:43:35 chipx86 Exp
Copyright:
(C) 1999-2002 The GNUpdate Project.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Typedef Documentation

typedef struct _PmBucket PmBucket
 

Bucket.

typedef struct _PmHashTable PmHashTable
 

Hash table.


Function Documentation

void pmDestroyHashTable PmHashTable   table
 

Destroys a hash table.

Parameters:
table  The hash table to destroy.
See also:
pmNewHashTable()

char pmHashTableAdd PmHashTable   table,
void *    key,
void *    data
 

Adds a key and its associated data to a hash table.

Parameters:
table  The hash table.
key  The key to add.
data  The data to add.
Returns:
1 on success. 0 on conflict or bad parameter.
See also:
pmHashTableRemove() , pmHashTableGet()

void* pmHashTableGet PmHashTable   table,
void *    key
 

Returns the data with the specified key.

Parameters:
table  The hash table.
key  The key the data is associated with.
Returns:
The data, or NULL if not found.
See also:
pmHashTableAdd() , pmHashTableRemove()

char pmHashTableRemove PmHashTable   table,
void *    key
 

Removes a key and its associated data from a hash table.

Parameters:
table  The hash table.
key  The key.
Returns:
1 on success. 0 on bad parameter, or if key is not found.
See also:
pmHashTableAdd() , pmHashTableGet()

PmHashTable* pmNewHashTable int(*    compare)(const void *key1, const void *key2),
unsigned short(*    hashkey)(PmHashTable *table, const void *key),
void(*    freeData)(void *data)
 

Creates a new hash table.

Parameters:
compare  The key comparison function.
hashkey  The hash key generation function.
freeData  The memory deallocation function for data (or NULL to not deallocate automatically).
Returns:
A new hash table.
See also:
pmDestroyHashTable()


Generated on Tue Jul 2 03:15:24 2002 for libpackman by doxygen1.2.15-20020430