Apr 4, 2013 at 5:52pm UTC
I have to iterate through a txt file with 370,000+ words, which data structure would you guys recommend? I started using a map<string,string> but it takes about 50 seconds to iterate through the whole thing.
Apr 4, 2013 at 5:57pm UTC
What is it you're doing per iteration?
If you want unique words for example, just put them into an std::set<std::string>
Last edited on Apr 4, 2013 at 5:57pm UTC
Apr 4, 2013 at 5:59pm UTC
A little tip with optimization:
If you need faster insertion time, use a std::vector / std::map
If you need faster iteration time to find a single object, use an ordered variant of them.
Show us some code examples and we'll tell you how can we help.
Last edited on Apr 4, 2013 at 6:00pm UTC
Apr 9, 2013 at 3:58pm UTC
ok i have to read a text file(dictionary) for a text based game. i was thinking of using a trie or dawg but dont know how to implement one.