|
-
May 29th, 2009, 10:05 AM
#12
Re: how to implement c++ table lookup?
 Originally Posted by sdcode
Not sure I can live with the crud :/
If data1, data2, etc. happen to be the same size, you can use a 2D array instead. Beyond that, I don't think there's much you can do, except use Speedo's solution, which is admittedly much cleaner.
One question, where can i find documentation that shows the map constructor for the following code?
Code:
const map<int, map<int, int> > some_class::table(data, data + N);
Take a look at http://www.sgi.com/tech/stl/Map.html
The constructor in question is this one:
Code:
template <class InputIterator>
map(InputIterator f, InputIterator l)
InputIterator can be any iterator (including a pointer into an array) whose value type is the map's value_type (the value type of map<T, U> is pair<T, U>).
Old Unix programmers never die, they just mv to /dev/null
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|