Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

mcAbstractArray Class Reference

#include <MathHelpers.h>

Inheritance diagram for mcAbstractArray:

Inheritance graph
[legend]
List of all members.

Detailed Description

Defines an array class for abstract classes.

This class should be used as parent class for specialized arrays.

Definition at line 75 of file MathHelpers.h.

Public Member Functions

 mcAbstractArray ()
 The constructor; does nothing.
virtual ~mcAbstractArray ()
 The destructor.
void data_Check () const
 Checks the array integrity.
Insert/Remove functions
Core array-management functions.

void data_Add (mcAbstractItem *pointer)
 math_Adds a pointer to the array.
void data_Insert (mcAbstractItem *pointer, int n)
 Inserts a pointer immediately before the n-th entry.
void data_SetItem (mcAbstractItem *pointer, int n)
 Removes the n-th object of the array (using data_Delete) and replaces it with the given pointer.
void data_RemoveAt (int idx, int count=1)
 Removes count elements starting from the idx-th entry of the array.
void data_Remove (const mcAbstractItem *p)
 Removes the given element if the data_Find() function returns a valid index.
mcAbstractItemdata_Detach (int idx)
 Detaches the i-th pointer and then returns it to the caller.
void data_Clear ()
 Removes all the elements of the array and free the memory occupied.
void data_DeepCopy (const mcAbstractArray &arr)
 Copies all the pointers in the given array; uses the data_GetCopyOf function to populate this array.
mcAbstractItemdata_GetItem (int idx)
 Returns a non-CONST pointer to the idx-th element of the array.
const mcAbstractItemdata_GetItem (int idx) const
 Returns a CONST pointer to the idx-th element of the array.
Query function
Miscellaneous aray-access functions.

bool data_isEmpty () const
 Returns TRUE if the array does not contain pointers.
int data_GetCount () const
 Returns the number of objects contained.
int data_Find (const mcAbstractItem *pointer) const
 Returns the index of the given pointer in this array or -1 if the given pointer is not stored in the array.

Protected Member Functions

virtual void data_Delete (int n)=0
 Deletes the n-th entry of the array.
virtual mcAbstractItemdata_GetCopyOf (int) const
 Copies the n-th object of the array and returns a pointer to it.
virtual void data_OnArrayChange ()
 This is a callback-like function called each time the array is modified (this does not mean *each* time a non-CONST function is called: RemoveAt(0, 0) would not trigger this function).

Private Attributes

wxArrayPtrVoid m_arr
 The array containing the pointers to the abstract items.


Constructor & Destructor Documentation

mcAbstractArray::mcAbstractArray  )  [inline]
 

The constructor; does nothing.

Definition at line 98 of file MathHelpers.h.

virtual mcAbstractArray::~mcAbstractArray  )  [inline, virtual]
 

The destructor.

Note:
: the Clear() function must be called from the derived-class destructor, since its a pure virtual function and thus it cannot be called from *this* destructor.

Definition at line 104 of file MathHelpers.h.


Member Function Documentation

void mcAbstractArray::data_Add mcAbstractItem pointer  ) 
 

math_Adds a pointer to the array.

The caller should never delete that pointer (it's owned from the array).

Definition at line 76 of file MathHelpers.cpp.

References data_OnArrayChange(), and m_arr.

Referenced by mcExtRange::data_Add(), mcSystemStepArray::data_AddFinalSys(), mcSystemStepArray::data_AddKeyLine(), mcSystemStepArray::data_AddLine(), mcMathAndSystemHelpers::data_AddLine(), mcSymbolArray::data_AddSymbol(), mcSystemStepArray::data_AddSys(), mcMathOrSystemHelpers::data_AddSys(), mcSystemStepArray::data_AddSysOnlyIfComplexEnough(), data_DeepCopy(), mcMathOrSystemHelpers::io_ImportToken(), mcSolverArray::math_Add(), mcMathOrSystemHelpers::math_AndMerge(), mcSystemStepArray::math_AppendCombinationOf(), mcMathAndSystemHelpers::math_Merge(), and mcMathOrSystemHelpers::math_OrMerge().

void mcAbstractArray::data_Check  )  const [inline]
 

