Welcome to Mandalay Technological University Forum

ဴမန္မာအင္ဂဵင္နီယာမဵားဖိုရမ္
 
HomePortalCalendarGalleryFAQSearchRegisterLog in

Share | 
 

 Hash table design

View previous topic View next topic Go down 
AuthorMessage
chochotinngwe
LEVEL '0'
LEVEL '0'


Female
Number of posts : 7
Age : 36
Location : Oxford,uk
Batch if MIT (if not simply fill YIT) : last batch
Registration date : 2006-10-28

PostSubject: Hash table design   Sun Oct 29, 2006 2:41 am

Dear all,
I would like to create a hash table using my own hash functions.If somebody know the books,links,website.. pls share me.
many thanks,
cctn
Back to top Go down
View user profile
ZawMinHt
Guest
avatar


PostSubject: Re: Hash table design   Sun Oct 29, 2006 3:43 am

There are many Hashing alogrithms in use today. Some strong hashing alogrithms are 'Message Digest' (MD4, MD5), secure hash alogrithm (SHA-1), various DES, etc. They all fall under category of cryptographic services. They are intended for secured environments. But they normally take some level of processing power (although negligible on modern PCs). You can choose a simpler solution such as checksums (CRC) . Cyclic Redundancy Check a.k.a CRC32 is not quite a secure one but can provide enough integrity checks on the contents. If you want to learn more on these :

http://en.wikipedia.org/wiki/Cryptographic_hash_function
http://en.wikipedia.org/wiki/Cyclic_redundancy_check

I think STL (standard template library ) won't be the choice since you want to create your own routing.

If your hash table just for use such search ,sort, etc, you can use the following snippet shown below. It is a very simple hashing technique by XOR.ing the integer values. It is very fast as well.

int ILibGetHashValue(void *key, int keylength)
{
int HashValue=0;
char TempValue[4];

if(keylength<=4)
{
//
// If the key length is <= 4, the hash is just the key expressed as an integer
//
memset(TempValue,0,4);
memcpy(TempValue,key,keylength);
// MEMCHECK(assert(keylength<=4)Wink // !! you can neglect this line

HashValue = *((int*)TempValue);
}
else
{
//
// If the key length is >4, the hash is the first 4 bytes XOR with the last 4
//
memcpy(TempValue,key,4);
HashValue = *((int*)TempValue);
memcpy(TempValue,(char*)key+(keylength-4),4);
HashValue = HashValue^(*((int*)TempValue));
//
// If the key length is >= 10, the hash is also XOR with the middle 4 bytes
//
if(keylength>=10)
{
memcpy(TempValue,(char*)key+(keylength/2),4);
HashValue = HashValue^(*((int*)TempValue));
}
}
return(HashValue);
}
Back to top Go down
chochotinngwe
LEVEL '0'
LEVEL '0'


Female
Number of posts : 7
Age : 36
Location : Oxford,uk
Batch if MIT (if not simply fill YIT) : last batch
Registration date : 2006-10-28

PostSubject: Re: Hash table design   Sun Oct 29, 2006 4:48 am

Many Thanks bro ZawMinHtut.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Hash table design   

Back to top Go down
 
Hash table design
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Planet Table
» the banquet table - the ocean - the kitten
» The role of the Design and Build Committee
» Honorarium for Design and Build Committee
» Getting Table ready

Permissions in this forum:You cannot reply to topics in this forum
Welcome to Mandalay Technological University Forum :: Computer Software and Programming :: C, C++, Visual C++, Basic, Visual Basic-
Jump to: