1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module glib.ListG;
26 
27 private import glib.Str;
28 private import glib.c.functions;
29 public  import glib.c.types;
30 private import gobject.ObjectG;
31 
32 
33 /**
34  * The #GList struct is used for each element in a doubly-linked list.
35  */
36 public class ListG
37 {
38 	/** the main Gtk struct */
39 	protected GList* gList;
40 	protected bool ownedRef;
41 
42 	/** Get the main Gtk struct */
43 	public GList* getListGStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return gList;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected void* getStruct()
52 	{
53 		return cast(void*)gList;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (GList* gList, bool ownedRef = false)
60 	{
61 		this.gList = gList;
62 		this.ownedRef = ownedRef;
63 	}
64 
65 	/** */
66 	@property void* data()
67 	{
68 		return gList.data;
69 	}
70 
71 	/**
72 	 * get the next element
73 	 * Returns: the next element, or NULL if there are no more elements.
74 	 */
75 	@property ListG next()
76 	{
77 		if ( gList.next is null )
78 		{
79 			return null;
80 		}
81 
82 		return new ListG(gList.next);
83 	}
84 
85 	/**
86 	 * get the previous element
87 	 * Returns: the previous element, or NULL if there are no more elements.
88 	 */
89 	@property ListG previous()
90 	{
91 		if ( gList.prev is null )
92 		{
93 			return null;
94 		}
95 
96 		return new ListG(gList.prev);
97 	}
98 
99 	/**
100 	 * Turn the list into a D array of the desiered type.
101 	 * Type T wraps should match the type of the data.
102 	 */
103 	public T[] toArray(T, TC = getCType!T)()
104 	if ( is(T == class) )
105 	{
106 		T[] arr = new T[length()];
107 		ListG list = this;
108 		size_t count;
109 
110 		while(list !is null && count < arr.length)
111 		{
112 			arr[count] = ObjectG.getDObject!(T)(cast(TC)list.data);
113 			list = list.next();
114 			count++;
115 		}
116 
117 		return arr;
118 	}
119 
120 	/** Ditto */
121 	public T[] toArray(T)()
122 	if ( is ( T == string ) )
123 	{
124 		T[] arr = new T[length()];
125 		ListG list = this;
126 		size_t count;
127 
128 		while(list !is null && count < arr.length)
129 		{
130 			arr[count] = Str.toString(cast(char*)list.data);
131 			list = list.next();
132 			count++;
133 		}
134 
135 		return arr;
136 	}
137 
138 	private template getCType(T)
139 	{
140 		static if ( is(T == class) )
141 			alias getCType = typeof(T.tupleof[0]);
142 		else
143 			alias getCType = void*;
144 	}
145 
146 	unittest
147 	{
148 		import gobject.Value;
149 
150 		auto list = new ListG(null);
151 		list = list.append(new Value(0).getValueStruct());
152 		list = list.append(new Value(1).getValueStruct());
153 		auto arr = list.toArray!Value();
154 
155 		assert(arr[0].getInt() == 0);
156 		assert(arr[1].getInt() == 1);
157 
158 		list = new ListG(null);
159 		list = list.append(cast(void*)"test\0".ptr);
160 		list = list.append(cast(void*)"test2\0".ptr);
161 
162 		assert(["test", "test2"] == list.toArray!string());
163 	}
164 
165 	/**
166 	 */
167 
168 	/**
169 	 * Allocates space for one #GList element. It is called by
170 	 * g_list_append(), g_list_prepend(), g_list_insert() and
171 	 * g_list_insert_sorted() and so is rarely used on its own.
172 	 *
173 	 * Returns: a pointer to the newly-allocated #GList element
174 	 */
175 	public static ListG alloc()
176 	{
177 		auto __p = g_list_alloc();
178 
179 		if(__p is null)
180 		{
181 			return null;
182 		}
183 
184 		return new ListG(cast(GList*) __p);
185 	}
186 
187 	/**
188 	 * Adds a new element on to the end of the list.
189 	 *
190 	 * Note that the return value is the new start of the list,
191 	 * if @list was empty; make sure you store the new value.
192 	 *
193 	 * g_list_append() has to traverse the entire list to find the end,
194 	 * which is inefficient when adding multiple elements. A common idiom
195 	 * to avoid the inefficiency is to use g_list_prepend() and reverse
196 	 * the list with g_list_reverse() when all elements have been added.
197 	 *
198 	 * |[<!-- language="C" -->
199 	 * // Notice that these are initialized to the empty list.
200 	 * GList *string_list = NULL, *number_list = NULL;
201 	 *
202 	 * // This is a list of strings.
203 	 * string_list = g_list_append (string_list, "first");
204 	 * string_list = g_list_append (string_list, "second");
205 	 *
206 	 * // This is a list of integers.
207 	 * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
208 	 * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
209 	 * ]|
210 	 *
211 	 * Params:
212 	 *     data = the data for the new element
213 	 *
214 	 * Returns: either @list or the new start of the #GList if @list was %NULL
215 	 */
216 	public ListG append(void* data)
217 	{
218 		auto __p = g_list_append(gList, data);
219 
220 		if(__p is null)
221 		{
222 			return null;
223 		}
224 
225 		return new ListG(cast(GList*) __p);
226 	}
227 
228 	/**
229 	 * Adds the second #GList onto the end of the first #GList.
230 	 * Note that the elements of the second #GList are not copied.
231 	 * They are used directly.
232 	 *
233 	 * This function is for example used to move an element in the list.
234 	 * The following example moves an element to the top of the list:
235 	 * |[<!-- language="C" -->
236 	 * list = g_list_remove_link (list, llink);
237 	 * list = g_list_concat (llink, list);
238 	 * ]|
239 	 *
240 	 * Params:
241 	 *     list2 = the #GList to add to the end of the first #GList,
242 	 *         this must point  to the top of the list
243 	 *
244 	 * Returns: the start of the new #GList, which equals @list1 if not %NULL
245 	 */
246 	public ListG concat(ListG list2)
247 	{
248 		auto __p = g_list_concat(gList, (list2 is null) ? null : list2.getListGStruct());
249 
250 		if(__p is null)
251 		{
252 			return null;
253 		}
254 
255 		return new ListG(cast(GList*) __p);
256 	}
257 
258 	/**
259 	 * Copies a #GList.
260 	 *
261 	 * Note that this is a "shallow" copy. If the list elements
262 	 * consist of pointers to data, the pointers are copied but
263 	 * the actual data is not. See g_list_copy_deep() if you need
264 	 * to copy the data as well.
265 	 *
266 	 * Returns: the start of the new list that holds the same data as @list
267 	 */
268 	public ListG copy()
269 	{
270 		auto __p = g_list_copy(gList);
271 
272 		if(__p is null)
273 		{
274 			return null;
275 		}
276 
277 		return new ListG(cast(GList*) __p);
278 	}
279 
280 	/**
281 	 * Makes a full (deep) copy of a #GList.
282 	 *
283 	 * In contrast with g_list_copy(), this function uses @func to make
284 	 * a copy of each list element, in addition to copying the list
285 	 * container itself.
286 	 *
287 	 * @func, as a #GCopyFunc, takes two arguments, the data to be copied
288 	 * and a @user_data pointer. On common processor architectures, it's safe to
289 	 * pass %NULL as @user_data if the copy function takes only one argument. You
290 	 * may get compiler warnings from this though if compiling with GCC’s
291 	 * `-Wcast-function-type` warning.
292 	 *
293 	 * For instance, if @list holds a list of GObjects, you can do:
294 	 * |[<!-- language="C" -->
295 	 * another_list = g_list_copy_deep (list, (GCopyFunc) g_object_ref, NULL);
296 	 * ]|
297 	 *
298 	 * And, to entirely free the new list, you could do:
299 	 * |[<!-- language="C" -->
300 	 * g_list_free_full (another_list, g_object_unref);
301 	 * ]|
302 	 *
303 	 * Params:
304 	 *     func = a copy function used to copy every element in the list
305 	 *     userData = user data passed to the copy function @func, or %NULL
306 	 *
307 	 * Returns: the start of the new list that holds a full copy of @list,
308 	 *     use g_list_free_full() to free it
309 	 *
310 	 * Since: 2.34
311 	 */
312 	public ListG copyDeep(GCopyFunc func, void* userData)
313 	{
314 		auto __p = g_list_copy_deep(gList, func, userData);
315 
316 		if(__p is null)
317 		{
318 			return null;
319 		}
320 
321 		return new ListG(cast(GList*) __p);
322 	}
323 
324 	/**
325 	 * Removes the node link_ from the list and frees it.
326 	 * Compare this to g_list_remove_link() which removes the node
327 	 * without freeing it.
328 	 *
329 	 * Params:
330 	 *     link = node to delete from @list
331 	 *
332 	 * Returns: the (possibly changed) start of the #GList
333 	 */
334 	public ListG deleteLink(ListG link)
335 	{
336 		auto __p = g_list_delete_link(gList, (link is null) ? null : link.getListGStruct());
337 
338 		if(__p is null)
339 		{
340 			return null;
341 		}
342 
343 		return new ListG(cast(GList*) __p);
344 	}
345 
346 	/**
347 	 * Finds the element in a #GList which contains the given data.
348 	 *
349 	 * Params:
350 	 *     data = the element data to find
351 	 *
352 	 * Returns: the found #GList element, or %NULL if it is not found
353 	 */
354 	public ListG find(void* data)
355 	{
356 		auto __p = g_list_find(gList, data);
357 
358 		if(__p is null)
359 		{
360 			return null;
361 		}
362 
363 		return new ListG(cast(GList*) __p);
364 	}
365 
366 	/**
367 	 * Finds an element in a #GList, using a supplied function to
368 	 * find the desired element. It iterates over the list, calling
369 	 * the given function which should return 0 when the desired
370 	 * element is found. The function takes two #gconstpointer arguments,
371 	 * the #GList element's data as the first argument and the
372 	 * given user data.
373 	 *
374 	 * Params:
375 	 *     data = user data passed to the function
376 	 *     func = the function to call for each element.
377 	 *         It should return 0 when the desired element is found
378 	 *
379 	 * Returns: the found #GList element, or %NULL if it is not found
380 	 */
381 	public ListG findCustom(void* data, GCompareFunc func)
382 	{
383 		auto __p = g_list_find_custom(gList, data, func);
384 
385 		if(__p is null)
386 		{
387 			return null;
388 		}
389 
390 		return new ListG(cast(GList*) __p);
391 	}
392 
393 	/**
394 	 * Gets the first element in a #GList.
395 	 *
396 	 * Returns: the first element in the #GList,
397 	 *     or %NULL if the #GList has no elements
398 	 */
399 	public ListG first()
400 	{
401 		auto __p = g_list_first(gList);
402 
403 		if(__p is null)
404 		{
405 			return null;
406 		}
407 
408 		return new ListG(cast(GList*) __p);
409 	}
410 
411 	alias foreac = foreach_;
412 	/**
413 	 * Calls a function for each element of a #GList.
414 	 *
415 	 * It is safe for @func to remove the element from @list, but it must
416 	 * not modify any part of the list after that element.
417 	 *
418 	 * Params:
419 	 *     func = the function to call with each element's data
420 	 *     userData = user data to pass to the function
421 	 */
422 	public void foreach_(GFunc func, void* userData)
423 	{
424 		g_list_foreach(gList, func, userData);
425 	}
426 
427 	/**
428 	 * Frees all of the memory used by a #GList.
429 	 * The freed elements are returned to the slice allocator.
430 	 *
431 	 * If list elements contain dynamically-allocated memory, you should
432 	 * either use g_list_free_full() or free them manually first.
433 	 *
434 	 * It can be combined with g_steal_pointer() to ensure the list head pointer
435 	 * is not left dangling:
436 	 * |[<!-- language="C" -->
437 	 * GList *list_of_borrowed_things = …;  /<!-- -->* (transfer container) *<!-- -->/
438 	 * g_list_free (g_steal_pointer (&list_of_borrowed_things));
439 	 * ]|
440 	 */
441 	public void free()
442 	{
443 		g_list_free(gList);
444 	}
445 
446 	/**
447 	 * Frees one #GList element, but does not update links from the next and
448 	 * previous elements in the list, so you should not call this function on an
449 	 * element that is currently part of a list.
450 	 *
451 	 * It is usually used after g_list_remove_link().
452 	 */
453 	public void free1()
454 	{
455 		g_list_free_1(gList);
456 	}
457 
458 	/**
459 	 * Convenience method, which frees all the memory used by a #GList,
460 	 * and calls @free_func on every element's data.
461 	 *
462 	 * @free_func must not modify the list (eg, by removing the freed
463 	 * element from it).
464 	 *
465 	 * It can be combined with g_steal_pointer() to ensure the list head pointer
466 	 * is not left dangling ­— this also has the nice property that the head pointer
467 	 * is cleared before any of the list elements are freed, to prevent double frees
468 	 * from @free_func:
469 	 * |[<!-- language="C" -->
470 	 * GList *list_of_owned_things = …;  /<!-- -->* (transfer full) (element-type GObject) *<!-- -->/
471 	 * g_list_free_full (g_steal_pointer (&list_of_owned_things), g_object_unref);
472 	 * ]|
473 	 *
474 	 * Params:
475 	 *     freeFunc = the function to be called to free each element's data
476 	 *
477 	 * Since: 2.28
478 	 */
479 	public void freeFull(GDestroyNotify freeFunc)
480 	{
481 		g_list_free_full(gList, freeFunc);
482 	}
483 
484 	/**
485 	 * Gets the position of the element containing
486 	 * the given data (starting from 0).
487 	 *
488 	 * Params:
489 	 *     data = the data to find
490 	 *
491 	 * Returns: the index of the element containing the data,
492 	 *     or -1 if the data is not found
493 	 */
494 	public int index(void* data)
495 	{
496 		return g_list_index(gList, data);
497 	}
498 
499 	/**
500 	 * Inserts a new element into the list at the given position.
501 	 *
502 	 * Params:
503 	 *     data = the data for the new element
504 	 *     position = the position to insert the element. If this is
505 	 *         negative, or is larger than the number of elements in the
506 	 *         list, the new element is added on to the end of the list.
507 	 *
508 	 * Returns: the (possibly changed) start of the #GList
509 	 */
510 	public ListG insert(void* data, int position)
511 	{
512 		auto __p = g_list_insert(gList, data, position);
513 
514 		if(__p is null)
515 		{
516 			return null;
517 		}
518 
519 		return new ListG(cast(GList*) __p);
520 	}
521 
522 	/**
523 	 * Inserts a new element into the list before the given position.
524 	 *
525 	 * Params:
526 	 *     sibling = the list element before which the new element
527 	 *         is inserted or %NULL to insert at the end of the list
528 	 *     data = the data for the new element
529 	 *
530 	 * Returns: the (possibly changed) start of the #GList
531 	 */
532 	public ListG insertBefore(ListG sibling, void* data)
533 	{
534 		auto __p = g_list_insert_before(gList, (sibling is null) ? null : sibling.getListGStruct(), data);
535 
536 		if(__p is null)
537 		{
538 			return null;
539 		}
540 
541 		return new ListG(cast(GList*) __p);
542 	}
543 
544 	/**
545 	 * Inserts @link_ into the list before the given position.
546 	 *
547 	 * Params:
548 	 *     sibling = the list element before which the new element
549 	 *         is inserted or %NULL to insert at the end of the list
550 	 *     link = the list element to be added, which must not be part of
551 	 *         any other list
552 	 *
553 	 * Returns: the (possibly changed) start of the #GList
554 	 *
555 	 * Since: 2.62
556 	 */
557 	public ListG insertBeforeLink(ListG sibling, ListG link)
558 	{
559 		auto __p = g_list_insert_before_link(gList, (sibling is null) ? null : sibling.getListGStruct(), (link is null) ? null : link.getListGStruct());
560 
561 		if(__p is null)
562 		{
563 			return null;
564 		}
565 
566 		return new ListG(cast(GList*) __p);
567 	}
568 
569 	/**
570 	 * Inserts a new element into the list, using the given comparison
571 	 * function to determine its position.
572 	 *
573 	 * If you are adding many new elements to a list, and the number of
574 	 * new elements is much larger than the length of the list, use
575 	 * g_list_prepend() to add the new items and sort the list afterwards
576 	 * with g_list_sort().
577 	 *
578 	 * Params:
579 	 *     data = the data for the new element
580 	 *     func = the function to compare elements in the list. It should
581 	 *         return a number > 0 if the first parameter comes after the
582 	 *         second parameter in the sort order.
583 	 *
584 	 * Returns: the (possibly changed) start of the #GList
585 	 */
586 	public ListG insertSorted(void* data, GCompareFunc func)
587 	{
588 		auto __p = g_list_insert_sorted(gList, data, func);
589 
590 		if(__p is null)
591 		{
592 			return null;
593 		}
594 
595 		return new ListG(cast(GList*) __p);
596 	}
597 
598 	/**
599 	 * Inserts a new element into the list, using the given comparison
600 	 * function to determine its position.
601 	 *
602 	 * If you are adding many new elements to a list, and the number of
603 	 * new elements is much larger than the length of the list, use
604 	 * g_list_prepend() to add the new items and sort the list afterwards
605 	 * with g_list_sort().
606 	 *
607 	 * Params:
608 	 *     data = the data for the new element
609 	 *     func = the function to compare elements in the list. It should
610 	 *         return a number > 0 if the first parameter  comes after the
611 	 *         second parameter in the sort order.
612 	 *     userData = user data to pass to comparison function
613 	 *
614 	 * Returns: the (possibly changed) start of the #GList
615 	 *
616 	 * Since: 2.10
617 	 */
618 	public ListG insertSortedWithData(void* data, GCompareDataFunc func, void* userData)
619 	{
620 		auto __p = g_list_insert_sorted_with_data(gList, data, func, userData);
621 
622 		if(__p is null)
623 		{
624 			return null;
625 		}
626 
627 		return new ListG(cast(GList*) __p);
628 	}
629 
630 	/**
631 	 * Gets the last element in a #GList.
632 	 *
633 	 * Returns: the last element in the #GList,
634 	 *     or %NULL if the #GList has no elements
635 	 */
636 	public ListG last()
637 	{
638 		auto __p = g_list_last(gList);
639 
640 		if(__p is null)
641 		{
642 			return null;
643 		}
644 
645 		return new ListG(cast(GList*) __p);
646 	}
647 
648 	/**
649 	 * Gets the number of elements in a #GList.
650 	 *
651 	 * This function iterates over the whole list to count its elements.
652 	 * Use a #GQueue instead of a GList if you regularly need the number
653 	 * of items. To check whether the list is non-empty, it is faster to check
654 	 * @list against %NULL.
655 	 *
656 	 * Returns: the number of elements in the #GList
657 	 */
658 	public uint length()
659 	{
660 		return g_list_length(gList);
661 	}
662 
663 	/**
664 	 * Gets the element at the given position in a #GList.
665 	 *
666 	 * This iterates over the list until it reaches the @n-th position. If you
667 	 * intend to iterate over every element, it is better to use a for-loop as
668 	 * described in the #GList introduction.
669 	 *
670 	 * Params:
671 	 *     n = the position of the element, counting from 0
672 	 *
673 	 * Returns: the element, or %NULL if the position is off
674 	 *     the end of the #GList
675 	 */
676 	public ListG nth(uint n)
677 	{
678 		auto __p = g_list_nth(gList, n);
679 
680 		if(__p is null)
681 		{
682 			return null;
683 		}
684 
685 		return new ListG(cast(GList*) __p);
686 	}
687 
688 	/**
689 	 * Gets the data of the element at the given position.
690 	 *
691 	 * This iterates over the list until it reaches the @n-th position. If you
692 	 * intend to iterate over every element, it is better to use a for-loop as
693 	 * described in the #GList introduction.
694 	 *
695 	 * Params:
696 	 *     n = the position of the element
697 	 *
698 	 * Returns: the element's data, or %NULL if the position
699 	 *     is off the end of the #GList
700 	 */
701 	public void* nthData(uint n)
702 	{
703 		return g_list_nth_data(gList, n);
704 	}
705 
706 	/**
707 	 * Gets the element @n places before @list.
708 	 *
709 	 * Params:
710 	 *     n = the position of the element, counting from 0
711 	 *
712 	 * Returns: the element, or %NULL if the position is
713 	 *     off the end of the #GList
714 	 */
715 	public ListG nthPrev(uint n)
716 	{
717 		auto __p = g_list_nth_prev(gList, n);
718 
719 		if(__p is null)
720 		{
721 			return null;
722 		}
723 
724 		return new ListG(cast(GList*) __p);
725 	}
726 
727 	/**
728 	 * Gets the position of the given element
729 	 * in the #GList (starting from 0).
730 	 *
731 	 * Params:
732 	 *     llink = an element in the #GList
733 	 *
734 	 * Returns: the position of the element in the #GList,
735 	 *     or -1 if the element is not found
736 	 */
737 	public int position(ListG llink)
738 	{
739 		return g_list_position(gList, (llink is null) ? null : llink.getListGStruct());
740 	}
741 
742 	/**
743 	 * Prepends a new element on to the start of the list.
744 	 *
745 	 * Note that the return value is the new start of the list,
746 	 * which will have changed, so make sure you store the new value.
747 	 *
748 	 * |[<!-- language="C" -->
749 	 * // Notice that it is initialized to the empty list.
750 	 * GList *list = NULL;
751 	 *
752 	 * list = g_list_prepend (list, "last");
753 	 * list = g_list_prepend (list, "first");
754 	 * ]|
755 	 *
756 	 * Do not use this function to prepend a new element to a different
757 	 * element than the start of the list. Use g_list_insert_before() instead.
758 	 *
759 	 * Params:
760 	 *     data = the data for the new element
761 	 *
762 	 * Returns: a pointer to the newly prepended element, which is the new
763 	 *     start of the #GList
764 	 */
765 	public ListG prepend(void* data)
766 	{
767 		auto __p = g_list_prepend(gList, data);
768 
769 		if(__p is null)
770 		{
771 			return null;
772 		}
773 
774 		return new ListG(cast(GList*) __p);
775 	}
776 
777 	/**
778 	 * Removes an element from a #GList.
779 	 * If two elements contain the same data, only the first is removed.
780 	 * If none of the elements contain the data, the #GList is unchanged.
781 	 *
782 	 * Params:
783 	 *     data = the data of the element to remove
784 	 *
785 	 * Returns: the (possibly changed) start of the #GList
786 	 */
787 	public ListG remove(void* data)
788 	{
789 		auto __p = g_list_remove(gList, data);
790 
791 		if(__p is null)
792 		{
793 			return null;
794 		}
795 
796 		return new ListG(cast(GList*) __p);
797 	}
798 
799 	/**
800 	 * Removes all list nodes with data equal to @data.
801 	 * Returns the new head of the list. Contrast with
802 	 * g_list_remove() which removes only the first node
803 	 * matching the given data.
804 	 *
805 	 * Params:
806 	 *     data = data to remove
807 	 *
808 	 * Returns: the (possibly changed) start of the #GList
809 	 */
810 	public ListG removeAll(void* data)
811 	{
812 		auto __p = g_list_remove_all(gList, data);
813 
814 		if(__p is null)
815 		{
816 			return null;
817 		}
818 
819 		return new ListG(cast(GList*) __p);
820 	}
821 
822 	/**
823 	 * Removes an element from a #GList, without freeing the element.
824 	 * The removed element's prev and next links are set to %NULL, so
825 	 * that it becomes a self-contained list with one element.
826 	 *
827 	 * This function is for example used to move an element in the list
828 	 * (see the example for g_list_concat()) or to remove an element in
829 	 * the list before freeing its data:
830 	 * |[<!-- language="C" -->
831 	 * list = g_list_remove_link (list, llink);
832 	 * free_some_data_that_may_access_the_list_again (llink->data);
833 	 * g_list_free (llink);
834 	 * ]|
835 	 *
836 	 * Params:
837 	 *     llink = an element in the #GList
838 	 *
839 	 * Returns: the (possibly changed) start of the #GList
840 	 */
841 	public ListG removeLink(ListG llink)
842 	{
843 		auto __p = g_list_remove_link(gList, (llink is null) ? null : llink.getListGStruct());
844 
845 		if(__p is null)
846 		{
847 			return null;
848 		}
849 
850 		return new ListG(cast(GList*) __p);
851 	}
852 
853 	/**
854 	 * Reverses a #GList.
855 	 * It simply switches the next and prev pointers of each element.
856 	 *
857 	 * Returns: the start of the reversed #GList
858 	 */
859 	public ListG reverse()
860 	{
861 		auto __p = g_list_reverse(gList);
862 
863 		if(__p is null)
864 		{
865 			return null;
866 		}
867 
868 		return new ListG(cast(GList*) __p);
869 	}
870 
871 	/**
872 	 * Sorts a #GList using the given comparison function. The algorithm
873 	 * used is a stable sort.
874 	 *
875 	 * Params:
876 	 *     compareFunc = the comparison function used to sort the #GList.
877 	 *         This function is passed the data from 2 elements of the #GList
878 	 *         and should return 0 if they are equal, a negative value if the
879 	 *         first element comes before the second, or a positive value if
880 	 *         the first element comes after the second.
881 	 *
882 	 * Returns: the (possibly changed) start of the #GList
883 	 */
884 	public ListG sort(GCompareFunc compareFunc)
885 	{
886 		auto __p = g_list_sort(gList, compareFunc);
887 
888 		if(__p is null)
889 		{
890 			return null;
891 		}
892 
893 		return new ListG(cast(GList*) __p);
894 	}
895 
896 	/**
897 	 * Like g_list_sort(), but the comparison function accepts
898 	 * a user data argument.
899 	 *
900 	 * Params:
901 	 *     compareFunc = comparison function
902 	 *     userData = user data to pass to comparison function
903 	 *
904 	 * Returns: the (possibly changed) start of the #GList
905 	 */
906 	public ListG sortWithData(GCompareDataFunc compareFunc, void* userData)
907 	{
908 		auto __p = g_list_sort_with_data(gList, compareFunc, userData);
909 
910 		if(__p is null)
911 		{
912 			return null;
913 		}
914 
915 		return new ListG(cast(GList*) __p);
916 	}
917 
918 	/**
919 	 * Clears a pointer to a #GList, freeing it and, optionally, freeing its elements using @destroy.
920 	 *
921 	 * @list_ptr must be a valid pointer. If @list_ptr points to a null #GList, this does nothing.
922 	 *
923 	 * Params:
924 	 *     listPtr = a #GList return location
925 	 *     destroy = the function to pass to g_list_free_full() or %NULL to not free elements
926 	 *
927 	 * Since: 2.64
928 	 */
929 	public static void clearList(out ListG listPtr, GDestroyNotify destroy)
930 	{
931 		GList* outlistPtr = null;
932 
933 		g_clear_list(&outlistPtr, destroy);
934 
935 		listPtr = new ListG(outlistPtr);
936 	}
937 }