interval Class Reference

#include <interval.h>


Public Types

typedef long data_t

Public Member Functions

 ~interval ()
 interval ()
 interval (const interval &rhs)
 interval (data_t first, data_t last)
intervaloperator= (const interval &rhs)
bool valid () const
void clear ()
interval operator+ (const interval &rhs) const
void operator+= (const interval &rhs)
interval operator* (const interval &rhs) const
void operator*= (const interval &rhs)
interval operator- (const interval &rhs) const
void operator-= (const interval &rhs)
bool member (data_t datum) const
void scan_begin ()
bool scan_next (data_t &datum)
void scan_end ()
bool empty () const
data_t first () const
data_t last () const
data_t second_last () const

Private Member Functions

void append (data_t datum)
void normalize ()

Private Attributes

size_t length
size_t size
size_t scan_index
data_t scan_next_datum
data_tdata


Detailed Description

The interval class is used to represent disjoint intervals of an integer type. The expected interval arithmtic operators (union, intersect and difference) are supported.

Definition at line 32 of file interval.h.


Member Typedef Documentation

typedef long interval::data_t

Definition at line 35 of file interval.h.


Constructor & Destructor Documentation

interval::~interval (  ) 

The destructor.

Note:
It is not virtual. Thou shalt not derive from this class.

interval::interval (  ) 

The default constructor. This constructs the empty interval.

interval::interval ( const interval rhs  ) 

The copy constructor.

interval::interval ( data_t  first,
data_t  last 
)

The constructor. It is used to construct a continuous interval with no holes. The arguments are inclusive.

Parameters:
first The first element in the interval.
last The last element in the interval.


Member Function Documentation

interval& interval::operator= ( const interval rhs  ) 

The assignment operator.

bool interval::valid (  )  const

The valid method is used when debugging, to ensure that the interval's internal state is self-consistent.

void interval::clear (  ) 

The clear method is used to discard all contents of the interval. It will be empty on return.

interval interval::operator+ ( const interval rhs  )  const

The addition operator is used to calculate the union of two intervals.

Parameters:
rhs The right hand side of the addition expression.
Returns:
a new interval containing the union of the two intervals

void interval::operator+= ( const interval rhs  ) 

interval interval::operator* ( const interval rhs  )  const

The multiplication operator is used to calculate the intersection of two intervals.

Parameters:
rhs The right hand side of the multiplication expression.
Returns:
a new interval containing the intersection of the two intervals

void interval::operator*= ( const interval rhs  ) 

interval interval::operator- ( const interval rhs  )  const

The subtraction operator is used to calculate the difference of two intervals.

Parameters:
rhs The right hand side of the subtraction expression.
Returns:
a new interval containing the difference of the two intervals

void interval::operator-= ( const interval rhs  ) 

bool interval::member ( data_t  datum  )  const

The member method is used to determine whether or not the given datum is a member of the interval.

Parameters:
datum The datum to look for in the interval.
Returns:
bool; true if is a member, false if is not

void interval::scan_begin (  ) 

bool interval::scan_next ( data_t datum  ) 

void interval::scan_end (  ) 

bool interval::empty (  )  const [inline]

The empty method is used to determine whether or not the interval is empty.

Returns:
bool; true if the interval is emoty, false if not.

Definition at line 144 of file interval.h.

data_t interval::first (  )  const

The first member is used to obtain the value of the first value in the interval.

Note:
the result is undefined if the interval is empty (assertion failure when debug enable)

data_t interval::last (  )  const

The last member is used to obtain the value of the last value in the interval.

Note:
the result is undefined if the interval is empty (assertion failure when debug enable)

data_t interval::second_last (  )  const

The second_last member is used to obtain the value of the first member of the contiguous portion of this interval.

Note:
the result is undefined if the interval is empty (assertion failure when debug enable)

void interval::append ( data_t  datum  )  [private]

The append method is used to add another datum to the data. It shall always be called in pairs. The first of every pair will result in an internal state which fails the valid() test.

void interval::normalize (  )  [private]

The normalize method is used to restore the interval to a valid() state after calculating a union, intersection or difference.


Field Documentation

size_t interval::length [private]

Definition at line 177 of file interval.h.

size_t interval::size [private]

Definition at line 178 of file interval.h.

size_t interval::scan_index [private]

Definition at line 179 of file interval.h.

Definition at line 180 of file interval.h.

data_t* interval::data [private]

Definition at line 181 of file interval.h.


The documentation for this class was generated from the following file:

Generated on Wed Mar 12 23:37:40 2008 for Aegis by  doxygen 1.5.5