473,382 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Question about Hashtable's Bucket

Hello all,

I've been scouring through the source code (reflector, shared source)
of the framework and was looking at the hashtable implementation.

From what I can tell, the default implentation uses an array of Bucket
objects which contain the key and value. Then the hash is calculated
elsewhere to point to the index in the array of buckets.

So hashTable.Add("tree","value") would create a bucket object with
"tree" and "value" which is added to the array (which is resized every
100 entries from what I can see). What I'm wondering is how does it
know where in the array to place the item? I appreciate some kind of
modula is done based on the int hash of "tree", but can anyone be more
precise? I'm interested in how it places it in the array rather than
the hash function itself.

Aug 6 '08 #1
1 1878
ah********@googlemail.com wrote:
Hello all,

I've been scouring through the source code (reflector, shared source)
of the framework and was looking at the hashtable implementation.

From what I can tell, the default implentation uses an array of Bucket
objects which contain the key and value. Then the hash is calculated
elsewhere to point to the index in the array of buckets.

So hashTable.Add("tree","value") would create a bucket object with
"tree" and "value" which is added to the array (which is resized every
100 entries from what I can see). What I'm wondering is how does it
know where in the array to place the item? I appreciate some kind of
modula is done based on the int hash of "tree", but can anyone be more
precise? I'm interested in how it places it in the array rather than
the hash function itself.
It takes the hashcode modulo the size of the array, so if the size is 5
and the hash code is 8, the index would be (8 % 5) = 3.

--
Göran Andersson
_____
http://www.guffa.com
Aug 6 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mark | last post by:
I'm using an enumerator to iterate through a HashTable that contains all numeric keys. I'd like to iterarate through the HashTable based on the ordered keys. Is there a quick way to do this?...
33
by: Ken | last post by:
I have a C# Program where multiple threads will operate on a same Hashtable. This Hashtable is synchronized by using Hashtable.Synchronized(myHashtable) method, so no further Lock statements are...
2
by: Terrance | last post by:
Hello, I have a question in regards to hashtables that I was hoping someone can share some light on. I'm currently working with VB.net and I'm trying to learn as much as possible about the...
16
by: akantrowitz | last post by:
In csharp, what is the correct locking around reading and writing into a hashtable. Note that the reader is not looping through the keys, simply reading an item out with a specific key: If i...
7
by: Eduardo F. Sandino | last post by:
I need help in how to implement a HashTable but specific the method getKeys(); anyone could help.?
17
by: John A Grandy | last post by:
For a Hashtable that is expected to contain no more than 100 DictionaryEntry elements , what is the best load factor ? ( This Hashtable is a encapsulted in a class , an instance of which is...
3
by: tony | last post by:
Hello! I have a question about design. I have below a method called InitData and a struct called Data. Metod InitData is used for loading a hashtable with some data that is about number of...
10
by: could.net | last post by:
Python dict is a hash table, isn't it? I know that hashtable has the concept of "bucket size" and "min bucket count" stuff, and they should be configurable so I can set them to the proper value...
0
by: xievvv | last post by:
We are experiencing a memory leak in one of our applications. It is a web-based reporting system that produces large (> 500mb) PDF reports. It takes approx 4 hours to run the largest of these reports...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.