|
Boost Users : |
From: Adán Cosgaya (acosgaya_at_[hidden])
Date: 2006-09-13 16:37:44
Hi, I am using multi_index to keep a set of d-dimensional points, where each
point is a vector inside the multi_index container.
e.g (3,5,8,9,5) is a 5-dimensional point (but this can vary and be 3-d, 7-d,
etc..). I need to have the set sorted by each of the dimensions.
I can do it statically if I know in advance how many dimensions I have, but
I don't know how to make dynamic to any number of dimensions.
I currently have:
template<int N>
struct nth_coordinate
{
typedef int result_type;
int operator()(const vector<int>& x)const
{
return x[N];
}
};
typedef multi_index_container<
vector<int>,
indexed_by<
sequenced<>,
ordered_non_unique<nth_coordinate<0> >,
ordered_non_unique<nth_coordinate<1> >,
ordered_non_unique<nth_coordinate<2> >,
ordered_non_unique<nth_coordinate<3> >,
ordered_non_unique<nth_coordinate<4> >
>
> multi_index_Points;
is it possible do it without explicitly saying how many indices do I need?
Also, I am trying to create a function which receives as a parameter the
dimension I want to work with, but it seems that I need to explicitly say
the number of the index in nth_index (it obviously needs a constant). For
example:
int median (int d){
...
typedef multi_index_Points::nth_index< d >::type
multi_index_Points_it; ===> I would like to pass "d" as a parameter
...
}
is there any workaround for this issues?
would you mind pointing me in the right direction with an example of how to
do it with thelibrary?
thanks in advance...
Adan
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net