|
-
May 24th, 2005, 02:46 AM
#1
Thread Starter
Addicted Member
What is a hash table? [RESOLVED]
I've got a question. What is a hash table? I tried looking for the term in my VB.NET book (learn vb.net in 21 days) but it doesn't have anything on hash tables.
Last edited by ultimate_girl; May 24th, 2005 at 05:26 AM.
-
May 24th, 2005, 03:02 AM
#2
Hyperactive Member
Re: What is a hash table?
A hash table is a powerful data storage structure. Essentially it provies a key value pair. In VB.Net an example would be as follows
VB Code:
Public Sub HashTableTest()
DIM hash AS new hashtable()
hash.add("somekey", "somevalue") 'Note key and value can be any object, here they are strings
IF hash.containskey("somekey") Then Console.writeline(CStr(hash("somekey")))
End Sub
It is a powerful data storage technique and I would highly recommend using them in the appropriate situation.
-
May 24th, 2005, 03:14 AM
#3
Frenzied Member
Re: What is a hash table?
Hash tables are good for storing data for quick retrieval. The problem is you have no choice in the way data is stored i.e the sort order, because of the hashing algorithm used. For this reason retreiving and sorting data from a hash table is too problematic.
-
May 24th, 2005, 03:18 AM
#4
Re: What is a hash table?
Can't remember where I saw it now but "Bubble-Up List" is also interesting. Commonly used items are brought up near the front of the list and rarely used ones make their way to the end. Speeds up search times no end and it also (partially) efficiently stores the items in a sensible sequence. Probably not compatible with most situations where a hashtable would be used though
I don't live here any more.
-
May 24th, 2005, 03:41 AM
#5
Thread Starter
Addicted Member
Re: What is a hash table?
 Originally Posted by The_Duck
A hash table is a powerful data storage structure. Essentially it provies a key value pair. In VB.Net an example would be as follows
VB Code:
Public Sub HashTableTest()
DIM hash AS new hashtable()
hash.add("somekey", "somevalue") 'Note key and value can be any object, here they are strings
IF hash.containskey("somekey") Then Console.writeline(CStr(hash("somekey")))
End Sub
It is a powerful data storage technique and I would highly recommend using them in the appropriate situation.
when is an appropriate situation?
-
May 24th, 2005, 03:50 AM
#6
Hyperactive Member
Re: What is a hash table?
You would generally use a hashtable where you have a 1-x relationship with your key and value, ie your key will always define a single object (keys in a hashtable need to be unique).
We could envisage a situation where you have say 10 student ID's
1, 2, ... 10
These ID's are unique. Each student could also have details stored about them, such as name, address etc.
Thus we could define a structure
Public Structure StudentInfo
DIm name as string
Dim address as string
Dim x as etc
End Structure
We can then use a hashtable to store the details on all our strudents. Thus to get a particualr students name (from ID) we would call
DirectCast(hash(SomeStudentID), StudentInfo).Name
-
May 24th, 2005, 03:59 AM
#7
Thread Starter
Addicted Member
Re: What is a hash table?
thanks guys! =) now how do i rename this thing to "RESOLVED"?
-
May 24th, 2005, 04:05 AM
#8
Hyperactive Member
Re: What is a hash table?
Edit your first post
-
May 24th, 2005, 07:48 AM
#9
Re: What is a hash table? [RESOLVED]
As i understant HashTable and Array look to be similar ..... No ?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|