473,403 Members | 2,222 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,403 software developers and data experts.

search in a HashTable, DataTable, and XmlDocument, which is faster?

Bob
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 corresponding menu IDs.
Some pages have the same menu IDs. One every page load, I want to check the
name, and get the menu ID so the menu can be displayed with the proper items
highlighted. The list various from a couple of dozen entries to a couple of
hundreds of entries depending on the number of pages an app has.

It's pretty easy to implement with either a HashTable, DataTable,
Dictionary, or XmlDocument. Since it's something every page load would hit,
every bit of performance counts. Thanks a lot for any suggestions.

Bob
Nov 18 '05 #1
3 2482
Tee
HashTable should be the fastest.
" Bob" <bo*******@yahoo.com> wrote in message
news:ue**************@TK2MSFTNGP12.phx.gbl...
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 corresponding menu IDs.
Some pages have the same menu IDs. One every page load, I want to check the name, and get the menu ID so the menu can be displayed with the proper items highlighted. The list various from a couple of dozen entries to a couple of hundreds of entries depending on the number of pages an app has.

It's pretty easy to implement with either a HashTable, DataTable,
Dictionary, or XmlDocument. Since it's something every page load would hit, every bit of performance counts. Thanks a lot for any suggestions.

Bob

Nov 18 '05 #2
Would need to test a bit to be sure. A Hybred Hash may be better when the
entries are low and will convert to normal hash when list grows over 10.
This is for speed. Note the speed of lookup will also depend on hash time
for strings. If you can use all lower or upper case, then you don't need a
case insensitive hashcode provider which will save time. Also the length of
strings should be as short as possible as the compare and hash gen will
reflect len of string. If possible, use a number as the key as the compares
and hash are fastest (hash == number value IIRC).

--
William Stacey, MVP

" Bob" <bo*******@yahoo.com> wrote in message
news:ue**************@TK2MSFTNGP12.phx.gbl...
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 corresponding menu IDs.
Some pages have the same menu IDs. One every page load, I want to check the name, and get the menu ID so the menu can be displayed with the proper items highlighted. The list various from a couple of dozen entries to a couple of hundreds of entries depending on the number of pages an app has.

It's pretty easy to implement with either a HashTable, DataTable,
Dictionary, or XmlDocument. Since it's something every page load would hit, every bit of performance counts. Thanks a lot for any suggestions.

Bob


Nov 18 '05 #3
Use hashtable - menuid=Hashtable[pagename].

" Bob" <bo*******@yahoo.com> píąe v diskusním příspěvku
news:ue**************@TK2MSFTNGP12.phx.gbl...
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 corresponding menu IDs.
Some pages have the same menu IDs. One every page load, I want to check
the
name, and get the menu ID so the menu can be displayed with the proper
items
highlighted. The list various from a couple of dozen entries to a couple
of
hundreds of entries depending on the number of pages an app has.

It's pretty easy to implement with either a HashTable, DataTable,
Dictionary, or XmlDocument. Since it's something every page load would
hit,
every bit of performance counts. Thanks a lot for any suggestions.

Bob

Nov 18 '05 #4

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

Similar topics

1
by: MrMike | last post by:
I have the following code which allows me to display records from a table named "lkup_Specie" in a datagrid. If I create a second datatable and a second hashtable for a table named "lkup_Grade",...
1
by: Zeng | last post by:
Hello, I have profiled my code, and the current performance bottleneck is this routine. It gets called 7400 times to do some intensive calculations when a user uses the feature. The xmlText...
3
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...
4
by: Vladimir C. | last post by:
Hashtable map = new Hashtable(); map = 10; map = 20; foreach(DictionaryEntry e in map) { e.Value = 100; Console.WriteLine("{0}: {1}", key, map); }
4
by: Matt C. | last post by:
I bet I know the answer already. I have a hashtable (hMaster) that holds several hashtables ("hTables") each of which holds other hashtables ("hColumns"). Presently, I am getting at the info I...
5
by: Dave | last post by:
Hi all, Is it possible to populate a listbox from a hashtable (complexbind) where the ValueMember of the listbox maps to the "key" member of the hashtable AND the DisplayMember of the listbox maps...
2
by: UJ | last post by:
I have a dataset that will have say 10000 records in it with the names of files that are used by the system. I then have a large directory of files that correspond to that list of files and want to...
4
by: Rich | last post by:
Hello, I need to store various values that I will need to look up later on. I have been using hashtables and arraylists. But I can only store 2 items per row in a hashtable - key, value, and...
3
by: Manish | last post by:
Hi m not able to convert the node values of a XML file to Hashtable Actaully i need to traverse the XML Nodes again and again and want to pick values on filters what i want is to stroe the...
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

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.