diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kpat/freecell-solver/fcs_hash.h | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kpat/freecell-solver/fcs_hash.h')
-rw-r--r-- | kpat/freecell-solver/fcs_hash.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/kpat/freecell-solver/fcs_hash.h b/kpat/freecell-solver/fcs_hash.h new file mode 100644 index 00000000..fbe6c78c --- /dev/null +++ b/kpat/freecell-solver/fcs_hash.h @@ -0,0 +1,102 @@ +/* + * fcs_hash.h - header file of Freecell Solver's internal hash implementation. + * + * Written by Shlomi Fish ([email protected]), 2000 + * + * This file is in the public domain (it's uncopyrighted). + */ + +#ifndef FC_SOLVE__FCS_HASH_H +#define FC_SOLVE__FCS_HASH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "alloc.h" +#include "lookup2.h" + +typedef int SFO_hash_value_t; + +struct SFO_hash_symlink_item_struct +{ + /* A pointer to the data structure that is to be collected */ + void * key; + /* We also store the hash value corresponding to this key for faster + comparisons */ + SFO_hash_value_t hash_value; + /* + * We also store a secondary hash value, which is not used for indexing, + * but is used to speed up comparison. + * */ + SFO_hash_value_t secondary_hash_value; + /* The next item in the list */ + struct SFO_hash_symlink_item_struct * next; +}; + +typedef struct SFO_hash_symlink_item_struct SFO_hash_symlink_item_t; + +struct SFO_hash_symlink_struct +{ + SFO_hash_symlink_item_t * first_item; +}; + +typedef struct SFO_hash_symlink_struct SFO_hash_symlink_t; + +struct SFO_hash_struct +{ + /* The vector of the hash table itself */ + SFO_hash_symlink_t * entries; + /* A comparison function that can be used for comparing two keys + in the collection */ + int (*compare_function)(const void * key1, const void * key2, void * context); + /* The size of the hash table */ + int size; + + /* A bit mask that extract the lowest bits out of the hash value */ + int size_bitmask; + /* The number of elements stored inside the hash */ + int num_elems; + /* A context to pass to the comparison function */ + void * context; + + fcs_compact_allocator_t * allocator; +}; + +typedef struct SFO_hash_struct SFO_hash_t; + + +SFO_hash_t * freecell_solver_hash_init( + SFO_hash_value_t wanted_size, + int (*compare_function)(const void * key1, const void * key2, void * context), + void * context + ); + +void * freecell_solver_hash_insert( + SFO_hash_t * hash, + void * key, + SFO_hash_value_t hash_value, + SFO_hash_value_t secondary_hash_value, + int optimize_for_caching + ); + + +void freecell_solver_hash_free( + SFO_hash_t * hash + ); + +void freecell_solver_hash_free_with_callback( + SFO_hash_t * hash, + void (*function_ptr)(void * key, void * context) + ); + + +#ifdef __cplusplus +} +#endif + +#endif /* FC_SOLVE__FCS_HASH_H */ + + + + |