|
-
October 5th, 2005, 01:14 PM
#1
Looking for some structure like a tree ...
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.
-
October 5th, 2005, 01:42 PM
#2
Re: Looking for some structure like a tree ...
Sounds like you need to use a Trie or something related.
http://www.csse.monash.edu.au/~lloyd...gDS/Tree/Trie/
-
October 6th, 2005, 04:58 AM
#3
Re: Looking for some structure like a tree ...
That's pretty much what I'm looking for. Is it implemented in the STL or somewhere else or would I have to do it myself?
-
October 6th, 2005, 10:49 AM
#4
Re: Looking for some structure like a tree ...
I googled "C++ trie library" and picked this out:
http://www.codeproject.com/cpp/Jumble.asp
It looks like it may at least give you something to work with.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|