For a problem like this, I'd be inclined to define an interface
Cloneable with one method clone() which when implented would return a
new object that was a deep copy of the instance it was called on.
You could have any object you plan on storing in the array implement
Cloneable, then you could have a module method ArrayCopy(origArray,
newArray) which clones every object in the old array and adds it to
the new array.
Then it would be a simple matter of just calling ArrayCopy from
anywhere in your code that you needed to duplicate an array. The
underlying objects in the array would be inconsequential.
Come to think of it, This functionality is needed often enough that
I'm surprised that it isn't included in RB.
-jason
On May 2, 2006, at 4:01 PM, Norman Palardy wrote:
On May 02, 2006, at 3:44 PM, Mark O'Neill wrote:
Hi Gerard,
On 2 May 2006, at 22:39, Dr Gerard Hammond wrote:
Yes, you will need to deep clone the entire structure.
You'd need something like
redim MyCancelArray(-1)
for each MC as MyClass in MyActualArray
MyCancelArray.Append new myClass(MC) /// this assumes you have
a COPY CONSTRUCTOR that makes a new myClass from an existing one
next
Basically myClass would need to have a constructor that looks like
Constructor(existingInstance as myClass)
me.property = existingInstance.property
// and so on for ALL other properties in myClass
This literally makes a copy
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>