I had originally thought of building a tree (char by char) or using something like a hashmap or hashset, but I was concerned because I didn’t want to have to build the tree or hashset at the beginning of each running of the game. For instance when I was building my tree, it took almost 3 minutes to populate the tree with every path of valid words, plus I realized with building a tree that you would have to make a tree for each length of word assuming that you check for a valid word by seeing if the next node is null. However I suppose you could make a tree with nodes of two elements one is the char and two is a boolean saying if ending on this node maps the path of a valid word. Unless I am confused, I don’t think I want to use a tree structure. Also, I am still concerned about the hashset… does it take too much build/initialization time?
[quote=“Treebranch,post:21,topic:32714”]
On my computer, populating a 500k HashSet with random Strings takes about 5 seconds, including the String generation (which is extremely inefficient, too).
I’m not sure how long it would take to load the data in from a file, but the bottleneck will almost certainly be file I/O, not HashSet overhead.
If you’re concerned, I’d just try it and see if it works well enough for you - the code is very simple, at least once you have the file loading handled.