Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

hashlist.c File Reference


Detailed Description

Needs brief description here.

An hashlist is a dual structure where data are both stored in a two-way list, preserving ordering, and indexed in a hash table.

This structure can quickly determine whether it contains some piece of data, as well as quickly remove data. It can be iterated over, in the order of the items or in reverse order.

Author:
Christian Biere
Date:
2003

#include "common.h"
#include "hashlist.h"
#include "misc.h"
#include "glib-missing.h"
#include "walloc.h"
#include "override.h"

Data Structures

struct  hash_list
struct  hash_list_item
struct  hash_list_iter

Defines

#define equiv(p, q)   (!(p) == !(q))
#define hash_list_regression(hl)

Enumerations

enum  hash_list_magic_t { HASH_LIST_MAGIC = 0x338954fdU }
enum  hash_list_iter_magic_t { HASH_LIST_ITER_MAGIC = 0x438954efU }

Functions

void hash_list_iter_check (const hash_list_iter_t *const iter)
void hash_list_check (const hash_list_t *const hl)
hash_list_thash_list_new (GHashFunc hash_func, GEqualFunc eq_func)
 Create a new hash list.
void hash_list_free (hash_list_t **hl_ptr)
 Dispose of the data structure, but not of the items it holds.
void hash_list_insert_item (hash_list_t *hl, struct hash_list_item *item)
void hash_list_append (hash_list_t *hl, gconstpointer key)
 Append `key' to the list.
void hash_list_prepend (hash_list_t *hl, gconstpointer key)
 Prepend `key' to the list.
void hash_list_insert_sorted (hash_list_t *hl, gconstpointer key, GCompareFunc func)
 Insert `key' into the list.
gpointer hash_list_remove_item (hash_list_t *hl, struct hash_list_item *item)
gpointer hash_list_remove (hash_list_t *hl, gconstpointer key)
 Remove `data' from the list.
gpointer hash_list_shift (hash_list_t *hl)
gpointer hash_list_tail (const hash_list_t *hl)
gpointer hash_list_head (const hash_list_t *hl)
void hash_list_moveto_head (hash_list_t *hl, gconstpointer key)
 Move entry to the head of the list.
void hash_list_moveto_tail (hash_list_t *hl, gconstpointer key)
 Move entry to the tail of the list.
guint hash_list_length (const hash_list_t *hl)
hash_list_iter_thash_list_iterator (hash_list_t *hl)
 Get an iterator on the list, positionned before first item.
hash_list_iter_thash_list_iterator_tail (hash_list_t *hl)
 Get an iterator on the list, positionned after last item.
gpointer hash_list_iter_next (hash_list_iter_t *iter)
 Get the next data item from the iterator, or NULL if none.
gboolean hash_list_iter_has_next (const hash_list_iter_t *iter)
 Checks whether there is a next item to be iterated over.
gpointer hash_list_iter_previous (hash_list_iter_t *iter)
 Get the previous data item from the iterator, or NULL if none.
gboolean hash_list_has_iter_previous (const hash_list_iter_t *iter)
 Checks whether there is a previous item in the iterator.
void hash_list_iter_release (hash_list_iter_t **iter_ptr)
 Release the iterator once we're done with it.
gboolean hash_list_contains (hash_list_t *hl, gconstpointer key, gconstpointer *orig_key_ptr)
 Check whether hashlist contains the `data'.
gpointer hash_list_next (hash_list_t *hl, gconstpointer key)
 Get the next item after a given key.
void hash_list_foreach (const hash_list_t *hl, GFunc func, gpointer user_data)
 Apply `func' to all the items in the structure.


Define Documentation

#define equiv p,
 )     (!(p) == !(q))
 

#define hash_list_regression hl   ) 
 


Enumeration Type Documentation

enum hash_list_iter_magic_t
 

Enumeration values:
HASH_LIST_ITER_MAGIC 

enum hash_list_magic_t
 

Enumeration values:
HASH_LIST_MAGIC 


Function Documentation

void hash_list_append hash_list_t hl,
gconstpointer  key
 

Append `key' to the list.

void hash_list_check const hash_list_t *const   hl  )  [static]
 

gboolean hash_list_contains hash_list_t hl,
gconstpointer  key,
gconstpointer *  orig_key_ptr
 

Check whether hashlist contains the `data'.

void hash_list_foreach const hash_list_t hl,
GFunc  func,
gpointer  user_data
 

Apply `func' to all the items in the structure.

void hash_list_free hash_list_t **  hl_ptr  ) 
 

Dispose of the data structure, but not of the items it holds.

Parameters:
hl_ptr pointer to the variable containing the address of the list
As a side effect, the variable containing the address of the list is nullified, since it is no longer allowed to refer to the structure.

gboolean hash_list_has_iter_previous const hash_list_iter_t iter  ) 
 

Checks whether there is a previous item in the iterator.

gpointer hash_list_head const hash_list_t hl  ) 
 

Returns:
the first item of the list, or NULL if none.

void hash_list_insert_item hash_list_t hl,
struct hash_list_item item
[static]
 

void hash_list_insert_sorted hash_list_t hl,
gconstpointer  key,
GCompareFunc  func
 

Insert `key' into the list.

void hash_list_iter_check const hash_list_iter_t *const   iter  )  [static]
 

gboolean hash_list_iter_has_next const hash_list_iter_t iter  ) 
 

Checks whether there is a next item to be iterated over.

gpointer hash_list_iter_next hash_list_iter_t iter  ) 
 

Get the next data item from the iterator, or NULL if none.

gpointer hash_list_iter_previous hash_list_iter_t iter  ) 
 

Get the previous data item from the iterator, or NULL if none.

void hash_list_iter_release hash_list_iter_t **  iter_ptr  ) 
 

Release the iterator once we're done with it.

hash_list_iter_t* hash_list_iterator hash_list_t hl  ) 
 

Get an iterator on the list, positionned before first item.

Get items with hash_list_next().

hash_list_iter_t* hash_list_iterator_tail hash_list_t hl  ) 
 

Get an iterator on the list, positionned after last item.

Get items with hash_list_previous().

guint hash_list_length const hash_list_t hl  ) 
 

Returns:
the length of the list.

void hash_list_moveto_head hash_list_t hl,
gconstpointer  key
 

Move entry to the head of the list.

void hash_list_moveto_tail hash_list_t hl,
gconstpointer  key
 

Move entry to the tail of the list.

hash_list_t* hash_list_new GHashFunc  hash_func,
GEqualFunc  eq_func
 

Create a new hash list.

gpointer hash_list_next hash_list_t hl,
gconstpointer  key
 

Get the next item after a given key.

void hash_list_prepend hash_list_t hl,
gconstpointer  key
 

Prepend `key' to the list.

gpointer hash_list_remove hash_list_t hl,
gconstpointer  key
 

Remove `data' from the list.

Returns:
The data that associated with the given key.

gpointer hash_list_remove_item hash_list_t hl,
struct hash_list_item item
[static]
 

gpointer hash_list_shift hash_list_t hl  ) 
 

gpointer hash_list_tail const hash_list_t hl  ) 
 

Returns:
The data associated with the last item, or NULL if none.


Generated on Sat Jun 30 17:53:27 2007 for gtk-gnutella by  doxygen 1.3.9.1