unordered_set<Interval>
yapmak için aşağıdaki kodu kullanıyorum. Bu iyi derler. Bu kodu kullanarak eklemeye çalıştığınızdaÖzel hash işleviyle unordered_set içine ekleme
struct Interval {
unsigned int begin;
unsigned int end;
bool updated; //true if concat. initially false
int patternIndex; //pattern index. valid for single pattern
int proteinIndex; //protein index. for retrieving the pattern
};
struct Hash {
size_t operator()(const Interval &interval);
};
size_t Hash::operator()(const Interval &interval){
string temp = to_string(interval.begin) + to_string(interval.end) + to_string(interval.proteinIndex);
return hash<string>()(temp);
}
unordered_set<Interval, string, Hash> test;
Ancak, ben derleme olamaz:
for(list<Interval>::iterator i = concat.begin(); i != concat.end(); ++i){
test.insert((*i));
}
Üstelik ben sorun hata mesajlarından ne belirleyemiyor. Ben sadece 1 argüman sağlanan düşünce
note: candidate is:
note: size_t Hash::operator()(const Interval&)
note: candidate expects 1 argument, 2 provided
...
kimse benim yerleştirme kodu ile ilgili bir sorun görüyor mu: Burada
bir örnektir? Lütfen yardım edin, eğer yapabilirseniz - uzun zamandır bir çözüm arıyorum.DÜZENLEME:
İşte yeni örnekleme kod:unordered_set<Interval, Hash> test;
Ancak, ben yine de hata iletileri ile ilgili bir takım alıyorum. Ör:
note: candidate is:
note: size_t Hash::operator()(const Interval&) <near match>
note: no known conversion for implicit ‘this’ parameter from ‘const Hash*’ to ‘Hash*’
Cevabımı güncelledim, bu sizin düzeninizde anlattığınız sorunu çözmelidir –
http://stackoverflow.com/questions/17016175/c-unordered-map-using-a-custom-class-type-as- Anahtar kelime –