Project:
boost
joel_f
-
C++,
pasted
on Mar 12:
|
int main()
{
boost::tuple< std::vector<float>
, std::vector<int>
> data;
std::vector< boost::tuple<float*,int*> > vrow_fi(6);
std::vector< boost::tuple<float*,int*>* > vdepth_fi(2);
// Size data
boost::get<0>(data).resize(24);
boost::get<1>(data).resize(24);
// Link 3d to 2d
vdepth_fi[0] = &vrow_fi[0];
vdepth_fi[1] = &vrow_fi[3];
// Link 2d to 1d
vrow_fi[0] = boost::make_tuple(&boost::get<0>(data)[0],&boost::get<1>(data)[0]);
vrow_fi[1] = boost::make_tuple(&boost::get<0>(data)[4],&boost::get<1>(data)[4]);
vrow_fi[2] = boost::make_tuple(&boost::get<0>(data)[8],&boost::get<1>(data)[8]);
vrow_fi[3] = boost::make_tuple(&boost::get<0>(data)[12],&boost::get<1>(data)[12]);
vrow_fi[4] = boost::make_tuple(&boost::get<0>(data)[16],&boost::get<1>(data)[16]);
vrow_fi[5] = boost::make_tuple(&boost::get<0>(data)[20],&boost::get<1>(data)[20]);
// fill 1d
for(int i=0;i<24;++i) { boost::get<0>(data)[i] = 1.f/(boost::get<1>(data)[i]=i+1);}
// display 3d
for(int k=0;k<2;++k)
{
for(int i=0;i<4;++i)
{
for(int j=0;j<3;++j)
{
std::cout << "{ " << boost::get<0>(vdepth_fi[k][j])[i] << ",";
std::cout << boost::get<1>(vdepth_fi[k][j])[i] << "} ";
}
std::cout << "\n";
}
std::cout << "\n";
}
}
|
Output:
|
{ 1,1} { 0.2,5} { 0.111111,9}
{ 0.5,2} { 0.166667,6} { 0.1,10}
{ 0.333333,3} { 0.142857,7} { 0.0909091,11}
{ 0.25,4} { 0.125,8} { 0.0833333,12}
{ 0.0769231,13} { 0.0588235,17} { 0.047619,21}
{ 0.0714286,14} { 0.0555556,18} { 0.0454545,22}
{ 0.0666667,15} { 0.0526316,19} { 0.0434783,23}
{ 0.0625,16} { 0.05,20} { 0.0416667,24}
|
|