Boost logo

Boost :

From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-12-20 21:04:27


Hi Chris,

On Dec 20, 2007 9:47 PM, Chris Hamilton <chamilton_at_[hidden]> wrote:
> In a recent project I've been working on, we had need for something that
> I'm calling (for lack of a better, more inspired name ;) an 'indexed'
> multi array. Essentially, we wanted something like a boost multi_array
> but that also allowed indexing along each dimension using some kind of
> indexing function. For example, along one dimension the indexing
> function may except a string as input and use a map to return an integer
> index, while along some other dimension the real line may be cut into
> non-overlapping intervals and a double value is looked up returning the
> index of the interval it belongs to.
>
> We looked at various solutions, but in the end rolled our own based off
> of the boost multi_array and a new concept of an 'indexer'.
>
> Is this something that anybody else would see as useful? I hope my
> explanation was sufficiently clear ;)
>

I definitely think this would be useful, but more in the line of a
general utility that allows me to create an input iterator that's
based on a function object. Something like
boost::make_function_output_iterator(...) only
boost::make_function_input_iterator(...).

I'm guessing, you might have a generic function that returns an
iterator from a container. You might argue that it would be good to
wrap your container in such a way that you have:

std::list<std::string> cities; // contain the list of cities
currently_unnamed_wrapper<unsigned int, std::list<std::string> >
city_finder(cities);
std::list<std::string>::iterator city_iterator = city_finder[zip_code];
std::cout << *city_iterator << std::endl;

Is this similar to what you've already implemented?

-- 
Dean Michael C. Berris
Software Engineer, Friendster, Inc.
[http://cplusplus-soup.blogspot.com/]
[mikhailberis_at_[hidden]]
[+63 928 7291459]
[+1 408 4049523]

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