extensions/sqlite/sqlite-source/hash.h
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/extensions/sqlite/sqlite-source/hash.h	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,110 +0,0 @@
     1.4 -/*
     1.5 -** 2001 September 22
     1.6 -**
     1.7 -** The author disclaims copyright to this source code.  In place of
     1.8 -** a legal notice, here is a blessing:
     1.9 -**
    1.10 -**    May you do good and not evil.
    1.11 -**    May you find forgiveness for yourself and forgive others.
    1.12 -**    May you share freely, never taking more than you give.
    1.13 -**
    1.14 -*************************************************************************
    1.15 -** This is the header file for the generic hash-table implemenation
    1.16 -** used in SQLite.
    1.17 -**
    1.18 -** $Id$
    1.19 -*/
    1.20 -#ifndef _SQLITE_HASH_H_
    1.21 -#define _SQLITE_HASH_H_
    1.22 -
    1.23 -/* Forward declarations of structures. */
    1.24 -typedef struct Hash Hash;
    1.25 -typedef struct HashElem HashElem;
    1.26 -
    1.27 -/* A complete hash table is an instance of the following structure.
    1.28 -** The internals of this structure are intended to be opaque -- client
    1.29 -** code should not attempt to access or modify the fields of this structure
    1.30 -** directly.  Change this structure only by using the routines below.
    1.31 -** However, many of the "procedures" and "functions" for modifying and
    1.32 -** accessing this structure are really macros, so we can't really make
    1.33 -** this structure opaque.
    1.34 -*/
    1.35 -struct Hash {
    1.36 -  char keyClass;          /* SQLITE_HASH_INT, _POINTER, _STRING, _BINARY */
    1.37 -  char copyKey;           /* True if copy of key made on insert */
    1.38 -  int count;              /* Number of entries in this table */
    1.39 -  int htsize;             /* Number of buckets in the hash table */
    1.40 -  HashElem *first;        /* The first element of the array */
    1.41 -  struct _ht {            /* the hash table */
    1.42 -    int count;               /* Number of entries with this hash */
    1.43 -    HashElem *chain;         /* Pointer to first entry with this hash */
    1.44 -  } *ht;
    1.45 -};
    1.46 -
    1.47 -/* Each element in the hash table is an instance of the following 
    1.48 -** structure.  All elements are stored on a single doubly-linked list.
    1.49 -**
    1.50 -** Again, this structure is intended to be opaque, but it can't really
    1.51 -** be opaque because it is used by macros.
    1.52 -*/
    1.53 -struct HashElem {
    1.54 -  HashElem *next, *prev;   /* Next and previous elements in the table */
    1.55 -  void *data;              /* Data associated with this element */
    1.56 -  void *pKey; int nKey;    /* Key associated with this element */
    1.57 -};
    1.58 -
    1.59 -/*
    1.60 -** There are 4 different modes of operation for a hash table:
    1.61 -**
    1.62 -**   SQLITE_HASH_INT         nKey is used as the key and pKey is ignored.
    1.63 -**
    1.64 -**   SQLITE_HASH_POINTER     pKey is used as the key and nKey is ignored.
    1.65 -**
    1.66 -**   SQLITE_HASH_STRING      pKey points to a string that is nKey bytes long
    1.67 -**                           (including the null-terminator, if any).  Case
    1.68 -**                           is ignored in comparisons.
    1.69 -**
    1.70 -**   SQLITE_HASH_BINARY      pKey points to binary data nKey bytes long. 
    1.71 -**                           memcmp() is used to compare keys.
    1.72 -**
    1.73 -** A copy of the key is made for SQLITE_HASH_STRING and SQLITE_HASH_BINARY
    1.74 -** if the copyKey parameter to HashInit is 1.  
    1.75 -*/
    1.76 -/* #define SQLITE_HASH_INT       1 // NOT USED */
    1.77 -/* #define SQLITE_HASH_POINTER   2 // NOT USED */
    1.78 -#define SQLITE_HASH_STRING    3
    1.79 -#define SQLITE_HASH_BINARY    4
    1.80 -
    1.81 -/*
    1.82 -** Access routines.  To delete, insert a NULL pointer.
    1.83 -*/
    1.84 -void sqlite3HashInit(Hash*, int keytype, int copyKey);
    1.85 -void *sqlite3HashInsert(Hash*, const void *pKey, int nKey, void *pData);
    1.86 -void *sqlite3HashFind(const Hash*, const void *pKey, int nKey);
    1.87 -HashElem *sqlite3HashFindElem(const Hash*, const void *pKey, int nKey);
    1.88 -void sqlite3HashClear(Hash*);
    1.89 -
    1.90 -/*
    1.91 -** Macros for looping over all elements of a hash table.  The idiom is
    1.92 -** like this:
    1.93 -**
    1.94 -**   Hash h;
    1.95 -**   HashElem *p;
    1.96 -**   ...
    1.97 -**   for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){
    1.98 -**     SomeStructure *pData = sqliteHashData(p);
    1.99 -**     // do something with pData
   1.100 -**   }
   1.101 -*/
   1.102 -#define sqliteHashFirst(H)  ((H)->first)
   1.103 -#define sqliteHashNext(E)   ((E)->next)
   1.104 -#define sqliteHashData(E)   ((E)->data)
   1.105 -#define sqliteHashKey(E)    ((E)->pKey)
   1.106 -#define sqliteHashKeysize(E) ((E)->nKey)
   1.107 -
   1.108 -/*
   1.109 -** Number of entries in a hash table
   1.110 -*/
   1.111 -#define sqliteHashCount(H)  ((H)->count)
   1.112 -
   1.113 -#endif /* _SQLITE_HASH_H_ */