Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > multidimensional vector to list

Reply
Thread Tools

multidimensional vector to list

 
 
haikoley@gmail.com
Guest
Posts: n/a
 
      06-01-2013
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

 
Reply With Quote
 
 
 
 
SG
Guest
Posts: n/a
 
      06-02-2013
On Jun 2, 1:28*am, (E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Can list container contain an vector object, such as list< vector<string> >?? ehui928 C++ 2 05-29-2006 01:09 PM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM



Advertisments