Difference between revisions of "Introduction to Pluggy Arrays"

No change in size ,  16:05, 26 March 2008
→‎Arrays in Pluggy: Tweaked order
imported>Speedo
(→‎Example: Added warning)
imported>Speedo
(→‎Arrays in Pluggy: Tweaked order)
Line 41: Line 41:
#Be ''very'' careful when overwriting an existing ArrayID.  Be ''sure'' that you've destroyed an array before overwriting its ArrayID - otherwise, you've got a memory leak.  If possible, you can reuse the existing array (rather than destroying it and creating a new one) by setting its size to 0 with [[ArraySize]].
#Be ''very'' careful when overwriting an existing ArrayID.  Be ''sure'' that you've destroyed an array before overwriting its ArrayID - otherwise, you've got a memory leak.  If possible, you can reuse the existing array (rather than destroying it and creating a new one) by setting its size to 0 with [[ArraySize]].
#Be ''sure'' that each use of [[CreateArray]] (or [[CopyArray]]) is matched with a use of [[DestroyArray]], except for the times when you specifically want an array to persist.
#Be ''sure'' that each use of [[CreateArray]] (or [[CopyArray]]) is matched with a use of [[DestroyArray]], except for the times when you specifically want an array to persist.
===Protection and Ownership===
Each array within Pluggy is "owned" by a particular Esp.  Usually, this will be the Esp which created it.  In addition, each array has a Protected flag.  When set, only the Esp which owns the array will be able to modify it.  By default, all arrays ''are not'' protected - unless you have a specific reason to leave your arrays open, you should always set them as protected, by using [[ArrayProtect]] or the Protected argument on [[CreateArray]].


===Data Types===
===Data Types===
Line 88: Line 85:
*[[SetInArray]], [[SetFloatInArray]] and [[SetRefInArray]] can take an optional argument (BlockSize) which allows them to expand an array to make room for new data.
*[[SetInArray]], [[SetFloatInArray]] and [[SetRefInArray]] can take an optional argument (BlockSize) which allows them to expand an array to make room for new data.
*[[RemInArray]] will clear the data at an index, leaving that index empty.  You can then use [[PackArray]] to delete the empty index from the array, decreasing its size.
*[[RemInArray]] will clear the data at an index, leaving that index empty.  You can then use [[PackArray]] to delete the empty index from the array, decreasing its size.
===Protection and Ownership===
Each array within Pluggy is "owned" by a particular Esp.  Usually, this will be the Esp which created it.  In addition, each array has a Protected flag.  When set, only the Esp which owns the array will be able to modify it.  By default, all arrays ''are not'' protected - unless you have a specific reason to leave your arrays open, you should always set them as protected, by using [[ArrayProtect]] or the Protected argument on [[CreateArray]].


==When to Use Arrays==
==When to Use Arrays==
Anonymous user