Path: blob/master/libs/fluidsynth/src/utils/fluid_hash.h
4396 views
/* GLIB - Library of useful routines for C programming1* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald2*3* This library is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2 of the License, or (at your option) any later version.7*8* This library is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with this library; if not, write to the15* Free Software Foundation, Inc., 59 Temple Place - Suite 330,16* Boston, MA 02110-1301, USA.17*/1819/*20* Modified by the GLib Team and others 1997-2000. See the AUTHORS21* file for a list of people on the GLib Team. See the ChangeLog22* files for a list of changes. These files are distributed with23* GLib at ftp://ftp.gtk.org/pub/gtk/.24*/2526/*27* Adapted for FluidSynth use by Josh Green <[email protected]>28* September 8, 2009 from glib 2.18.429*30* - Self contained (no dependencies on glib)31* - changed names to fluid_hashtable_...32*/3334#ifndef _FLUID_HASH_H35#define _FLUID_HASH_H3637#include "fluidsynth_priv.h"38#include "fluid_list.h"39#include "fluid_sys.h"4041/* Extracted from gtypes.h */42typedef void (*fluid_destroy_notify_t)(void *data);43typedef unsigned int (*fluid_hash_func_t)(const void *key);44typedef int (*fluid_equal_func_t)(const void *a, const void *b);45/* End gtypes.h extraction */4647typedef int (*fluid_hr_func_t)(void *key, void *value, void *user_data);48typedef struct _fluid_hashtable_iter_t fluid_hashtable_iter_t;4950typedef struct _fluid_hashnode_t fluid_hashnode_t;5152struct _fluid_hashnode_t53{54void *key;55void *value;56fluid_hashnode_t *next;57unsigned int key_hash;58};5960struct _fluid_hashtable_t61{62int size;63int nnodes;64fluid_hashnode_t **nodes;65fluid_hash_func_t hash_func;66fluid_equal_func_t key_equal_func;67fluid_atomic_int_t ref_count;68fluid_destroy_notify_t key_destroy_func;69fluid_destroy_notify_t value_destroy_func;70fluid_rec_mutex_t mutex; // Optionally used in other modules (fluid_settings.c for example)71};7273struct _fluid_hashtable_iter_t74{75/*< private >*/76void *dummy1;77void *dummy2;78void *dummy3;79int dummy4;80int dummy5; // Bool81void *dummy6;82};8384fluid_hashtable_t *new_fluid_hashtable(fluid_hash_func_t hash_func,85fluid_equal_func_t key_equal_func);86fluid_hashtable_t *new_fluid_hashtable_full(fluid_hash_func_t hash_func,87fluid_equal_func_t key_equal_func,88fluid_destroy_notify_t key_destroy_func,89fluid_destroy_notify_t value_destroy_func);90void delete_fluid_hashtable(fluid_hashtable_t *hashtable);9192void fluid_hashtable_iter_init(fluid_hashtable_iter_t *iter, fluid_hashtable_t *hashtable);93int fluid_hashtable_iter_next(fluid_hashtable_iter_t *iter, void **key, void **value);94fluid_hashtable_t *fluid_hashtable_iter_get_hash_table(fluid_hashtable_iter_t *iter);95void fluid_hashtable_iter_remove(fluid_hashtable_iter_t *iter);96void fluid_hashtable_iter_steal(fluid_hashtable_iter_t *iter);9798fluid_hashtable_t *fluid_hashtable_ref(fluid_hashtable_t *hashtable);99void fluid_hashtable_unref(fluid_hashtable_t *hashtable);100101void *fluid_hashtable_lookup(fluid_hashtable_t *hashtable, const void *key);102int fluid_hashtable_lookup_extended(fluid_hashtable_t *hashtable, const void *lookup_key,103void **orig_key, void **value);104105void fluid_hashtable_insert(fluid_hashtable_t *hashtable, void *key, void *value);106void fluid_hashtable_replace(fluid_hashtable_t *hashtable, void *key, void *value);107108int fluid_hashtable_remove(fluid_hashtable_t *hashtable, const void *key);109int fluid_hashtable_steal(fluid_hashtable_t *hashtable, const void *key);110void fluid_hashtable_remove_all(fluid_hashtable_t *hashtable);111void fluid_hashtable_steal_all(fluid_hashtable_t *hashtable);112unsigned int fluid_hashtable_foreach_steal(fluid_hashtable_t *hashtable,113fluid_hr_func_t func, void *user_data);114void fluid_hashtable_foreach(fluid_hashtable_t *hashtable, fluid_hr_func_t func,115void *user_data);116void *fluid_hashtable_find(fluid_hashtable_t *hashtable, fluid_hr_func_t predicate,117void *user_data);118unsigned int fluid_hashtable_size(fluid_hashtable_t *hashtable);119fluid_list_t *fluid_hashtable_get_keys(fluid_hashtable_t *hashtable);120fluid_list_t *fluid_hashtable_get_values(fluid_hashtable_t *hashtable);121122int fluid_str_equal(const void *v1, const void *v2);123unsigned int fluid_str_hash(const void *v);124int fluid_direct_equal(const void *v1, const void *v2);125unsigned int fluid_direct_hash(const void *v);126int fluid_int_equal(const void *v1, const void *v2);127unsigned int fluid_int_hash(const void *v);128129#endif /* _FLUID_HASH_H */130131132