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

idtable.h File Reference


Detailed Description

Needs brief description here.

The idtable provides a automatically growing table which can resolve ids to values very fast. The ids are issues by the table and internally refer to an array row in the table. The table starts with an initial size and if full is extended by a definable number of rows. Initial size and extend size are internally rounded up to a multiple of 32. There is no limitation to the value and is can be queried whether a given id is in use.

You can also request special id/value combinations, but you need to keep in mind that the ids are row numbers. The table is then automatically grown to contain the requested id, but you can't shrink it later, because that would mean that the row numbers change and the ids already issued would become invalid.

If the application needs to shrink a table, I suggest creating a new table and request the needed number of ids from that. Of course all ids currently in use by the application must be updated. Once that is done, flush and destroy the old table.

Author:
Richard Eckart
Date:
2001-2003

#include <glib.h>

Go to the source code of this file.

Data Structures

struct  idtable

Defines

#define idtable_ids(tbl)   (tbl->ids)
#define idtable_size(tbl)   (tbl->size)

Typedefs

typedef idtable idtable_t

Functions

idtable_tidtable_new (guint32 isize, guint32 esize)
 idtable_new

void idtable_destroy (idtable_t *table)
 idtable_destroy:

guint32 idtable_new_id (idtable_t *tbl, gpointer value)
 idtable_new_id:

void idtable_new_id_value (idtable_t *tbl, guint32 id, gpointer value)
 idtable_new_id_value

void idtable_free_id (idtable_t *tbl, guint32 id)
 idtable_free_id:

G_INLINE_FUNC gboolean idtable_is_id_used (idtable_t *tbl, guint32 id)
 idtable_is_id_used:

void idtable_set_value (idtable_t *tbl, guint32 id, gpointer value)
 idtable_set_value:

gpointer idtable_get_value (idtable_t *tbl, guint32 id)
 idtable_get_value:


Define Documentation

#define idtable_ids tbl   )     (tbl->ids)
 

#define idtable_size tbl   )     (tbl->size)
 


Typedef Documentation

typedef struct idtable idtable_t
 


Function Documentation

void idtable_destroy idtable_t tbl  ) 
 

idtable_destroy:

Free all memory occupied by this table. The table must not be used again after idtable_destroy call called on it.

void idtable_free_id idtable_t tbl,
guint32  id
 

idtable_free_id:

Mark this id as unused. If will eventually be reissued.

gpointer idtable_get_value idtable_t tbl,
guint32  id
 

idtable_get_value:

Fetch the value associated with the given id. The id must have been requested with idtable_request_id before and must not be accessed after it has been dropped by idtable_drop_id.

G_INLINE_FUNC gboolean idtable_is_id_used idtable_t tbl,
guint32  id
 

idtable_is_id_used:

Returns:
TRUE if a id is already in use, returns FALSE if the id is not in use. If the id is outside the current table range it also returns FALSE. The table is not modified by this call.

idtable_t* idtable_new guint32  isize,
guint32  esize
 

idtable_new

Allocate new id table. Sizes will be rounded up to multiples of 32. The size of the table will be automatically expanded if necessary. Initial size and extend size must be larger then 0 and are internally rounded up to the closest multiple of 32.

guint32 idtable_new_id idtable_t tbl,
gpointer  value
 

idtable_new_id:

Get a id for the given value. The id can be used to look up the value later.

void idtable_new_id_value idtable_t tbl,
guint32  id,
gpointer  value
 

idtable_new_id_value

Request a special id for a given value. If the id must not be already in use.Best check whether the id is already in use with the idtable_is_id_used call. If the id is outside the current id range, the table is extend until the id is in range.

void idtable_set_value idtable_t tbl,
guint32  id,
gpointer  value
 

idtable_set_value:

Replace the value of a give id. The id must already be in use.


Generated on Sun Feb 12 10:50:03 2006 for Gtk-Gnutella by doxygen 1.3.6