Boost logo

Boost Users :

From: Ed (linux_at_[hidden])
Date: 2008-08-12 11:41:01


#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;

matrix<MyObject> m_MyObjects(nRows, nCols);

I have a ublas matrix of objects as declared above... Is there a way
within the Boost lib (i.e. something I don't have to write much custom
code to use) that I can use to sort the matrix by a value of one
of the data members of MyObject? For example

If

class MyObject {
    int thisOne;
}

and

m_MyObjects(0,0).thisOne = 1;
m_MyObjects(1,0).thisOne = 0;
m_MyObjects(0,1).thisOne = 4;
m_MyObjects(1,1).thisOne = 2;

It will sort the matrix so that

m_MyObjects(0,0).thisOne = 0;
m_MyObjects(1,0).thisOne = 1;
m_MyObjects(0,1).thisOne = 2;
m_MyObjects(1,1).thisOne = 4;

Ed


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