/g/entlemen please help a nigga out.
I want to learn some C/C++ and I'm doing well with the basics. However what I'm having difficultly wrapping my head around is the use of hashes/dictionary structures
I write mostly in Perl or Python and the hash structure is my bread and butter. Especially using mutliple keys like this
# perl
my ($name,$status,$gender) = @row;
$hash{$gender}{$status}{$name}++;
# advantages
my $males = keys %{$hash{"Male"}};
my $affectedMale = keys %{$hash{"Male"}{"AFF"}};
Is there a simply way to construct the Perl hash structure in C? Or how do you solve a problem like this in C if Perl hashes is not the way?
I'm a biologist in training so I'm sorry if I come off as naive. :3
>>57940163
you implement them yourself from scratch
>>57940163
use glib
https://developer.gnome.org/glib/2.50/glib-Hash-Tables.html
>>57940193
I don't get it. Use an array with a key->value pair?
>>57940163
c++ has std::map
how come you wanted to use C
>>57940235
>>57940207
thank you
>>57940241
faster and there is the htslib resource for BAM files
In C++, the standard template library has an implementation of a hash table in std::unordered_map. Most implementations are inefficient, however, so an ideal alternative is google dense hash map.
In C, the standard library does not include any abstract data structures, so you will have to implement them all yourself, or use a third party library. I would STRONGLY recommend learning how a hash table is implemented in the first place, especially if you find yourself needing features not available in your third party library. If you feel lazy, the best library I know of for this task is klib, which allows for some generic programming by using macros.
>>57940163
Just use Rust. C++ is deprecated, not to even speak of C.
>>57940316
>tripfag
>retarded
POTTERY
>>57940340
>C++ is deprecated,
kek all the best programs in bioinformatics are written in C,C++ or Java
>>57940364
were*
decades ago*
>>57940340
> JUST USE RUST BECAUSE IT'S CURRENT YEAR. MUUH SECURITY MUUH FUNCTIONAL MUUUH ZERO COST ABSTRACTIONS MUUUH CARGO MUUUH XDDDDDDDDDDDDDDDDDDDD LOLOLOL
Just end yourself.
>>57940594
>If I say good thing about a language it will surely put people off of it
Huh?