1 /* Libvisual - The audio visualisation framework. 2 * 3 * Copyright (C) 2004, 2005, 2006 Dennis Smit <ds@nerds-incorporated.org> 4 * 5 * List implementation from RCL. 6 * Copyright (C) 2002, 2003, 2004 7 * Dennis Smit <ds@nerds-incorporated.org>, 8 * Sepp Wijnands <mrrazz@nerds-incorporated.org>, 9 * Tom Wimmenhove <nohup@nerds-incorporated.org> 10 * 11 * Authors: Dennis Smit <ds@nerds-incorporated.org> 12 * Sepp Wijnands <mrrazz@nerds-incorporated.org>, 13 * Tom Wimmenhove <nohup@nerds-incorporated.org> 14 * 15 * $Id: lv_list.h,v 1.19 2006/01/22 13:23:37 synap Exp $ 16 * 17 * This program is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU Lesser General Public License as 19 * published by the Free Software Foundation; either version 2.1 20 * of the License, or (at your option) any later version. 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU Lesser General Public License for more details. 26 * 27 * You should have received a copy of the GNU Lesser General Public License 28 * along with this program; if not, write to the Free Software 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 */ 31 32 #ifndef _LV_LIST_H 33 #define _LV_LIST_H 34 35 #include <libvisual-0.4/libvisual/lv_common.h> 36 #include <libvisual-0.4/libvisual/lv_collection.h> 37 38 #if defined(__FreeBSD__) || defined(__OpenBSD__) 39 #include <sys/queue.h> 40 #endif 41 42 VISUAL_BEGIN_DECLS 43 44 #define VISUAL_LIST(obj) (VISUAL_CHECK_CAST ((obj), VisList)) 45 46 typedef struct _VisListEntry VisListEntry; 47 typedef struct _VisList VisList; 48 49 /** 50 * The VisListEntry data structure is an entry within the linked list. 51 * It does contain a pointer to both the previous and next entry in the list and 52 * a void * to the data. 53 */ 54 struct _VisListEntry { 55 VisListEntry *prev; /**< Previous entry in the list. */ 56 VisListEntry *next; /**< Next entry in the list. */ 57 58 void *data; /**< Pointer to the data for this entry. */ 59 }; 60 61 /** 62 * The VisList data structure represents a linked list. It inherents from the 63 * VisCollection class. 64 */ 65 struct _VisList { 66 VisCollection collection; /**< The VisCollection data. */ 67 68 VisListEntry *head; /**< Pointer to the beginning of the list. */ 69 VisListEntry *tail; /**< Pointer to the end of the list. */ 70 71 int count; /**< Number of entries that are in the list. */ 72 }; 73 74 75 /* prototypes */ 76 VisList *visual_list_new (VisCollectionDestroyerFunc destroyer); 77 int visual_list_init (VisList *list, VisCollectionDestroyerFunc destroyer); 78 79 void *visual_list_next (VisList *list, VisListEntry **le); 80 void *visual_list_prev (VisList *list, VisListEntry **le); 81 82 void *visual_list_get (VisList *list, int index); 83 84 int visual_list_add_at_begin (VisList *list, void *data); 85 int visual_list_add (VisList *list, void *data); 86 87 int visual_list_chain_at_begin (VisList *list, VisListEntry *le); 88 int visual_list_chain (VisList *list, VisListEntry *le); 89 int visual_list_unchain (VisList *list, VisListEntry *le); 90 91 int visual_list_insert (VisList *list, VisListEntry **le, void *data); 92 int visual_list_delete (VisList *list, VisListEntry **le); 93 94 int visual_list_destroy (VisList *list, VisListEntry **le); 95 96 int visual_list_count (VisList *list); 97 98 VISUAL_END_DECLS 99 100 #endif /* _LV_LIST_H */ 101