srecord: srecord::interval Class Reference

srecord 1.65.0

Loading...
Searching...
No Matches
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.
typedef uint64_t | long_data_t

## Public Member Functions
| ~interval ()
| The destructor.
| interval ()
| The default constructor.
| interval (data_t val)
| The constructor.
| interval (data_t lo, data_t hi)
| The constructor.
| interval (const interval &)
| The copy constructor.
interval & | operator= (const interval &)
| The assignment operator.
bool | member (data_t val) const
| The member method is used to test whether a given value is a member of the interval.
bool | empty () const
| The empty method is used to test whether the interval is empty.
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.
void | scan_begin ()
| The interval_scan_begin method is used to start traversing every integer value in the interval.
bool | scan_next (data_t &)
| The interval_scan_next method is used to traverse every integer value in the interval.
void | scan_end ()
| The interval_scan_end method is used to finish traversing every integer value in the interval.
data_t | get_lowest () const
| The get_lowest method is used to obtain the lower bound of the interval.
data_t | get_highest () const
| The get_highest method is used to obtain the upper bound of the interval.
void | print (std::ostream &) const
| The print method is used to print an interval on an output stream.
interval | pad (int x) const
| The pad method is used to expand an interval by padding each sub-interval.
std::string | representation () const
| The representation method is used to manufacture a textural representation of this interval.
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.
long_data_t | coverage () const
| The coverage method is used to obtain the size of the interval in bytes.

## 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.
static interval | intersection (const interval &, const interval &)
| The intersection class method is used to calculate the set intersection of two intervals.
static interval | difference (const interval &, const interval &)
| The difference class method is used to calculate the set difference of two intervals.
static bool | equal (const interval &, const interval &)
| The equal class method is used to test the equality of two intervals.

## 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

typedef uint64_t srecord::interval::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.

Referenced by difference(), equal(), flatten(), intersection(), interval(), operator=(), pad(), and union_().

## ◆ interval() [2/4]

srecord::interval::interval | ( | data_t | val | ) |

The constructor.

The interval contains the single integer supplied.

Parameters

  val | The 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

  lo | The lower bound of the integers in the initial interval.
  hi | The 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.

References interval().

## Member Function Documentation

## ◆ operator=()

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

The assignment operator.

References interval().

## ◆ union_()

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

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

References interval().

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

## ◆ intersection()

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

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

References interval().

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

## ◆ difference()

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

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

References interval().

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

## ◆ equal()

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

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

References interval().

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

  val | The 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

  x | The multiple to expand to. No action is taken if x < 2.

Returns
  new padded interval.

References 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.

References interval().

## ◆ 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:

- interval.h