Container for database-like searches
Posted
by Milan Babuškov
on Stack Overflow
See other posts from Stack Overflow
or by Milan Babuškov
Published on 2010-04-22T10:26:40Z
Indexed on
2010/04/22
10:33 UTC
Read the original article
Hit count: 238
I'm looking for some STL, boost, or similar container to use the same way indexes are used in databases to search for record using a query like this:
select * from table1 where field1 starting with 'X';
or
select * from table1 where field1 like 'X%';
I thought about using std::map, but I cannot because I need to search for fields that "start with" some text, and not those that are "equal to".
I could create a sorted vector or list and use binary search (breaking the set in 2 in each step by reading the element in the middle and seeing if it's more or less than 'X'), but I wonder if there is some ready-made container I could use without reinventing the wheel?
© Stack Overflow or respective owner