in reply to Re^4: foreach to for (related to my last question)
in thread foreach to for (related to my last question)
OK, then, when you translate it to C++, make your life simpler and use STL. Then you'll find that your hashes, vectors and foreach loops translate fairly easily:
Also, what I've shown isn't great STL. There are functors and predicates that let you do things like map and grep. Give it a try. You'll find that it makes C++ much nicer. (Though it does take a bit of time to wrap your head around it when you start.)vector<X> aas; vector<X>::iterator aa; map<K,V> SEQ; map<K,V>::iterator seq; vector<Z> codons; vector<Z>::iterator codon; for (aa=aas.begin(); aa!=aas.end(); ++aa) { for (seq=SEQ.begin(); seq!=SEQ.end(); ++seq) { for (codon=codons.begin(); codon!=codons.end(); ++codon) { ... do something ... } } }
--roboticus
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: foreach to for (related to my last question)
by ikegami (Patriarch) on Jun 23, 2006 at 00:01 UTC | |
by roboticus (Chancellor) on Jun 23, 2006 at 00:07 UTC |