Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-06-29 01:54:35


Meador Inge wrote:
> A typical idiom in C is to initialize map data structure statically.
>
>...snip detail...
>
> Static_map::find would just be a simple linear search. However, there
> could be another type, say sorted_static_map, that relies on the keys
> in the initialization list to be sorted by the user. Then a binary
> search could be used for sorted_static_map::find.
>
> Does anyone else have a need for such a beast?

How about boost.assign:

http://www.boost.org/libs/assign/doc/index.html

using namespace std;
using namespace boost::assign; // bring 'map_list_of()' into scope

map<int,int> mii = map_list_of(1,2)(2,3)(3,4)(4,5)(5,6);

Same idea should work with strings.

Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk