Hi,
tks for the answer,
and yes, my original idea was something along the lines of a vector of vector, but what you described seem to be the right way to go.
would you mind giving me an example of how to insert some points ( e.g. 4-d or 5-d points), and iterate over them, I will need to access each point during the next stage of my problem
Thanks

Adan

On 7/4/06, Joaquin M Lopez Munoz <joaquin@tid.es> wrote:
Hello Adán,

Adán Cosgaya <acosgaya <at> gmail.com> writes:
>
> hi,i am new using the multiindex library, and I need to do the
> following.I have a set of d-dimensional points ( e.g (3,5,8,9,5)
> is a 5-dimensional point), and I need to sort the points on
> each of the coordinates.
> I want to store the points in a vector,

Do you mean that the points *are* vectors or that, moreover,
they are stored in a vector (thus, a vector of vectors)?
If the latter, why do you want to have them in a vector?
Does not having them stored in the multi_index_container
suffice? In the following I assume that the points are
stored only in a multi_index_container whose first index is
of type sequenced (std::list-like), which gives you the
free-positioning interface you seem to need. If this is not
what you're after please tell me so.

> and use multiindex
> to have all the points (vectors in this case) sorted in each of
> the coordinates
[...]
> would you mind pointing me in the right direction with an
> example of how to do it with multiindex library? thanks

You only need to define an appropriate key extractor
for the N-th element of a vector:

  template<int N>
  struct nth_coordinate
  {
    typedef int result_type;

    int operator()(const std::vector<int>& x)const
    {
      return x[N]; // or .at(N) for greater safety
    }
  };

so that the multi_index_container definition becomes:

  typedef multi_index_container<
    std::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_t;

Does this help? If for some reason the sequenced index
at position #0 does not suffice, in Boost 1.34 there
will be random access indices which are more similar
to a vector, see http://tinyurl.com/psr6o .

Good luck with your project,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users