Main Page   Modules   Compound List   File List   Compound Members   File Members  

linked_list.h

Go to the documentation of this file.
00001 
00014 /* This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Lesser General Public
00016    License as published by the Free Software Foundation; either
00017    version 2.1 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Lesser General Public License for more details.
00023 
00024    You should have received a copy of the GNU Lesser General Public
00025    License along with this library; if not, write to the Free Software
00026    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00027 */
00028 
00029 #ifndef _GAN_LINKED_LIST_H
00030 #define _GAN_LINKED_LIST_H
00031 
00032 #include <gandalf/common/misc_defs.h>
00033 
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00051 typedef struct Gan_List_Node
00052 {
00053    void                 *p_data;
00054    struct Gan_List_Node *p_next;
00055    struct Gan_List_Node *p_prev;
00056 } Gan_List_Node;
00057 
00058 
00059 
00063 typedef struct Gan_List
00064 {
00065    
00066    Gan_List_Node *p_first;         
00067    Gan_List_Node *p_current;       
00068    Gan_List_Node *p_last;          
00069    Gan_List_Node *p_stack_current; 
00071    int node_count;                 
00072    int current_position;           
00073    int current_position_stack;     
00074    Gan_Bool is_straight;           
00076 
00077    Gan_Bool alloc;
00078 } Gan_List;
00079 
00080 
00081 /* Constructor and Destructor */
00082 Gan_List*        gan_list_new ( void );
00083 Gan_List*        gan_list_form(Gan_List *list);
00084 Gan_List*        gan_list_new_from_array( void **array, unsigned n );
00085 void             gan_list_free ( Gan_List *list, void (*free_func)(void *));
00086 Gan_Bool gan_list_insert_first ( Gan_List *list, void *data );
00087 Gan_Bool gan_list_insert_next  ( Gan_List *list, void *data );
00088 Gan_Bool gan_list_insert_prev  ( Gan_List *list, void *data );
00089 Gan_Bool gan_list_insert_last  ( Gan_List *list, void *data );
00090 Gan_Bool gan_list_insert_at ( Gan_List *list, void *data, int pos );
00091 Gan_Bool gan_list_delete_first   ( Gan_List *list, void (*free_func)(void *) );
00092 Gan_Bool gan_list_delete_next    ( Gan_List *list, void (*free_func)(void *) );
00093 Gan_Bool gan_list_delete_current ( Gan_List *list, void (*free_func)(void *) );
00094 Gan_Bool gan_list_delete_prev    ( Gan_List *list, void (*free_func)(void *) );
00095 Gan_Bool gan_list_delete_last    ( Gan_List *list, void (*free_func)(void *) );
00096 Gan_Bool gan_list_delete_at( Gan_List *list, void (*free_func)(void *),
00097                              int pos );
00098 void gan_list_delete_all ( Gan_List *list, void (*free_func)(void *) );
00099 void gan_list_goto_head ( Gan_List *list);
00100 void gan_list_goto_tail ( Gan_List *list);
00101 Gan_Bool gan_list_goto_pos ( Gan_List *list, int pos );
00102 void *gan_list_set_prev ( Gan_List *list, void *new_data );
00103 void *gan_list_set_current (Gan_List *list, void *new_data);
00104 void *gan_list_set_next ( Gan_List *list, void *new_data );
00105 void gan_list_push_current ( Gan_List *list );
00106 void gan_list_pop_current ( Gan_List *list );
00107 int gan_list_get_pos ( Gan_List *list );
00108 int gan_list_get_size ( Gan_List *list );
00109 void gan_list_process_data( Gan_List *list,
00110                             void (*process_func)(void *, void *), void *data );
00111 Gan_List* gan_list_concat( Gan_List *list1, Gan_List *list2 );
00112 void gan_list_reverse( Gan_List *list );
00113 int gan_list_to_array ( Gan_List *list, void ***array_ptr );
00114 Gan_List* gan_list_copy( Gan_List *list );
00115 void gan_list_sort_asc ( Gan_List *list,
00116                          int (*compare)(const void *, const void *) );
00117 void gan_list_make_straight                        ( Gan_List *list );
00118 void gan_list_make_circular                        ( Gan_List *list );
00119 Gan_Bool gan_list_is_circular                        ( Gan_List *list );
00120 
00121 Gan_Bool gan_list_contains  ( Gan_List *list, void *data );
00122 
00123 #define TYPE int
00124 
00137 TYPE *gan_list_get_prev ( Gan_List *list, TYPE node_type );
00138 
00148 TYPE *gan_list_get_current ( Gan_List *list, TYPE node_type );
00149 
00162 TYPE *gan_list_get_next ( Gan_List *list, TYPE node_type );
00163 
00164 #undef TYPE
00165 
00166 /* not user functions  */
00167 void *gan_list_get_prev_node ( Gan_List *list );
00168 void *gan_list_get_next_node ( Gan_List *list );
00169 void *gan_list_get_current_node ( Gan_List *list );
00170 
00179 #ifdef __cplusplus
00180 }
00181 #endif
00182 
00183 #endif /* _GAN_LINKED_LIST_H */

Generated on Mon Oct 13 16:14:33 2003 by doxygen1.3-rc1