00001 /***************************************************************************** 00002 00003 Copyright (C) 2006, 2009, Innobase Oy. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it under 00006 the terms of the GNU General Public License as published by the Free Software 00007 Foundation; version 2 of the License. 00008 00009 This program is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License along with 00014 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin 00015 St, Fifth Floor, Boston, MA 02110-1301 USA 00016 00017 *****************************************************************************/ 00018 00019 /*******************************************************************/ 00026 /*******************************************************************/ 00046 #pragma once 00047 #ifndef IB_LIST_H 00048 #define IB_LIST_H 00049 00050 #include "mem0mem.h" 00051 00052 typedef struct ib_list_struct ib_list_t; 00053 typedef struct ib_list_node_struct ib_list_node_t; 00054 typedef struct ib_list_helper_struct ib_list_helper_t; 00055 00056 /****************************************************************/ 00060 UNIV_INTERN 00061 ib_list_t* 00062 ib_list_create(void); 00063 /*=================*/ 00064 00065 00066 /****************************************************************/ 00070 UNIV_INTERN 00071 ib_list_t* 00072 ib_list_create_heap( 00073 /*================*/ 00074 mem_heap_t* heap); 00076 /****************************************************************/ 00078 UNIV_INTERN 00079 void 00080 ib_list_free( 00081 /*=========*/ 00082 ib_list_t* list); 00084 /****************************************************************/ 00087 UNIV_INTERN 00088 ib_list_node_t* 00089 ib_list_add_first( 00090 /*==============*/ 00091 ib_list_t* list, 00092 void* data, 00093 mem_heap_t* heap); 00095 /****************************************************************/ 00098 UNIV_INTERN 00099 ib_list_node_t* 00100 ib_list_add_last( 00101 /*=============*/ 00102 ib_list_t* list, 00103 void* data, 00104 mem_heap_t* heap); 00106 /****************************************************************/ 00109 UNIV_INTERN 00110 ib_list_node_t* 00111 ib_list_add_after( 00112 /*==============*/ 00113 ib_list_t* list, 00114 ib_list_node_t* prev_node, 00116 void* data, 00117 mem_heap_t* heap); 00119 /****************************************************************/ 00121 UNIV_INTERN 00122 void 00123 ib_list_remove( 00124 /*===========*/ 00125 ib_list_t* list, 00126 ib_list_node_t* node); 00128 /****************************************************************/ 00131 UNIV_INLINE 00132 ib_list_node_t* 00133 ib_list_get_first( 00134 /*==============*/ 00135 ib_list_t* list); 00137 /****************************************************************/ 00140 UNIV_INLINE 00141 ib_list_node_t* 00142 ib_list_get_last( 00143 /*=============*/ 00144 ib_list_t* list); 00146 /* List. */ 00147 struct ib_list_struct { 00148 ib_list_node_t* first; 00149 ib_list_node_t* last; 00150 ibool is_heap_list; 00152 }; 00153 00154 /* A list node. */ 00155 struct ib_list_node_struct { 00156 ib_list_node_t* prev; 00157 ib_list_node_t* next; 00158 void* data; 00159 }; 00160 00161 /* Quite often, the only additional piece of data you need is the per-item 00162 memory heap, so we have this generic struct available to use in those 00163 cases. */ 00164 struct ib_list_helper_struct { 00165 mem_heap_t* heap; 00166 void* data; 00167 }; 00168 00169 #ifndef UNIV_NONINL 00170 #include "ut0list.ic" 00171 #endif 00172 00173 #endif