Skip to content

Range

class Range

Class representing an integer range.

DEFINITION
class Range;

constructor Range

Create an empty range.

DEFINITION
Range ( );

constructor Range

Create a range with a specified start and size.

DEFINITION
Range ( uint64_t  start,
uint64_t  size );
PARAMETERDESCRIPTION
start

The starting value of the range.

size

The size of the range.

method addconst

Add another range to this range, creating a new range that includes all values included in either range or between them.

DEFINITION
Range  add ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The other range to add.

RETURNSDESCRIPTION
Range

A new range that includes all values included in either range or between them.

method add_left

Extend the range to the left.

DEFINITION
void  add_left ( uint64_t  amount );
PARAMETERDESCRIPTION
amount

The amount to extend the range by.

method add_right

Extend the range to the right.

DEFINITION
void  add_right ( uint64_t  amount );
PARAMETERDESCRIPTION
amount

The amount to extend the range by.

method align

Adjust the start of the range to a specified alignment without changing its end.

DEFINITION
void  align ( uint64_t  alignment );
PARAMETERDESCRIPTION
alignment

The alignment to align the range to.

THROWSDESCRIPTION
Exception

if the resulting range would be empty.

method containsconst

Check if the range contains another range.

DEFINITION
bool  contains ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The range to check.

RETURNSDESCRIPTION
bool

true if the range contains the other range, false otherwise.

method emptyconst

Check if the range is empty.

DEFINITION
bool  empty ( ) const;
RETURNSDESCRIPTION
bool

true if the range is empty, false otherwise.

method endconst

Get the last value included in the range.

DEFINITION
uint64_t  end ( ) const;
RETURNSDESCRIPTION
uint64_t

The last value included in the range.

method intersectconst

Get the intersection of the range with another range.

DEFINITION
Range  intersect ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The other range.

RETURNSDESCRIPTION
Range

The intersection of the two ranges.

method operator!=const

Check if two ranges are different.

DEFINITION
bool  operator!= ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The other range to compare with.

RETURNSDESCRIPTION
bool

true if the ranges are different, false otherwise.

method operator<const

Order two ranges, first by their starting value, then by their size.

DEFINITION
bool  operator< ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The other range to compare with.

RETURNSDESCRIPTION
bool

true if this range compares less than the other range, false otherwise.

method operator==const

Check if two ranges are the same.

DEFINITION
bool  operator== ( const Range & other ) const;
PARAMETERDESCRIPTION
other

The other range to compare with.

RETURNSDESCRIPTION
bool

true if the ranges are the same, false otherwise.

method remove_left

Remove a specified amount from the left of the range.

DEFINITION
void  remove_left ( uint64_t  amount );
PARAMETERDESCRIPTION
amount

The amount to remove from the left of the range.

THROWSDESCRIPTION
Exception

if the range is smaller than amount.

method remove_right

Remove a specified amount from the right of the range.

DEFINITION
void  remove_right ( uint64_t  amount );
PARAMETERDESCRIPTION
amount

The amount to remove from the right of the range.

THROWSDESCRIPTION
Exception

if the range is smaller than amount.

method serializeconst

Serialize the range to a stream.

DEFINITION
void  serialize ( std::ostream & stream ) const;
PARAMETERDESCRIPTION
stream

The stream to serialize to.

method set_end

Set the ending value of the range, keeping the start fixed.

DEFINITION
void  set_end ( uint64_t  new_end );
PARAMETERDESCRIPTION
new_end

The new ending value of the range.

THROWSDESCRIPTION
Exception

if the new_end is less than the current start.

method set_start

Set the starting value of the range, keeping the end fixed.

DEFINITION
void  set_start ( uint64_t  new_start );
PARAMETERDESCRIPTION
new_start

The new starting value of the range.

THROWSDESCRIPTION
Exception

if the new_start is greater than the current end.

member size

The size of the range. The range includes the values from start to start + size - 1.

DEFINITION
uint64_t  size;

member start

The starting value of the range.

DEFINITION
uint64_t  start;