This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Search algorithms in __gnu_cxx::


On 9/7/06, Paolo Carlini <pcarlini@suse.de> wrote:
Benjamin Kosnik wrote:

>Sounds good to me. There are already some non-standard things in
>include/ext/algorithm, but everything you mentioned seems like a good
>addition.
>
>
Yes, we could also use the existing ext/algorithm, good point. My only
concern is that at some point we may want to clearly differentiate to
different namespaces real extensions from legacy HP / SGI stuff (I think
we have a PR about that...), we talked about a __gnu_ext namespace if I
remember correctly the exact name... For sure not something we have to
decide immediately.


Ok, so as a first step, let me mention that most of these _alternate_
search algorithms perform some sort of pre-processing, and are
_mainly_ useful when you need to search for many strings in one huge
block of text(say a file). In such scenarios, it makes sense to have
separate pre-processing functions, and a separate search function.
Also, we could(for convenience) provide a wrapper around these to make
it look the same like std::search().


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);


Do you agree, or does anyone have anything else in mind?



Regards, -Dhruv.




-- -Dhruv Matani. http://www.geocities.com/dhruvbird/

"Life is wasted on the living"
 - Zaphod Beeblebrox the Fourth.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]