// HashTable ->无法测试,改测set吧 #include #include #include #include class DellCom{ public: int type; int price; public: DellCom(int name,int price):type(name),price(price){ } ~DellCom(){ } // string show(){ // return ("Type: "+this->type+" Price: "+this->price); // } int getPrice() const{ return this->price; } }; struct Hash_Dec{ size_t operator()(const DellCom& de)const noexcept{ // cout< bool operator()(const DellCom& x,const DellCom& y) const noexcept{ int x1= x.getPrice(); int x2= y.getPrice(); return x1==x2; } }; void test_hashTable(){ unordered_set sets; // unordered_set sets; // unordered_set sets; // sets.insert(3); sets.insert(DellCom(12,1)); sets.insert(DellCom(3,2)); sets.insert(DellCom(3,25)); sets.insert(DellCom(3,24)); cout << " sets size " << sets.size() << endl; cout << " sets max_size " << sets.max_size() << endl; // cout << " bucket size" << sets.bucket_size()< li; for (unsigned i = 0; i < 7; i++) { cout<<" bucket"<
上一篇 pycharm 快捷键
下一篇 输出100-200之间所有的素数 c语言
版权所有 (c)2021-2022 MSHXW.COM
ICP备案号:晋ICP备2021003244-6号