March 2014 update
This commit is contained in:
parent
09687c4926
commit
a25938f123
1846 changed files with 21876 additions and 5203 deletions
13
Task/Deepcopy/AutoHotkey/deepcopy.ahk
Normal file
13
Task/Deepcopy/AutoHotkey/deepcopy.ahk
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
DeepCopy(Array, Objs=0)
|
||||
{
|
||||
If !Objs
|
||||
Objs := Object()
|
||||
Obj := Array.Clone() ; produces a shallow copy in that any sub-objects are not cloned
|
||||
Objs[&Array] := Obj ; Save this new array - & returns the address of Array in memory
|
||||
For Key, Val in Obj
|
||||
If (IsObject(Val)) ; If it is a subarray
|
||||
Obj[Key] := Objs[&Val] ; If we already know of a reference to this array
|
||||
? Objs[&Val] ; Then point it to the new array (to prevent infinite recursion on self-references
|
||||
: DeepCopy(Val,Objs) ; Otherwise, clone this sub-array
|
||||
Return Obj
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue