I have build an application which uses Hashtables for storing information in
collections.
My question is simple - I wonder how big a (performance) difference it is,
to lookup a value in a hashtable with 500.000 items, and a hashtable with 500
items ?
Is there any difference or anything else I should be aware of ?
Regards,
Tony 2 1492
Hi,
It mostly depends on the distribution of your hashcodes. In the ideal
case, the hashtable lookup should be always an O(1) operation regardless
of the item count. In the worst case, however, with all items having the
same hashcode, you would get an O(n) operation.
HTH,
Stefan
Tony Godt wrote: I have build an application which uses Hashtables for storing information in collections.
My question is simple - I wonder how big a (performance) difference it is, to lookup a value in a hashtable with 500.000 items, and a hashtable with 500 items ?
Is there any difference or anything else I should be aware of ?
Regards, Tony
Tony,
Like Stefan said if the hashcodes are well distributed then the
hashtable will have an average case runtime complexity of O(1). That
means that the operations will run in the same amount of time
regardless of the size of the table. If you're using the primitive
types as the keys for the table then this won't be a problem. If you
have created your own class to be used as keys then pay special
attention to the implementation of the GetHashCode method.
Brian
Tony Godt wrote: I have build an application which uses Hashtables for storing information in collections.
My question is simple - I wonder how big a (performance) difference it is, to lookup a value in a hashtable with 500.000 items, and a hashtable with 500 items ?
Is there any difference or anything else I should be aware of ?
Regards, Tony This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alfonso Morra |
last post by:
I am implementing an application which requires the storage of a large
number of items in a cache.
I have 3-tuple key reprented by a struct, as well as an n-tuple (n is
fixed) dataset, also...
|
by: _eee_ |
last post by:
I have been using a HashTable to store name/value pairs, but now I
need to add a third element (name/value/flag). I still need to be
able to index by , and I'd like to keep lookup speed as high...
|
by: Anders Borum |
last post by:
Hello!
I have a list of singleton classes (model managers) that store objects
internally using hashtables. Each of these classes use a single hashtable to
store e.g. users, pages, elements and...
|
by: Steven Wolf |
last post by:
Hi guys,
can a hashtable be faster than a sql server??
i made my own O/R mapping with an "entity cache" (caching all mapped
objects). So, when i get some data from my sql server, i map that data...
|
by: John Grandy |
last post by:
What are good rules of thumb to use when deciding between a
NameValueCollection, an ArrayList, or a Hashtable ?
|
by: Bob |
last post by:
I have a name-value pair type of data that I need to search against. It's
to determine what menu item to highlight given the asp.net page name. So
the list has all my page names (unique) and the...
|
by: Tony Godt |
last post by:
I have build an application which uses Hashtables for storing information in
collections.
My question is simple - I wonder how big a (performance) difference it is,
to lookup a value in a...
|
by: Martin Pöpping |
last post by:
Hello,
I´ve implemented a Hashtable with Int-Keys and Double Values.
Now I want to get the i-th Int-Key of my hashtable.
How do I do that?
I tried it like that:
ICollection intKeys =...
|
by: Bruce |
last post by:
Hi
I am having a problem understanding the exact advantages of using an
ArrayList over a Hashtable in any situation.
In most areas of an application I am working on, lookup needs to be
fast. If I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |