Milo  0.1
Milo:EquationManipulationProgram
Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
FactorIterator Class Reference

#include <milo.h>

Inheritance diagram for FactorIterator:
Inheritance graph
[legend]
Collaboration diagram for FactorIterator:
Collaboration graph
[legend]

Public Member Functions

Constructors
 FactorIterator (Node *node)
 
 FactorIterator (NodeIterator n)
 
 FactorIterator (Expression *expr)
 
Overloaded Operators
Node *& operator* ()
 
Node *& operator-> ()
 
bool operator== (const FactorIterator &rhs)
 
bool operator!= (const FactorIterator &rhs)
 
bool operator> (const FactorIterator &rhs)
 
bool operator>= (const FactorIterator &rhs)
 
bool operator< (const FactorIterator &rhs)
 
bool operator<= (const FactorIterator &rhs)
 
FactorIterator & operator++ ()
 
FactorIterator operator++ (int)
 
FactorIterator & operator-- ()
 
FactorIterator operator-- (int)
 
Helper Member Functions
void erase ()
 
void erase (const FactorIterator &end)
 
void mergeNextTerm ()
 
Term * splitTerm (bool fNeg=false)
 
void replace (Term *term)
 
void replace (Node *node)
 
void insert (Node *node)
 
void insertAfter (Node *node)
 
void insert (Term *node, bool sign=true)
 
void insertAfter (Term *term, bool sign=true)
 
bool isBegin ()
 
bool isEnd ()
 
bool isBeginTerm ()
 
bool isEndTerm ()
 
void setNode (int factor, int term)
 
FactorIterator getBegin ()
 
FactorIterator getLast ()
 

Static Public Member Functions

static void swap (FactorIterator &a, FactorIterator &b)
 

Private Member Functions

void next ()
 Get next factor in expression.
 
void prev ()
 Get previous factor in expression.
 

Private Attributes

Node * m_node
 Current factor.
 
Term * m_pTerm
 Parent term of current factor.
 
Expression * m_gpExpr
 Grandparent expresson of current factor.
 
unsigned int m_factor_index
 Index of current factor in parent term.
 
unsigned int m_term_index
 Term index of current factor in grandparent expression.
 

Detailed Description

Iteratorate over every factor in an expression. The precedence is the first factor in the first termn to the last factor in the last term.

Constructor & Destructor Documentation

FactorIterator::FactorIterator ( Node *  node)

Constructor for FactorIterator class. Initialize the current node this iterator points to.

Parameters
nodeNew current node.
FactorIterator::FactorIterator ( NodeIterator  n)
inline

Constructor for FactorIterator class from NodeIterator. Initialize the current node this iterator points to from NodeIterator.

Parameters
nNew current node.
FactorIterator::FactorIterator ( Expression *  expr)

Constructor for FactorIterator class from Expression object. Initialize the current node this iterator points to from first factor in Expression.

Parameters
exprNew cucrrent node from first factor of expr.

Member Function Documentation

void FactorIterator::erase ( )

Erase factor pointed to by iterator. Erase current node leaving iterator pointing to next factor.

void FactorIterator::erase ( const FactorIterator &  end)

Erase all nodes to given iterator. Starting with this iterators node to node pointed to by given iterator is erased. Iterator will be left pointing to next iterator.

Parameters
endFinal node to be erased.
FactorIterator FactorIterator::getBegin ( )
inline

Get iterator pointing to first factor in the expression of this FactorIterator.

Returns
New iterator pointing to first factor.
FactorIterator FactorIterator::getLast ( )
inline

Get iterator pointing to last factor in the expression of this FactorIterator.

Returns
New iterator pointing to last factor.
void FactorIterator::insert ( Node *  node)

Insert node before factor pointed to by this iterator. After insertion this iterator will point to new node.

Parameters
nodeFactor to be inserted.
void FactorIterator::insert ( Term *  node,
bool  sign = true 
)

Insert term before the parent term of the current factor.

