Closed markg85 closed 6 years ago
Yes, it would be difficult to put that in a general API as it's really domain specific.
The best would be to use an iterator adaptor around the iterators of the HAT-trie (something like boost::filter_iterator). Even implemented in the internal of the HAT-trie it would be difficult to do much better better (except in some specific cases) as it only requires one extra comparison per iteration.
Hi,
Another request :)
The case is as follows, again for filesystem trees. Right now a ::equal_prefix_range call gives all items that match the given prefix. For for a prefx of /home/a/Downloads it would give back the following (highlighted): /home/a/Downloads/ /home/a/File /home/a/Downloads/File2 /home/a/Downloads/SomeDir/ /home/a/Downloads/SomeDir/File
In other terms, basically a recursive list of files and folders for a given path. That is fine and mostly what you need. However, in my case i only want to have the direct child items of a given prefix (same prefix as before), so the following: /home/a/Downloads/ /home/a/File /home/a/Downloads/File2 /home/a/Downloads/SomeDir/ /home/a/Downloads/SomeDir/File
And for a prefix of /home/a i would only want the following as a result: /home/a/Downloads/ /home/a/File /home/a/Downloads/File2 /home/a/Downloads/SomeDir/ /home/a/Downloads/SomeDir/File
There should not be a problem for this in terms of the tree structure behind all of this. At the moment it's simply returning too much where the end iterator would have to be set back some position for the match i want. But how to do this in a clear API way seems like a challenge.
It is in fact rather easy to do this with the current code, but a bit wasteful as well. I could for instance iterate over the results and look for the first occurrence that starts with "/", has some text before the "/" and use that point as my end iterator.
But putting something like that in the API is... nasty.
Oh well, just putting it on here, perhaps you like the idea and want to implement it :)
Best regards, Mark