1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
class triple_type
{
public:
int i;
int j;
int k;
triple_type():i(0),j(0),k(0){};
triple_type(int _i,int _j, int _k):i(_i),j(_j),k(_k){};
};
struct lttriplet
{
bool operator()(const triple_type & s1, const triple_type& s2) const
{
if(s1.i<s2.i) return true;
if(s1.j<s2.j) return true;
if(s1.k<s2.k) return true;
return false;
}
};
int main()
{
map<triple_type, bool,lttriplet> m;
map<triple_type, bool,lttriplet>::iterator it;
list<triple_type> l;
triple_type test(1,3,-1);
m[triple_type(1,2,4)]=true;
m[triple_type(1,3,2)]=true;
m[triple_type(1,3,5)]=false;
m[triple_type(1,3,12)]=true;
m[triple_type(2,5,0)]=true;
for(it=m.begin();it!=m.end();++it)
{
if(((*it).first.i==test.i)&&((*it).first.j==test.j))cout<<(*it).first.k<<endl;
}
std::cout << "Hello world!" << std::endl;
return 0;
} |
Partager