ARB
Classes | Macros | Functions | Variables
adhash.cxx File Reference
#include "gb_data.h"
#include "gb_tune.h"
#include "gb_hashindex.h"
#include <arb_strbuf.h>
#include <arb_sort.h>
#include <climits>
#include <cfloat>
#include <cctype>
Include dependency graph for adhash.cxx:

Go to the source code of this file.

Classes

struct  gbs_hash_entry
 
struct  GB_HASH
 
struct  numhash_entry
 
struct  GB_NUMHASH
 

Macros

#define KNOWN_PRIMES   279
 

Functions

size_t gbs_get_a_prime (size_t above_or_equal_this)
 
size_t hash_size (size_t estimated_elements)
 
GB_HASHGBS_create_hash (long estimated_elements, GB_CASE case_sens)
 
GB_HASHGBS_create_dynaval_hash (long estimated_elements, GB_CASE case_sens, void(*freefun)(long))
 
void GBS_dynaval_free (long val)
 
void GBS_optimize_hash (const GB_HASH *hs)
 
static void gbs_hash_to_strstruct (const char *key, long val, void *cd_out)
 
charGBS_hashtab_2_string (const GB_HASH *hash)
 
static gbs_hash_entryfind_hash_entry (const GB_HASH *hs, const char *key, size_t *index)
 
long GBS_read_hash (const GB_HASH *hs, const char *key)
 
static void delete_from_list (GB_HASH *hs, size_t i, gbs_hash_entry *e)
 
static long write_hash (GB_HASH *hs, char *key, bool copyKey, long val)
 
long GBS_write_hash (GB_HASH *hs, const char *key, long val)
 
long GBS_write_hash_no_strdup (GB_HASH *hs, char *key, long val)
 
long GBS_incr_hash (GB_HASH *hs, const char *key)
 
static void GBS_erase_hash (GB_HASH *hs)
 
void GBS_free_hash (GB_HASH *hs)
 
void GBS_hash_do_loop (GB_HASH *hs, gb_hash_loop_type func, void *client_data)
 
