|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Array common:GenericArray
class
Generic object dynamic array object wrapper.
This is a generic dynamic array wrapper class for Generic data. That is, you can create an array to hold any kind of object that is derived from the Generic base class. Unlike the other Array classes, elements in a GenericArray do not have to be of the same type. This gives you a lof of flexibility. However, when you access your objects from the m_Elements array, they will appear to be Generic objects rather than whatever class they really are. It is up to you to cast them to the correct type in your code; if you try to make a cast that is not valid (because the object is not of that type or derived from that type) UF will give a null (0) result for the cast.
See the Array base class for more information.
class GenericArray(Array) { ; Generic object dynamic array object wrapper. ; <p> ; This is a generic dynamic array wrapper class for ; Generic data. That is, you can create an array ; to hold any kind of object that is derived from ; the Generic base class. Unlike the other Array ; classes, elements in a GenericArray do not have ; to be of the same type. This gives you a lof of ; flexibility. However, when you access your objects ; from the m_Elements array, they will appear to be ; Generic objects rather than whatever class they ; really are. It is up to you to cast them to the ; correct type in your code; if you try to make a ; cast that is not valid (because the object is not ; of that type or derived from that type) UF will ; give a null (0) result for the cast. ; <p> ; See the Array base class for more information. public: ; Constructor ; ; @param plength initial length of the array func GenericArray(int plength) setLength(m_Elements, plength) endfunc ; Length wrapper ; ; @return the number of elements in the array int func GetArrayLength() return length(m_Elements) 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) setLength(m_Elements, plength) endfunc ; Copy (must be implemented in each type) ; ; @param dest GenericArray object to copy all values into; previous contents of dest will be discarded. func Copy(GenericArray &dest) int l = this.GetArrayLength() if (dest == 0) dest = new GenericArray(l) else dest.SetArrayLength(l) endif int j = 0 while (j < l) dest.m_Elements[j] = m_Elements[j] j = j + 1 endwhile endfunc ; Array elements (for direct access) Generic m_Elements[] default: }
Constructor Summary | |
---|---|
GenericArray()
|
|
GenericArray(int plength)
Constructor |
Method Summary | |
---|---|
void |
Copy(GenericArray dest)
Copy (must be implemented in each type) |
int |
GetArrayLength()
Length wrapper |
void |
SetArrayLength(int plength)
setLength wrapper |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public GenericArray(int plength)
plength
- initial length of the arraypublic GenericArray()
Method Detail |
---|
public int GetArrayLength()
GetArrayLength
in class Array
public void SetArrayLength(int plength)
This is analagous to UF's native setLength() function for dynamic arrays.
SetArrayLength
in class Array
plength
- new length of the arraypublic void Copy(GenericArray dest)
dest
- GenericArray object to copy all values into; previous contents of dest will be discarded.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |