
29 Jun
2006
29 Jun
'06
5:54 a.m.
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