void GBS_hash_do_const_loop (const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
 
size_t GBS_hash_elements (const GB_HASH *hs)
 
const charGBS_hash_next_element_that (const GB_HASH *hs, const char *last_key, bool(*condition)(const char *key, long val, void *cd), void *cd)
 
static int wrap_hashCompare4gb_sort (const void *v0, const void *v1, void *sorter)
 
static size_t get_sorted_hash_values (const GB_HASH *hs, gbs_hash_compare_function sorter, gbs_hash_entry **&mtab)
 
void GBS_hash_do_sorted_loop (GB_HASH *hs, gb_hash_loop_type func, gbs_hash_compare_function sorter, void *client_data)
 
void GBS_hash_do_const_sorted_loop (const GB_HASH *hs, gb_hash_const_loop_type func, gbs_hash_compare_function sorter, void *client_data)
 
int GBS_HCF_sortedByKey (const char *k0, long, const char *k1, long)
 
long gbs_numhash_index (long key, long size)
 
GB_NUMHASHGBS_create_numhash (size_t estimated_elements)
 
long GBS_read_numhash (GB_NUMHASH *hs, long key)
 
long GBS_write_numhash (GB_NUMHASH *hs, long key, long val)
 
static void GBS_erase_numhash (GB_NUMHASH *hs)
 
void GBS_free_numhash (GB_NUMHASH *hs)
 

Variables

static size_t sorted_primes [KNOWN_PRIMES]
 

Macro Definition Documentation

#define KNOWN_PRIMES   279

Definition at line 52 of file adhash.cxx.

Referenced by gbs_get_a_prime().

Function Documentation

size_t gbs_get_a_prime ( size_t  above_or_equal_this)

Definition at line 193 of file adhash.cxx.

References gb_assert, KNOWN_PRIMES, and sorted_primes.

Referenced by GB_create_index(), GBS_optimize_hash(), and hash_size().

size_t hash_size ( size_t  estimated_elements)
inline

Definition at line 245 of file adhash.cxx.

References gbs_get_a_prime().

Referenced by GBS_create_hash(), GBS_create_numhash(), GBT_begin_rename_session(), and GBT_open().

GB_HASH* GBS_create_hash ( long  estimated_elements,
GB_CASE  case_sens 
)

Create a hash

Parameters
estimated_elementsestimated number of elements added to hash (if you add more elements, hash will still work, but get slow)
case_sensGB_IGNORE_CASE or GB_MIND_CASE Uses linked lists to avoid collisions.

Definition at line 253 of file adhash.cxx.

References ARB_calloc(), GB_HASH::case_sens, GB_HASH::entries, GB_HASH::freefun, hash_size(), GB_HASH::nelem, NULp, and GB_HASH::size.

Referenced by an_get_prefix_hash(), arb_prm_primer(), aw_install_xkeys(), aw_question(), AW_xfig::AW_xfig(), AWT_translator::AWT_translator(), AWTC_pars_names(), ST_ML::calc_st_ml(), callDelay(), DI_MATRIX::compress(), ConsensusTree::ConsensusTree(), AW_xfig::create_gcs(), create_item_hash(), create_ref_hash(), MO_Liste::fill_marked_bakts(), g_bs_add_value_tag_to_hash(), gb_cache::gb_cache(), GB_DbScanner::GB_DbScanner(), gb_read_bin(), GB_remove_on_exit(), GBP_add_callback(), GBS_create_dynaval_hash(), GBS_merge_tagged_strings(), GBS_modify_tagged_string_with_ACI(), GBT_check_data(), GBT_link_tree_using_species_hash(), GDE_popup_filename_browser(), GEN_create_pseudo_species_hash(), GEN_testAndRemoveTranslations(), MO_Liste::get_all_species(), get_cached_taxonomy(), get_short(), getIcon(), BI_helix::initFromData(), AP_tree::mark_duplicates(), MatrixOrder::MatrixOrder(), mg_transfer_listed_species(), nt_add(), nt_add_partial(), nt_build_sai_string(), nt_create_configuration(), Package::Package(), PT_build_species_hash(), QUERY::search_duplicated_field_content(), Sondentopf::Sondentopf(), species_rename_join(), ST_Container::ST_Container(), AW_selection_list::to_hash(), and UniqueNameDetector::UniqueNameDetector().

GB_HASH* GBS_create_dynaval_hash ( long  estimated_elements,
GB_CASE  case_sens,
void(*)(long freefun 
)

like GBS_create_hash, but values stored in hash get freed using 'freefun' when hash gets destroyed

Definition at line 271 of file adhash.cxx.

References GB_HASH::freefun, and GBS_create_hash().

Referenced by aw_help_search(), QUERY::create_query_box(), DefinedCommands::DefinedCommands(), g_bs_get_string_of_tag_hash(), GBT_begin_rename_session(), get_cached_taxonomy(), and st_ml_check_sequence_quality().

void GBS_dynaval_free ( long  val)
void GBS_optimize_hash ( const GB_HASH hs)
static void gbs_hash_to_strstruct ( const char key,
long  val,
void *  cd_out 
)
static

Definition at line 357 of file adhash.cxx.

References GBS_chrcat(), and GBS_intcat().

Referenced by GBS_hashtab_2_string().

char* GBS_hashtab_2_string ( const GB_HASH hash)
static gbs_hash_entry* find_hash_entry ( const GB_HASH hs,
const char key,
size_t *  index 
)
static
long GBS_read_hash ( const GB_HASH hs,
const char key 
)

Definition at line 395 of file adhash.cxx.

References find_hash_entry(), and gbs_hash_entry::val.

Referenced by an_find_shrt_prefix(), ap_mark_duplicates_rek(), arb_reduce_primer_len(), are_not_in_tree(), AW_window::at(), AW_window::at_ifdef(), aw_create_shell(), AW_forget_all_window_geometry(), aw_help_search(), aw_question(), aw_xkey_2_awkey(), AW_root::awar_no_error(), AWTC_create_numbered_suffix(), awtc_mark_hits(), callDelay(), AWT_translator::codon2aa(), AP_tree::colorize(), compare_hits(), QUERY::copy_selection_list_2_query_box(), AW_xfig::create_gcs(), ST_ML::find_node_by_name(), find_SAI_candidates(), find_species_candidates(), flush_cache_entry(), g_bs_add_value_tag_to_hash(), gb_write_key(), GBP_add_callback(), GBP_remove_callback(), GBT_check_alignment(), GBT_check_data(), GBT_commit_rename_session(), gbt_link_tree_to_hash_rek(), GBT_remove_leafs(), GBT_rename_species(), gbt_rename_tree_rek(), GDE_popup_filename_browser(), GEN_find_origin_organism(), GEN_read_pseudo_species_from_hash(), DefinedCommands::get(), ST_Container::get_cached_sonde(), get_cached_taxonomy(), ST_ML::get_color_string(), MatrixOrder::get_index(), MO_Liste::get_index_by_entry(), ST_ML::get_ml_vectors(), get_short(), SpecSetRegistry::get_species_index(), get_taxonomy(), get_taxonomy_string(), getHitInfo(), getIcon(), BI_helix::initFromData(), key2quark(), MERGE_sequences_simple(), MG_export_fields(), MG_transfer_one_species(), MP_mark_probes_in_tree(), UniqueNameDetector::name_known(), Package::not_defined(), nt_build_conf_marked(), nt_extract_configuration(), perform_query_cb(), ptpd_read_names(), QUERY::search_duplicated_field_content(), AW_root::search_remote_command(), species_rename_join(), st_ml_add_quality_string_to_species(), st_ml_add_sequence_part_to_stat(), and ST_ML::update_ml_likelihood().

static void delete_from_list ( GB_HASH hs,
size_t  i,
gbs_hash_entry e 
)
static
static long write_hash ( GB_HASH hs,
char key,
bool  copyKey,
long  val 
)
static
long GBS_write_hash ( GB_HASH hs,
const char key,
long  val 
)

Definition at line 457 of file adhash.cxx.

References write_hash().

Referenced by UniqueNameDetector::add_name(), an_add_short(), an_remove_short(), ap_mark_duplicates_rek(), arb_reduce_primer_len(), aw_create_shell(), aw_help_search(), aw_question(), AW_xfig::AW_xfig(), AW_root::awar_float(), AW_root::awar_int(), AW_root::awar_pointer(), AW_root::awar_string(), build_taxonomy_rek(), ST_Container::cache_Sonde(), ST_ML::calc_st_ml(), callDelay(), CLEAR_QUERIED(), DI_MATRIX::compress(), ConsensusTree::ConsensusTree(), AW_xfig::create_gcs(), create_ref_hash(), AW_root::define_remote_command(), flush_cache_entry(), flush_taxonomy_cb(), GB_MAIN_TYPE::free_all_keys(), g_bs_add_value_tag_to_hash(), g_bs_read_tagged_hash(), gb_create_key(), GB_remove_on_exit(), gbcmc_read_keys(), GBP_add_callback(), GBP_remove_callback(), GBS_hash_do_sorted_loop(), GBT_add_item_to_hash(), GBT_check_alignment(), gbt_link_tree_to_hash_rek(), GBT_rename_species(), GDE_popup_filename_browser(), GEN_add_pseudo_species_to_hash(), Sondentopf::gen_color_hash(), get_cached_taxonomy(), get_short(), getIcon(), BI_helix::initFromData(), map_awXKey(), Package::mark_function_defined(), MERGE_sequences_simple(), MG_transfer_one_species(), nt_add(), nt_add_partial(), nt_build_conf_string_rek(), nt_build_sai_string(), NT_remove_species_in_tree_from_hash(), PT_build_species_hash(), MO_Liste::put_entry(), QUERY::search_duplicated_field_content(), DefinedCommands::set(), SET_QUERIED(), species_rename_join(), st_ml_add_sequence_part_to_stat(), AW_selection_list::to_hash(), and UniqueNameDetector::UniqueNameDetector().

long GBS_write_hash_no_strdup ( GB_HASH hs,
char key,
long  val 
)

Definition at line 462 of file adhash.cxx.

References write_hash().

Referenced by an_get_prefix_hash().

long GBS_incr_hash ( GB_HASH hs,
const char key 
)
static void GBS_erase_hash ( GB_HASH hs)
static
void GBS_free_hash ( GB_HASH hs)

Definition at line 541 of file adhash.cxx.

References GB_HASH::entries, gb_assert, and GBS_erase_hash().

Referenced by ARB_main(), arb_prm_primer(), aw_uninstall_xkeys(), AWTC_pars_names(), KeySorter::bubble_sort(), ST_ML::calc_st_ml(), ST_ML::cleanup(), probe_struct_global::cleanup(), DI_MATRIX::compress(), QUERY::copy_selection_list_2_query_box(), AW_xfig::create_gcs(), exit_removal(), find_SAI_candidates(), find_species_candidates(), free_cached_taxonomy(), g_bs_free_hash_of_hashes(), g_bs_free_hash_of_hashes_elem(), g_bs_get_string_of_tag_hash(), GBT_check_data(), gbt_free_rename_session_data(), GBT_link_tree(), GBT_link_tree_using_species_hash(), GEN_testAndRemoveTranslations(), getIcon(), BI_helix::initFromData(), insert_all_species_into_tree(), AP_tree::mark_duplicates(), mark_gene_species_of_marked_genes(), mark_genes_of_marked_gene_species(), MERGE_sequences_simple(), mg_transfer_listed_species(), nt_add(), nt_add_partial(), NT_alltree_remove_leafs(), nt_build_sai_string(), nt_create_configuration(), nt_extract_configuration(), NT_pseudo_species_to_organism(), perform_query_cb(), QUERY::search_duplicated_field_content(), species_rename_join(), st_ml_check_sequence_quality(), AW_root_Motif::~AW_root_Motif(), AW_xfig::~AW_xfig(), AWT_translator::~AWT_translator(), ConsensusTree::~ConsensusTree(), QUERY::DbQuery::~DbQuery(), DefinedCommands::~DefinedCommands(), EG2PS_data::~EG2PS_data(), gb_cache::~gb_cache(), GB_DbScanner::~GB_DbScanner(), GB_MAIN_TYPE::~GB_MAIN_TYPE(), MatrixOrder::~MatrixOrder(), MO_Liste::~MO_Liste(), Package::~Package(), Sondentopf::~Sondentopf(), SpecSetRegistry::~SpecSetRegistry(), ST_Container::~ST_Container(), ST_ML::~ST_ML(), and UniqueNameDetector::~UniqueNameDetector().

void GBS_hash_do_loop ( GB_HASH hs,
gb_hash_loop_type  func,
void *  client_data 
)
void GBS_hash_do_const_loop ( const GB_HASH hs,
gb_hash_const_loop_type  func,
void *  client_data 
)
size_t GBS_hash_elements ( const GB_HASH hs)
const char* GBS_hash_next_element_that ( const GB_HASH hs,
const char last_key,
bool(*)(const char *key, long val, void *cd)  condition,
void *  cd 
)
static int wrap_hashCompare4gb_sort ( const void *  v0,
const void *  v1,
void *  sorter 
)
static

Definition at line 608 of file adhash.cxx.

References gbs_hash_entry::key, and gbs_hash_entry::val.

Referenced by get_sorted_hash_values().

static size_t get_sorted_hash_values ( const GB_HASH hs,
gbs_hash_compare_function  sorter,
gbs_hash_entry **&  mtab 
)
static
void GBS_hash_do_sorted_loop ( GB_HASH hs,
gb_hash_loop_type  func,
gbs_hash_compare_function  sorter,
void *  client_data 
)

Definition at line 632 of file adhash.cxx.

References GBS_write_hash(), and get_sorted_hash_values().

Referenced by insert_all_species_into_tree().

void GBS_hash_do_const_sorted_loop ( const GB_HASH hs,
gb_hash_const_loop_type  func,
gbs_hash_compare_function  sorter,
void *  client_data 
)
int GBS_HCF_sortedByKey ( const char k0,
long  ,
const char k1,
long   
)
long gbs_numhash_index ( long  key,
long  size 
)
inline

Definition at line 663 of file adhash.cxx.

References long.

Referenced by GBS_read_numhash(), and GBS_write_numhash().

GB_NUMHASH* GBS_create_numhash ( size_t  estimated_elements)
long GBS_read_numhash ( GB_NUMHASH hs,
long  key 
)
long GBS_write_numhash ( GB_NUMHASH hs,
long  key,
long  val 
)
static void GBS_erase_numhash ( GB_NUMHASH hs)
static
void GBS_free_numhash ( GB_NUMHASH hs)

Definition at line 745 of file adhash.cxx.

References GB_NUMHASH::entries, and GBS_erase_numhash().

Referenced by aw_uninstall_xkeys(), and GB_MAIN_TYPE::~GB_MAIN_TYPE().

Variable Documentation

size_t sorted_primes[KNOWN_PRIMES]
static
Initial value:
= {
3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 47, 53, 59, 67, 71, 79, 89, 97, 103, 109, 127, 137, 149, 157, 167, 179, 191, 211,
223, 239, 257, 271, 293, 311, 331, 349, 373, 397, 419, 443, 467, 499, 541, 571, 607, 641, 677, 719, 757, 797, 839, 887, 937,
991, 1049, 1109, 1171, 1237, 1303, 1373, 1447, 1531, 1613, 1699, 1789, 1889, 1993, 2099, 2213, 2333, 2459, 2591, 2729, 2879,
3037, 3203, 3373, 3557, 3761, 3967, 4177, 4397, 4637, 4889, 5147, 5419, 5711, 6029, 6353, 6689, 7043, 7417, 7817, 8231, 8669,
9127, 9613, 10133, 10667, 11239, 11831, 12457, 13121, 13829, 14557, 15329, 16139, 16993, 17891, 18839, 19841, 20887, 21991, 23159,
24379, 25667, 27031, 28463, 29983, 31567, 33247, 35023, 36871, 38821, 40867, 43019, 45289, 47681, 50207, 52859, 55661, 58601,
61687, 64937, 68371, 71971, 75767, 79757, 83969, 88397, 93053, 97961, 103123, 108553, 114269, 120293, 126631, 133303, 140321,
147709, 155501, 163697, 172313, 181387, 190979, 201031, 211619, 222773, 234499, 246889, 259907, 273601, 288007, 303187, 319147,
335953, 353641, 372263, 391861, 412487, 434201, 457057, 481123, 506449, 533111, 561173, 590713, 621821, 654553, 689021, 725293,
763471, 803659, 845969, 890501, 937373, 986717, 1038671, 1093357, 1150909, 1211489, 1275269, 1342403, 1413077, 1487459, 1565747,
1648181, 1734937, 1826257, 1922383, 2023577, 2130101, 2242213, 2360243, 2484473, 2615243, 2752889, 2897789, 3050321, 3210871,
3379877, 3557773, 3745051, 3942209, 4149703, 4368113, 4598063, 4840103, 5094853, 5363011, 5645279, 5942399, 6255157, 6584377,
6930929, 7295719, 7679713, 8083919, 8509433, 8957309, 9428759, 9925021, 10447391, 10997279, 11576087, 12185359, 12826699, 13501819,
14212447, 14960471, 15747869, 16576727, 17449207, 18367597, 19334317, 20351927, 21423107, 22550639, 23737523, 24986867, 26301967,
27686291, 29143493, 30677363, 32291971, 33991597, 35780639, 37663841, 39646153, 41732809, 43929307, 46241389, 48675167, 51237019,
53933713, 56772371, 59760391, 62905681, 66216511, 69701591, 73370107, 77231711, 81296543, 85575313, 90079313, 94820347, 99810899
}

Definition at line 53 of file adhash.cxx.

Referenced by gbs_get_a_prime().