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