My Project
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | Friends
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) More...
 
void Reset (poly p)
 Reset this polynomial Enumerator with a different input polynomial. More...
 
 CBasePolyEnumerator (poly p=NULL)
 This enumerator is an empty polynomial by default. More...
 
virtual void Reset ()
 Sets the position marker to the leading term. More...
 
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. More...
 
virtual bool MoveNext ()=0
 Advances the enumerator to the next element of the collection. returns true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. More...
 
virtual void Reset ()=0
 Sets the enumerator to its initial position: -1, which is before the first element in the collection. More...
 
virtual bool IsValid () const =0
 Current position is inside the collection (not -1 or past the end) More...
 

Protected Attributes

poly m_position
 current position in the iterable object More...
 

Private Attributes

poly m_poly
 essentially immutable original iterable object More...
 

Static Private Attributes

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

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 desn't 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.

62 :
64 {
65 assume( !IsValid() );
66 }
int p
Definition: cfModGcd.cc:4078
static const spolyrec m_prevposition_struct
tag for "-1" position
virtual bool IsValid() const
Current position is inside the collection (not -1 or past the end)
poly m_poly
essentially immutable original iterable object
poly m_position
current position in the iterable object
#define assume(x)
Definition: mod2.h:389

Member Function Documentation

◆ IsValid()

virtual bool CBasePolyEnumerator::IsValid ( ) const
inlinevirtual

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

Implements IBaseEnumerator.

Definition at line 46 of file PolyEnumerator.h.

47 {
48 // not -1 or past the end position?
50 }
#define NULL
Definition: omList.c:12

◆ MoveNext()

virtual bool CBasePolyEnumerator::MoveNext ( )
inlinevirtual

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.

82 {
84
85 {
86 const poly p_next = pNext(m_position);
87
88 if (p_next != NULL) // not the last term?
89 {
90 m_position = p_next;
91 assume( IsValid() );
92 return true;
93 }
94 }
95
96 if (m_position == &m_prevposition_struct) // -1 position?
97 {
98 assume( !IsValid() );
100 return (m_position != NULL);
101 }
102
103 // else: past the end (or an empty polynomial)
105 assume( !IsValid() );
106 return false;
107 }
#define pNext(p)
Definition: monomials.h:36

◆ Reset() [1/2]

virtual void CBasePolyEnumerator::Reset ( )
inlinevirtual

Sets the position marker to the leading term.

Implements IBaseEnumerator.

Definition at line 69 of file PolyEnumerator.h.

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

◆ 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.

55 {
56 m_poly = p;
57 m_position = const_cast<poly>(&m_prevposition_struct);
58 assume( !IsValid() );
59 }

Friends And Related Function 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 = {}
staticprivate

tag for "-1" position

Definition at line 40 of file PolyEnumerator.h.


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