/usr/include/globus/globus_hashtable.h is in libglobus-common-dev 14.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | /*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GLOBUS_COMMON_HASHTABLE_H
#define GLOBUS_COMMON_HASHTABLE_H
/********************************************************************
*
* This file defines the globus_hashtable_t type,
* a lightweight chaining hashtable
*
*
********************************************************************/
#include "globus_common_include.h"
#include "globus_list.h"
EXTERN_C_BEGIN
/**
* Hash function. User result must be modulo limit
*/
typedef int
(*globus_hashtable_hash_func_t)(
void * key,
int limit);
/**
* Comparator function. 0 if not equal, non-zero if equal
*/
typedef int
(*globus_hashtable_keyeq_func_t)(
void * key1,
void * key2);
/**
* datum copy func
*/
typedef void
(*globus_hashtable_copy_func_t)(
void ** dest_key,
void ** dest_datum,
void * src_key,
void * src_datum);
/**
* Destructor callback for use with globus_hashtable_destroy_all
*/
typedef void
(*globus_hashtable_destructor_func_t)(
void * datum);
typedef struct globus_l_hashtable_s * globus_hashtable_t;
/**
* Initialize hashtable with a bucket count of size, using hash_func for
* hashing and keyeq_func for comparison
*/
int
globus_hashtable_init(
globus_hashtable_t * table,
int size,
globus_hashtable_hash_func_t hash_func,
globus_hashtable_keyeq_func_t keyeq_func);
/**
* Initialize dest_table and copy src_table into it. copy_func is called for
* each datum in src_table. if copy_func is null, dest will contain same
* values as src. does not duplicate ordering of entries in src_table.
*/
int
globus_hashtable_copy(
globus_hashtable_t * dest_table,
globus_hashtable_t * src_table,
globus_hashtable_copy_func_t copy_func);
/**
* Lookup datum associated with key. NULL if not found
*/
void *
globus_hashtable_lookup(
globus_hashtable_t * table,
void * key);
/**
* Insert new key->datum association. key must not already exist and datum
* must be non-null. If key is non-scalar (ie, string), it should be part of
* datum so its resources may be recovered.
*/
int
globus_hashtable_insert(
globus_hashtable_t * table,
void * key,
void * datum);
/**
* Update an existing key->datum association with new values for both, key and
* datum. The old datum is returned. If key is non-scalar (ie, string),
* it should be part of datum so its resources may be recovered. If old key
* does not exist, NULL is returned.
*/
void *
globus_hashtable_update(
globus_hashtable_t * table,
void * key,
void * datum);
/**
* Remove entry associated with key. Old datum is returned. NULL if not found
*/
void *
globus_hashtable_remove(
globus_hashtable_t * table,
void * key);
/**
* Create a list of all datums in hashtable
*/
int
globus_hashtable_to_list(
globus_hashtable_t * table,
globus_list_t ** list);
/**
* GLOBUS_TRUE if hashtable is empty, GLOBUS_FALSE otherwise
*/
globus_bool_t
globus_hashtable_empty(
globus_hashtable_t * table);
/**
* returns number of entries in hashtable
*/
int
globus_hashtable_size(
globus_hashtable_t * table);
/**
* For the following, the iterator is initially NULL until one of
* globus_hashtable_first or globus_hashtable_last has been called. All other
* calls have no effect on iterator except for globus_hashtable_remove. If
* the iterator points at the entry being removed, the iterator is moved to
* the next entry.
*
* Once an 'end' has been reached with globus_hashtable_next or
* globus_hashtable_prev, the iterator must again be reset with
* globus_hashtable_first or globus_hashtable_last
*/
/**
* set iterator to first entry and return datum, NULL if empty
*/
void *
globus_hashtable_first(
globus_hashtable_t * table);
/**
* set iterator to next entry and return datum, NULL if at end
*/
void *
globus_hashtable_next(
globus_hashtable_t * table);
/**
* set iterator to last entry and return datum, NULL if empty
*/
void *
globus_hashtable_last(
globus_hashtable_t * table);
/**
* set iterator to prev entry and return datum, NULL if at beginning
*/
void *
globus_hashtable_prev(
globus_hashtable_t * table);
/**
* Free all memory allocated by hashtable. If the datums that were inserted
* are non-scalar, you should use globus_hashtable_destroy_all to allow freeing
* of any remaining entries.
*/
int
globus_hashtable_destroy(
globus_hashtable_t * table);
/**
* Free all memory associated with hashtable. element_free will be called on
* each remaining datum in the table.
*/
void
globus_hashtable_destroy_all(
globus_hashtable_t * table,
globus_hashtable_destructor_func_t element_free);
/**
* Predefined hash/eq functions for common data types
*/
int
globus_hashtable_string_hash(
void * string,
int limit);
int
globus_hashtable_string_keyeq(
void * string1,
void * string2);
int
globus_hashtable_voidp_hash(
void * voidp,
int limit);
int
globus_hashtable_voidp_keyeq(
void * voidp1,
void * voidp2);
int
globus_hashtable_int_hash(
void * integer,
int limit);
int
globus_hashtable_int_keyeq(
void * integer1,
void * integer2);
int
globus_hashtable_ulong_hash(
void * integer,
int limit);
int
globus_hashtable_ulong_keyeq(
void * integer1,
void * integer2);
EXTERN_C_END
#endif /* GLOBUS_COMMON_HASHTABLE_H */
|