Galago - desktop presence framework

galago-hashtable.h File Reference

Hash Table API. More...

#include <libgalago/galago-list.h>
#include <libgalago/galago-types.h>

Go to the source code of this file.


Hash Table API

GalagoHashTable * galago_hash_table_new (GalagoHashFunc hash_func, GalagoEqualFunc key_equal_func)
 Creates a new hash table.
GalagoHashTable * galago_hash_table_new_full (GalagoHashFunc hash_func, GalagoEqualFunc key_equal_func, GalagoFreeFunc destroy_key_func, GalagoFreeFunc destroy_value_func)
 Creates a new hash table.
void galago_hash_table_destroy (GalagoHashTable *hash_table)
 Destroys a hash table.
void galago_hash_table_clear (GalagoHashTable *hash_table)
 Clears a hashtable of all data.
void galago_hash_table_insert (GalagoHashTable *hash_table, void *key, void *value)
 Inserts an item into a hash table.
void galago_hash_table_replace (GalagoHashTable *hash_table, void *key, void *value)
 Replaces an item in a hash table.
void galago_hash_table_remove (GalagoHashTable *hash_table, const void *key)
 Removes an item from a hash table.
void * galago_hash_table_lookup (const GalagoHashTable *hash_table, const void *key)
 Looks up and returns data from a hash table.
galago_bool galago_hash_table_exists (const GalagoHashTable *hash_table, const void *key)
 Returns whether or not data with the specified key exists in a hash table.
GalagoListgalago_hash_table_get_keys (const GalagoHashTable *hash_table)
 Returns a list of all keys in a hash table.
GalagoListgalago_hash_table_get_values (const GalagoHashTable *hash_table)
 Returns a list of all values in a hash table.
void galago_hash_table_foreach (const GalagoHashTable *hash_table, GalagoHForEachFunc func, void *user_data)
 Calls a function on every key and value in a hash table.
void galago_hash_table_foreach_key (const GalagoHashTable *hash_table, GalagoForEachFunc func, void *user_data)
 Calls a function on every key in a hash table.
void galago_hash_table_foreach_value (const GalagoHashTable *hash_table, GalagoForEachFunc func, void *user_data)
 Calls a function on every value in a hash table.
size_t galago_hash_table_get_size (const GalagoHashTable *hash_table)
 Returns the size of the hash table.

Hash Functions

galago_bool galago_str_equal (const void *a, const void *b)
 Checks if two strings are equal.
unsigned int galago_str_hash (const void *str)
 Returns the hash of a string.
galago_bool galago_int_equal (const void *a, const void *b)
 Checks if two integers are equal.
unsigned int galago_int_hash (const void *i)
 Returns the hash of an integer.
galago_bool galago_direct_equal (const void *a, const void *b)
 Checks if two pointers are equal.
unsigned int galago_direct_hash (const void *ptr)
 Returns the hash of a pointer.

Typedefs

typedef _GalagoHashTable GalagoHashTable

Detailed Description

Hash Table API.

Copyright:
(C) 2004-2005 Christian Hammond.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser 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.

Definition in file galago-hashtable.h.


Function Documentation

galago_bool galago_direct_equal const void *  a,
const void *  b
 

Checks if two pointers are equal.

Parameters:
a The first pointer.
b The second pointer.
Returns:
TRUE if the pointers are equal.

unsigned int galago_direct_hash const void *  ptr  ) 
 

Returns the hash of a pointer.

Parameters:
ptr The pointer.
Returns:
The hash of the pointer.

void galago_hash_table_clear GalagoHashTable *  hash_table  ) 
 

Clears a hashtable of all data.

Parameters:
hash_table The hash table to clear.

void galago_hash_table_destroy GalagoHashTable *  hash_table  ) 
 

Destroys a hash table.

Parameters:
hash_table The hash table to destroy.

galago_bool galago_hash_table_exists const GalagoHashTable *  hash_table,
const void *  key
 

Returns whether or not data with the specified key exists in a hash table.

Parameters:
hash_table The hash table.
key The key.
Returns:
TRUE if any value exists, or FALSE.

void galago_hash_table_foreach const GalagoHashTable *  hash_table,
GalagoHForEachFunc  func,
void *  user_data
 

Calls a function on every key and value in a hash table.

Parameters:
hash_table The hash table.
func The function.
user_data User-specified data.

void galago_hash_table_foreach_key const GalagoHashTable *  hash_table,
GalagoForEachFunc  func,
void *  user_data
 

Calls a function on every key in a hash table.

Parameters:
hash_table The hash table.
func The function.
user_data User-specified data.

void galago_hash_table_foreach_value const GalagoHashTable *  hash_table,
GalagoForEachFunc  func,
void *  user_data
 

Calls a function on every value in a hash table.

Parameters:
hash_table The hash table.
func The function.
user_data User-specified data.

GalagoList* galago_hash_table_get_keys const GalagoHashTable *  hash_table  ) 
 

Returns a list of all keys in a hash table.

The returned list must be freed.

Parameters:
hash_table The hash table.
Returns:
The list of keys in the hash table. This must be freed.

size_t galago_hash_table_get_size const GalagoHashTable *  hash_table  ) 
 

Returns the size of the hash table.

Parameters:
hash_table The hash table.
Returns:
The number of items in the hash table.

GalagoList* galago_hash_table_get_values const GalagoHashTable *  hash_table  ) 
 

Returns a list of all values in a hash table.

The returned list must be freed.

Parameters:
hash_table The hash table.
Returns:
The list of values in the hash table. This must be freed.

void galago_hash_table_insert GalagoHashTable *  hash_table,
void *  key,
void *  value
 

Inserts an item into a hash table.

Parameters:
hash_table The hash table.
key The key.
value The value to insert.

void* galago_hash_table_lookup const GalagoHashTable *  hash_table,
const void *  key
 

Looks up and returns data from a hash table.

Parameters:
hash_table The hash table.
key The key.
Returns:
The value associated with that key, if any.

GalagoHashTable* galago_hash_table_new GalagoHashFunc  hash_func,
GalagoEqualFunc  key_equal_func
 

Creates a new hash table.

Parameters:
hash_func The hashing function.
key_equal_func Determines if the keys are equal.
Returns:
The hash table.

GalagoHashTable* galago_hash_table_new_full GalagoHashFunc  hash_func,
GalagoEqualFunc  key_equal_func,
GalagoFreeFunc  destroy_key_func,
GalagoFreeFunc  destroy_value_func
 

Creates a new hash table.

Parameters:
hash_func The hashing function.
key_equal_func Determines if the keys are equal.
destroy_key_func Destroys a key.
destroy_value_func Destroys a value.
Returns:
The hash table.

void galago_hash_table_remove GalagoHashTable *  hash_table,
const void *  key
 

Removes an item from a hash table.

Parameters:
hash_table The hash table.
key The key.

void galago_hash_table_replace GalagoHashTable *  hash_table,
void *  key,
void *  value
 

Replaces an item in a hash table.

Parameters:
hash_table The hash table.
key The key.
value The value to insert.

galago_bool galago_int_equal const void *  a,
const void *  b
 

Checks if two integers are equal.

Parameters:
a The first integer.
b The second integer.
Returns:
TRUE if the integers are equal, or FALSE.

unsigned int galago_int_hash const void *  i  ) 
 

Returns the hash of an integer.

Parameters:
i The integer.
Returns:
The hash of the integer.

galago_bool galago_str_equal const void *  a,
const void *  b
 

Checks if two strings are equal.

Parameters:
a The first string.
b The second string.
Returns:
TRUE if the strings are equal, or FALSE.

unsigned int galago_str_hash const void *  str  ) 
 

Returns the hash of a string.

Parameters:
str The string.
Returns:
The hash of the string.