www.pudn.com > TestMap.rar > TestMap.cpp
// TestMap.cpp : Defines the entry point for the console application. #include "stdafx.h" #include #include #include #include #if defined (_MSC_VER) #pragma warning(disable:4786) #endif typedef struct TriKey { int k[3]; bool operator<(const TriKey rhs) const { return ((k[0] < rhs.k[0] || k[1] < rhs.k[1] || k[2] < rhs.k[2]) && (k[0] < rhs.k[0] || k[1] < rhs.k[2] || k[2] < rhs.k[1]) && (k[0] < rhs.k[1] || k[1] < rhs.k[0] || k[2] < rhs.k[2]) && (k[0] < rhs.k[1] || k[1] < rhs.k[2] || k[2] < rhs.k[0]) && (k[0] < rhs.k[2] || k[1] < rhs.k[1] || k[2] < rhs.k[0]) && (k[0] < rhs.k[2] || k[1] < rhs.k[0] || k[2] < rhs.k[1]) ); } } TRIKEY; using namespace std; typedef map MY_TYPE; typedef map::iterator MY_ITER; int main() { MY_TYPE nums; TRIKEY key; key.k[0] = 1; key.k[1] = 2; key.k[2] = 3; nums[key] = 100.0; key.k[0] = 3; key.k[1] = 4; key.k[2] = 5; nums[key] = 200.0; MY_ITER iter; key.k[0] = 3; key.k[1] = 2; key.k[2] = 1; iter = nums.find(key); if (iter != nums.end()) { cout<second<