Êý¾Ý½á¹¹33£¨Ï£©
ÉÏһƪ /
ÏÂһƪ 2010-07-04 21:16:16
Èý¡¢¹þÏ£±íµÄ²éÕÒ
//¿ª·Å¶¨Ö·¹þÏ£±íµÄ´æ´¢½á¹¹
int
hashsize[]={997,...};
typedef
struct{
ElemType
*elem;
int
count;
int
sizeindex;
}HashTable;
#define
SUCCESS 1
#define
UNSUCCESS 0
#define
DUPLICATE -1
Status
SearchHash(HashTable H,KeyType K,int &p,int &c){
p=Hash(K);
while(H.elem[p].key!=NULLKEY
&&
!EQ(K,H.elem[p].key))
collision(p,++c);
if(EQ(K,H.elem[p].key)
return
SUCCESS;
else
return UNSUCCESS;
}
Status
InsertHash(HashTable &H,EleType e){
c=0;
if(SearchHash(H,e.key,p,c))
return
DUPLICATE;
else
if(c<hashsize[H.sizeindex]/2){
H.elem[p]=e;
++H.count; return OK;
}
else
RecreateHashTable(H);
}
ËÄ¡¢×ܽá
´¦Àí³åÍ»µÄÒªÇóÊÇʲô£¿
»ØĿ¼ÉÏÒ»¿ÎÏÂÒ»¿Î
ÊÕ²Ø
¾Ù±¨
TAG: