00001 /* --------------------------------------------------------------------------- 00002 00003 00004 This file is part of the ``utils'' package of NuSMV version 2. 00005 Copyright (C) 2011 by FBK. 00006 00007 NuSMV version 2 is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 NuSMV version 2 is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00020 00021 For more information on NuSMV see <http://nusmv.fbk.eu> 00022 or email to <nusmv-users@fbk.eu>. 00023 Please report bugs to <nusmv-users@fbk.eu>. 00024 00025 To contact the NuSMV development board, email to <nusmv@fbk.eu>. 00026 00027 -----------------------------------------------------------------------------*/ 00028 00037 #ifndef __NUSMV_CORE_UTILS_STACK_H__ 00038 #define __NUSMV_CORE_UTILS_STACK_H__ 00039 00040 #include "nusmv/core/utils/defs.h" 00041 00042 /*---------------------------------------------------------------------------*/ 00043 /* Structure declarations */ 00044 /*---------------------------------------------------------------------------*/ 00051 struct Stack_TAG { 00052 size_t allocated; 00053 size_t index; 00054 00055 void** array; 00056 }; 00057 00058 /*---------------------------------------------------------------------------*/ 00059 /* Type declarations */ 00060 /*---------------------------------------------------------------------------*/ 00061 00068 typedef struct Stack_TAG Stack; 00069 typedef struct Stack_TAG* Stack_ptr; 00070 00076 #define STACK(x) \ 00077 ((Stack_ptr) x) 00078 00084 #define STACK_CHECK_INSTANCE(x) \ 00085 ( nusmv_assert(STACK(x) != STACK(NULL)) ) 00086 00092 #define STACK_TOP(self) *(self->array + self->index - 1) 00093 00099 #define STACK_IS_EMPTY(self) (self->index == 0) 00100 00101 /* ---------------------------------------------------------------------- */ 00102 /* Public interface */ 00103 /* ---------------------------------------------------------------------- */ 00104 00111 Stack_ptr Stack_create(void); 00112 00119 Stack_ptr Stack_create_with_param(int size); 00120 00129 void Stack_destroy(Stack_ptr self); 00130 00137 Stack_ptr Stack_copy(Stack_ptr self); 00138 00147 void Stack_push(Stack_ptr self, void* element); 00148 00157 void* Stack_pop(Stack_ptr self); 00158 00167 void* Stack_top(Stack_ptr self); 00168 00175 boolean Stack_is_empty(Stack_ptr self); 00176 00183 size_t Stack_get_size(Stack_ptr self); 00184 00185 #endif /* __S_LIST_H__ */