数组或ArrayList [英] Array or ArrayList

查看:83
本文介绍了数组或ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我正计划编写一个应用程序,允许用户动态添加他们的积分(比如你可以加30,000)和然后绘制xy图。我应该使用数组作为我的坐标点存储,并在

有新点时动态调整大小,还是应该使用ArrayList?

两者之间的速度是否显着?

问候,


Sam

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 storage and dynamically resize it when
there is a new point or should I use ArrayList? Is speed noticable between
the two?

Regards,

Sam

推荐答案

我会使用arraylist或者甚至是哈希表。我只发现了动态调整大小的问题。常规数组。


柯蒂斯


" Sam" < qd*@datawave.com>在消息中写道

news:Ou ************** @ tk2msftngp13.phx.gbl ...
I would use an arraylist or possibly even a hashtable. I have only found
problems with "dynamically resizing" regular arrays.

Curtis

"Sam" <qd*@datawave.com> wrote in message
news:Ou**************@tk2msftngp13.phx.gbl...
大家好
我正计划编写一个应用程序,允许用户动态添加他们的点数(比如说你可以加30,000),然后绘制xy图。应该
我使用数组作为我的坐标点存储并动态调整大小
当有新点或我应该使用ArrayList?两者之间的速度是否明显?

问候,

Sam
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 storage and dynamically resize it
when there is a new point or should I use ArrayList? Is speed noticable
between the two?

Regards,

Sam



" ;萨姆和QUOT; < qd*@datawave.com> schrieb:
"Sam" <qd*@datawave.com> schrieb:
我正在计划编写一个应用程序,允许用户动态添加他们的点(比如说你可以加30,000),然后绘制xy图。应该
我使用数组作为我的坐标点存储并动态调整大小
当有新点或我应该使用ArrayList?两者之间的速度是否明显?
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 storage and dynamically resize it
when there is a new point or should I use ArrayList? Is speed noticable
between the two?




使用arraylist或强类型集合(请参阅类''DictionaryBase'',

或.NET 2.0中的List(Of T)。使用数组时,每次使用ReDim Preserve添加项目时,都必须重新编译数组
,这将在内部创建一个新数组,并且
然后将现有

数组中的数据复制到新数组,这是一个非常昂贵的过程。


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http:// classicvb。 org / petition />



Use an arraylist or a strongly-typed collection (see class ''DictionaryBase'',
or ''List(Of T)'' in .NET 2.0). When using arrays you''d have to redimension
the array every time an item is added using ''ReDim Preserve'', which would
internally create a new array and then copy over the data from the existing
array to the new array, which is a very costly process.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


使用collectionbase类比arraylist

类有什么优势来存储我的自定义点结构,如果我不需要所有花哨的东西

来自arraylist类?我看到了一些使用collectionbase的示例代码,用于代替arraylist的
存储。有谁知道有什么好理由?


问候


Sam


" Herfried K.瓦格纳[MVP]" <喜*************** @ gmx.at>在消息中写道

news:%2 **************** @ tk2msftngp13.phx.gbl ...
Is there any advantage of using collectionbase class over the arraylist
class to store my custom point structure if I don''t need all the fancy stuff
from arraylist class? I saw some sample codes using collectionbase for
storage in stead of arraylist. Does anyone know any good reasons?

Regards

Sam

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"山姆" < qd*@datawave.com> schrieb:
"Sam" <qd*@datawave.com> schrieb:
我正在计划编写一个应用程序,允许用户动态添加他们的点(比如说你可以加30,000),然后绘制xy图。应该
我使用数组作为我的坐标点存储并动态调整大小
当有新点或我应该使用ArrayList?两者之间的速度是否明显?
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 storage and dynamically resize it
when there is a new point or should I use ArrayList? Is speed noticable
between the two?



使用arraylist或强类型集合(参见类
''DictionaryBase''或''List(在.NET 2.0中的T)''。使用数组时,每次使用ReDim
Preserve添加项目时,都必须重新定义数组,这将在内部创建一个新数组,然后复制
从现有阵列到新阵列的数据,这是一个非常昂贵的过程。

- MS Herfried K. Wagner
MVP< URL:http ://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>



Use an arraylist or a strongly-typed collection (see class
''DictionaryBase'', or ''List(Of T)'' in .NET 2.0). When using arrays you''d
have to redimension the array every time an item is added using ''ReDim
Preserve'', which would internally create a new array and then copy over
the data from the existing array to the new array, which is a very costly
process.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>



这篇关于数组或ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