I am a new developer for a DOORS database and I'm writing scripts in dxl. As you know there are 1-dimensional arrays in dxl. I wanted to use more than one dimension so I decided to use a dynamic array, but this slowed my script down a lot, and when we have around 14,000 objects per module it would take a day or so for the script to run.
I was wondering if it is reasonable to use dynamic arrays in these scripts or if anyone has experience in dealing with dynamic arrays in databases?
Just curious thanks!
Dynamic arrays benefit from many of the advantages of arrays, including good locality of reference and data cache utilization, compactness (low memory use), and random access. They usually have only a small fixed additional overhead for storing information about the size and capacity.
A dynamic array is an array with a big improvement: automatic resizing. One limitation of arrays is that they're fixed size, meaning you need to specify the number of elements your array will hold ahead of time. A dynamic array expands as you add more elements. So you don't need to determine the size ahead of time.
Dynamic array usually have a growth factor of 3/2 to 2. But once the memory is allocated, it is never shrank automatically.
Functions to be implemented in the Dynamic array class:void push(int data): This function takes one element and inserts it at the last. Amortized time complexity is O(1). void push(int data, int index): It inserts data at the specified index.
Dynamic arrays are considerably slower than C style arrays in DOORS, so you should avoid them if you know the size of the array beforehand.
If you know the number of elements but need more dimensions you can do it like this:
//Define an array of (for example) bool
int imax=5
int jmax=7
bool myarray[imax*jmax]
//Access for example element myarray[3][2]
int i=3
int j=2
bool mybool=myarray[i*jmax+j]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With