00001 /* --------------------------------------------------------------------------- 00002 00003 00004 This file is part of the ``utils'' package of NuSMV version 2. 00005 Copyright (C) 2011 by FBK-irst. 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 00039 #ifndef __NUSMV_CORE_UTILS_OAHASH_PRIVATE_H__ 00040 #define __NUSMV_CORE_UTILS_OAHASH_PRIVATE_H__ 00041 00042 00043 #include "nusmv/core/utils/utils.h" 00044 #include "nusmv/core/utils/OAHash.h" 00045 00046 00054 #define OA_HASH_MINSIZE 8 00055 00061 #define PERTURB_SHIFT 5 00062 00063 typedef struct OAEntry_TAG { 00064 size_t hash; /* This is for performances, if key_eq_fun is fast 00065 (e.g. pointers equality) can be removed, sparing 64 00066 bits for each entry*/ 00067 void* key; 00068 void* value; 00069 } OAEntry; 00070 00077 typedef struct OAHash_TAG 00078 { 00079 /* -------------------------------------------------- */ 00080 /* Private members */ 00081 /* -------------------------------------------------- */ 00082 00083 size_t fill; 00084 size_t used; 00085 size_t mask; 00086 00087 OAEntry* table; 00088 OAEntry small_table[OA_HASH_MINSIZE]; 00089 00090 /* The argument passed to key_eq_fun, key_hash_fun and 00091 free_entry_fun */ 00092 void* custom_arg; 00093 00094 /* In the OAHash, this value is equal to custom_arg. However, having 00095 it adds the possibility to class extending the OAHash to have a 00096 custom value. */ 00097 void* free_fun_arg; 00098 00099 /* Function to check keys equality. Parameters are key1, key2 and 00100 the custom argument */ 00101 OA_HASH_EQ_FUN key_eq_fun; 00102 00103 /* The function for calculating the hash of the given 00104 key. Parameters are key and the custom argument */ 00105 OA_HASH_HASH_FUN key_hash_fun; 00106 00107 /* The function used for deleting entries. Parameters are key, value 00108 and the custom argument */ 00109 OA_HASH_FREE_FUN free_entry_fun; 00110 00111 } OAHash; 00112 00113 00114 00115 /*---------------------------------------------------------------------------*/ 00116 /* Function prototypes */ 00117 /*---------------------------------------------------------------------------*/ 00118 00123 void oa_hash_init(OAHash_ptr self, 00124 OA_HASH_EQ_FUN key_eq_fun, 00125 OA_HASH_HASH_FUN key_hash_fun, 00126 OA_HASH_FREE_FUN free_entry_fun, 00127 void* custom_arg); 00128 00133 void oa_hash_deinit(OAHash_ptr self); 00134 00139 #endif /* __OA_HASH_H__ */