multidimensional vector to list

Discussion in 'C++' started by haikoley@gmail.com, Jun 2, 2013.

  1. Guest

    Hi there,

    I'm trying to convert a three dimensional vector to a list.

    I have a three dimenional vector of type float, which looks like this:

    std::vector< TPoint3D<float> > points;
    points.push_back(TPoint3D<float>(x,y,z);

    And I thought about converting the vector to a list like this:
    list<TPoint3D<float>> myList(points.begin(), points.end());

    But I want to filter the values, so that if the z-values are greater than acertain threshold, they and the corresponding x and y values from the vector are removed. It works for vectors, because I can access the values usingtheir indices, but how do you do something like that with a list?

    Cheers,
    Haiko
     
    , Jun 2, 2013
    #1
    1. Advertising

  2. SG Guest

    On Jun 2, 1:28 am, wrote:
    >
    > I'm trying to convert a three dimensional vector to a list.
    >
    > I have a three dimenional vector of type float, which looks like this:
    >
    > std::vector< TPoint3D<float> > points;
    > points.push_back(TPoint3D<float>(x,y,z);


    It does not look like a 3-dimensional vector to me.
    More like a 1-dimensional vector of 3D points.

    > And I thought about converting the vector to a list like this:
    > list<TPoint3D<float>> myList(points.begin(), points.end());


    Why? Seriously. Why?
    It does not look like a good idea to me.

    > But I want to filter the values, so that if the z-values are greater
    > than a certain threshold, they and the corresponding x and y values
    > from the vector are removed. It works for vectors, because I can
    > access the values using their indices, but how do you do something
    > like that with a list?


    You don't need random access for processing a list from front to back.

    One or two things of these might help you:
    - std::copy_if
    - std::back_inserter
    - Boost's filter_iterator
    - std::list<>::remove_if
     
    SG, Jun 2, 2013
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pmatos
    Replies:
    6
    Views:
    24,132
  2. Replies:
    8
    Views:
    2,001
    Csaba
    Feb 18, 2006
  3. ehui928
    Replies:
    2
    Views:
    481
    ehui928
    May 29, 2006
  4. Javier
    Replies:
    2
    Views:
    624
    James Kanze
    Sep 4, 2007
  5. Rushikesh Joshi
    Replies:
    0
    Views:
    398
    Rushikesh Joshi
    Jul 10, 2004
Loading...

Share This Page