2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A** The author disclaims copyright to this source code. In place of 2N/A** a legal notice, here is a blessing: 2N/A** May you do good and not evil. 2N/A** May you find forgiveness for yourself and forgive others. 2N/A** May you share freely, never taking more than you give. 2N/A************************************************************************* 2N/A** This is the header file for the generic hash-table implemenation 2N/A** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $ 2N/A/* Forward declarations of structures. */ 2N/A/* A complete hash table is an instance of the following structure. 2N/A** The internals of this structure are intended to be opaque -- client 2N/A** code should not attempt to access or modify the fields of this structure 2N/A** directly. Change this structure only by using the routines below. 2N/A** However, many of the "procedures" and "functions" for modifying and 2N/A** accessing this structure are really macros, so we can't really make 2N/A** this structure opaque. 2N/A char keyClass;
/* SQLITE_HASH_INT, _POINTER, _STRING, _BINARY */ 2N/A char copyKey;
/* True if copy of key made on insert */ 2N/A int count;
/* Number of entries in this table */ 2N/A int htsize;
/* Number of buckets in the hash table */ 2N/A struct _ht {
/* the hash table */ 2N/A int count;
/* Number of entries with this hash */ 2N/A/* Each element in the hash table is an instance of the following 2N/A** structure. All elements are stored on a single doubly-linked list. 2N/A** Again, this structure is intended to be opaque, but it can't really 2N/A** be opaque because it is used by macros. 2N/A void *
data;
/* Data associated with this element */ 2N/A void *
pKey;
int nKey;
/* Key associated with this element */ 2N/A** There are 4 different modes of operation for a hash table: 2N/A** SQLITE_HASH_INT nKey is used as the key and pKey is ignored. 2N/A** SQLITE_HASH_POINTER pKey is used as the key and nKey is ignored. 2N/A** SQLITE_HASH_STRING pKey points to a string that is nKey bytes long 2N/A** (including the null-terminator, if any). Case 2N/A** is ignored in comparisons. 2N/A** SQLITE_HASH_BINARY pKey points to binary data nKey bytes long. 2N/A** memcmp() is used to compare keys. 2N/A** A copy of the key is made for SQLITE_HASH_STRING and SQLITE_HASH_BINARY 2N/A** if the copyKey parameter to HashInit is 1. 2N/A/* #define SQLITE_HASH_POINTER 2 // NOT USED */ 2N/A** Access routines. To delete, insert a NULL pointer. 2N/A** Macros for looping over all elements of a hash table. The idiom is 2N/A** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ 2N/A** SomeStructure *pData = sqliteHashData(p); 2N/A** // do something with pData 2N/A** Number of entries in a hash table 2N/A#
endif /* _SQLITE_HASH_H_ */