File: adhashtools.cxx

package info (click to toggle)
arb 6.0.2-1%2Bdeb8u1
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie
  • size: 65,916 kB
  • ctags: 53,258
  • sloc: ansic: 394,903; cpp: 250,252; makefile: 19,620; sh: 15,878; perl: 10,461; fortran: 6,019; ruby: 683; xml: 503; python: 53; awk: 32
file content (50 lines) | stat: -rw-r--r-- 2,026 bytes parent folder | download | duplicates (6)
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
// =============================================================== //
//                                                                 //
//   File      : adhashtools.cxx                                   //
//   Purpose   : convenience functions for hashes                  //
//                                                                 //
//   Institute of Microbiology (Technical University Munich)       //
//   http://www.arb-home.de/                                       //
//                                                                 //
// =============================================================== //

#include "gb_local.h"
#include "arbdbt.h"

static void GBT_add_item_to_hash(GBDATA *gb_item, GB_HASH *item_hash) {
    GBS_write_hash(item_hash, GBT_read_name(gb_item), (long)gb_item);
}

typedef GBDATA *(*item_iterator)(GBDATA *);

static GB_HASH *create_item_hash(long size, GBDATA *gb_start, item_iterator getFirst, item_iterator getNext) {
    GB_HASH *item_hash = GBS_create_hash(size, GB_IGNORE_CASE);
    GBDATA  *gb_item;

    for (gb_item = getFirst(gb_start); gb_item; gb_item = getNext(gb_item)) {
        GBT_add_item_to_hash(gb_item, item_hash);
    }

    return item_hash;
}

GB_HASH *GBT_create_species_hash_sized(GBDATA *gb_main, long species_count) {
    return create_item_hash(species_count, gb_main, GBT_first_species, GBT_next_species);
}

GB_HASH *GBT_create_species_hash(GBDATA *gb_main) {
    return GBT_create_species_hash_sized(gb_main, GBT_get_species_count(gb_main));
}

GB_HASH *GBT_create_marked_species_hash(GBDATA *gb_main) {
    return create_item_hash(GBT_get_species_count(gb_main), gb_main, GBT_first_marked_species, GBT_next_marked_species);
}

GB_HASH *GBT_create_SAI_hash(GBDATA *gb_main) {
    return create_item_hash(GBT_get_SAI_count(gb_main), gb_main, GBT_first_SAI, GBT_next_SAI);
}

GB_HASH *GBT_create_organism_hash(GBDATA *gb_main) {
    return create_item_hash(GEN_get_organism_count(gb_main), gb_main, GEN_first_organism, GEN_next_organism);
}