Parameters
nodeTerm to be inserted.
signSign of term.
void FactorIterator::insertAfter ( Node *  node)

Insert node after factor pointed to by this iterator. After insertion this iterator will point to new node. If iterator is end, exception thrown.

Parameters
nodeFactor to be inserted.
void FactorIterator::insertAfter ( Term *  term,
bool  sign = true 
)

Insert term after the parent term of the current factor.

Parameters
termTerm to be inserted.
signSign of term.
bool FactorIterator::isBegin ( )
inline

Check if current factor is first in its grandparent expresion.

Returns
Return true if factor is first in expression.
bool FactorIterator::isBeginTerm ( )
inline

Check if current factor is first in its parent term.

Returns
Return true if factor is first in term.
bool FactorIterator::isEnd ( )
inline

Check if current factor is last in its grandparent expresion.

Returns
Return true if factor is last in expression.
bool FactorIterator::isEndTerm ( )

Check if current factor is last in its parent term.

Returns
Return true if factor is last in term.
void FactorIterator::mergeNextTerm ( )

Merge term pointed to by this iterator with next term if it exists.

bool FactorIterator::operator!= ( const FactorIterator &  rhs)
inline

Overloaded not equal operator.

Parameters
rhsNode to be compared.
Returns
True if node is not equal to rhs node.
Node*& FactorIterator::operator* ( )
inline

Overloaded dereference operator.

Returns
Current node.
FactorIterator& FactorIterator::operator++ ( )
inline

Overloaded postfix increment operator.

Returns
NodeIterator object pointing to next factor.
FactorIterator FactorIterator::operator++ ( int  )
inline

Overloaded prefix increment operator. This NodeIterator object will be decremented. Return an object with old iterator value.

Returns
Copy of NodeIterator pointing to old iterator value.
FactorIterator& FactorIterator::operator-- ( )
inline

Overloaded postfix decrement operator.

Returns
NodeIterator object pointing to previous factor.
FactorIterator FactorIterator::operator-- ( int  )
inline

Overloaded prefix decrement operator. This NodeIterator object will be decremented. Return an object with old iterator value.

Returns
Copy of NodeIterator pointing to old iterator value.
Node*& FactorIterator::operator-> ( )
inline

Overloaded member function operator. Returns pointer to current node to access member functions.

Returns
Current node member functions.
bool FactorIterator::operator< ( const FactorIterator &  rhs)

Overloaded lesser operator.

Parameters
rhsNode to be compared
Returns
True if rhs if after this node in same expression.
bool FactorIterator::operator<= ( const FactorIterator &  rhs)

Overloaded lesser or equal operator.

Parameters
rhsNode to be compared
Returns
True if rhs if after this node in same expression.
bool FactorIterator::operator== ( const FactorIterator &  rhs)
inline

Overloaded equal operator.

Parameters
rhsNode to be compared.
Returns
True if node is equal to rhs node.
bool FactorIterator::operator> ( const FactorIterator &  rhs)

Overloaded greater operator.

Parameters
rhsNode to be compared
Returns
True if rhs if after this node in same expression.
bool FactorIterator::operator>= ( const FactorIterator &  rhs)

Overloaded greater or equal operator.

Parameters
rhsNode to be compared
Returns
True if rhs if after this node in same expression.
void FactorIterator::replace ( Term *  term)

Replace the parent term of factor pointed to by iterator with new term.

Parameters
termTerm to replace factor's parent term pointed to by iterator.
void FactorIterator::replace ( Node *  node)

Replace factor pointed to by iterator with node.

Parameters
nodeNode to replace factor pointed to by iterator.
void FactorIterator::setNode ( int  factor,
int  term 
)

Point iterator to a specific factor in a specific term.

Parameters
factorIndex of factor in term.
termIndex of term in expression.
Term * FactorIterator::splitTerm ( bool  fNeg = false)

Split current term at factor pointed to by this iterator.

Parameters
fNegIf true, term is negative.
Returns
New term split from old one.

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