Using dimmed matrixes is still a lot faster.  

If you have a dynamic array of 10,000 items and you want    A<9995> when you 
extract it, it will parse the whole until it passes 9994 @AM then it will 
extract whatever is between the 9994 and 9995.
Having it in a dynamic array is like having a pointer to each @AM position.    

This is why the REMOVE command was added for when a dynamic array is processed 
within a for loop.  The REMOVE command keeps track of the position of the last 
AM, VM, SVM used.

One exemple:   
DIM B(10)
A = CONVERT("]",@AM,"AAAAAA]BBBBBB]CCCC]DDDD")
MATPARSE B FROM A USING @AM

B now has a pointer to each of the 4 elements of 4:
B(1) ->  "AAAAAA"
B(2) -> "BBBBB"
B(3) -> "CCCC"
B(4) -> "DDDD"

When you want the third row, you don't have to pass through the contents of 
B(1) and B(2) you have a pointer to the start of the string that contains 
"CCCC".    


I've used dimmed matrixes to speed sorts and binary search algorithms.

One other advantage of a dimmed matrix is that you can use it to pass several 
files as arguments to a subroutine.  With a dynamic array it can only be a file 
or a string.  You don't change a subroutine's signature if you pass  

call MYSUB(MAT FILES,MAT ARGV_IN, MAT ARGV_OUT)

This way you can add to the number of files and arguments of a subroutine 
without changing the number of arguments.  With dynamic arrays you would have 
to add more arguments to add more files. Ei from:

CALL MYSUB(FILE1, ARGV_IN, ARGV_OUT)

to 

CALL MYSUB(FILE1, FILE2, ARGV_IN, ARGV_OUT)

This means each program calling MYSUB has to be modified.



----- Original Message ----
From: John Hester <jhes...@momtex.com>
To: U2 Users List <u2-users@listserver.u2ug.org>
Sent: Tue, May 18, 2010 3:31:25 PM
Subject: Re: [U2] OPENSEQ and Abnormal termination of UV

Reading my own response just made me realize what's going on.  I think
Jerry's response was right.  I remember many years ago (I won't say how
many) when we were on much slower hardware, explaining to a coworker
that it was better to use dimensioned arrays when possible because they
were faster to populate than dynamic arrays.  The reason they're faster
is because the necessary space for them is already reserved in memory.
A dynamic array has to go out and find add'l memory each time you add to
it.  Looks like putting a sequential file in a dimensioned array makes
it go out and reserve a block of memory the size of the entire file.  If
that's the case then making FILEVARS a dynamic array *should* work.

-John


      
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to