diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2014-03-04 13:19:00 -0500 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2014-03-04 13:19:00 -0500 |
commit | a14b311161676703eb14c6ede8f8f440dadcf875 (patch) | |
tree | 6809be018c86f2900bf0b7c5def1f18ecea6f9aa | |
parent | 3c94f327bdafc8ffc9fce53c578fde7102475088 (diff) |
use iterator for non zero... wayy faster
-rw-r--r-- | kmer_utils.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/kmer_utils.c b/kmer_utils.c index c46e580..bc78999 100644 --- a/kmer_utils.c +++ b/kmer_utils.c @@ -363,19 +363,16 @@ void print_kmer(kmer_map *counts, bool label, bool nonzero, unsigned int kmer) { if(nonzero) { // if labels is set, print out our labels if(label) { - for(i = 0; i < width; i++) - if(counts->count(i) != 0) { - char *kmer_str = index_to_kmer(i, kmer); - fprintf(stdout, "%s\t%llu\n", kmer_str, counts->at(i)); - free(kmer_str); - } - + for(auto it = counts->begin(); it != counts->end(); it++ ) { + char *kmer_str = index_to_kmer(it->first, kmer); + fprintf(stdout, "%s\t%llu\n", kmer_str, it->second); + free(kmer_str); + } } else { - for(i = 0; i < width; i++) - if(counts->count(i) != 0) - fprintf(stdout, "%zu\t%llu\n", i, counts->at(i)); - + for(auto it = counts->begin(); it != counts->end(); it++ ) { + fprintf(stdout, "%zu\t%llu\n", it->first, it->second); + } } } // If we aren't printing nonzeros print everything |