ARB
adhashtools.cxx
Go to the documentation of this file.
1 // =============================================================== //
2 // //
3 // File : adhashtools.cxx //
4 // Purpose : convenience functions for hashes //
5 // //
6 // Institute of Microbiology (Technical University Munich) //
7 // http://www.arb-home.de/ //
8 // //
9 // =============================================================== //
10 
11 #include "gb_local.h"
12 #include "arbdbt.h"
13 
14 static void GBT_add_item_to_hash(GBDATA *gb_item, GB_HASH *item_hash) {
15  const char *name = GBT_get_name(gb_item);
16  if (name) GBS_write_hash(item_hash, name, (long)gb_item);
17 }
18 
19 typedef GBDATA *(*item_iterator)(GBDATA *);
20 
21 static GB_HASH *create_item_hash(long size, GBDATA *gb_start, item_iterator getFirst, item_iterator getNext) {
22  GB_HASH *item_hash = GBS_create_hash(size, GB_IGNORE_CASE);
23  GBDATA *gb_item;
24 
25  for (gb_item = getFirst(gb_start); gb_item; gb_item = getNext(gb_item)) {
26  GBT_add_item_to_hash(gb_item, item_hash);
27  }
28 
29  return item_hash;
30 }
31 
33  return create_item_hash(species_count, gb_main, GBT_first_species, GBT_next_species);
34 }
35 
37  return GBT_create_species_hash_sized(gb_main, GBT_get_species_count(gb_main));
38 }
39 
42 }
43 
46 }
47 
50 }
51 
long GEN_get_organism_count(GBDATA *gb_main)
Definition: adGene.cxx:756
GBDATA * GBT_first_SAI(GBDATA *gb_main)
Definition: aditem.cxx:162
GBDATA * GBT_first_marked_species(GBDATA *gb_main)
Definition: aditem.cxx:113
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
Definition: adhash.cxx:454
GB_HASH * GBT_create_organism_hash(GBDATA *gb_main)
Definition: adhashtools.cxx:48
long GBT_get_SAI_count(GBDATA *gb_main)
Definition: aditem.cxx:211
static void GBT_add_item_to_hash(GBDATA *gb_item, GB_HASH *item_hash)
Definition: adhashtools.cxx:14
GBDATA * GBT_next_marked_species(GBDATA *gb_species)
Definition: aditem.cxx:116
GB_HASH * GBT_create_species_hash_sized(GBDATA *gb_main, long species_count)
Definition: adhashtools.cxx:32
GBDATA * GEN_next_organism(GBDATA *gb_organism)
Definition: adGene.cxx:745
GB_HASH * GBT_create_species_hash(GBDATA *gb_main)
Definition: adhashtools.cxx:36
GBDATA * GBT_next_SAI(GBDATA *gb_sai)
Definition: aditem.cxx:166
GBDATA * GBT_first_species(GBDATA *gb_main)
Definition: aditem.cxx:124
GBDATA * GBT_next_species(GBDATA *gb_species)
Definition: aditem.cxx:128
GB_HASH * GBT_create_SAI_hash(GBDATA *gb_main)
Definition: adhashtools.cxx:44
const char * GBT_get_name(GBDATA *gb_item)
Definition: aditem.cxx:468
GBDATA *(* item_iterator)(GBDATA *)
Definition: adhashtools.cxx:19
long GBT_get_species_count(GBDATA *gb_main)
Definition: aditem.cxx:207
GBDATA * gb_main
Definition: adname.cxx:32
GBDATA * GEN_first_organism(GBDATA *gb_main)
Definition: adGene.cxx:739
static GB_HASH * create_item_hash(long size, GBDATA *gb_start, item_iterator getFirst, item_iterator getNext)
Definition: adhashtools.cxx:21
GB_HASH * GBT_create_marked_species_hash(GBDATA *gb_main)
Definition: adhashtools.cxx:40
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)
Definition: adhash.cxx:253