151 lines
5.2 KiB
C
151 lines
5.2 KiB
C
|
/* GLIB - Library of useful routines for C programming
|
||
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||
|
*
|
||
|
* This library is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* This library is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
/*
|
||
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
||
|
* file for a list of people on the GLib Team. See the ChangeLog
|
||
|
* files for a list of changes. These files are distributed with
|
||
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
||
|
*/
|
||
|
|
||
|
#ifndef __F_LIST_H__
|
||
|
#define __F_LIST_H__
|
||
|
|
||
|
#define F_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||
|
|
||
|
typedef void (*FDestroyNotify) (void * data);
|
||
|
typedef void (*FFunc) (void * data, void * user_data);
|
||
|
typedef int (*FCompareDataFunc) (const void * a, const void * b, void * user_data);
|
||
|
typedef int (*FCompareFunc) (const void * a, const void * b);
|
||
|
typedef void * (*FCopyFunc) (const void * src, void * data);
|
||
|
|
||
|
typedef struct _FList FList;
|
||
|
|
||
|
struct _FList
|
||
|
{
|
||
|
void * data;
|
||
|
FList *next;
|
||
|
FList *prev;
|
||
|
};
|
||
|
|
||
|
/* Doubly linked lists
|
||
|
*/
|
||
|
|
||
|
FList* f_list_alloc (void) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
void f_list_free (FList *list);
|
||
|
|
||
|
void f_list_free_1 (FList *list);
|
||
|
#define f_list_free1 f_list_free_1
|
||
|
|
||
|
void f_list_free_full (FList *list,
|
||
|
FDestroyNotify free_func);
|
||
|
|
||
|
FList* f_list_append (FList *list,
|
||
|
void * data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_prepend (FList *list,
|
||
|
void * data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_insert (FList *list,
|
||
|
void * data,
|
||
|
int position) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_insert_sorted (FList *list,
|
||
|
void * data,
|
||
|
FCompareFunc func) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_insert_sorted_with_data (FList *list,
|
||
|
void * data,
|
||
|
FCompareDataFunc func,
|
||
|
void * user_data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_insert_before (FList *list,
|
||
|
FList *sibling,
|
||
|
void * data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_concat (FList *list1,
|
||
|
FList *list2) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_remove (FList *list,
|
||
|
const void * data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_remove_all (FList *list,
|
||
|
const void * data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_remove_link (FList *list,
|
||
|
FList *llink) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_delete_link (FList *list,
|
||
|
FList *link_) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_reverse (FList *list) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_copy (FList *list) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
|
||
|
FList* f_list_copy_deep (FList *list,
|
||
|
FCopyFunc func,
|
||
|
void * user_data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
|
||
|
FList* f_list_nth (FList *list,
|
||
|
unsigned int n);
|
||
|
|
||
|
FList* f_list_nth_prev (FList *list,
|
||
|
unsigned int n);
|
||
|
|
||
|
FList* f_list_find (FList *list,
|
||
|
const void * data);
|
||
|
|
||
|
FList* f_list_find_custom (FList *list,
|
||
|
const void * data,
|
||
|
FCompareFunc func);
|
||
|
|
||
|
int f_list_position (FList *list,
|
||
|
FList *llink);
|
||
|
|
||
|
int f_list_index (FList *list,
|
||
|
const void * data);
|
||
|
|
||
|
FList* f_list_last (FList *list);
|
||
|
|
||
|
FList* f_list_first (FList *list);
|
||
|
|
||
|
unsigned int f_list_length (FList *list);
|
||
|
|
||
|
void f_list_foreach (FList *list,
|
||
|
FFunc func,
|
||
|
void * user_data);
|
||
|
|
||
|
FList* f_list_sort (FList *list,
|
||
|
FCompareFunc compare_func) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
FList* f_list_sort_with_data (FList *list,
|
||
|
FCompareDataFunc compare_func,
|
||
|
void * user_data) F_GNUC_WARN_UNUSED_RESULT;
|
||
|
|
||
|
void * f_list_nth_data (FList *list,
|
||
|
unsigned int n);
|
||
|
|
||
|
|
||
|
#define f_list_previous(list) ((list) ? (((FList *)(list))->prev) : NULL)
|
||
|
#define f_list_next(list) ((list) ? (((FList *)(list))->next) : NULL)
|
||
|
|
||
|
|
||
|
#endif /* __F_LIST_H__ */
|