source: git/factory/cf_iter_inline.cc @ 362fc67

spielwiese
Last change on this file since 362fc67 was 362fc67, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: remove $Id$
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3//{{{ docu
4//
5// cf_iter_inline.cc - definition of configurable inline
6//   `CFIterator' methods.
7//
8// Hierarchy: canonicalform, utility class
9//
10// Header file: cf_iter.h
11//
12// See `cf_inline.cc' for a description of "configurable inline
13// methods".
14//
15//}}}
16
17// check whether we are included or translated and
18// define `INCL_CF_ITER_INLINE_CC' if we are included
19#ifdef INCL_CF_ITER_H
20#define INCL_CF_ITER_INLINE_CC
21#endif
22
23#include "config.h"
24
25#include "cf_assert.h"
26
27// regular include file
28#include "canonicalform.h"
29
30// temporarily switch off `CF_USE_INLINE' and include
31// `cf_iter.h' if we are being translated.
32// `CF_USE_INLINE_SAVE' is used to save the state of
33// `CF_USE_INLINE'.  It is unset after use.
34#ifndef INCL_CF_ITER_INLINE_CC
35#ifdef CF_USE_INLINE
36#define CF_USE_INLINE_SAVE
37#undef CF_USE_INLINE
38#endif
39#include "cf_iter.h"
40#ifdef CF_USE_INLINE_SAVE
41#define CF_USE_INLINE
42#undef CF_USE_INLINE_SAVE
43#endif
44#endif /* ! INCL_CF_ITER_INLINE_CC */
45
46// more regular include files
47#include "int_cf.h"
48#include "int_poly.h"
49
50// set the value of `CF_INLINE' for the following methods and
51// functions
52#if defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC )
53#undef CF_INLINE
54#define CF_INLINE inline
55#else
56#undef CF_INLINE
57#define CF_INLINE
58#endif /* ! defined( CF_USE_INLINE ) && defined( INCL_CF_ITER_INLINE_CC ) */
59
60#ifndef INCL_CF_ITER_INLINE_CC
61// selectors
62//{{{ CF_INLINE int CFIterator::hasTerms () const
63//{{{ docu
64//
65// hasTerm() - check whether CO points to a valid term.
66//
67// Return true if CO points to a valid term, false if CO points
68// to the end of the sequence of terms.
69//
70//}}}
71CF_INLINE int
72CFIterator::hasTerms () const
73{
74    return hasterms;
75}
76//}}}
77
78//{{{ CF_INLINE CanonicalForm CFIterator::coeff () const
79//{{{ docu
80//
81// coeff() - return coefficient of current term of CO.
82//
83// CO has to point to a valid term.
84//
85//}}}
86CF_INLINE CanonicalForm
87CFIterator::coeff () const
88{
89    ASSERT( hasterms, "lib error: iterator out of terms" );
90    if ( ispoly )
91        return cursor->coeff;
92    else
93        return data;
94}
95//}}}
96
97//{{{ CF_INLINE int CFIterator::exp () const
98//{{{ docu
99//
100// exp() - return exponent of current term of CO.
101//
102// CO has to point to a valid term.
103//
104//}}}
105CF_INLINE int
106CFIterator::exp () const
107{
108    ASSERT( hasterms, "lib error: iterator out of terms" );
109    if ( ispoly )
110        return cursor->exp;
111    else
112        return 0;
113}
114//}}}
115
116// implementor methods
117//{{{ CFIterator::operator ++ (), operator ++ ( int )
118//{{{ docu
119//
120// operator ++() - advance CO to next term.
121//
122// Advance current term to next term in the sequence of terms or
123// to end of sequence.  CO has to point to a valid term.
124//
125// The postfix and prefix operator are identical.
126//
127//}}}
128CF_INLINE CFIterator &
129CFIterator::operator ++ ()
130{
131    ASSERT( hasterms, "lib error: iterator out of terms" );
132    if ( ispoly ) {
133        cursor = cursor->next;
134        hasterms = cursor != 0;
135    } else
136        hasterms = false;
137
138    return *this;
139}
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//}}}
154#endif
Note: See TracBrowser for help on using the repository browser.