2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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-Singly-Linked-Lists.html
52 private import glib
.glibtypes
;
54 private import lib
.glib
;
56 private import glib
.ListG
;
60 * The GSList structure and its associated functions provide a standard
61 * singly-linked list data structure.
62 * Each element in the list contains a piece of data, together with a pointer
63 * which links to the next element in the list.
64 * Using this pointer it is possible to move through the list in one
65 * direction only (unlike the
67 * which allow movement in both directions).
68 * The data contained in each element can be either integer values, by using one
70 * Type Conversion Macros,
71 * or simply pointers to any type of data.
72 * List elements are allocated from the slice
73 * allocator, which is more efficient than allocating elements
75 * Note that most of the GSList functions expect to be passed a pointer to
76 * the first element in the list. The functions which insert elements return
77 * the new start of the list, which may have changed.
78 * There is no function to create a GSList. NULL is considered to be the empty
79 * list so you simply set a GSList* to NULL.
80 * To add elements, use g_slist_append(), g_slist_prepend(), g_slist_insert()
81 * and g_slist_insert_sorted().
82 * To remove elements, use g_slist_remove().
83 * To find elements in the list use g_slist_last(), g_slist_next(),
84 * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
85 * g_slist_find_custom().
86 * To find the index of an element use g_slist_position() and g_slist_index().
87 * To call a function for each element in the list use g_slist_foreach().
88 * To free the entire list, use g_slist_free().
93 /** the main Gtk struct */
94 protected GSList
* gSList
;
97 public GSList
* getListSGStruct()
103 /** the main Gtk struct as a void* */
104 protected void* getStruct()
106 return cast(void*)gSList
;
110 * Sets our main struct and passes it to the parent class
112 public this (GSList
* gSList
)
114 this.gSList
= gSList
;
122 * Allocates space for one GSList element.
123 * It is called by the g_slist_append(), g_slist_prepend(), g_slist_insert() and
124 * g_slist_insert_sorted() functions and so is rarely used on its own.
126 * a pointer to the newly-allocated GSList element.
128 public static ListSG
alloc()
130 // GSList* g_slist_alloc (void);
131 return new ListSG( g_slist_alloc() );
135 * Adds a new element on to the end of the list.
137 * The return value is the new start of the list, which may have changed, so
138 * make sure you store the new value.
140 * Note that g_slist_append() has to traverse the entire list to find the end,
141 * which is inefficient when adding multiple elements. A common idiom to
142 * avoid the inefficiency is to prepend the elements and reverse the list
143 * when all elements have been added.
144 * /+* Notice that these are initialized to the empty list. +/
145 * GSList *list = NULL, *number_list = NULL;
146 * /+* This is a list of strings. +/
147 * list = g_slist_append (list, "first");
148 * list = g_slist_append (list, "second");
149 * /+* This is a list of integers. +/
150 * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
151 * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
155 * the data for the new element.
157 * the new start of the GSList.
159 public ListSG
append(void* data
)
161 // GSList* g_slist_append (GSList *list, gpointer data);
162 return new ListSG( g_slist_append(gSList
, data
) );
166 * Adds a new element on to the start of the list.
168 * The return value is the new start of the list, which may have changed, so
169 * make sure you store the new value.
170 * /+* Notice that it is initialized to the empty list. +/
171 * GSList *list = NULL;
172 * list = g_slist_prepend (list, "last");
173 * list = g_slist_prepend (list, "first");
177 * the data for the new element.
179 * the new start of the GSList.
181 public ListSG
prepend(void* data
)
183 // GSList* g_slist_prepend (GSList *list, gpointer data);
184 return new ListSG( g_slist_prepend(gSList
, data
) );
188 * Inserts a new element into the list at the given position.
192 * the data for the new element.
194 * the position to insert the element. If this is negative, or is
195 * larger than the number of elements in the list, the new element is added on
196 * to the end of the list.
198 * the new start of the GSList.
200 public ListSG
insert(void* data
, int position
)
202 // GSList* g_slist_insert (GSList *list, gpointer data, gint position);
203 return new ListSG( g_slist_insert(gSList
, data
, position
) );
207 * Inserts a node before sibling containing data. Returns the new head of the list.
211 * node to insert data before.
213 * data to put in the newly-inserted node.
215 * new head of the list.
217 public ListSG
insertBefore(ListSG sibling
, void* data
)
219 // GSList* g_slist_insert_before (GSList *slist, GSList *sibling, gpointer data);
220 return new ListSG( g_slist_insert_before(gSList
, (sibling
is null) ?
null : sibling
.getListSGStruct(), data
) );
224 * Inserts a new element into the list, using the given comparison function
225 * to determine its position.
229 * the data for the new element.
231 * the function to compare elements in the list. It should return a
232 * number > 0 if the first parameter comes after the second parameter in
235 * the new start of the GSList.
237 public ListSG
insertSorted(void* data
, GCompareFunc func
)
239 // GSList* g_slist_insert_sorted (GSList *list, gpointer data, GCompareFunc func);
240 return new ListSG( g_slist_insert_sorted(gSList
, data
, func
) );
244 * Removes an element from a GSList.
245 * If two elements contain the same data, only the first is removed.
246 * If none of the elements contain the data, the GSList is unchanged.
250 * the data of the element to remove.
252 * the new start of the GSList.
254 public ListSG
remove(void* data
)
256 // GSList* g_slist_remove (GSList *list, gconstpointer data);
257 return new ListSG( g_slist_remove(gSList
, data
) );
261 * Removes an element from a GSList, without freeing the element.
262 * The removed element's next link is set to NULL, so that it becomes a
263 * self-contained list with one element.
267 * an element in the GSList.
269 * the new start of the GSList, without the element.
271 public ListSG
removeLink(ListSG link
)
273 // GSList* g_slist_remove_link (GSList *list, GSList *link_);
274 return new ListSG( g_slist_remove_link(gSList
, (link
is null) ?
null : link
.getListSGStruct()) );
278 * Deletes a node of list. Returns the new list head.
286 public ListSG
deleteLink(ListSG link
)
288 // GSList* g_slist_delete_link (GSList *list, GSList *link_);
289 return new ListSG( g_slist_delete_link(gSList
, (link
is null) ?
null : link
.getListSGStruct()) );
293 * Removes all list nodes with data equal to data. Returns the new
294 * head of the list. Contrast with g_slist_remove() which removes only
295 * the first node matching the given data.
303 public ListSG
removeAll(void* data
)
305 // GSList* g_slist_remove_all (GSList *list, gconstpointer data);
306 return new ListSG( g_slist_remove_all(gSList
, data
) );
310 * Frees all of the memory used by a GSList.
311 * The freed elements are returned to the slice allocator.
317 // void g_slist_free (GSList *list);
318 g_slist_free(gSList
);
322 * Frees one GSList element.
323 * It is usually used after g_slist_remove_link().
329 // void g_slist_free_1 (GSList *list);
330 g_slist_free_1(gSList
);
335 * Gets the number of elements in a GSList.
339 * the number of elements in the GSList.
343 // guint g_slist_length (GSList *list);
344 return g_slist_length(gSList
);
349 * Note that this is a "shallow" copy. If the list elements consist of pointers
350 * to data, the pointers are copied but the actual data isn't.
358 // GSList* g_slist_copy (GSList *list);
359 return new ListSG( g_slist_copy(gSList
) );
367 * the start of the reversed GSList.
369 public ListSG
reverse()
371 // GSList* g_slist_reverse (GSList *list);
372 return new ListSG( g_slist_reverse(gSList
) );
376 * Inserts a new element into the list, using the given comparison function
377 * to determine its position.
381 * the data for the new element.
383 * the function to compare elements in the list. It should return a
384 * number > 0 if the first parameter comes after the second parameter in
387 * data to pass to comparison function.
389 * the new start of the GSList.
392 public ListSG
insertSortedWithData(void* data
, GCompareDataFunc func
, void* userData
)
394 // GSList* g_slist_insert_sorted_with_data (GSList *list, gpointer data, GCompareDataFunc func, gpointer user_data);
395 return new ListSG( g_slist_insert_sorted_with_data(gSList
, data
, func
, userData
) );
399 * Sorts a GSList using the given comparison function.
403 * the comparison function used to sort the GSList.
404 * This function is passed the data from 2 elements of the GSList and should
405 * return 0 if they are equal, a negative value if the first element
406 * comes before the second, or a positive value if the first element
407 * comes after the second.
409 * the start of the sorted GSList.
411 public ListSG
sort(GCompareFunc compareFunc
)
413 // GSList* g_slist_sort (GSList *list, GCompareFunc compare_func);
414 return new ListSG( g_slist_sort(gSList
, compareFunc
) );
418 * Like g_slist_sort(), but the sort function accepts a user data argument.
422 * comparison function.
424 * data to pass to comparison function.
426 * new head of the list.
428 public ListSG
sortWithData(GCompareDataFunc compareFunc
, void* userData
)
430 // GSList* g_slist_sort_with_data (GSList *list, GCompareDataFunc compare_func, gpointer user_data);
431 return new ListSG( g_slist_sort_with_data(gSList
, compareFunc
, userData
) );
435 * Adds the second GSList onto the end of the first GSList.
436 * Note that the elements of the second GSList are not copied.
437 * They are used directly.
441 * the GSList to add to the end of the first GSList.
443 * the start of the new GSList.
445 public ListSG
concat(ListSG list2
)
447 // GSList* g_slist_concat (GSList *list1, GSList *list2);
448 return new ListSG( g_slist_concat(gSList
, (list2
is null) ?
null : list2
.getListSGStruct()) );
452 * Calls a function for each element of a GSList.
456 * the function to call with each element's data.
458 * user data to pass to the function.
460 public void foreac(GFunc func
, void* userData
)
462 // void g_slist_foreach (GSList *list, GFunc func, gpointer user_data);
463 g_slist_foreach(gSList
, func
, userData
);
467 * Gets the last element in a GSList.
471 * the last element in the GSList, or NULL if the GSList has no
476 // GSList* g_slist_last (GSList *list);
477 return new ListSG( g_slist_last(gSList
) );
482 * Gets the element at the given position in a GSList.
486 * the position of the element, counting from 0.
488 * the element, or NULL if the position is off the end of the GSList.
490 public ListSG
nth(uint n
)
492 // GSList* g_slist_nth (GSList *list, guint n);
493 return new ListSG( g_slist_nth(gSList
, n
) );
497 * Gets the data of the element at the given position.
501 * the position of the element.
503 * the element's data, or NULL if the position is off the end of the
506 public void* nthData(uint n
)
508 // gpointer g_slist_nth_data (GSList *list, guint n);
509 return g_slist_nth_data(gSList
, n
);
513 * Finds the element in a GSList which contains the given data.
517 * the element data to find.
519 * the found GSList element, or NULL if it is not found.
521 public ListSG
find(void* data
)
523 // GSList* g_slist_find (GSList *list, gconstpointer data);
524 return new ListSG( g_slist_find(gSList
, data
) );
528 * Finds an element in a GSList, using a supplied function to find the desired
530 * It iterates over the list, calling the given function which should return 0
531 * when the desired element is found.
532 * The function takes two gconstpointer arguments, the GSList element's data as
533 * the first argument and the given user data.
537 * user data passed to the function.
539 * the function to call for each element. It should return 0 when the
540 * desired element is found.
542 * the found GSList element, or NULL if it is not found.
544 public ListSG
findCustom(void* data
, GCompareFunc func
)
546 // GSList* g_slist_find_custom (GSList *list, gconstpointer data, GCompareFunc func);
547 return new ListSG( g_slist_find_custom(gSList
, data
, func
) );
551 * Gets the position of the given element in the GSList (starting from 0).
555 * an element in the GSList.
557 * the position of the element in the GSList, or -1 if the element
560 public int position(ListSG llink
)
562 // gint g_slist_position (GSList *list, GSList *llink);
563 return g_slist_position(gSList
, (llink
is null) ?
null : llink
.getListSGStruct());
567 * Gets the position of the element containing the given data (starting from 0).
573 * the index of the element containing the data, or -1 if the data
576 public int index(void* data
)
578 // gint g_slist_index (GSList *list, gconstpointer data);
579 return g_slist_index(gSList
, data
);
584 * g_slist_push_allocator has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since GSList has been
585 * converted to the slice allocator
586 * Sets the allocator to use to allocate GSList elements.
587 * Use g_slist_pop_allocator() to restore the previous allocator.
588 * Note that this function is not available if GLib has been compiled
589 * with --disable-mem-pools
591 * the GAllocator to use when allocating GSList elements.
593 public static void pushAllocator(void* dummy
)
595 // void g_slist_push_allocator (gpointer dummy);
596 g_slist_push_allocator(dummy
);
601 * g_slist_pop_allocator has been deprecated since version 2.10 and should not be used in newly-written code. It does nothing, since GSList has been
602 * converted to the slice allocator
603 * Restores the previous GAllocator, used when allocating GSList elements.
604 * Note that this function is not available if GLib has been compiled
605 * with --disable-mem-pools
607 public static void popAllocator()
609 // void g_slist_pop_allocator (void);
610 g_slist_pop_allocator();