c++ - Hash set function for hashing -


i trying implement hash set have trouble hash function. want add in set, persons have name , phone number:

class person{     string name;     long long int phonenumber; } 

and indexes in set calculated summing digits of phonenumber. problem dont want functions this:

int add(long long int nr, element e) - function adds element set {      int hashcode = hash(nr);;      ... } 

where long long int nr should phonenumber , element e should person. mean, it's pretty stupid. if have person parameter, why have it's phonenumber too? can see using templates, , teacher advised me virtual class hashfunction force respective type(something hashset in java). thing have no idea how that. have ideas me?

if :

 int add(person p, element e) 

you restrict hastset class dependent on person class. taking integer or string value hash method more plausible in way. can determine parameter hash outside hash method , give input.

moreover, when add member person class age , use in in hashing, need modify hash method use particular member.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -