glib.QueueG.QueueG Class Reference

List of all members.

Detailed Description

Description The GQueue structure and its associated functions provide a standard queue data structure.

Internally, GQueue uses the same data structure as GList to store elements. The data contained in each element can be either integer values, by using one of the Type Conversion Macros, or simply pointers to any type of data. To create a new GQueue, use g_queue_new(). To add elements, use g_queue_push_head(), g_queue_push_head_link(), g_queue_push_tail() and g_queue_push_tail_link(). To remove elements, use g_queue_pop_head() and g_queue_pop_tail(). To free the entire queue, use g_queue_free().


Public Member Functions

GQueuegetQueueGStruct ()
 this (GQueue *gQueue)
 Sets our main struct and passes it to the parent class.
 this ()
 Creates a new GQueue.
void free ()
 Frees the memory allocated for the GQueue.
int isEmpty ()
 Returns TRUE if the queue is empty.
uint getLength ()
 Returns the number of items in queue.
void reverse ()
 Reverses the order of the items in queue.
QueueG copy ()
 Copies a queue.
void foreac (GFunc func, void *userData)
 Calls func for each element in the queue passing user_data to the function.
ListG find (void *data)
 Finds the first link in queue which contains data.
ListG findCustom (void *data, GCompareFunc func)
 Finds an element in a GQueue, using a supplied function to find the desired element.
void sort (GCompareDataFunc compareFunc, void *userData)
 Sorts queue using compare_func.
void pushHead (void *data)
 Adds a new element at the head of the queue.
void pushTail (void *data)
 Adds a new element at the tail of the queue.
void pushNth (void *data, int n)
 Inserts a new element into queue at the given position queue: a GQueue data: the data for the new element n: the position to insert the new element.
void * popHead ()
 Removes the first element of the queue.
void * popTail ()
 Removes the last element of the queue.
void * popNth (uint n)
 Removes the n'th element of queue.
void * peekHead ()
 Returns the first element of the queue.
void * peekTail ()
 Returns the last element of the queue.
void * peekNth (uint n)
 Returns the n'th element of queue.
int index (void *data)
 Returns the position of the first element in queue which contains data.
void remove (void *data)
 Removes the first element in queue that contains data.
void removeAll (void *data)
 Remove all elemeents in queue which contains data.
void insertBefore (ListG sibling, void *data)
 Inserts data into queue before sibling.
void insertAfter (ListG sibling, void *data)
 Inserts data into queue after sibling sibling must be part of queue queue: a GQueue sibling: a GList link that must be part of queue data: the data to insert Since 2.4.
void insertSorted (void *data, GCompareDataFunc func, void *userData)
 Inserts data into queue using func to determine the new position.
void pushHeadLink (ListG link)
 Adds a new element at the head of the queue.
void pushTailLink (ListG link)
 Adds a new element at the tail of the queue.
void pushNthLink (int n, ListG link)
 Inserts link into queue at the given position.
ListG popHeadLink ()
 Removes the first element of the queue.
ListG popTailLink ()
 Removes the last element of the queue.
ListG popNthLink (uint n)
 Removes and returns the link at the given position.
ListG peekHeadLink ()
 Returns the first link in queue queue: a GQueue Returns: the first link in queue, or NULL if queue is empty Since 2.4.
ListG peekTailLink ()
 Returns the last link queue.
ListG peekNthLink (uint n)
 Returns the link at the given position queue: a GQueue n: the position of the link Returns: The link at the n'th position, or NULL if n is off the end of the list Since 2.4.
int linkIndex (ListG link)
 Returns the position of link_ in queue.
void unlink (ListG link)
 Unlinks link_ so that it will no longer be part of queue.
void deleteLink (ListG link)
 Removes link_ from queue and frees it.

Protected Member Functions

void * getStruct ()
 the main Gtk struct as a void*

Protected Attributes

GQueuegQueue
 the main Gtk struct


Constructor & Destructor Documentation

glib.QueueG.QueueG.this ( GQueue gQueue  ) 

Sets our main struct and passes it to the parent class.

glib.QueueG.QueueG.this (  ) 

Creates a new GQueue.

Returns: a new GQueue.


Member Function Documentation

QueueG glib.QueueG.QueueG.copy (  ) 

