[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Hashes/Dicts in C

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 14
Thread images: 1

File: 1468479317182.jpg (38KB, 300x250px) Image search: [Google]
1468479317182.jpg
38KB, 300x250px
/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?
Thread posts: 14
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.