source: git/factory/cf_iter_inline.cc @ 8d1432e

spielwiese
Last change on this file since 8d1432e was b52d27, checked in by Martin Lee <martinlee84@…>, 10 years ago
chg: more docu changes
  • Property mode set to 100644
File size: 3.2 KB
Line 
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
75CFIterator::hasTerms () const
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**/
87CF_INLINE CanonicalForm
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**/
125CF_INLINE CFIterator &
126CFIterator::operator ++ ()
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**/
141CF_INLINE CFIterator &
142CFIterator::operator ++ ( int )
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
Note: See TracBrowser for help on using the repository browser.