Checks the array integrity.

Reimplemented in mcMathSystemHelpers, mcSolverArray, and mcSystemStepArray.

Definition at line 110 of file MathHelpers.h.

Referenced by mcSystemStepArray::data_Check(), and mcSolverArray::data_Check().

void mcAbstractArray::data_Clear  ) 
 

Removes all the elements of the array and free the memory occupied.

Definition at line 132 of file MathHelpers.cpp.

References data_GetCount(), data_RemoveAt(), and m_arr.

Referenced by mcMathCore::CleanupMath(), mcSymbol::CleanupSymbols(), mcExtRange::data_DeepCopy(), data_DeepCopy(), mcMathSystemHelpers::io_ImportInlinedExpr(), mcMathSystemHelpers::io_ImportPresentationMathML(), mcMathOrSystemHelpers::math_AndMerge(), mcMathAndSystemHelpers::math_Merge(), mcMathOrSystemHelpers::math_OrMerge(), mcExtRange::~mcExtRange(), mcMathAndSystemHelpers::~mcMathAndSystemHelpers(), mcMathOrSystemHelpers::~mcMathOrSystemHelpers(), mcSolverArray::~mcSolverArray(), mcSymbolArray::~mcSymbolArray(), and mcSystemStepArray::~mcSystemStepArray().

void mcAbstractArray::data_DeepCopy const mcAbstractArray arr  ) 
 

Copies all the pointers in the given array; uses the data_GetCopyOf function to populate this array.

Definition at line 148 of file MathHelpers.cpp.

References data_Add(), and data_Clear().

Referenced by mcMathSystemHelpers::data_DeepCopy().

virtual void mcAbstractArray::data_Delete int  n  )  [protected, pure virtual]
 

Deletes the n-th entry of the array.

Implemented in mcMathAndSystemHelpers, mcSymbolArray, mcMathOrSystemHelpers, mcExtRange, mcSolverArray, and mcSystemStepArray.

Referenced by data_RemoveAt().

mcAbstractItem * mcAbstractArray::data_Detach int  idx  ) 
 

Detaches the i-th pointer and then returns it to the caller.

Note:
The caller will have to handle its destruction.

Definition at line 121 of file MathHelpers.cpp.

References data_GetItem(), m_arr, and mcAbstractItem.

int mcAbstractArray::data_Find const mcAbstractItem pointer  )  const
 

Returns the index of the given pointer in this array or -1 if the given pointer is not stored in the array.

Definition at line 140 of file MathHelpers.cpp.

References data_GetCount(), and data_GetItem().

Referenced by data_Remove().

virtual mcAbstractItem* mcAbstractArray::data_GetCopyOf int   )  const [inline, protected, virtual]
 

Copies the n-th object of the array and returns a pointer to it.

Those arrays which do not need to use #DeepCopy can safely ignore function; a default implementation which returns NULL is provided.

Reimplemented in mcMathAndSystemHelpers, mcSymbolArray, and mcMathOrSystemHelpers.

Definition at line 88 of file MathHelpers.h.

References mcAbstractItem.

int mcAbstractArray::data_GetCount  )  const [inline]
 

Returns the number of objects contained.

Reimplemented in mcMathSystemHelpers.

Definition at line 168 of file MathHelpers.h.

References m_arr.

