position_array
List of: Classes
Subjects: Mathematics
Contents: Kernel

Purpose: Creates dynamic arrays of positions.

Derivation: position_array : ACIS_OBJECT : -

Filename: kern/kernel/geomhusk/posarray.hxx

Description: This class creates dynamic arrays of positions. There is an operator to cast a position_array to a SPAposition* so it can be used when a SPAposition* is needed, but it automatically grows as positions are added to it.

References: BASE SPAposition

Data: protected int m_nArraySize;

The initial size of the array.


protected int m_nNumPositions;

The number of positions in the initial size of the array.


protected SPAposition* m_pPositions;

The new position in the initial size of the array.

Constructor: public: position_array::position_array ();


C++ allocation constructor requests memory for this object but does not populate it.






public: position_array::position_array (


const position_array& // position_array


);


C++ copy constructor requests memory for this object and populates it with the data from the object supplied as an argument.






public: position_array::position_array (


int initialSize // initial size


);


C++ initialize constructor requests memory for this object and populates it with the data supplied as arguments.




Destructor: public: virtual position_array::~position_array ();


C++ destructor, deleting a position_array.



Methods: public: int position_array::Add (


const SPAposition& pos // position


);


Adds a SPAposition as the last position in the array, which expands the array as needed. Use the Add and RemoveLast methods for convenience to add positions to the array without keeping track of the current index.






public: SPAposition*


position_array::CopyBuffer () const;


Copies the position_array. The user must delete the returned buffer when it is no longer needed.






public: SPAposition& position_array::ElementAt (


int nIndex // index value


);


Gets the element at a given index in the array, which expands the size of the array if needed. The element returns as a reference so that it can be used on the left side of an assignment.






public: void position_array::Empty ();


Empties the array. This sets the number of positions in the array to 0, but it does not free up allocated storage.






public: SPAposition* position_array::GetBuffer () const;


Casts a position_array to a SPAposition* so that it can be used as an argument in procedures that require a SPAposition*. The returned pointer is only valid as long as the size of the array is not changed.






public: SPAposition position_array::GetLast () const;


Gets the last position in the array that is set.






public: int position_array::GetSize () const;


Returns the size of the position_array.






public: SPAposition& position_array::operator[] (


int nIndex // index value


);


Makes the operator look like an array. Because this method returns a position, it can be used on the left side of an assignment. The array is expanded, if needed, if the index is too large.






public: operator position_array::SPAposition* () const;


Returns a copy of the position. The user must must delete the returned buffer when it is no longer needed.






public: SPAposition position_array::PositionAt (


int nIndex // index value


) const;


Provides a copy of the position at a given index. This method also provides access to a constant position_array. The index must be within the range.






public: int position_array::RemoveLast ();


Removes the last position in the array. Use this with the Add method.






protected: void position_array::SetMinSize (


int size // initial size


);


Sets the size of the array so that it contains at least size positions. If the array is already the right size, the size does not change.






public: void position_array::SetSize (


int size // size


);


Sets the size of the array., which expands the array, if needed. If size is smaller than the current size, this sets the number of positions, but it does not change the amount of allocated memory.






public: void position_array::Shrink ();


Truncates the size of the internal position buffer so that it is exactly big enough to hold the specified number of positions.
PDF/KERN/34CLP.PDF
HTM/DATA/KERN/KERN/34CLP/0011.HTM