Comparison of two 'dynamic arrays'.

DLearner bmqazwsx123 at gmail.com
Sun Nov 13 14:28:45 UTC 2022


Hi

Program has two steps:
1. Creates an array (int[] A), whose size and element values are 
only known at run-time.

Then:
2. The elements (but not the array size) are further processed in 
a way that may or may not alter their value.

Requirement: to identify the indices (if any) of the elements 
whose value changed in step 2.

What is the recommended way to do this?


Creating a step 1.5:
```
int[] B = A;
```
And then step 2.5:
```
for (int j=0, j < A.length, j = j+1) {

    if (B[j] != A[J]) {
       < write the j value away somewhere>
    } else {
    }
}
```

Won't work, as any step 2 changes to A will be reflected in B.


In passing,is 'dynamic array' a good title for a 
structure/concept that seems more of a 'view'?
Surely 'dynamic array' is best used for something that is (no 
more than) a static array whose dimensions can vary at run time?


Best regards


More information about the Digitalmars-d-learn mailing list