Copies a queue.

Note that is a shallow copy. If the elements in the queue consist of pointers to data, the pointers are copied, but the actual data is not. queue: a GQueue Returns: A copy of queue Since 2.4

void glib.QueueG.QueueG.deleteLink ( ListG  link  ) 

Removes link_ from queue and frees it.

link_ must be part of queue. queue: a GQueue link_: a GList link that must be part of queue Since 2.4

ListG glib.QueueG.QueueG.find ( void *  data  ) 

Finds the first link in queue which contains data.

queue: a GQueue data: data to find Returns: The first link in queue which contains data. Since 2.4

ListG glib.QueueG.QueueG.findCustom ( void *  data,
GCompareFunc  func 
)

Finds an element in a GQueue, using a supplied function to find the desired element.

It iterates over the queue, calling the given function which should return 0 when the desired element is found. The function takes two gconstpointer arguments, the GQueue element's data as the first argument and the given user data as the second argument. queue: a GQueue data: user data passed to func func: a GCompareFunc to call for each element. It should return 0 when the desired element is found Returns: The found link, or NULL if it wasn't found Since 2.4

void glib.QueueG.QueueG.foreac ( GFunc  func,
void *  userData 
)

Calls func for each element in the queue passing user_data to the function.

queue: a GQueue func: the function to call for each element's data user_data: user data to pass to func Since 2.4

void glib.QueueG.QueueG.free (  ) 

Frees the memory allocated for the GQueue.

queue: a GQueue.

uint glib.QueueG.QueueG.getLength (  ) 

Returns the number of items in queue.

queue: a GQueue Returns: The number of items in queue. Since 2.4

GQueue* glib.QueueG.QueueG.getQueueGStruct (  ) 

void* glib.QueueG.QueueG.getStruct (  )  [protected]

the main Gtk struct as a void*

int glib.QueueG.QueueG.index ( void *  data  ) 

Returns the position of the first element in queue which contains data.

queue: a GQueue data: the data to find. Returns: The position of the first element in queue which contains data, or -1 if no element in queue contains data. Since 2.4

void glib.QueueG.QueueG.insertAfter ( ListG  sibling,
void *  data 
)

Inserts data into queue after sibling sibling must be part of queue queue: a GQueue sibling: a GList link that must be part of queue data: the data to insert Since 2.4.

void glib.QueueG.QueueG.insertBefore ( ListG  sibling,
void *  data 
)

Inserts data into queue before sibling.

sibling must be part of queue. queue: a GQueue sibling: a GList link that must be part of queue data: the data to insert Since 2.4

void glib.QueueG.QueueG.insertSorted ( void *  data,
GCompareDataFunc  func,
void *  userData 
)

Inserts data into queue using func to determine the new position.

queue: a GQueue data: the data to insert func: the GCompareDataFunc used to compare elements in the queue. It is called with two elements of the queue and user_data. It should return 0 if the elements are equal, a negative value if the first element comes before the second, and a positive value if the second element comes before the first. user_data: user data passed to func. Since 2.4

int glib.QueueG.QueueG.isEmpty (  ) 

Returns TRUE if the queue is empty.

queue: a GQueue. Returns: TRUE if the queue is empty.

int glib.QueueG.QueueG.linkIndex ( ListG  link  ) 

Returns the position of link_ in queue.

queue: a Gqueue link_: A GList link Returns: The position of link_, or -1 if the link is not part of queue Since 2.4

void* glib.QueueG.QueueG.peekHead (  ) 

Returns the first element of the queue.

queue: a GQueue. Returns: the data of the first element in the queue, or NULL if the queue is empty.

ListG glib.QueueG.QueueG.peekHeadLink (  ) 

Returns the first link in queue queue: a GQueue Returns: the first link in queue, or NULL if queue is empty Since 2.4.

void* glib.QueueG.QueueG.peekNth ( uint  n  ) 

Returns the n'th element of queue.

queue: a GQueue n: the position of the element. Returns: The data for the n'th element of queue, or NULL if n is off the end of queue. Since 2.4

ListG glib.QueueG.QueueG.peekNthLink ( uint  n  ) 

Returns the link at the given position queue: a GQueue n: the position of the link Returns: The link at the n'th position, or NULL if n is off the end of the list Since 2.4.