Referenced by mcSymbolArray::data_AddSymbol(), mcSystemStepArray::data_AddSysOnlyIfComplexEnough(), mcSystemStepArray::data_Check(), mcSolverArray::data_Check(), data_Clear(), data_Find(), mcSymbolArray::data_FindSymbol(), mcMathSystemHelpers::data_GetChildrenCount(), mcSystemStepArray::data_GetLast(), data_RemoveAt(), mcSolverArray::io_GetDescArray(), mcSystemStepArray::io_GetInlinedExpr(), mcSolverArray::math_Contains(), mcExtRange::math_isFinite(), mcSystemStepArray::math_RemoveIdenticSteps(), and mcSystemStepArray::math_RemoveSimpleSteps().

const mcAbstractItem* mcAbstractArray::data_GetItem int  idx  )  const [inline]
 

Returns a CONST pointer to the idx-th element of the array.

Definition at line 154 of file MathHelpers.h.

References m_arr, and mcAbstractItem.

mcAbstractItem* mcAbstractArray::data_GetItem int  idx  )  [inline]
 

Returns a non-CONST pointer to the idx-th element of the array.

Definition at line 151 of file MathHelpers.h.

References m_arr, and mcAbstractItem.

Referenced by mcMathOrSystemHelpers::data_Delete(), mcMathAndSystemHelpers::data_Delete(), data_Detach(), data_Find(), mcSystemStepArray::data_Get(), mcSolverArray::data_Get(), mcMathSystemHelpers::data_GetConstChild(), mcExtRange::data_GetRange(), and mcSymbolArray::data_GetSymbol().

void mcAbstractArray::data_Insert mcAbstractItem pointer,
int  n
 

Inserts a pointer immediately before the n-th entry.

Definition at line 82 of file MathHelpers.cpp.

References data_OnArrayChange(), and m_arr.

Referenced by data_SetItem().

bool mcAbstractArray::data_isEmpty  )  const [inline]
 

Returns TRUE if the array does not contain pointers.

Definition at line 165 of file MathHelpers.h.

References m_arr.

virtual void mcAbstractArray::data_OnArrayChange  )  [inline, protected, virtual]
 

This is a callback-like function called each time the array is modified (this does not mean *each* time a non-CONST function is called: RemoveAt(0, 0) would not trigger this function).

Definition at line 93 of file MathHelpers.h.

Referenced by data_Add(), data_Insert(), and data_RemoveAt().

void mcAbstractArray::data_Remove const mcAbstractItem p  ) 
 

Removes the given element if the data_Find() function returns a valid index.

Definition at line 113 of file MathHelpers.cpp.

References data_Find(), and data_RemoveAt().

Referenced by mcSymbolHelpers::data_Update().

void mcAbstractArray::data_RemoveAt int  idx,
int  count = 1
 

Removes count elements starting from the idx-th entry of the array.

Unlike wxArray does, this function also deletes, using the data_Delete() function the memory associated with the pointers removed.

Definition at line 96 of file MathHelpers.cpp.

References data_Delete(), data_GetCount(), data_OnArrayChange(), and m_arr.

Referenced by mcSymbol::CheckArray(), mcSymbolArray::data_AddSymbol(), data_Clear(), data_Remove(), data_SetItem(), mcSystemStepArray::math_RemoveIdenticSteps(), and mcSystemStepArray::math_RemoveSimpleSteps().

void mcAbstractArray::data_SetItem mcAbstractItem pointer,
int  n
 

Removes the n-th object of the array (using data_Delete) and replaces it with the given pointer.

This function is a sort of #Insert which overwrites destination entry.

Definition at line 90 of file MathHelpers.cpp.

References data_Insert(), and data_RemoveAt().


Member Data Documentation

wxArrayPtrVoid mcAbstractArray::m_arr [private]
 

The array containing the pointers to the abstract items.

Definition at line 78 of file MathHelpers.h.

Referenced by data_Add(), data_Clear(), data_Detach(), data_GetCount(), data_GetItem(), data_Insert(), data_isEmpty(), and data_RemoveAt().


The documentation for this class was generated from the following files:

Documentation generated with Doxygen on Sun Feb 6 17:12:17 2005
Visit MathStudio home page for more info

[ Top ]