| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 22 | 2 ** 2001 September 22 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| 11 ************************************************************************* | 11 ************************************************************************* |
| 12 ** This is the header file for the generic hash-table implemenation | 12 ** This is the header file for the generic hash-table implementation |
| 13 ** used in SQLite. | 13 ** used in SQLite. |
| 14 */ | 14 */ |
| 15 #ifndef _SQLITE_HASH_H_ | 15 #ifndef _SQLITE_HASH_H_ |
| 16 #define _SQLITE_HASH_H_ | 16 #define _SQLITE_HASH_H_ |
| 17 | 17 |
| 18 /* Forward declarations of structures. */ | 18 /* Forward declarations of structures. */ |
| 19 typedef struct Hash Hash; | 19 typedef struct Hash Hash; |
| 20 typedef struct HashElem HashElem; | 20 typedef struct HashElem HashElem; |
| 21 | 21 |
| 22 /* A complete hash table is an instance of the following structure. | 22 /* A complete hash table is an instance of the following structure. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 52 | 52 |
| 53 /* Each element in the hash table is an instance of the following | 53 /* Each element in the hash table is an instance of the following |
| 54 ** structure. All elements are stored on a single doubly-linked list. | 54 ** structure. All elements are stored on a single doubly-linked list. |
| 55 ** | 55 ** |
| 56 ** Again, this structure is intended to be opaque, but it can't really | 56 ** Again, this structure is intended to be opaque, but it can't really |
| 57 ** be opaque because it is used by macros. | 57 ** be opaque because it is used by macros. |
| 58 */ | 58 */ |
| 59 struct HashElem { | 59 struct HashElem { |
| 60 HashElem *next, *prev; /* Next and previous elements in the table */ | 60 HashElem *next, *prev; /* Next and previous elements in the table */ |
| 61 void *data; /* Data associated with this element */ | 61 void *data; /* Data associated with this element */ |
| 62 const char *pKey; int nKey; /* Key associated with this element */ | 62 const char *pKey; /* Key associated with this element */ |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 /* | 65 /* |
| 66 ** Access routines. To delete, insert a NULL pointer. | 66 ** Access routines. To delete, insert a NULL pointer. |
| 67 */ | 67 */ |
| 68 void sqlite3HashInit(Hash*); | 68 void sqlite3HashInit(Hash*); |
| 69 void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData); | 69 void *sqlite3HashInsert(Hash*, const char *pKey, void *pData); |
| 70 void *sqlite3HashFind(const Hash*, const char *pKey, int nKey); | 70 void *sqlite3HashFind(const Hash*, const char *pKey); |
| 71 void sqlite3HashClear(Hash*); | 71 void sqlite3HashClear(Hash*); |
| 72 | 72 |
| 73 /* | 73 /* |
| 74 ** Macros for looping over all elements of a hash table. The idiom is | 74 ** Macros for looping over all elements of a hash table. The idiom is |
| 75 ** like this: | 75 ** like this: |
| 76 ** | 76 ** |
| 77 ** Hash h; | 77 ** Hash h; |
| 78 ** HashElem *p; | 78 ** HashElem *p; |
| 79 ** ... | 79 ** ... |
| 80 ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ | 80 ** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ |
| 81 ** SomeStructure *pData = sqliteHashData(p); | 81 ** SomeStructure *pData = sqliteHashData(p); |
| 82 ** // do something with pData | 82 ** // do something with pData |
| 83 ** } | 83 ** } |
| 84 */ | 84 */ |
| 85 #define sqliteHashFirst(H) ((H)->first) | 85 #define sqliteHashFirst(H) ((H)->first) |
| 86 #define sqliteHashNext(E) ((E)->next) | 86 #define sqliteHashNext(E) ((E)->next) |
| 87 #define sqliteHashData(E) ((E)->data) | 87 #define sqliteHashData(E) ((E)->data) |
| 88 /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ | 88 /* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ |
| 89 /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ | 89 /* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ |
| 90 | 90 |
| 91 /* | 91 /* |
| 92 ** Number of entries in a hash table | 92 ** Number of entries in a hash table |
| 93 */ | 93 */ |
| 94 /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ | 94 /* #define sqliteHashCount(H) ((H)->count) // NOT USED */ |
| 95 | 95 |
| 96 #endif /* _SQLITE_HASH_H_ */ | 96 #endif /* _SQLITE_HASH_H_ */ |
| OLD | NEW |