srecord  1.65.0
srecord::interval Class Reference

The interval class is used to represent a set of integer values, usually composed of runs of adjacent value. More...

#include <interval.h>

Public Types

typedef uint32_t data_t
 The data_t type is used to parameterize the integr type used in the interval. More...
 
typedef uint64_t long_data_t
 

Public Member Functions

 ~interval ()
 The destructor. More...
 
 interval ()
 The default constructor. More...
 
 interval (data_t val)
 The constructor. More...
 
 interval (data_t lo, data_t hi)
 The constructor. More...
 
 interval (const interval &)
 The copy constructor. More...
 
intervaloperator= (const interval &)
 The assignment operator. More...
 
bool member (data_t val) const
 The member method is used to test whether a given value is a member of the interval. More...
 
bool empty () const
 The empty method is used to test whether the interval is empty. More...
 
void first_interval_only ()
 The first_interval_only method is used to crop the interval to the first (numerically least) run of consecutive integers in the set. More...
 
void scan_begin ()
 The interval_scan_begin method is used to start traversing every integer value in the interval. More...
 
bool scan_next (data_t &)
 The interval_scan_next method is used to traverse every integer value in the interval. More...
 
void scan_end ()
 The interval_scan_end method is used to finish traversing every integer value in the interval. More...
 
data_t get_lowest () const
 The get_lowest method is used to obtain the lower bound of the interval. More...
 
data_t get_highest () const
 The get_highest method is used to obtain the upper bound of the interval. More...
 
void print (std::ostream &) const
 The print method is used to print an interval on an output stream. More...
 
interval pad (int x) const
 The pad method is used to expand an interval by padding each sub-interval. More...
 
std::string representation () const
 The representation method is used to manufacture a textural representation of this interval. More...
 
interval flatten () const
 The flatten method is used to convert an interval with holes in it to a simple interval with no holes in it, by using the mimimum and maximum values. More...
 
long_data_t coverage () const
 The coverage method is used to obtain the size of the interval in bytes. More...
 

Static Public Member Functions

static interval union_ (const interval &, const interval &)
 The union_ class method is used to calculate the set union of two intervals. More...
 
static interval intersection (const interval &, const interval &)
 The intersection class method is used to calculate the set intersection of two intervals. More...
 
static interval difference (const interval &, const interval &)
 The difference class method is used to calculate the set difference of two intervals. More...
 
static bool equal (const interval &, const interval &)
 The equal class method is used to test the equality of two intervals. More...
 

Detailed Description

The interval class is used to represent a set of integer values, usually composed of runs of adjacent value.

Set arithmetic is implemented on these intervals.

Definition at line 35 of file interval.h.

Member Typedef Documentation

◆ data_t

typedef uint32_t srecord::interval::data_t

The data_t type is used to parameterize the integr type used in the interval.

Definition at line 47 of file interval.h.

◆ long_data_t

Definition at line 48 of file interval.h.

Constructor & Destructor Documentation

◆ ~interval()

srecord::interval::~interval ( )

The destructor.

It isn't virtual, so don't derive from this class.

◆ interval() [1/4]

srecord::interval::interval ( )

The default constructor.

The interval is empty.

◆ interval() [2/4]

srecord::interval::interval ( data_t  val)

The constructor.

The interval contains the single integer supplied.

Parameters
valThe interval is constructed to contain the single interger value supplied.

◆ interval() [3/4]

srecord::interval::interval ( data_t  lo,
data_t  hi 
)

The constructor.

The interval contains all values >= lo and < hi.

Parameters
loThe lower bound of the integers in the initial interval.
hiThe upper bound of the integers in the initial interval; this value is not included.

◆ interval() [4/4]

srecord::interval::interval ( const interval )

The copy constructor.

Member Function Documentation

◆ operator=()

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

The assignment operator.

◆ union_()

static interval srecord::interval::union_ ( const interval ,
const interval  
)
static

The union_ class method is used to calculate the set union of two intervals.

Referenced by srecord::operator+(), and srecord::operator+=().

◆ intersection()

static interval srecord::interval::intersection ( const interval ,
const interval  
)
static

The intersection class method is used to calculate the set intersection of two intervals.

Referenced by srecord::operator*(), and srecord::operator*=().

◆ difference()

static interval srecord::interval::difference ( const interval ,
const interval  
)
static

The difference class method is used to calculate the set difference of two intervals.

Referenced by srecord::operator-(), and srecord::operator-=().

◆ equal()

static bool srecord::interval::equal ( const interval ,
const interval  
)
static

The equal class method is used to test the equality of two intervals.

Referenced by srecord::operator!=(), and srecord::operator==().

◆ member()

bool srecord::interval::member ( data_t  val) const

The member method is used to test whether a given value is a member of the interval.

Parameters
valThe value to test for membership
Returns
True if the given value is a member of the interval, false if it is not.

◆ empty()

bool srecord::interval::empty ( ) const

The empty method is used to test whether the interval is empty.

Returns
True if the interval is empty, false if the interval is not empty.

◆ first_interval_only()

void srecord::interval::first_interval_only ( )

The first_interval_only method is used to crop the interval to the first (numerically least) run of consecutive integers in the set.

◆ scan_begin()

void srecord::interval::scan_begin ( )

The interval_scan_begin method is used to start traversing every integer value in the interval.

◆ scan_next()

bool srecord::interval::scan_next ( data_t )

The interval_scan_next method is used to traverse every integer value in the interval.

◆ scan_end()

void srecord::interval::scan_end ( )

The interval_scan_end method is used to finish traversing every integer value in the interval.

◆ get_lowest()

data_t srecord::interval::get_lowest ( ) const

The get_lowest method is used to obtain the lower bound of the interval.

It is inclusive.

◆ get_highest()

data_t srecord::interval::get_highest ( ) const

The get_highest method is used to obtain the upper bound of the interval.

It is exclusive (i.e. one beyond the highest integer in the set).

◆ print()

void srecord::interval::print ( std::ostream &  ) const

The print method is used to print an interval on an output stream.

Referenced by srecord::operator<<().

◆ pad()

interval srecord::interval::pad ( int  x) const

The pad method is used to expand an interval by padding each sub-interval.

For each sub-interval the minimum is rounded down to a multiple of x, and the upper bound is rounded up to a multiple of x.

Parameters
xThe multiple to expand to. No action is taken if x < 2.
Returns
new padded interval.

◆ representation()

std::string srecord::interval::representation ( ) const

The representation method is used to manufacture a textural representation of this interval.

◆ flatten()

interval srecord::interval::flatten ( ) const

The flatten method is used to convert an interval with holes in it to a simple interval with no holes in it, by using the mimimum and maximum values.

◆ coverage()

long_data_t srecord::interval::coverage ( ) const

The coverage method is used to obtain the size of the interval in bytes.

Returns
The number of bytes cobered by the interval, NOT including holes. Because the result could be 2**32, the 64-bit result is used so that this is representable.

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