GIDForums  

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 06-Oct-2006, 09:27
acosgaya acosgaya is offline
New Member
 
Join Date: Jun 2006
Posts: 13
acosgaya is on a distinguished road

partition a vector of vectors


hi,

I am working in this problem, where I have a set of N d-dimensional points, e.g. (4,5,6,8 ) (2,0,4,6), are 4-d points, which I have stored in a vector of vectors.

I am trying to partition the vector of vectors according to the median value of one the dimensions.

I tried to use the stl partition method like this:

CPP / C++ / C Code:
// S is a vector of vectors containing the points
vector < vector <int> >::iterator iter;
vector < vector <int> >::iterator pos_beg = S.begin();
vector < vector <int> >::iterator pos_end = S.end();

iter = partition (pos_beg, pos_end, bind2nd( is_less(d),7) );


// "is_less" is a class I use to sort the vector of vectors according to an arbitraty dimension.
// e.g. sort(S.begin(), S.end(), is_less(d));
class is_less {
public:
is_less(const int index = 0): i(index) {}
bool operator()(const vector<int>& v1, const vector<int>& v2) {
return v1[i] < v2[i];
}
private:
const int i;
};

Unfortunately, it doesn't work, (or compile correctly). It seems that I have a problem with the predicate of the partition method; the bind2nd function I saw it in an example, but it worked there for just a common vector, and does not seem to work in this case.

Would anyone know how I might solve this problem with the partition.

thanks
 
 

Recent GIDBlogNARMY by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Generic searching through vectors zdenek CPP / C++ Forum 1 10-Oct-2006 08:44
how to commute values of vectors cpit CPP / C++ Forum 4 23-Jun-2006 08:27
Quicksort and randomized hoare partition dayrinni CPP / C++ Forum 2 24-Sep-2005 21:23
vectors of references mirizar CPP / C++ Forum 1 12-Apr-2005 02:02
Declaring a vector of vectors? Lethal411 CPP / C++ Forum 2 20-Mar-2004 09:02

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 19:46.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.