2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Double-ended-Queues.html
59 import tango
.io
.Stdout
; // use the tango loging?
63 private import gtkc
.glibtypes
;
65 private import gtkc
.glib
;
68 private import glib
.ListG
;
69 private import glib
.ListG
;
76 * The GQueue structure and its associated functions provide a standard
77 * queue data structure. Internally, GQueue uses the same data structure as
78 * GList to store elements.
79 * The data contained in each element can be either integer values, by using one
81 * Type Conversion Macros,
82 * or simply pointers to any type of data.
83 * To create a new GQueue, use g_queue_new().
84 * To add elements, use g_queue_push_head(), g_queue_push_head_link(),
85 * g_queue_push_tail() and g_queue_push_tail_link().
86 * To remove elements, use g_queue_pop_head() and g_queue_pop_tail().
87 * To free the entire queue, use g_queue_free().
92 /** the main Gtk struct */
93 protected GQueue
* gQueue
;
96 public GQueue
* getQueueGStruct()
102 /** the main Gtk struct as a void* */
103 protected void* getStruct()
105 return cast(void*)gQueue
;
109 * Sets our main struct and passes it to the parent class
111 public this (GQueue
* gQueue
)
115 if ( gQueue
is null )
120 Stdout("struct gQueue is null on constructor").newline
;
124 printf("struct gQueue is null on constructor");
131 assert(gQueue
!is null, "struct gQueue is null on constructor");
133 this.gQueue
= gQueue
;
141 * Creates a new GQueue.
147 // GQueue* g_queue_new (void);
148 this(cast(GQueue
*)g_queue_new() );
152 * Frees the memory allocated for the GQueue.
158 // void g_queue_free (GQueue *queue);
159 g_queue_free(gQueue
);
163 * Returns TRUE if the queue is empty.
167 * TRUE if the queue is empty.
171 // gboolean g_queue_is_empty (GQueue *queue);
172 return g_queue_is_empty(gQueue
);
176 * Returns the number of items in queue.
180 * The number of items in queue.
183 public uint getLength()
185 // guint g_queue_get_length (GQueue *queue);
186 return g_queue_get_length(gQueue
);
190 * Reverses the order of the items in queue.
195 public void reverse()
197 // void g_queue_reverse (GQueue *queue);
198 g_queue_reverse(gQueue
);
202 * Copies a queue. Note that is a shallow copy. If the elements in the
203 * queue consist of pointers to data, the pointers are copied, but the
204 * actual data is not.
213 // GQueue* g_queue_copy (GQueue *queue);
214 return new QueueG( g_queue_copy(gQueue
) );
218 * Calls func for each element in the queue passing user_data to the
223 * the function to call for each element's data
225 * user data to pass to func
228 public void foreac(GFunc func
, void* userData
)
230 // void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data);
231 g_queue_foreach(gQueue
, func
, userData
);
235 * Finds the first link in queue which contains data.
241 * The first link in queue which contains data.
244 public ListG
find(void* data
)
246 // GList* g_queue_find (GQueue *queue, gconstpointer data);
247 return new ListG( g_queue_find(gQueue
, data
) );
251 * Finds an element in a GQueue, using a supplied function to find the
252 * desired element. It iterates over the queue, calling the given function
253 * which should return 0 when the desired element is found. The function
254 * takes two gconstpointer arguments, the GQueue element's data as the
255 * first argument and the given user data as the second argument.
259 * user data passed to func
261 * a GCompareFunc to call for each element. It should return 0
262 * when the desired element is found
264 * The found link, or NULL if it wasn't found
267 public ListG
findCustom(void* data
, GCompareFunc func
)
269 // GList* g_queue_find_custom (GQueue *queue, gconstpointer data, GCompareFunc func);
270 return new ListG( g_queue_find_custom(gQueue
, data
, func
) );
274 * Sorts queue using compare_func.
278 * the GCompareDataFunc used to sort queue. This function
279 * is passed two elements of the queue and should return 0 if they are
280 * equal, a negative value if the first comes before the second, and
281 * a positive value if the second comes before the first.
283 * user data passed to compare_func
286 public void sort(GCompareDataFunc compareFunc
, void* userData
)
288 // void g_queue_sort (GQueue *queue, GCompareDataFunc compare_func, gpointer user_data);
289 g_queue_sort(gQueue
, compareFunc
, userData
);
293 * Adds a new element at the head of the queue.
297 * the data for the new element.
299 public void pushHead(void* data
)
301 // void g_queue_push_head (GQueue *queue, gpointer data);
302 g_queue_push_head(gQueue
, data
);
306 * Adds a new element at the tail of the queue.
310 * the data for the new element.
312 public void pushTail(void* data
)
314 // void g_queue_push_tail (GQueue *queue, gpointer data);
315 g_queue_push_tail(gQueue
, data
);
319 * Inserts a new element into queue at the given position
323 * the data for the new element
325 * the position to insert the new element. If n is negative or
326 * larger than the number of elements in the queue, the element is
327 * added to the end of the queue.
330 public void pushNth(void* data
, int n
)
332 // void g_queue_push_nth (GQueue *queue, gpointer data, gint n);
333 g_queue_push_nth(gQueue
, data
, n
);
337 * Removes the first element of the queue.
341 * the data of the first element in the queue, or NULL if the queue
344 public void* popHead()
346 // gpointer g_queue_pop_head (GQueue *queue);
347 return g_queue_pop_head(gQueue
);
351 * Removes the last element of the queue.
355 * the data of the last element in the queue, or NULL if the queue
358 public void* popTail()
360 // gpointer g_queue_pop_tail (GQueue *queue);
361 return g_queue_pop_tail(gQueue
);
365 * Removes the n'th element of queue.
369 * the position of the element.
371 * the element's data, or NULL if n is off the end of queue.
374 public void* popNth(uint n
)
376 // gpointer g_queue_pop_nth (GQueue *queue, guint n);
377 return g_queue_pop_nth(gQueue
, n
);
381 * Returns the first element of the queue.
385 * the data of the first element in the queue, or NULL if the queue
388 public void* peekHead()
390 // gpointer g_queue_peek_head (GQueue *queue);
391 return g_queue_peek_head(gQueue
);
395 * Returns the last element of the queue.
399 * the data of the last element in the queue, or NULL if the queue
402 public void* peekTail()
404 // gpointer g_queue_peek_tail (GQueue *queue);
405 return g_queue_peek_tail(gQueue
);
409 * Returns the n'th element of queue.
413 * the position of the element.
415 * The data for the n'th element of queue, or NULL if n is
416 * off the end of queue.
419 public void* peekNth(uint n
)
421 // gpointer g_queue_peek_nth (GQueue *queue, guint n);
422 return g_queue_peek_nth(gQueue
, n
);
426 * Returns the position of the first element in queue which contains data.
432 * The position of the first element in queue which contains data, or -1 if no element in queue contains data.
435 public int index(void* data
)
437 // gint g_queue_index (GQueue *queue, gconstpointer data);
438 return g_queue_index(gQueue
, data
);
442 * Removes the first element in queue that contains data.
449 public void remove(void* data
)
451 // void g_queue_remove (GQueue *queue, gconstpointer data);
452 g_queue_remove(gQueue
, data
);
456 * Remove all elemeents in queue which contains data.
463 public void removeAll(void* data
)
465 // void g_queue_remove_all (GQueue *queue, gconstpointer data);
466 g_queue_remove_all(gQueue
, data
);
470 * Inserts data into queue before sibling.
471 * sibling must be part of queue.
475 * a GList link that must be part of queue
480 public void insertBefore(ListG sibling
, void* data
)
482 // void g_queue_insert_before (GQueue *queue, GList *sibling, gpointer data);
483 g_queue_insert_before(gQueue
, (sibling
is null) ?
null : sibling
.getListGStruct(), data
);
487 * Inserts data into queue after sibling
488 * sibling must be part of queue
492 * a GList link that must be part of queue
497 public void insertAfter(ListG sibling
, void* data
)
499 // void g_queue_insert_after (GQueue *queue, GList *sibling, gpointer data);
500 g_queue_insert_after(gQueue
, (sibling
is null) ?
null : sibling
.getListGStruct(), data
);
504 * Inserts data into queue using func to determine the new position.
510 * the GCompareDataFunc used to compare elements in the queue. It is
511 * called with two elements of the queue and user_data. It should
512 * return 0 if the elements are equal, a negative value if the first
513 * element comes before the second, and a positive value if the second
514 * element comes before the first.
516 * user data passed to func.
519 public void insertSorted(void* data
, GCompareDataFunc func
, void* userData
)
521 // void g_queue_insert_sorted (GQueue *queue, gpointer data, GCompareDataFunc func, gpointer user_data);
522 g_queue_insert_sorted(gQueue
, data
, func
, userData
);
526 * Adds a new element at the head of the queue.
530 * a single GList element, not a list with
531 * more than one element.
533 public void pushHeadLink(ListG link
)
535 // void g_queue_push_head_link (GQueue *queue, GList *link_);
536 g_queue_push_head_link(gQueue
, (link
is null) ?
null : link
.getListGStruct());
540 * Adds a new element at the tail of the queue.
544 * a single GList element, not a list with
545 * more than one element.
547 public void pushTailLink(ListG link
)
549 // void g_queue_push_tail_link (GQueue *queue, GList *link_);
550 g_queue_push_tail_link(gQueue
, (link
is null) ?
null : link
.getListGStruct());
554 * Inserts link into queue at the given position.
558 * the position to insert the link. If this is negative or larger than
559 * the number of elements in queue, the link is added to the end of
562 * the link to add to queue
565 public void pushNthLink(int n
, ListG link
)
567 // void g_queue_push_nth_link (GQueue *queue, gint n, GList *link_);
568 g_queue_push_nth_link(gQueue
, n
, (link
is null) ?
null : link
.getListGStruct());
572 * Removes the first element of the queue.
576 * the GList element at the head of the queue, or NULL if the queue
579 public ListG
popHeadLink()
581 // GList* g_queue_pop_head_link (GQueue *queue);
582 return new ListG( g_queue_pop_head_link(gQueue
) );
586 * Removes the last element of the queue.
590 * the GList element at the tail of the queue, or NULL if the queue
593 public ListG
popTailLink()
595 // GList* g_queue_pop_tail_link (GQueue *queue);
596 return new ListG( g_queue_pop_tail_link(gQueue
) );
600 * Removes and returns the link at the given position.
604 * the link's position
606 * The n'th link, or NULL if n is off the end of queue.
609 public ListG
popNthLink(uint n
)
611 // GList* g_queue_pop_nth_link (GQueue *queue, guint n);
612 return new ListG( g_queue_pop_nth_link(gQueue
, n
) );
616 * Returns the first link in queue
620 * the first link in queue, or NULL if queue is empty
623 public ListG
peekHeadLink()
625 // GList* g_queue_peek_head_link (GQueue *queue);
626 return new ListG( g_queue_peek_head_link(gQueue
) );
630 * Returns the last link queue.
634 * the last link in queue, or NULL if queue is empty
637 public ListG
peekTailLink()
639 // GList* g_queue_peek_tail_link (GQueue *queue);
640 return new ListG( g_queue_peek_tail_link(gQueue
) );
644 * Returns the link at the given position
648 * the position of the link
650 * The link at the n'th position, or NULL if n is off the
654 public ListG
peekNthLink(uint n
)
656 // GList* g_queue_peek_nth_link (GQueue *queue, guint n);
657 return new ListG( g_queue_peek_nth_link(gQueue
, n
) );
661 * Returns the position of link_ in queue.
667 * The position of link_, or -1 if the link is
671 public int linkIndex(ListG link
)
673 // gint g_queue_link_index (GQueue *queue, GList *link_);
674 return g_queue_link_index(gQueue
, (link
is null) ?
null : link
.getListGStruct());
678 * Unlinks link_ so that it will no longer be part of queue. The link is
680 * link_ must be part of queue,
684 * a GList link that must be part of queue
687 public void unlink(ListG link
)
689 // void g_queue_unlink (GQueue *queue, GList *link_);
690 g_queue_unlink(gQueue
, (link
is null) ?
null : link
.getListGStruct());
694 * Removes link_ from queue and frees it.
695 * link_ must be part of queue.
699 * a GList link that must be part of queue
702 public void deleteLink(ListG link
)
704 // void g_queue_delete_link (GQueue *queue, GList *link_);
705 g_queue_delete_link(gQueue
, (link
is null) ?
null : link
.getListGStruct());