/* The MIT License Copyright (c) 2008, 2009, 2011 by Attractive Chaos <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef __AC_KHASH_H #define __AC_KHASH_H #include "hash.h" #define AC_VERSION_KHASH_H … khint32_t; khint64_t; khint_t; khiter_t; #define __ac_isempty(flag, i) … #define __ac_isdel(flag, i) … #define __ac_iseither(flag, i) … #define __ac_set_isdel_false(flag, i) … #define __ac_set_isempty_false(flag, i) … #define __ac_set_isboth_false(flag, i) … #define __ac_set_isdel_true(flag, i) … #define __ac_fsize(m) … #define kroundup32(x) … static inline khint_t __ac_X31_hash_string(const char *s) { … } #define kh_str_hash_func(key) … #define kh_str_hash_equal(a, b) … static const double __ac_HASH_UPPER = …; #define __KHASH_TYPE(name, khkey_t, khval_t) … #define __KHASH_PROTOTYPES(name, khkey_t, khval_t) … #define __KHASH_IMPL(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) … #define KHASH_DECLARE(name, khkey_t, khval_t) … #define KHASH_INIT2(name, SCOPE, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) … #define KHASH_INIT(name, khkey_t, khval_t, kh_is_map, __hash_func, __hash_equal) … /* Other convenient macros... */ /*! @function @abstract Test whether a bucket contains data. @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return 1 if containing data; 0 otherwise [int] */ #define kh_exist(h, x) … /*! @function @abstract Get key given an iterator @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return Key [type of keys] */ #define kh_key(h, x) … /*! @function @abstract Get value given an iterator @param h Pointer to the hash table [khash_t(name)*] @param x Iterator to the bucket [khint_t] @return Value [type of values] @discussion For hash sets, calling this results in segfault. */ #define kh_val(h, x) … /*! @function @abstract Alias of kh_val() */ #define kh_value(h, x) … /*! @function @abstract Get the start iterator @param h Pointer to the hash table [khash_t(name)*] @return The start iterator [khint_t] */ #define kh_begin(h) … /*! @function @abstract Get the end iterator @param h Pointer to the hash table [khash_t(name)*] @return The end iterator [khint_t] */ #define kh_end(h) … /*! @function @abstract Get the number of elements in the hash table @param h Pointer to the hash table [khash_t(name)*] @return Number of elements in the hash table [khint_t] */ #define kh_size(h) … /*! @function @abstract Get the number of buckets in the hash table @param h Pointer to the hash table [khash_t(name)*] @return Number of buckets in the hash table [khint_t] */ #define kh_n_buckets(h) … /*! @function @abstract Iterate over the entries in the hash table @param h Pointer to the hash table [khash_t(name)*] @param kvar Variable to which key will be assigned @param vvar Variable to which value will be assigned @param code Block of code to execute */ #define kh_foreach(h, kvar, vvar, code) … /*! @function @abstract Iterate over the values in the hash table @param h Pointer to the hash table [khash_t(name)*] @param vvar Variable to which value will be assigned @param code Block of code to execute */ #define kh_foreach_value(h, vvar, code) … static inline unsigned int oidhash_by_value(struct object_id oid) { … } static inline int oideq_by_value(struct object_id a, struct object_id b) { … } KHASH_INIT(oid_set, struct object_id, int, 0, oidhash_by_value, oideq_by_value) KHASH_INIT(oid_map, struct object_id, void *, 1, oidhash_by_value, oideq_by_value) KHASH_INIT(oid_pos, struct object_id, int, 1, oidhash_by_value, oideq_by_value) #endif /* __AC_KHASH_H */