#ifndef _biregistry_h_
#define _biregistry_h_

#include "sysdep.h"
#include "bool.h"
#include "darray.h"
#include "registry.h"

typedef struct Biregistry_st *Biregistry;

#ifdef __STDC__
extern Biregistry Biregistry_create(Registry_CompareFunc, Registry_HashFunc, Registry_CompareFunc, Registry_HashFunc);
extern NORET Biregistry_size_hint(Biregistry, unsigned int);
extern Bool Biregistry_add(Biregistry, VOIDP, VOIDP);
extern Bool Biregistry_remove(Biregistry, CONSTVOIDP);
extern VOIDP Biregistry_get(Biregistry, CONSTVOIDP);
extern Bool Biregistry_rev_remove(Biregistry, CONSTVOIDP);
extern VOIDP Biregistry_rev_get(Biregistry, CONSTVOIDP);
extern NORET Biregistry_traverse(Biregistry, Registry_ActionProc, VOIDP);
extern unsigned int Biregistry_entry_count(Biregistry);
extern NORET Biregistry_fetch_contents(Biregistry, Darray, Darray);
extern NORET Biregistry_destroy(Biregistry);
#else
extern Biregistry Biregistry_create();
extern NORET Biregistry_size_hint();
extern int Biregistry_add();
extern int Biregistry_remove();
extern VOIDP Biregistry_get();
extern int Biregistry_rev_remove();
extern VOIDP Biregistry_rev_get();
extern NORET Biregistry_traverse();
extern unsigned int Biregistry_entry_count();
extern NORET Biregistry_fetch_contents();
extern NORET Biregistry_destroy();
extern int Biregistry_ptrcmp();
extern unsigned int Biregistry_ptrhash();
extern int Biregistry_strcmp();
extern unsigned int Biregistry_strhash();
#endif /* __STDC__ */


/* 
 * Biregistry_create(compare_func1, hash_func1, compare_func2, hash_func2)
 * Creates and returns an empty biregistry.  compare_func1, compare_func2, 
 * hash_func1, and hash_func2 are used as in Registry_create().
 * The functions Registry_strcmp, Registry_strhash, etc. can be used
 * here as well.
 * 
 * Biregistry_size_hint(biregistry, size_hint_value)
 * The Biregistry may operate more efficiently if this operator is called
 * and size_hint is close to the maximum number of elements to be in 
 * the Biregistry, at the possible cost of additional memory use.  Likely
 * to be effective only on an empty Biregistry.
 * 
 * Biregistry_add(biregistry, key, value)
 * Adds the association between key and value to the biregistry.  Neither
 * key nor value are copied, and neither may be freed before being removed
 * from the biregistry.  Neither the key nor the value should be modified
 * in a way that would change the value of the corresponding compare_func
 * or hash_func.  Will return Bool_FALSE if an association with the 
 * same key or the same value is already in the biregistry (in which case 
 * the add will not be performed), Bool_TRUE otherwise (on successful 
 * completion).
 * 
 * Biregistry_remove(biregistry, key)
 * Removes the association with key from the biregistry.  Returns Bool_FALSE
 * if no such association exists, Bool_TRUE otherwise (on successful
 * completion) 
 *
 * Biregistry_get(biregistry, key)
 * Returns the value associated with key in the biregistry.  Returns NULL
 * if there is no such association.
 * 
 * Biregistry_rev_remove(biregistry, value)
 * Removes the association with value from the biregistry.  Returns Bool_FALSE
 * if no such association exists, Bool_TRUE otherwise (on successful
 * completion) 
 *
 * Biregistry_rev_get(biregistry, value)
 * Returns the key associated with value in the biregistry.  Returns NULL
 * if there is no such association.
 * 
 * Biregistry_traverse(biregistry, action_proc, private_pointer)
 * Calls action_proc once for each entry in the biregistry.  private_pointer
 * is a VOIDP which is passed to the action_proc, but not otherwise used.
 * action_proc should not modify the biregistry in any way.  action_proc takes
 * three arguments, the key, the value, and private_pointer.  
 * 
 * Biregistry_entry_count(biregistry)
 * Returns the number of associations in the biregistry.
 *
 * Biregistry_fetch_contents(biregistry, key_darray, value_darray)
 * Stores the contents of the biregistry as follows:  In no particular 
 * order, each association is processed in turn by storing (using Darray_addh)
 * the key into key_darray and the value into value_darray.  Either 
 * or both key_darray and/or value_darray may be NULL, in which case
 * the corresponding data will not be processed.  Actual Darrays passed
 * (not NULL) must be empty.  Any objects added to key_darray must be 
 * treated as described in the description of Biregistry_add (i.e. not 
 * modified)
 * 
 * Biregistry_destroy(biregistry)
 * Deallocates all resources used by the biregistry.  Should be the last
 * operation performed on the biregistry.  Does not deallocate the objects
 * (keys and values) contained in the biregistry (this should be done after 
 * the biregistry is destroyed).
 */
#endif /* _resgistry_h_ */
