unordered_set을 사용하여 해시 테이블을 구현하고 있습니다. 찾기 기능을 사용하는 방법을 알아낼 수 없습니다. 이 코드를 실행할 때 계속 seg 오류가 발생합니다. find()가 요소를 찾지 못했기 때문에 find()가 그것을 알아야하기 때문에 나는 그것을 안다. 내 질문은 내가 제대로 제공 한 사용자 지정 해시 함수를 사용하여 찾을 수 있습니까?unordered_set의 해시 함수
unordered_set<Play*, Play::Hash> hashedData
unordered_set<Play*>::iterator got;
for (int i = 0; i < 10; ++i) {
got = hashedData.find(data[i]);
cout << (*got)->getSummary() << endl << endl;
}
데이터는 단지
vector<Play*>
내 해시 함수가 unordered_set 세 번째 인수로 자신의 Pred를 가산의 평가를 추가하는이
struct Hash {
size_t operator()(Play* const &x) const {
size_t t = 0;
static int hash = 0;
string u = x->getOffense();
string v = x->getDefence();
string w = x->getPlayDesc();
t = u.length() + v.length() + w.length();
t += hash;
++hash;
return t;
}
};