Loading...
Searching...
No Matches
CBasePolyEnumerator Class Reference

Base polynomial enumerator for simple iteration over terms of polynomials. More...

`#include <PolyEnumerator.h>`

## Public Member Functions

virtual bool | IsValid () const
| Current position is inside the collection (not -1 or past the end).
void | Reset (poly p)
| Reset this polynomial Enumerator with a different input polynomial.
| CBasePolyEnumerator (poly p=NULL)
| This enumerator is an empty polynomial by default.
virtual void | Reset ()
| Sets the position marker to the leading term.
virtual bool | MoveNext ()
| Advances the position to the next term of the polynomial. returns true if the position marker was successfully advanced to the next term which can be used; false if the position marker has passed the end of the polynomial.

## Protected Attributes

poly | m_position
| current position in the iterable object

## Private Attributes

poly | m_poly
| essentially immutable original iterable object

## Static Private Attributes

static const spolyrec | m_prevposition_struct = {}
| tag for "-1" position

## Friends

template<class T>
class | CRecursivePolyCoeffsEnumerator

## Additional Inherited Members

Protected Member Functions inherited from IBaseEnumerator
| IBaseEnumerator ()
| ~IBaseEnumerator ()

## Detailed Description

Base polynomial enumerator for simple iteration over terms of polynomials.

Note that the first element does not exist directly after Reset() call.

The class doesn't inherit from IAccessor and thus doesn't override Current().

See also
  IBaseEnumerator,
  CPolyCoeffsEnumerator

Definition at line 33 of file PolyEnumerator.h.

## Constructor & Destructor Documentation

## CBasePolyEnumerator()

CBasePolyEnumerator::CBasePolyEnumerator | ( | poly | p = NULL | ) |

inline

This enumerator is an empty polynomial by default.

Definition at line 62 of file PolyEnumerator.h.

:
IBaseEnumerator(), m_poly(p), m_position(const_cast<poly>(&m_prevposition_struct))
{
assume( !IsValid() );
}
p
int p
Definition cfModGcd.cc:4086
CBasePolyEnumerator::m_prevposition_struct
static const spolyrec m_prevposition_struct
tag for "-1" position
Definition PolyEnumerator.h:9
CBasePolyEnumerator::IsValid
virtual bool IsValid() const
Current position is inside the collection (not -1 or past the end).
Definition PolyEnumerator.h:46
CBasePolyEnumerator::m_poly
poly m_poly
essentially immutable original iterable object
Definition PolyEnumerator.h:38
CBasePolyEnumerator::m_position
poly m_position
current position in the iterable object
Definition PolyEnumerator.h:43
IBaseEnumerator::IBaseEnumerator
IBaseEnumerator()
Definition Enumerator.h:65
assume
#define assume(x)
Definition mod2.h:389

## Member Function Documentation

## IsValid()

virtual bool CBasePolyEnumerator::IsValid | ( |  | ) | const

inline virtual

Current position is inside the collection (not -1 or past the end).

Implements IBaseEnumerator.

Definition at line 46 of file PolyEnumerator.h.

{
// not -1 or past the end position?
return (m_position != NULL) && (m_position != &m_prevposition_struct);
}
NULL
#define NULL
Definition omList.c:12

## MoveNext()

virtual bool CBasePolyEnumerator::MoveNext | ( |  | ) |

inline virtual

Advances the position to the next term of the polynomial. returns true if the position marker was successfully advanced to the next term which can be used; false if the position marker has passed the end of the polynomial.

Implements IBaseEnumerator.

Definition at line 81 of file PolyEnumerator.h.

{
assume( m_position != NULL );
{
const poly p_next = pNext(m_position);
if (p_next != NULL) // not the last term?
{
m_position = p_next;
assume( IsValid() );
return true;
}
}
if (m_position == &m_prevposition_struct) // -1 position?
{
assume( !IsValid() );
m_position = m_poly;
return (m_position != NULL);
}
// else: past the end (or an empty polynomial)
m_position = NULL;
assume( !IsValid() );
return false;
}
pNext
#define pNext(p)
Definition monomials.h:36

## Reset() [1/2]

virtual void CBasePolyEnumerator::Reset | ( |  | ) |

inline virtual

Sets the position marker to the leading term.

Implements IBaseEnumerator.

Definition at line 69 of file PolyEnumerator.h.

{
m_position = const_cast<poly>(&m_prevposition_struct);
assume( !IsValid() );
}

## Reset() [2/2]

void CBasePolyEnumerator::Reset | ( | poly | p | ) |

inline

Reset this polynomial Enumerator with a different input polynomial.

Definition at line 54 of file PolyEnumerator.h.

{
m_poly = p;
m_position = const_cast<poly>(&m_prevposition_struct);
assume( !IsValid() );
}

## Friends And Related Symbol Documentation

## CRecursivePolyCoeffsEnumerator

template<class T>

friend class CRecursivePolyCoeffsEnumerator

friend

Definition at line 36 of file PolyEnumerator.h.

## Field Documentation

## m_poly

poly CBasePolyEnumerator::m_poly

private

essentially immutable original iterable object

Definition at line 38 of file PolyEnumerator.h.

## m_position

poly CBasePolyEnumerator::m_position

protected

current position in the iterable object

Definition at line 43 of file PolyEnumerator.h.

## m_prevposition_struct

const spolyrec CBasePolyEnumerator::m_prevposition_struct = {}

static private

tag for "-1" position

Definition at line 9 of file PolyEnumerator.h.

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

- libpolys/polys/PolyEnumerator.h
- libpolys/polys/PolyEnumerator.cc