Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ModN Class Reference

List of all members.

Public Methods

 ModN (int mod, int value=0)
ModN & operator++ (int)
ModN & operator-- (int)
bool operator== (const ModN &operand) const
 operator int () const
bool completed ()

Private Attributes

int fMod
int fValue
bool fCompleted

Detailed Description

© Bernhard Wagner, bw@xmlizer.biz, 2003.

Models a "mod n set" (see e.g., John K. Truss "Discrete Mathematics for Computer Scientists", p.7)

Definition at line 23 of file LifeExercise.cpp.


Constructor & Destructor Documentation

ModN::ModN int    mod,
int    value = 0
[inline]
 

Parameters:
mod  The mod of the set
value  The value of the variable

Definition at line 30 of file LifeExercise.cpp.

References fCompleted, fMod, and fValue.


Member Function Documentation

bool ModN::completed   [inline]
 

Simulates iterator behaviour. Is set to true if the last increment or decrement lead to wraparound.

Returns:
True if the last increment or decrement lead to wraparound.

Definition at line 74 of file LifeExercise.cpp.

References fCompleted.

Referenced by Life::calculate().

ModN::operator int   const [inline]
 

As a convenience so ModN can be used directly within integer algebraic expressions. There is a danger though, since comparisons might lead to confusing results e.g.

 ModN mod34(4,3) int i = 4; mod43 == i; // ok, false, mod43 is 3, let's increment...
 mod43++; mod43 == i; // oops, false too, because of wrap around, i.e. mod43 now is 0!
 

Definition at line 66 of file LifeExercise.cpp.

References fValue.

ModN& ModN::operator++ int    [inline]
 

Asserts maintenance of affiliation to the set, i.e. "wraps around" Side effect: Updates inner state of completed which is used for iteration.

Definition at line 36 of file LifeExercise.cpp.

References fCompleted, fMod, and fValue.

ModN& ModN::operator-- int    [inline]
 

Asserts maintenance of affiliation to the set, i.e. "wraps around" Side effect: Updates inner state of completed which is used for iteration.

Definition at line 46 of file LifeExercise.cpp.

References fCompleted, fMod, and fValue.

bool ModN::operator== const ModN &    operand const [inline]
 

We compare mod and the value. FIXME: Probably should throw exception if mods are not the same.

Definition at line 56 of file LifeExercise.cpp.

References fMod, and fValue.


Member Data Documentation

bool ModN::fCompleted [private]
 

Definition at line 78 of file LifeExercise.cpp.

Referenced by completed(), ModN(), operator++(), and operator--().

int ModN::fMod [private]
 

Definition at line 76 of file LifeExercise.cpp.

Referenced by ModN(), operator++(), operator--(), and operator==().

int ModN::fValue [private]
 

Definition at line 77 of file LifeExercise.cpp.

Referenced by ModN(), operator int(), operator++(), operator--(), and operator==().


The documentation for this class was generated from the following file:
Generated on Sat Jul 19 18:19:55 2003 for Exercise Framework by doxygen1.2.18