Recrehal
October 5th, 2005, 01:14 PM
I'm looking for a structure, something like a tree or map, which allows me to check if a key is in there but also if the path to it matches in a specific order. Think of "hello". I'd like to know that the o is in the map but also that I've chosen the path "h" "e" "l" "l" "o" to get there. I'm not sure what structure I can use for this.
background: I want a tree of commands that will be read character by character out of a file. To avoid searching for every possible command, I'd like to speed things up by narrowing down the path in a tree. So the tree could consists of the three commands "hello1", "hello2" and "test".
Actually I would only need to store the position in the tree and check if the siblings have the next character. As the key would be unique the position would also be unique. So if you can store a position in a STL map and access the siblings let me know. The tree can't be binary.
background: I want a tree of commands that will be read character by character out of a file. To avoid searching for every possible command, I'd like to speed things up by narrowing down the path in a tree. So the tree could consists of the three commands "hello1", "hello2" and "test".
Actually I would only need to store the position in the tree and check if the siblings have the next character. As the key would be unique the position would also be unique. So if you can store a position in a STL map and access the siblings let me know. The tree can't be binary.