void* glib.QueueG.QueueG.peekTail (  ) 

Returns the last element of the queue.

queue: a GQueue. Returns: the data of the last element in the queue, or NULL if the queue is empty.

ListG glib.QueueG.QueueG.peekTailLink (  ) 

Returns the last link queue.

queue: a GQueue Returns: the last link in queue, or NULL if queue is empty Since 2.4

void* glib.QueueG.QueueG.popHead (  ) 

Removes the first element of the queue.

queue: a GQueue. Returns: the data of the first element in the queue, or NULL if the queue is empty.

ListG glib.QueueG.QueueG.popHeadLink (  ) 

Removes the first element of the queue.

queue: a GQueue. Returns: the GList element at the head of the queue, or NULL if the queue is empty.

void* glib.QueueG.QueueG.popNth ( uint  n  ) 

Removes the n'th element of queue.

queue: a GQueue n: the position of the element. Returns: the element's data, or NULL if n is off the end of queue. Since 2.4

ListG glib.QueueG.QueueG.popNthLink ( uint  n  ) 

Removes and returns the link at the given position.

queue: a GQueue n: the link's position Returns: The n'th link, or NULL if n is off the end of queue. Since 2.4

void* glib.QueueG.QueueG.popTail (  ) 

Removes the last element of the queue.

queue: a GQueue. Returns: the data of the last element in the queue, or NULL if the queue is empty.

ListG glib.QueueG.QueueG.popTailLink (  ) 

Removes the last element of the queue.

queue: a GQueue. Returns: the GList element at the tail of the queue, or NULL if the queue is empty.

void glib.QueueG.QueueG.pushHead ( void *  data  ) 

Adds a new element at the head of the queue.

queue: a GQueue. data: the data for the new element.

void glib.QueueG.QueueG.pushHeadLink ( ListG  link  ) 

Adds a new element at the head of the queue.

queue: a GQueue. link_: a single GList element, not a list with more than one element.

void glib.QueueG.QueueG.pushNth ( void *  data,
int  n 
)

Inserts a new element into queue at the given position queue: a GQueue data: the data for the new element n: the position to insert the new element.

If n is negative or larger than the number of elements in the queue, the element is added to the end of the queue. Since 2.4

void glib.QueueG.QueueG.pushNthLink ( int  n,
ListG  link 
)

Inserts link into queue at the given position.

queue: a GQueue n: the position to insert the link. If this is negative or larger than the number of elements in queue, the link is added to the end of queue. link_: the link to add to queue Since 2.4

void glib.QueueG.QueueG.pushTail ( void *  data  ) 

Adds a new element at the tail of the queue.

queue: a GQueue. data: the data for the new element.

void glib.QueueG.QueueG.pushTailLink ( ListG  link  ) 

Adds a new element at the tail of the queue.

queue: a GQueue. link_: a single GList element, not a list with more than one element.

void glib.QueueG.QueueG.remove ( void *  data  ) 

Removes the first element in queue that contains data.

queue: a GQueue data: data to remove. Since 2.4

void glib.QueueG.QueueG.removeAll ( void *  data  ) 

Remove all elemeents in queue which contains data.

queue: a GQueue data: data to remove Since 2.4

void glib.QueueG.QueueG.reverse (  ) 

Reverses the order of the items in queue.

queue: a GQueue Since 2.4

void glib.QueueG.QueueG.sort ( GCompareDataFunc  compareFunc,
void *  userData 
)

Sorts queue using compare_func.

queue: a GQueue compare_func: the GCompareDataFunc used to sort queue. This function is passed two elements of the queue and should return 0 if they are equal, a negative value if the first comes before the second, and a positive value if the second comes before the first. user_data: user data passed to compare_func Since 2.4

void glib.QueueG.QueueG.unlink ( ListG  link  ) 

Unlinks link_ so that it will no longer be part of queue.

The link is not freed. link_ must be part of queue, queue: a GQueue link_: a GList link that must be part of queue Since 2.4


Member Data Documentation

GQueue* glib.QueueG.QueueG.gQueue [protected]

the main Gtk struct


SourceForge.net Logo DSource.org Logo digitalmars.com Logo