|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Array
class
Generic dynamic array object wrapper.
This is a generic dynamic array wrapper class. Normally you cannot pass arrays (in their entirety) as parameters to functions; if you instead create an Array object of the appropriate type, you can store all the values in the array and still pass it to a function.
Also, with dynamic arrays, you cannot assign the contents of one array to another in a single assignment. If you do this with an Array object, you will be making both variables refer to the same array. Instead, use the Copy() function.
Because accessing elements in an Array object require a reference to the object, there is an ever-so-slight performance cost for using an Array instead of a built-in dynamic array. This cost should be negligible.
To use an Array class, create an object of the required type:
myobject = new ComplexArray(3)
You set the initial size when you create the object. You can change the size using SetArrayLength() just as you would use setLength() on a built-in dynamic array type:
myobject.SetArrayLength(12)
To access the array elements, use the m_Elements member:
complex p = myobject.m_Elements[5]
class Array { ; Generic dynamic array object wrapper. ; <p> ; This is a generic dynamic array wrapper class. Normally ; you cannot pass arrays (in their entirety) as parameters ; to functions; if you instead create an Array object of ; the appropriate type, you can store all the values in ; the array and still pass it to a function. ; <p> ; Also, with dynamic arrays, you cannot assign the contents ; of one array to another in a single assignment. If you ; do this with an Array object, you will be making both ; variables refer to the same array. Instead, use the ; Copy() function. ; <p> ; Because accessing elements in an Array object require a ; reference to the object, there is an ever-so-slight ; performance cost for using an Array instead of a built-in ; dynamic array. This cost should be negligible. ; <p> ; To use an Array class, create an object of the required ; type: ; <p> ; myobject = new ComplexArray(3) ; <p> ; You set the initial size when you create the object. You ; can change the size using SetArrayLength() just as you ; would use setLength() on a built-in dynamic array type: ; <p> ; myobject.SetArrayLength(12) ; <p> ; To access the array elements, use the m_Elements member: ; <p> ; complex p = myobject.m_Elements[5] public: ; Constructor ; ; @param plength initial length of the array func Array(int plength) endfunc ; Length wrapper ; ; @return the number of elements in the array int func GetArrayLength() return 0 endfunc ; setLength wrapper ; <p> ; This is analagous to UF's native setLength() function ; for dynamic arrays. ; ; @param plength new length of the array func SetArrayLength(int plength) endfunc ; Copy (must be implemented in each type) ; func Copy(Array &dest) default: }
Constructor Summary | |
---|---|
Array()
|
|
Array(int plength)
Constructor |
Method Summary | |
---|---|
int |
GetArrayLength()
Length wrapper |
void |
SetArrayLength(int plength)
setLength wrapper |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public Array(int plength)
plength
- initial length of the arraypublic Array()
Method Detail |
---|
public int GetArrayLength()
public void SetArrayLength(int plength)
This is analagous to UF's native setLength() function for dynamic arrays.
plength
- new length of the array
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |