Doh!
| actual business probably, rather then creating general classes such as
Thats "actual business problem"... Darn spell checker... ;-)
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:er**************@TK2MSFTNGP15.phx.gbl...
|| done but what's then in is the advantage in this case of the arraylist
| over
|| an array sized to 30k then redim preserved at the end?
|
| I would say primarily ArrayList like the rest of the Framework has already
| been written & more importantly tested, saving you the time of writing &
| testing your own version of the routine.
|
| Seeing as ArrayList is already written, you can spend your time solving
your
| actual business probably, rather then creating general classes such as
| ArrayList...
|
| Of course writing your own ArrayList style class allows you to customize
the
| allocation algorithm, possibly with a replaceable one via the Strategy
| pattern.
|
| --
| Hope this helps
| Jay [MVP - Outlook]
| .NET Application Architect, Enthusiast, & Evangelist
| T.S. Bradley -
http://www.tsbradley.net
|
|
| "Dennis" <De****@discussions.microsoft.com> wrote in message
| news:D1**********************************@microsof t.com...
|| Yes but not before you are thru adding. Doesn't an arraylist double in
| size
|| everytime it's count exceeds it's maximum size. If you are at 25,000
count
|| and the array was at it's maximum, it would resize to 50k. To avoid this,
| you
|| could an arraylist size at your maximum of 30,000 then trim it when you
| are
|| done but what's then in is the advantage in this case of the arraylist
| over
|| an array sized to 30k then redim preserved at the end?
|| --
|| Dennis in Houston
||
||
|| "Jay B. Harlow [MVP - Outlook]" wrote:
||
|| > Dennis,
|| > | with 50,000 or 60,000 size of an arraylist when you only needed a
| maximum
|| > of
|| > | 30,000 unless you set the starting size of the arraylist at 30,000.
|| > Yes that is a factor...
|| >
|| > If you are going to keep the ArrayList object for a while, you can use
|| > ArrayList.TrimToSize to discard the unused elements:
|| >
|| >
|
http://msdn.microsoft.com/library/de...oSizeTopic.asp
|| >
|| > --
|| > Hope this helps
|| > Jay [MVP - Outlook]
|| > ..NET Application Architect, Enthusiast, & Evangelist
|| > T.S. Bradley -
http://www.tsbradley.net
|| >
|| >
|| > "Dennis" <De****@discussions.microsoft.com> wrote in message
|| > news:07**********************************@microsof t.com...
|| > | My point was that one could use any type structure or class for that
|| > matter.
|| > | Also, I don't understand why people are hung up on using ArrayLists
so
|| > much.
|| > | Granted, they are better in cases where you have no idea of the
| maximum
|| > but
|| > | they also redim preserve every time the count gets to the maximum
size
|| > | although they double the size every time or am I wrong. If I'm
| correct,
|| > then
|| > | one disadvantage of array lists in Sam's case is that you could
easily
| end
|| > up
|| > | with 50,000 or 60,000 size of an arraylist when you only needed a
| maximum
|| > of
|| > | 30,000 unless you set the starting size of the arraylist at 30,000.
| In
|| > this
|| > | case, an array would be, I think, faster and easier.
|| > | --
|| > | Dennis in Houston
|| > |
|| > |
|| > | "Cor Ligthert [MVP]" wrote:
|| > |
|| > | > Dennis,
|| > | >
|| > | > A point is already a structure
|| > | >
|| > | >
|| >
|
http://msdn.microsoft.com/library/de...classtopic.asp
|| > | >
|| > | > Therefore I think that I would go for the already by Herfrieds
| mentioned
|| > | > solution "the generic list" if Sam has VS 2005.
|| > | >
|| > | > For me it seems build for this problem.
|| > | > \\\
|| > | > Public Class Form1
|| > | > Public ScreenPoints As New List(Of Point)
|| > | > Private Sub Form1_Click(ByVal sender As Object, _
|| > | > ByVal e As System.EventArgs) Handles Me.Click
|| > | > ScreenPoints.Add(New Point(Cursor.Position.X,
|| > Cursor.Position.Y))
|| > | > End Sub
|| > | > End Class
|| > | > ///
|| > | >
|| > | > Just my idea.
|| > | >
|| > | > Cor
|| > | >
|| > | > "Dennis" <De****@discussions.microsoft.com> schreef in bericht
|| > | > news:CD**********************************@microsof t.com...
|| > | > > Not sure but I think the fastest would be to dim an array of
|| > structures
|| > | > > where
|| > | > > the structure has an x and y. Initially dimension the array to
| the
|| > | > > maximum
|| > | > > size you will need then count the number of entries. After the
| data
|| > has
|| > | > > been
|| > | > > added, you can redim preserve the array to exact number of
entries
|| > that
|| > | > > you
|| > | > > counted.
|| > | > > --
|| > | > > Dennis in Houston
|| > | > >
|| > | > >
|| > | > > "Sam" wrote:
|| > | > >
|| > | > >> 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...
|| > | > >> > "Sam" <qd*@datawave.com> schrieb:
|| > | > >> >> 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?
|| > | > >> >
|| > | > >> > 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/>
|| > | > >>
|| > | > >>
|| > | > >>
|| > | >
|| > | >
|| > | >
|| >
|| >
|| >
|
|