[ICL] interval_map::find(const domain_type_comparable&) instead of interval_map::find(const domain_type&)

Hi Joachim One small note about Icl maps. I think would be useful to make interval_map::find()'s function accept any type comparable to map's key. For example, the key type is std::string and the user want to search using a 0-terminated string or a string defined as arbitrary pointer and a length. Then the user will have to allocate the temporary string only to pass it to interval_map::find() You may argue that the std::map works same way. But there is the difference. If I want to do the trick above, I can use boost::multi_index or at least instead of std::map<std::string, ValueT> I can define something like std::map<tuple<const char*, size_t>, tuple<std::string, ValueT>> with key's const char* and size_t pointing to the data hosted in value. This is not possible with interval_map, where the values can be joined

Denis wrote:
Hi Joachim
One small note about Icl maps.
I think would be useful to make interval_map::find()'s function accept any type comparable to map's key. For example, the key type is std::string and the user want to search using a 0-terminated string or a string defined as arbitrary pointer and a length. Then the user will have to allocate the temporary string only to pass it to interval_map::find()
Hmm, I can't find find in the docs :-p, and don't have ICL. Have you tried wrapping your null terminated string with boost::as_literal at the call site? Jeff

2011/5/22 Jeff Flinn <Jeffrey.Flinn@gmail.com>:
Denis wrote:
Hi Joachim
One small note about Icl maps.
I think would be useful to make interval_map::find()'s function accept any type comparable to map's key. For example, the key type is std::string and the user want to search using a 0-terminated string or a string defined as arbitrary pointer and a length. Then the user will have to allocate the temporary string only to pass it to interval_map::find()
Hmm, I can't find find in the docs :-p,
http://www.boost.org/doc/libs/1_46_1/libs/icl/doc/html/boost_icl/function_re...
and don't have ICL.
=( - Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de

2011/5/22 Denis <comp.lib.boost.devel@camfex.cz>:
Hi Joachim One small note about Icl maps. I think would be useful to make interval_map::find()'s function accept any type comparable to map's key. For example, the key type is std::string and the user want to search using a 0-terminated string or a string defined as arbitrary pointer and a length. Then the user will have to allocate the temporary string only to pass it to interval_map::find() You may argue that the std::map works same way. But there is the difference. If I want to do the trick above, I can use boost::multi_index or at least instead of std::map<std::string, ValueT> I can define something like std::map<tuple<const char*, size_t>, tuple<std::string, ValueT>> with key's const char* and size_t pointing to the data hosted in value. This is not possible with interval_map, where the values can be joined
... working with large objects as domain_types in ICL may generally be unfortunate as it is to do so with std::AssociativeContainers. If efficiency is not crucial, (1) it may be ok to create objects temporarily. Otherwise (2) you may consider dealing with your large objects via (smart)pointers or iterators or any other proxy technique that allows you use small proxy objects as domain_type-objects. Cheers, Joachim -- Interval Container Library [Boost.Icl] http://www.joachim-faulhaber.de
participants (3)
-
Denis
-
Jeff Flinn
-
Joachim Faulhaber