which data structure for speed?

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.
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
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
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.
bob39rocks wrote:
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.

?????
Topic archived. No new replies allowed.