Eneboo - Documentación para desarrolladores
|
00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* Dynamic hashing of record with different key-length */ 00018 00019 #ifndef _hash_h 00020 #define _hash_h 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 /* 00026 Overhead to store an element in hash 00027 Can be used to approximate memory consumption for a hash 00028 */ 00029 #define HASH_OVERHEAD (sizeof(char*)*2) 00030 00031 typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); 00032 typedef void (*hash_free_key)(void *); 00033 00034 typedef struct st_hash { 00035 uint key_offset,key_length; /* Length of key if const length */ 00036 uint records,blength,current_record; 00037 uint flags; 00038 DYNAMIC_ARRAY array; /* Place for hash_keys */ 00039 hash_get_key get_key; 00040 void (*free)(void *); 00041 CHARSET_INFO *charset; 00042 } HASH; 00043 00044 #define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO) 00045 my_bool _hash_init(HASH *hash, CHARSET_INFO *charset, 00046 uint default_array_elements, uint key_offset, 00047 uint key_length, hash_get_key get_key, 00048 void (*free_element)(void*), uint flags CALLER_INFO_PROTO); 00049 void hash_free(HASH *tree); 00050 void my_hash_reset(HASH *hash); 00051 byte *hash_element(HASH *hash,uint idx); 00052 gptr hash_search(HASH *info,const byte *key,uint length); 00053 gptr hash_next(HASH *info,const byte *key,uint length); 00054 my_bool my_hash_insert(HASH *info,const byte *data); 00055 my_bool hash_delete(HASH *hash,byte *record); 00056 my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length); 00057 void hash_replace(HASH *hash, uint idx, byte *new_row); 00058 my_bool hash_check(HASH *hash); /* Only in debug library */ 00059 00060 #define hash_clear(H) bzero((char*) (H),sizeof(*(H))) 00061 #define hash_inited(H) ((H)->array.buffer != 0) 00062 00063 #ifdef __cplusplus 00064 } 00065 #endif 00066 #endif