Code to implementing erasing of vectors
----------------------------Code 1 ----------------------------------------------------------
# include <iostream>
# include <vector>
# include <algorithm>
using namespace std;
typedef std::pair<int, vector<int> > int_vec_pair;
typedef std::pair<int, int > int_pair;
typedef std::vector<int_vec_pair> vec_int_vec_pair;
typedef std::vector<int_pair> vec_int_pair;
typedef vec_int_vec_pair::iterator vec_int_vec_pair_it;
int main()
{
int const proc_id = 5; // we have more of these/hardcode 1 for test purposes.
typedef vector<int> VEC_INT;
VEC_INT size_vec;
size_vec.reserve(8);
size_vec.push_back(0x100000);
size_vec.push_back(0x200000);
size_vec.push_back(0x300000);
size_vec.push_back(0x400000);
vec_int_vec_pair v1;
v1.push_back(std::make_pair(proc_id, size_vec));
// will be doing push_back on more proc_id with different size_vecs..for
// now use 1 element.
vec_int_pair v2;
v2.push_back(std::make_pair(proc_id, 0));
// ditto.. more proc_ids all zerod out.. for now use 1 element
int bytes_xferred = 0x100000;
{
v2[0].second = bytes_xferred;
if (v1[0].first == proc_id) // pure test purspose. so fix this so the construct is true ..
{
if (v2[0].second == v1[0].second[0])
{
// I would like to erase
// v1[0].second[0] here...
// my intent is to ultimately erase all the size_vec elements in vec_int_vec_pair
cout << " erasing " << endl;
cout << v1[0].second.size(); // check to see if size is 3.
// revist this afterperusing text.. how to do this
// given vector pair
v2[0].second = 0;
}
}
}
return 0;
}
------------------------------------------EOF------------------------------------------------
Pradyut
http://pradyut.tk
http://spaces.msn.com/members/oop-edge/
http://groups-beta.google.com/group/oop_programming
No comments:
Post a Comment