alternative to assert
[gtkD.git] / gtkD / src / glib / QueueG.d
blob6efe81b463f5c416fcebaac9e161d33fa92a67b1
1 /*
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
26 * outPack = glib
27 * outFile = QueueG
28 * strct = GQueue
29 * realStrct=
30 * ctorStrct=
31 * clss = QueueG
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_queue_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ListG
45 * - glib.ListG
46 * structWrap:
47 * - GList* -> ListG
48 * - GQueue* -> QueueG
49 * module aliases:
50 * local aliases:
53 module glib.QueueG;
55 version(noAssert)
57 version(Tango)
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;
74 /**
75 * Description
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
80 * of the
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().
89 public class QueueG
92 /** the main Gtk struct */
93 protected GQueue* gQueue;
96 public GQueue* getQueueGStruct()
98 return gQueue;
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)
113 version(noAssert)
115 if ( gQueue is null )
117 int zero = 0;
118 version(Tango)
120 Stdout("struct gQueue is null on constructor").newline;
122 else
124 printf("struct gQueue is null on constructor");
126 zero = zero / zero;
129 else
131 assert(gQueue !is null, "struct gQueue is null on constructor");
133 this.gQueue = gQueue;
141 * Creates a new GQueue.
142 * Returns:
143 * a new GQueue.
145 public this ()
147 // GQueue* g_queue_new (void);
148 this(cast(GQueue*)g_queue_new() );
152 * Frees the memory allocated for the GQueue.
153 * queue:
154 * a GQueue.
156 public void free()
158 // void g_queue_free (GQueue *queue);
159 g_queue_free(gQueue);
163 * Returns TRUE if the queue is empty.
164 * queue:
165 * a GQueue.
166 * Returns:
167 * TRUE if the queue is empty.
169 public int isEmpty()
171 // gboolean g_queue_is_empty (GQueue *queue);
172 return g_queue_is_empty(gQueue);
176 * Returns the number of items in queue.
177 * queue:
178 * a GQueue
179 * Returns:
180 * The number of items in queue.
181 * Since 2.4
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.
191 * queue:
192 * a GQueue
193 * Since 2.4
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.
205 * queue:
206 * a GQueue
207 * Returns:
208 * A copy of queue
209 * Since 2.4
211 public QueueG copy()
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
219 * function.
220 * queue:
221 * a GQueue
222 * func:
223 * the function to call for each element's data
224 * user_data:
225 * user data to pass to func
226 * Since 2.4
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.
236 * queue:
237 * a GQueue
238 * data:
239 * data to find
240 * Returns:
241 * The first link in queue which contains data.
242 * Since 2.4
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.
256 * queue:
257 * a GQueue
258 * data:
259 * user data passed to func
260 * func:
261 * a GCompareFunc to call for each element. It should return 0
262 * when the desired element is found
263 * Returns:
264 * The found link, or NULL if it wasn't found
265 * Since 2.4
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.
275 * queue:
276 * a GQueue
277 * 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.
282 * user_data:
283 * user data passed to compare_func
284 * Since 2.4
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.
294 * queue:
295 * a GQueue.
296 * data:
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.
307 * queue:
308 * a GQueue.
309 * data:
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
320 * queue:
321 * a GQueue
322 * data:
323 * the data for the new element
324 * n:
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.
328 * Since 2.4
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.
338 * queue:
339 * a GQueue.
340 * Returns:
341 * the data of the first element in the queue, or NULL if the queue
342 * is empty.
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.
352 * queue:
353 * a GQueue.
354 * Returns:
355 * the data of the last element in the queue, or NULL if the queue
356 * is empty.
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.
366 * queue:
367 * a GQueue
368 * n:
369 * the position of the element.
370 * Returns:
371 * the element's data, or NULL if n is off the end of queue.
372 * Since 2.4
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.
382 * queue:
383 * a GQueue.
384 * Returns:
385 * the data of the first element in the queue, or NULL if the queue
386 * is empty.
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.
396 * queue:
397 * a GQueue.
398 * Returns:
399 * the data of the last element in the queue, or NULL if the queue
400 * is empty.
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.
410 * queue:
411 * a GQueue
412 * n:
413 * the position of the element.
414 * Returns:
415 * The data for the n'th element of queue, or NULL if n is
416 * off the end of queue.
417 * Since 2.4
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.
427 * queue:
428 * a GQueue
429 * data:
430 * the data to find.
431 * Returns:
432 * The position of the first element in queue which contains data, or -1 if no element in queue contains data.
433 * Since 2.4
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.
443 * queue:
444 * a GQueue
445 * data:
446 * data to remove.
447 * Since 2.4
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.
457 * queue:
458 * a GQueue
459 * data:
460 * data to remove
461 * Since 2.4
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.
472 * queue:
473 * a GQueue
474 * sibling:
475 * a GList link that must be part of queue
476 * data:
477 * the data to insert
478 * Since 2.4
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
489 * queue:
490 * a GQueue
491 * sibling:
492 * a GList link that must be part of queue
493 * data:
494 * the data to insert
495 * Since 2.4
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.
505 * queue:
506 * a GQueue
507 * data:
508 * the data to insert
509 * func:
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.
515 * user_data:
516 * user data passed to func.
517 * Since 2.4
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.
527 * queue:
528 * a GQueue.
529 * link_:
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.
541 * queue:
542 * a GQueue.
543 * link_:
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.
555 * queue:
556 * a GQueue
557 * n:
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
560 * queue.
561 * link_:
562 * the link to add to queue
563 * Since 2.4
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.
573 * queue:
574 * a GQueue.
575 * Returns:
576 * the GList element at the head of the queue, or NULL if the queue
577 * is empty.
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.
587 * queue:
588 * a GQueue.
589 * Returns:
590 * the GList element at the tail of the queue, or NULL if the queue
591 * is empty.
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.
601 * queue:
602 * a GQueue
603 * n:
604 * the link's position
605 * Returns:
606 * The n'th link, or NULL if n is off the end of queue.
607 * Since 2.4
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
617 * queue:
618 * a GQueue
619 * Returns:
620 * the first link in queue, or NULL if queue is empty
621 * Since 2.4
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.
631 * queue:
632 * a GQueue
633 * Returns:
634 * the last link in queue, or NULL if queue is empty
635 * Since 2.4
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
645 * queue:
646 * a GQueue
647 * n:
648 * the position of the link
649 * Returns:
650 * The link at the n'th position, or NULL if n is off the
651 * end of the list
652 * Since 2.4
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.
662 * queue:
663 * a Gqueue
664 * link_:
665 * A GList link
666 * Returns:
667 * The position of link_, or -1 if the link is
668 * not part of queue
669 * Since 2.4
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
679 * not freed.
680 * link_ must be part of queue,
681 * queue:
682 * a GQueue
683 * link_:
684 * a GList link that must be part of queue
685 * Since 2.4
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.
696 * queue:
697 * a GQueue
698 * link_:
699 * a GList link that must be part of queue
700 * Since 2.4
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());