My Project
Loading...
Searching...
No Matches
cf_iter_inline.cc
Go to the documentation of this file.
1/* emacs edit mode for this file is -*- C++ -*- */
2
3/**
4 *
5 * @file cf_iter_inline.cc
6 *
7 * definition of configurable inline
8 * `CFIterator' methods.
9 *
10 * Hierarchy: canonicalform, utility class
11 *
12 * Header file: cf_iter.h
13 *
14 * See `cf_inline.cc' for a description of "configurable inline
15 * methods".
16 *
17**/
18
19// check whether we are included or translated and
20// define `INCL_CF_ITER_INLINE_CC' if we are included
21#ifdef INCL_CF_ITER_H
22#define INCL_CF_ITER_INLINE_CC
23#endif
24
25
26#include "config.h"
27
28
29#include "cf_assert.h"
30
31// regular include file
32#include "canonicalform.h"
33
34// temporarily switch off `CF_USE_INLINE' and include
35// `cf_iter.h' if we are being translated.
36// `CF_USE_INLINE_SAVE' is used to save the state of
37// `CF_USE_INLINE'. It is unset after use.
38#ifndef INCL_CF_ITER_INLINE_CC
39#ifdef CF_USE_INLINE
40#define CF_USE_INLINE_SAVE
41#undef CF_USE_INLINE
42#endif
43#include "cf_iter.h"
44#ifdef CF_USE_INLINE_SAVE
45#define CF_USE_INLINE
46#undef CF_USE_INLINE_SAVE
47#endif
48#endif /* ! INCL_CF_ITER_INLINE_CC */
49
50// more regular include files
51#include "int_cf.h"
52#include "int_poly.h"
53
54// set the value of `CF_INLINE' for the following methods and
55// functions
56#if defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC )
57#undef CF_INLINE
58#define CF_INLINE inline
59#else
60#undef CF_INLINE
61#define CF_INLINE
62#endif /* ! defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC ) */
63
64#ifndef INCL_CF_ITER_INLINE_CC
65// selectors
66/** CF_INLINE int CFIterator::hasTerms () const
67 *
68 * hasTerm() - check whether CO points to a valid term.
69 *
70 * Return true if CO points to a valid term, false if CO points
71 * to the end of the sequence of terms.
72 *
73**/
74CF_INLINE int
76{
77 return hasterms;
78}
79
80/** CF_INLINE CanonicalForm CFIterator::coeff () const
81 *
82 * coeff() - return coefficient of current term of CO.
83 *
84 * CO has to point to a valid term.
85 *
86**/
88CFIterator::coeff () const
89{
90 ASSERT( hasterms, "lib error: iterator out of terms" );
91 if ( ispoly )
92 return cursor->coeff;
93 else
94 return data;
95}
96
97/** CF_INLINE int CFIterator::exp () const
98 *
99 * exp() - return exponent of current term of CO.
100 *
101 * CO has to point to a valid term.
102 *
103**/
104CF_INLINE int
105CFIterator::exp () const
106{
107 ASSERT( hasterms, "lib error: iterator out of terms" );
108 if ( ispoly )
109 return cursor->exp;
110 else
111 return 0;
112}
113
114// implementor methods
115/** CFIterator::operator ++ (), operator ++ ( int )
116 *
117 * operator ++() - advance CO to next term.
118 *
119 * Advance current term to next term in the sequence of terms or
120 * to end of sequence. CO has to point to a valid term.
121 *
122 * The postfix and prefix operator are identical.
123 *
124**/
127{
128 ASSERT( hasterms, "lib error: iterator out of terms" );
129 if ( ispoly ) {
130 cursor = cursor->next;
131 hasterms = cursor != 0;
132 } else
133 hasterms = false;
134
135 return *this;
136}
137
138/**
139 * @sa CFIterator::operator
140**/
143{
144 ASSERT( hasterms, "lib error: iterator out of terms" );
145 if ( ispoly ) {
146 cursor = cursor->next;
147 hasterms = cursor != 0;
148 } else
149 hasterms = false;
150
151 return *this;
152}
153#endif
Header for factory's main class CanonicalForm.
assertions for Factory
#define ASSERT(expression, message)
Definition: cf_assert.h:99
Iterators for CanonicalForm's.
#define CF_INLINE
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
bool ispoly
Definition: cf_iter.h:48
CF_NO_INLINE int exp() const
get the current exponent
CF_NO_INLINE CFIterator & operator++()
CF_NO_INLINE CanonicalForm coeff() const
get the current coefficient
CanonicalForm data
Definition: cf_iter.h:46
termList cursor
Definition: cf_iter.h:47
bool hasterms
Definition: cf_iter.h:48
CF_NO_INLINE int hasTerms() const
check if iterator has reached the end of CanonicalForm
factory's main class
Definition: canonicalform.h:86
term * next
Definition: int_poly.h:35
CanonicalForm coeff
Definition: int_poly.h:36
int exp
Definition: int_poly.h:37
Factory's internal CanonicalForm's.
Factory's internal polynomials.