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

ArrayList vs Arrays - Performance

I wish to build up a byte array from various sources of different lengths. I
can either use a byte array and redimension it as needed as I add the various
values or use an arraylist which automatically expands as required then
convert it to an array after I finish adding the elements. Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array. Microsoft's literature suggests using an
arraylist would be better but I don't always trust M'soft.
--
Dennis in Houston
Nov 21 '05 #1
5 1563
Dennis,
Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array.


Can't you allocate a byte array that is larger than you initially
need, to reduce the number of ReDims?

I'd avoid ArrayList when working with bytes due to the boxing
overhead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2
What is "boxing overhead"?

"Mattias Sjögren" wrote:
Dennis,
Does anyone know
which would be faster considering that I would probably have about 10 redim
statements if I use a byte array.


Can't you allocate a byte array that is larger than you initially
need, to reduce the number of ReDims?

I'd avoid ArrayList when working with bytes due to the boxing
overhead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 21 '05 #3
Dennis,
Microsoft's literature suggests using an arraylist would be better
but I don't always trust M'soft.


Why do you have doubts in the case of the arraylist.

It is a list that adds a reference against redimmension a complete array.

When you have doubts about that than you would start in my opinion as well
checking if a multiply operator is faster than a repeated add.

Just my thought,

Cor
Nov 21 '05 #4
* =?Utf-8?B?RGVubmlz?= <De****@discussions.microsoft.com> scripsit:
What is "boxing overhead"?


<URL:http://msdn.microsoft.com/library/en-us/csref/html/vclrfboxingconversionpg.asp>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #5
Obviously someone disagrees with you, i.e., post from mattias.

"Cor Ligthert" wrote:
Dennis,
Microsoft's literature suggests using an arraylist would be better
but I don't always trust M'soft.


Why do you have doubts in the case of the arraylist.

It is a list that adds a reference against redimmension a complete array.

When you have doubts about that than you would start in my opinion as well
checking if a multiply operator is faster than a repeated add.

Just my thought,

Cor

Nov 21 '05 #6

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

Similar topics

3
by: george r smith | last post by:
I am trying to create an arrayList that contains multiple arrayLists. My code attempt is below. The question I have is how can I get away from creating another pAttribute list than can be added to...
5
by: Kevin | last post by:
Hi All Can someone please tell me the difference between an Array and an ArrayList, and where I would be likely to use one over the other Thanks alot for any help
4
by: Ricardo | last post by:
how can i acess the members of an array that i put into a arraylist, like this: int dez = new int; ArrayList arList = new ArrayList(); arList.add(dez); I want to get the dez value.
1
by: Craig | last post by:
Hey Everyone - I'm trying to determine the fastest way of moving array information around and could use some help. Here's the setup: Class A stores a DateTime and an amount (a payment)....
2
by: D. Shane Fowlkes | last post by:
I've been reading up on Arrays in ASP.NET. I'm going to create an two dimensional array of some type to contain 5 columns but a variable amount of rows. I read up on the ArrayList function and...
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...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
3
by: Zenon | last post by:
I have a function which returns array of structs. I need to create a collection of those arrays and thought that an ArrayList would be a good way to do this since the count is variable. The...
20
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to...
1
by: cowboyrocks2009 | last post by:
Hi. I want to return values from multiple Arraylist. How can I do that ? later I want to use these values in another class. Can somebody help class myClass{ public ArrayList<Rectangle>...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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 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.