Template Class Modular

Class Documentation

template<typename V>
class Modular

This class allows us to correctly handle version number overflow. Since the schedule needs to continue running for an arbitrarily long time, we cannot expect its versions numbers to get reset before it reaches the limit of its integer representation. This class allows us to compare version numbers that could have overflowed at some point.

Public Functions

inline Modular(V basis)
inline bool less_than(const V rhs) const

Compare rhs (right-hand side of the less-than comparison) directly to the basis value. This comparison is only permitted if the value of rhs is within half of the maximum modular distance of the basis. If rhs is further than that distance from the basis (either from above or below) then an exception will be thrown.

inline bool less_than_or_equal(const V rhs) const

Modify less(V) to also return true when equal.

inline bool less_than(const V lhs, const V rhs) const

Compare lhs (left-hand side) to rhs (right-hand side), and return true if and only if lhs is less than rhs.

This assumes that both lhs and rhs are greater than the basis, i.e. neither of these values has spilled past (overlapped) the basis value. This assumption allows us to do this comparison without any risk of an excpetion.

inline bool less_than_or_equal(const V lhs, const V rhs) const

Modify less(V, V) to also return true when lhs and rhs are equal.