Page 1 of 1 1
Topic Options
#143470 - 2005-07-13 01:37 AM Automatic Array Resizing
It_took_my_meds Offline
Hey THIS is FUN
*****

Registered: 2003-05-07
Posts: 273
Loc: Sydney, Australia
Hi All,

I think it would be good to be able to have arrays automically resize if you use certain additional functions. Such functions could be

PUSH - push a variable onto the end of an array
POP - pop the last variable off the end of an array

You could even have an optional parameter to indicate you want it to PUSH/POP from the front of the array?

Perhaps you could just use something like

Code:
 $Array[Ubound($Array)+1] = $Var  



although I think the PUSH/POP methodology would probably be better.

Cheers,

Richard

Top
#143471 - 2005-07-13 01:50 AM Re: Automatic Array Resizing
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
hmm...
push/pop is something used elsewhere, indeed.
but, specially for pop, I see no use at all.
simple "redim preserve $a[ubound($a)-1]" is sufficient.
with push, one line of code could be avoided, though...
_________________________
!

download KiXnet

Top
#143472 - 2005-07-13 02:35 AM Re: Automatic Array Resizing
It_took_my_meds Offline
Hey THIS is FUN
*****

Registered: 2003-05-07
Posts: 273
Loc: Sydney, Australia
From the documentation for ReDim

Quote:

The values in the existing array are copied into the new array:




I believe the current way ReDim works is very inefficient. I understand there are methods where an array can be resized without requiring copying the entire contents of the old array into the new. This would be very processor intensive when you want to incrementally create a large array. The believe PUSH/POP methodology would make KiX much faster in dealing with such situations. It is not a big deal but it would be a nice feature.

Top
#143473 - 2005-07-13 03:06 AM Re: Automatic Array Resizing
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well.
indeed, if the documentation is right and copy is taking place, there is an issue.
if the documentation actually lies, all is needed is fixing it.

high changes are, the documentation does not provide full truth on the matter.
documentation rarely does.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Lonkero, ShaneEP, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.027 seconds in which 0.012 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org