Main Page | Modules | Alphabetical List | Data Structures | Directories | 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 "common.h"

Go to the source code of this file.

Typedefs

typedef idtable idtable_t

Functions

idtable_tidtable_new (void)
 Allocate new id table.
void idtable_destroy (idtable_t *table)
 Free all memory occupied by this table.
guint idtable_ids (idtable_t *tbl)
guint32 idtable_new_id (idtable_t *tbl, gpointer value)
 Get a id for the given value.
void idtable_free_id (idtable_t *tbl, guint32 id)
 Mark this id as unused.
gboolean idtable_is_id_used (const idtable_t *tbl, guint32 id)
void idtable_set_value (idtable_t *tbl, guint32 id, gpointer value)
 Replace the value of a give id.
gpointer idtable_get_value (const idtable_t *tbl, guint32 id)
 Fetch the value associated with the given id.


Typedef Documentation

typedef struct idtable idtable_t
 


Function Documentation

void idtable_destroy idtable_t tbl  ) 
 

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
 

Mark this id as unused.

It will eventually be reissued.

gpointer idtable_get_value const idtable_t tbl,
guint32  id
 

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.

guint idtable_ids idtable_t tbl  ) 
 

gboolean idtable_is_id_used const idtable_t tbl,
guint32  id
 

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 void   ) 
 

Allocate new id table.

guint32 idtable_new_id idtable_t tbl,
gpointer  value
 

Get a id for the given value.

The id can be used to look up the value later.

void idtable_set_value idtable_t tbl,
guint32  id,
gpointer  value
 

Replace the value of a give id.

The id must already be in use.


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