Search algorithms in __gnu_cxx::

Paolo Carlini pcarlini@suse.de
Fri Sep 8 01:00:00 GMT 2006


Hi Dhruv,

> something like:
>
> /* Preprocess string str. */
> bm_struct bm_preprocess(std::string const& str);
>
> /* Ignoring templates for the time being, takes in the string
> * to be searched for(short_str), the string to search in(long_str),
> * and the start position in long_str(start_at). Returns the
> * position at which the first match was found.
> */
> size_t bm_search(bm_struct& long_str, bm_struct& short_str, size_t 
> start_at);

I would rather prefer more iterators and a tad more consistency with 
std::search. More like:

template<typename _ForIter>
    _ForIter
    __*_search(const __bm_struct<typename 
iterator_traits<_ForIter>::value_type>& __b,
                       _ForIter __first, _ForIter __last)

In case, _RandomAccessIterator or what else, it depends on the 
algorithm, of course. What do you think?

Paolo.





More information about the Libstdc++ mailing list