ModN Class Reference

List of all members.

Public Member Functions

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

Private Attributes

int fMod
int fValue
bool fCompleted

Detailed Description

© Bernhard Wagner, 2003.

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

Definition at line 24 of file Life001.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 31 of file Life001.cpp.


Member Function Documentation

ModN& ModN::operator++ (  )  [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 37 of file Life001.cpp.

References fCompleted, fMod, and fValue.

ModN& ModN::operator-- (  )  [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 48 of file Life001.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 58 of file Life001.cpp.

References fMod, and fValue.

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 68 of file Life001.cpp.

References fValue.

bool ModN::completed (  )  [inline]

Simulates iterator behaviour. Is set to true if the last increment or decrement lead to wraparound. FIXME: better introduce iterators! This class actually is an iterator.

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

Definition at line 77 of file Life001.cpp.

References fCompleted.


Member Data Documentation

int ModN::fMod [private]

Definition at line 79 of file Life001.cpp.

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

int ModN::fValue [private]

Definition at line 80 of file Life001.cpp.

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

bool ModN::fCompleted [private]

Definition at line 81 of file Life001.cpp.

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


The documentation for this class was generated from the following file:
Generated on Thu Jul 3 19:12:45 2008 for Exercise Framework by  doxygen 1.5.1