Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int hash(int x, int i, HT*ht)
- {
- return (hash(x)+i)%ht->size;
- }
- HT* enlarge(HT*ht)
- {
- HT*tab=new HT;
- tab->size=2*(ht->size);
- tab->table=new int [tab->size];
- for(int i=0; i<tab->size; i++) tab->table[i]=-1;
- for(int i=0; i<ht->size; i++)
- {
- if(ht->table[i]>0 && tab->table[hash(ht->table[i])]<0){
- tab->table[hash(ht->table[i]]=ht->table[i];
- ht->table[i]=-1;
- }
- }
- for(int i=0; i<ht->size; i++)
- {
- if(ht->table[i]>=0){
- int b=0;
- while(tab->table[hash(ht->table[i], b, tab)]>=0)
- b++;
- tab->table[hash(ht->table[i], b, tab)]=ht->table[i];
- }
- return tab;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement