📄 stdhash.h
字号:
/* Copyright (c) 2000, The Johns Hopkins University * All rights reserved. * * The contents of this file are subject to a license (the ``License'') * that is the exact equivalent of the BSD license as of July 23, 1999. * You may not use this file except in compliance with the License. The * specific language governing the rights and limitations of the License * can be found in the file ``STDUTIL_LICENSE'' found in this * distribution. * * Software distributed under the License is distributed on an AS IS * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. * * The Original Software is: * The Stdutil Library * * Contributors: * Creator - John Lane Schultz (jschultz@cnds.jhu.edu) * The Center for Networking and Distributed Systems * (CNDS - http://www.cnds.jhu.edu) */ #ifndef stdhash_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu#define stdhash_h_2000_02_14_16_22_38_jschultz_at_cnds_jhu_edu#include "stdutil.h"/* defined in stdutil.h: only if all the necessary types exist can you use stdhash */#ifdef STDRAND_EXISTS /* static initializers with no safety checks */# define STDHASH_STATIC_CONSTRUCT(sizeof_key, sizeof_val, stdequals_fcn, stdhcode_fcn)# define STDHASH_STATIC_CONSTRUCT2(sizeof_key, sizeof_val, stdequals_fcn, stdhcode_fcn, dseed)# include "stddefines.h"# include "stdkvp.h"# include "stdhash_p.h"# ifdef __cplusplusextern "C" {# endif/* stdhash_it: must first be initialized by a stdhash iterator fcn (see below) */extern inline void *stdhash_it_key(const stdhash_it *it);extern inline void *stdhash_it_val(const stdhash_it *it);extern inline stdkvp *stdhash_it_kvp(const stdhash_it *it);extern inline stdbool stdhash_it_equals(const stdhash_it *it1, const stdhash_it *it2);extern inline stdbool stdhash_it_is_begin(const stdhash_it *it);extern inline stdbool stdhash_it_is_end(const stdhash_it *it);extern inline stdhash_it *stdhash_it_seek_begin(stdhash_it *it);extern inline stdhash_it *stdhash_it_seek_end(stdhash_it *it);extern inline stdhash_it *stdhash_it_next(stdhash_it *it);extern inline stdhash_it *stdhash_it_advance(stdhash_it *it, size_t num_advance);extern inline stdhash_it *stdhash_it_prev(stdhash_it *it);extern inline stdhash_it *stdhash_it_retreat(stdhash_it *it, size_t num_retreat);extern inline stdhash_it *stdhash_it_keyed_next(stdhash_it *it);/* stdhash *//* Constructors, Destructor */extern inline int stdhash_construct(stdhash *h, size_t sizeof_key, size_t sizeof_val, stdequals_fcn key_eq, stdhcode_fcn key_hcode);extern inline int stdhash_construct2(stdhash *h, size_t sizeof_key, size_t sizeof_val, stdequals_fcn key_eq, stdhcode_fcn key_hcode, size_t dseed);extern inline int stdhash_copy_construct(stdhash *dst, const stdhash *src);extern inline void stdhash_destruct(stdhash *h);/* Iterator Interface */extern inline stdhash_it *stdhash_begin(const stdhash *h, stdhash_it *it);extern inline stdhash_it *stdhash_last(const stdhash *h, stdhash_it *it);extern inline stdhash_it *stdhash_end(const stdhash *h, stdhash_it *it);extern inline stdhash_it *stdhash_get(const stdhash *h, stdhash_it *it, size_t elem_num);/* Size and Capacity Information */extern inline size_t stdhash_size(const stdhash *h);extern inline stdbool stdhash_empty(const stdhash *h);extern inline size_t stdhash_max_size(const stdhash *h);extern inline size_t stdhash_key_size(const stdhash *h);extern inline size_t stdhash_val_size(const stdhash *h);extern inline size_t stdhash_kvp_size(const stdhash *h);/* Size and Capacity Operations */extern inline int stdhash_clear(stdhash *h);extern inline int stdhash_reserve(stdhash *h, size_t num_elems);extern inline int stdhash_rehash(stdhash *h);/* Hash Operations: O(1) expected, O(n) worst case */extern inline stdhash_it *stdhash_find(const stdhash *h, stdhash_it *it, const void *key);extern inline stdhash_it *stdhash_insert(stdhash *h, stdhash_it *it, const void *key, const void *val);extern inline stdhash_it *stdhash_erase(stdhash_it *erase);extern inline int stdhash_erase_key(stdhash *h, const void *key);/* Equals and hashcode function pairs for commonly used key types *//* key type is int or uint */stdbool stdhash_int_equals(const void *int1, const void *int2);size_t stdhash_int_hashcode(const void *kint);/* key type is a C string (key type is pointer to a null terminated array of characters) */stdbool stdhash_str_equals(const void *str_ptr1, const void *str_ptr2);size_t stdhash_str_hashcode(const void *str_ptr);# ifdef __cplusplus}# endif#endif /* ifdef STDRAND_EXISTS */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -