473,320 Members | 1,926 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,320 software developers and data experts.

HashList or Array/Arraylist

Does anyone know how efficient the HashList is to lookup values compared to
an Array?

I know that on large amounts of data, the HashList is better, but i got a
list that dosen't seem to get any bigger than 150 items.

And is it better to make your own Array or using ArrayList?
Nov 20 '05 #1
2 1672
* "Jarod_24" <ja******@hotmail.com> scripsit:
Does anyone know how efficient the HashList is to lookup values compared to
an Array?
Which answer do you expect? A number of ns?

SCNR
I know that on large amounts of data, the HashList is better, but i got a
list that dosen't seem to get any bigger than 150 items.

And is it better to make your own Array or using ArrayList?


Accessing elements in an array is faster than accessing items in a
hastable. If there are only 150 items in the array, you may consider
using an array (but that depends on the circumstances).

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Jarod_24,
Does anyone know how efficient the HashList is to lookup values compared to an Array? Are you looking up indexes, keys, or the object reference itself? Is the
Array sorted?
In addition to the other comments.

I normally view it as:

Use a HashTable if I need to look up values by a specific key.

Use an Array if I need to lookup values by index, and the size is fixed.

Use an ArrayList if I need to lookup values by index, and the size is
variable.

If I need to lookup by either key or index, I would define a custom
collection class.

Based on unique requirements I would consider the other collection classes
in the System.Collections & System.Collections.Specialized. Such as
SortedList, HybridDictionary, ListDictionary, NameValueCollection,
StringCollection & StringDictionary...

Further I tend to program for "correctness" first, then program for
"efficiency" once a routine is proved to be inefficient via profiling.

Hope this helps
Jay

"Jarod_24" <ja******@hotmail.com> wrote in message
news:c9******************************@news.teranew s.com... Does anyone know how efficient the HashList is to lookup values compared to an Array?

I know that on large amounts of data, the HashList is better, but i got a
list that dosen't seem to get any bigger than 150 items.

And is it better to make your own Array or using ArrayList?

Nov 20 '05 #3

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

Similar topics

13
by: Hrvoje Voda | last post by:
How to put a specified dataset table into an array list ? Hrcko
9
by: Steve | last post by:
Hello, I created a structure ABC and an array of type ABC Public Structure ABC Dim str1 As String Dim int1 As Integer End Structure Public ABC1 As New ABC, ABC2 As New ABC
4
by: Peter | last post by:
I run into this situation all the time and I'm wondering what is the most efficient way to handle this issue: I'll be pulling data out of a data source and want to load the data into an array so...
5
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was...
18
by: Sam | last post by:
Hi All I'm planing to write an application which allows users dynamically add their points (say you can add upto 30,000) and then draw xy graph. Should I use an array for my coordinate point...
24
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what...
5
by: Paulers | last post by:
Hello all, I have a string array with duplicate elements. I need to create a new string array containing only the unique elements. Is there an easy way to do this? I have tried looping through...
12
by: Maxwell2006 | last post by:
Hi, I declared an array like this: string scriptArgs = new string; Can I resize the array later in the code? Thank you, Max
9
by: Brian Tkatch | last post by:
I'm looking for a simple way to unique an array of strings. I came up with this. Does it make sense? Am i missing anything? (Testing seems to show it to work.) Public Function Unique(ByVal...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.