Created
October 23, 2010 23:00
-
-
Save ybenjo/642797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <unordered_map> | |
| #include <map> | |
| #include <iostream> | |
| using namespace std; | |
| struct myeq : std::binary_function<pair<int , int> , pair<int , int> , bool>{ | |
| bool operator() (const pair<int , int> & x , const pair<int , int> & y) const{ | |
| //keyの一致って普通これですよね | |
| return x.first == y.first && x.second == y.second; | |
| } | |
| }; | |
| struct myhash : std::unary_function<pair<int , int> , size_t>{ | |
| size_t operator()(const pair<int , int> & p) const{ | |
| //hash関数これでいいのかよくわかってない | |
| return p.first ^ p.second; | |
| } | |
| }; | |
| int main(){ | |
| myhash h; | |
| myeq e; | |
| //一つめの数字が何してるのかわかってない | |
| unordered_map<pair<int , int> , int , myhash , myeq> m(100 , h , e); | |
| for(int i = 0; i < 100; ++i){ | |
| for(int j = 0; j < 100; ++j){ | |
| m.insert(pair<pair<int,int> , int>(make_pair(i, j) , 100)); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment