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

slist.c File Reference


Detailed Description

Handling of slists on a slightly higher level than GSList.

The purpose of this slist functions is providing efficient appending, prepending of items to a slist structure, fast lookup of the slist length, fast access to the slist head and tail. Additionally, some basic checks prevent modification of the slist whilst traversing it.

Author:
Christian Biere
Date:
2006

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

Data Structures

struct  slist
struct  slist_iter

Defines

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

Enumerations

enum  slist_magic_t { LIST_MAGIC = 0x3d59b1fU }
enum  slist_iter_magic_t { LIST_ITER_MAGIC = 0x2f744ad1U }

Functions

void slist_check (const slist_t *slist)
void slist_iter_check (const slist_iter_t *iter)
slist_tslist_new (void)
 Create a new slist.
void slist_free (slist_t **slist_ptr)
 Dispose of the data structure.
void slist_append (slist_t *slist, gpointer key)
 Append `key' to the slist.
void slist_prepend (slist_t *slist, gpointer key)
 Prepend `key' to the slist.
void slist_insert_sorted (slist_t *slist, gpointer key, GCompareFunc func)
 Insert `key' into the slist.
void slist_remove_item (slist_t *slist, GSList *prev, GSList *item)
gboolean slist_remove (slist_t *slist, gpointer key)
 Remove `key' from the slist.
gpointer slist_shift (slist_t *slist)
 Remove first item from the slist, if any.
gpointer slist_tail (const slist_t *slist)
gpointer slist_head (const slist_t *slist)
gboolean slist_moveto_head (slist_t *slist, gpointer key)
 Move entry to the head of the slist.
gboolean slist_moveto_tail (slist_t *slist, gpointer key)
 Move entry to the tail of the slist.
guint slist_length (const slist_t *slist)
slist_iter_tslist_iter_new (slist_t *slist, gboolean before)
 Get an iterator on the slist.
slist_iter_tslist_iter_on_head (slist_t *slist)
 Get an iterator on the slist, positioned on the first item.
slist_iter_tslist_iter_before_head (slist_t *slist)
 Get an iterator on the slist, positioned before the first item.
gpointer slist_iter_next (slist_iter_t *iter)
 Moves the iterator to the next element and returns its value.
gboolean slist_iter_has_item (const slist_iter_t *iter)
 Checks whether there is an item at the current position.
gboolean slist_iter_has_next (const slist_iter_t *iter)
gpointer slist_iter_current (const slist_iter_t *iter)
void slist_iter_remove (slist_iter_t *iter)
 Removes the item at the current position and moves the iterator to the next item.
void slist_iter_free (slist_iter_t **iter_ptr)
 Release the iterator once we're done with it.
gboolean slist_contains (const slist_t *slist, gconstpointer key, GEqualFunc func, gpointer *orig_key)
 Check whether slist contains the `key' whereas equality is determined using `func'.
gboolean slist_contains_identical (const slist_t *slist, gconstpointer key)
 Check whether slist contains the `key'.
void slist_foreach (const slist_t *slist, GFunc func, gpointer user_data)
 Apply `func' to all the items in the structure.


Define Documentation

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

#define slist_regression slist   ) 
 


Enumeration Type Documentation

enum slist_iter_magic_t
 

Enumeration values:
LIST_ITER_MAGIC 

enum slist_magic_t
 

Enumeration values:
LIST_MAGIC 


Function Documentation

void slist_append slist_t slist,
gpointer  key
 

Append `key' to the slist.

void slist_check const slist_t slist  )  [inline, static]
 

gboolean slist_contains const slist_t slist,
gconstpointer  key,
GEqualFunc  func,
gpointer *  orig_key
 

Check whether slist contains the `key' whereas equality is determined using `func'.

gboolean slist_contains_identical const slist_t slist,
gconstpointer  key
 

Check whether slist contains the `key'.

void slist_foreach const slist_t slist,
GFunc  func,
gpointer  user_data
 

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

void slist_free slist_t **  slist_ptr  ) 
 

Dispose of the data structure.

gpointer slist_head const slist_t slist  ) 
 

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

void slist_insert_sorted slist_t slist,
gpointer  key,
GCompareFunc  func
 

Insert `key' into the slist.

slist_iter_t* slist_iter_before_head slist_t slist  ) 
 

Get an iterator on the slist, positioned before the first item.

void slist_iter_check const slist_iter_t iter  )  [inline, static]
 

gpointer slist_iter_current const slist_iter_t iter  ) 
 

void slist_iter_free slist_iter_t **  iter_ptr  ) 
 

Release the iterator once we're done with it.

gboolean slist_iter_has_item const slist_iter_t iter  ) 
 

Checks whether there is an item at the current position.

gboolean slist_iter_has_next const slist_iter_t iter  ) 
 

slist_iter_t* slist_iter_new slist_t slist,
gboolean  before
[static]
 

Get an iterator on the slist.

gpointer slist_iter_next slist_iter_t iter  ) 
 

Moves the iterator to the next element and returns its value.

If there is no next element, NULL is returned.

slist_iter_t* slist_iter_on_head slist_t slist  ) 
 

Get an iterator on the slist, positioned on the first item.

void slist_iter_remove slist_iter_t iter  ) 
 

Removes the item at the current position and moves the iterator to the next item.

guint slist_length const slist_t slist  ) 
 

Returns:
the length of the slist.

gboolean slist_moveto_head slist_t slist,
gpointer  key
 

Move entry to the head of the slist.

gboolean slist_moveto_tail slist_t slist,
gpointer  key
 

Move entry to the tail of the slist.

slist_t* slist_new void   ) 
 

Create a new slist.

void slist_prepend slist_t slist,
gpointer  key
 

Prepend `key' to the slist.

gboolean slist_remove slist_t slist,
gpointer  key
 

Remove `key' from the slist.

Returns:
TRUE if the given key was found and remove, FALSE otherwise.

void slist_remove_item slist_t slist,
GSList *  prev,
GSList *  item
[inline, static]
 

gpointer slist_shift slist_t slist  ) 
 

Remove first item from the slist, if any.

Returns:
the data pointer of the removed item, or NULL if there was no item.

gpointer slist_tail const slist_t slist  ) 
 

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


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