Lines Matching full:list
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
42 #define _g_list_free1(list) g_slice_free (GList, list)
52 * @list: a #GList
58 * If list elements contain dynamically-allocated memory,
63 g_list_free (GList *list)
65 g_slice_free_chain (GList, list, next);
70 * @list: a #GList element
76 g_list_free_1 (GList *list)
78 _g_list_free1 (list);
83 * @list: a pointer to a #GList
86 * Adds a new element on to the end of the list.
89 * The return value is the new start of the list, which
94 * Note that g_list_append() has to traverse the entire list
97 * the elements and reverse the list when all elements have been added.
101 * /* Notice that these are initialized to the empty list. */
102 * GList *list = NULL, *number_list = NULL;
104 * /* This is a list of strings. */
105 * list = g_list_append (list, "first");
106 * list = g_list_append (list, "second");
108 * /* This is a list of integers. */
116 g_list_append (GList *list,
126 if (list)
128 last = g_list_last (list);
133 return list;
144 * @list: a pointer to a #GList
147 * Adds a new element on to the start of the list.
150 * The return value is the new start of the list, which
155 * /* Notice that it is initialized to the empty list. */
156 * GList *list = NULL;
157 * list = g_list_prepend (list, "last");
158 * list = g_list_prepend (list, "first");
164 g_list_prepend (GList *list,
171 new_list->next = list;
173 if (list)
175 new_list->prev = list->prev;
176 if (list->prev)
177 list->prev->next = new_list;
178 list->prev = new_list;
188 * @list: a pointer to a #GList
192 * list, the new element is added on to the end of the list.
194 * Inserts a new element into the list at the given position.
199 g_list_insert (GList *list,
207 return g_list_append (list, data);
209 return g_list_prepend (list, data);
211 tmp_list = g_list_nth (list, position);
213 return g_list_append (list, data);
223 if (tmp_list == list)
226 return list;
231 * @list: a pointer to a #GList
232 * @sibling: the list element before which the new element
233 * is inserted or %NULL to insert at the end of the list
236 * Inserts a new element into the list before the given position.
241 g_list_insert_before (GList *list,
245 if (!list)
247 list = g_list_alloc ();
248 list->data = data;
249 g_return_val_if_fail (sibling == NULL, list);
250 return list;
264 return list;
268 g_return_val_if_fail (sibling == list, node);
276 last = list;
285 return list;
320 * @list: a #GList
330 g_list_remove (GList *list,
335 tmp = list;
347 if (list == tmp)
348 list = list->next;
355 return list;
360 * @list: a #GList
363 * Removes all list nodes with data equal to @data.
364 * Returns the new head of the list. Contrast with
368 * Returns: new head of @list
371 g_list_remove_all (GList *list,
374 GList *tmp = list;
387 list = next;
395 return list;
399 _g_list_remove_link (GList *list,
409 if (link == list)
410 list = list->next;
416 return list;
421 * @list: a #GList
426 * that it becomes a self-contained list with one element.
431 g_list_remove_link (GList *list,
434 return _g_list_remove_link (list, llink);
439 * @list: a #GList
440 * @link_: node to delete from @list
442 * Removes the node link_ from the list and frees it.
446 * Returns: the new head of @list
449 g_list_delete_link (GList *list,
452 list = _g_list_remove_link (list, link_);
455 return list;
460 * @list: a #GList
465 * Note that this is a "shallow" copy. If the list elements
470 * Returns: a copy of @list
473 g_list_copy (GList *list)
477 if (list)
482 new_list->data = list->data;
485 list = list->next;
486 while (list)
491 last->data = list->data;
492 list = list->next;
502 * @list: a #GList
510 g_list_reverse (GList *list)
515 while (list)
517 last = list;
518 list = last->next;
520 last->prev = list;
528 * @list: a #GList
537 g_list_nth (GList *list,
540 while ((n-- > 0) && list)
541 list = list->next;
543 return list;
548 * @list: a #GList
551 * Gets the element @n places before @list.
557 g_list_nth_prev (GList *list,
560 while ((n-- > 0) && list)
561 list = list->prev;
563 return list;
568 * @list: a #GList
577 g_list_nth_data (GList *list,
580 while ((n-- > 0) && list)
581 list = list->next;
583 return list ? list->data : NULL;
588 * @list: a #GList
598 g_list_find (GList *list,
601 while (list)
603 if (list->data == data)
605 list = list->next;
608 return list;
613 * @list: a #GList
619 * find the desired element. It iterates over the list, calling
628 g_list_find_custom (GList *list,
632 g_return_val_if_fail (func != NULL, list);
634 while (list)
636 if (! func (list->data, data))
637 return list;
638 list = list->next;
647 * @list: a #GList
657 g_list_position (GList *list,
663 while (list)
665 if (list == llink)
668 list = list->next;
676 * @list: a #GList
686 g_list_index (GList *list,
692 while (list)
694 if (list->data == data)
697 list = list->next;
705 * @list: a #GList
713 g_list_last (GList *list)
715 if (list)
717 while (list->next)
718 list = list->next;
721 return list;
726 * @list: a #GList
734 g_list_first (GList *list)
736 if (list)
738 while (list->prev)
739 list = list->prev;
742 return list;
747 * @list: a #GList
752 * This function iterates over the whole list to
759 g_list_length (GList *list)
764 while (list)
767 list = list->next;
775 * @list: a #GList
782 g_list_foreach (GList *list,
786 while (list)
788 GList *next = list->next;
789 (*func) (list->data, user_data);
790 list = next;
795 g_list_insert_sorted_real (GList *list,
800 GList *tmp_list = list;
804 g_return_val_if_fail (func != NULL, list);
806 if (!list)
829 return list;
840 if (tmp_list == list)
843 return list;
848 * @list: a pointer to a #GList
850 * @func: the function to compare elements in the list. It should
854 * Inserts a new element into the list, using the given comparison
860 g_list_insert_sorted (GList *list,
864 return g_list_insert_sorted_real (list, data, (GFunc) func, NULL);
869 * @list: a pointer to a #GList
871 * @func: the function to compare elements in the list.
876 * Inserts a new element into the list, using the given comparison
884 g_list_insert_sorted_with_data (GList *list,
889 return g_list_insert_sorted_real (list, data, (GFunc) func, user_data);
898 GList list, *l, *lprev;
901 l = &list;
925 return list.next;
929 g_list_sort_real (GList *list,
935 if (!list)
937 if (!list->next)
938 return list;
940 l1 = list;
941 l2 = list->next;
952 return g_list_sort_merge (g_list_sort_real (list, compare_func, user_data),
960 * @list: a #GList
972 g_list_sort (GList *list,
975 return g_list_sort_real (list, (GFunc) compare_func, NULL);
981 * @list: a #GList
988 * Returns: the new head of @list
991 g_list_sort_with_data (GList *list,
995 return g_list_sort_real (list, (GFunc) compare_func, user_data);