Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::Range Class Reference

Class to manage 64-bit integer ranges. More...

#include <Range.h>

Inheritance diagram for sf::Range:
[legend]
Collaboration diagram for sf::Range:
[legend]

Classes

class  Vector
 Type to contain and manipulate range lists. More...

Public Types

enum  ECompare : int {
  cmpError = std::numeric_limits<int>::max() , cmpSame = 0 , cmpWithinSelf = 1 , cmpWithinOther = -1 ,
  cmpOverlapsOther = 2 , cmpOverlapsSelf = -2 , cmpExtendsOther = 3 , cmpExtendsSelf = -3 ,
  cmpBeforeSelf = 4 , cmpAfterSelf = -4 , cmpSelfEmpty = 5 , cmpOtherEmpty = -5
}
 All possible comparison results.
. More...
typedef RANGE::size_type size_type
 Integer type used for start and stop.
typedef RANGE::id_type id_type
 Integer type used for the ID.
typedef Vector::iter_type Iterator
 Iteration type for lists of ranges.

Public Member Functions

 Range ()
 Default constructor.
Range & operator= (Range &&)=default
 Move assignment operator is default.
 Range (const Range &r)
 Copy constructor.
 Range (const RANGE &r)
 Base class constructor.
 Range (size_type start, size_type stop, id_type id=0)
 Initializing constructor.
void normalize ()
 Swaps start and stop if the order is wrong.
Range & assign (size_type start, size_type stop, id_type id=0)
 Assigns the data members.
Range & assign (const Range &r)
 InitializeBase instance with other instance.
Range & set (const RANGE &r)
 InitializeBase instance with other instance.
const Range & copyTo (RANGE &dst) const
size_type getStart () const
 Const function to access the start of the range.
size_type getStop () const
 Const function to access the stop of the range.
void clear ()
 Clears the range to an empty state.
size_type getSize () const
 Returns the size of the range minimum is 1.
bool isEmpty () const
 Return true if the range is empty.
bool isOverlapped (const Range &r) const
 Returns if the passed range have some overlap.
bool isWithinOther (const Range &r) const
 Returns true if the passed range is part of this range.
bool isWithinSelf (const Range &r) const
 Returns true if this range is part of the passed range.
bool isExtension (const Range &r) const
 Returns if the passed range an extension of this one.
bool isMergeable (const Range &r) const
 Returns true if the passed range can be combined to this range without having to bridge a gap.
size_type split (size_type seg_sz, Vector &rl_dst) const
 Splits this range into segments bounded ranges according to the passed segment size.
bool isInRange (size_type idx) const
 Check if idx is within this range.
const RANGE & getBase () const
 Gets the underlying base structure.
 operator bool () const
 Boolean operator for testing content of this instance.
ECompare compare (const Range &other) const
 Base function for comparing ranges.
id_type getId () const
 Returns the owner id of this range.
Range & setId (id_type id)
 Set the owner id of this range.
Range & operator= (const Range &r)
 Assignment operator allow derived classes to copy their data members.
Range & operator= (const RANGE &r)
 Assignment operator allow derived classes to copy their data members.
bool operator== (const Range &r) const
 Tests if the range start and stop members are the same.
bool operator!= (const Range &r) const
 Tests if the range start and stop members are not the same.
bool operator< (const Range &r) const
 Operator used for sorting. Depends only on the start position first and then the stop position. Empty ranges are always larger than non-empty ones to be able to move empty ones to the end of a vector.
Range operator& (const Range &r) const
 And operator which is a subset of both range where elements of the one also exist in the other range.
Range & operator&= (const Range &r)
 And operator which is a subset of both range where elements of the one also exist in the other range.
Range operator+ (const Range &r) const
 Returns a new range which is a super Set of the two ranges.
Range & operator+= (const Range &r)
 Returns a new range which is a super Set of the two ranges.
 int (const Range &r, Range &rest, Range::ECompare *cmp=nullptr)
 Exclude the range in the other which could result in an single range (0), an additional second range (1) or in an single empty range (-1).
Range & offsetBy (size_type ofs)
 Shifts this range using the passed offset.
Range offset (size_type ofs) const
 Shifts the range using the passed offset.
bool operator> (const Range &r) const =delete
 Not allowed operator.
bool operator> (const Range &r)=delete
 Not allowed operator.
bool operator<= (const Range &r) const =delete
 Not allowed operator.
bool operator<= (const Range &r)=delete
 Not allowed operator.
bool operator>= (const Range &r) const =delete
 Not allowed operator.
bool operator>= (const Range &r)=delete
 Not allowed operator.

Static Public Member Functions

static size_type split (size_type seg_sz, const Range &req, Vector &rl_dst)
 Splits a range into segments bounded ranges according to the passed segment size.
static size_type split (size_type seg_sz, const Vector &req, Vector &rl)
 Same as split but now for a complete vector of ranges.

Friends

std::ostream & operator<< (std::ostream &os, const Range &r)
 Output stream operator for a range.
std::istream & operator>> (std::istream &is, Range &r)
 Input stream operator for a range.

Detailed Description

Class to manage 64-bit integer ranges.

Member Typedef Documentation

◆ id_type

Integer type used for the ID.

◆ Iterator

Iteration type for lists of ranges.

◆ size_type

Integer type used for start and stop.

Member Enumeration Documentation

◆ ECompare

All possible comparison results.
.

'-' token of 'this' range.
'=' token of the 'other' range.

Enumerator
cmpError 

Failed to compare.

cmpSame 

Both ranges are the same.

|------------|
|============|
cmpWithinSelf 

The other range fits in this range.

|--------------|
|=======|
cmpWithinOther 

This range is fits in the other range.

|-------|
|==============|
cmpOverlapsOther 

This range overlaps and extends the other.

|---------|
|=========|
cmpOverlapsSelf 

The other range overlaps and extends this.

|---------|
|=========|
cmpExtendsOther 

This range extends the other exact.

|-----|
|=====|
cmpExtendsSelf 

The other range extends this one exact.

|-----|
|=====|
cmpBeforeSelf 

The other range does not overlap and is located before this one.

|-----|
|=====|
cmpAfterSelf 

The other range does not overlap and is located after this one.

|-----|
|=====|
cmpSelfEmpty 
||
|=====|
cmpOtherEmpty 
|-----|
||

Constructor & Destructor Documentation

◆ Range() [1/4]

sf::Range::Range ( )
inline

Default constructor.

◆ Range() [2/4]

sf::Range::Range ( const Range & r)
inline

Copy constructor.

Parameters
r

◆ Range() [3/4]

sf::Range::Range ( const RANGE & r)
inlineexplicit

Base class constructor.

◆ Range() [4/4]

sf::Range::Range ( size_type start,
size_type stop,
id_type id = 0 )
inline

Initializing constructor.

Parameters
startStart of the range.
stopStart of the range.
idIdentifier of the range.

Member Function Documentation

◆ assign() [1/2]

Range & sf::Range::assign ( const Range & r)
inline

InitializeBase instance with other instance.

◆ assign() [2/2]

Range & sf::Range::assign ( size_type start,
size_type stop,
id_type id = 0 )

Assigns the data members.

Parameters
startStart of the range.
stopStart of the range.
idIdentifier of the range.
Returns
Itself

◆ clear()

void sf::Range::clear ( )
inline

Clears the range to an empty state.

◆ compare()

ECompare sf::Range::compare ( const Range & other) const
nodiscard

Base function for comparing ranges.

◆ copyTo()

const Range & sf::Range::copyTo ( RANGE & dst) const
inline

Copies the current instance to RANGE base struct.

◆ getBase()

const RANGE & sf::Range::getBase ( ) const

Gets the underlying base structure.

◆ getId()

id_type sf::Range::getId ( ) const
inlinenodiscard

Returns the owner id of this range.

◆ getSize()

size_type sf::Range::getSize ( ) const
inlinenodiscard

Returns the size of the range minimum is 1.

◆ getStart()

size_type sf::Range::getStart ( ) const
inlinenodiscard

Const function to access the start of the range.

◆ getStop()

size_type sf::Range::getStop ( ) const
inlinenodiscard

Const function to access the stop of the range.

◆ int()

sf::Range::int ( const Range & r,
Range & rest,
Range::ECompare * cmp = nullptr )

Exclude the range in the other which could result in an single range (0), an additional second range (1) or in an single empty range (-1).

Parameters
rRange excluded from this one.
restSet when 2 is returned.
cmpOptional compare result.
Returns
Amount of resulting ranges. Could be -1, 0 or 1.

◆ isEmpty()

bool sf::Range::isEmpty ( ) const
inlinenodiscard

Return true if the range is empty.

◆ isExtension()

bool sf::Range::isExtension ( const Range & r) const
nodiscard

Returns if the passed range an extension of this one.

◆ isInRange()

bool sf::Range::isInRange ( size_type idx) const
inlinenodiscard

Check if idx is within this range.

◆ isMergeable()

bool sf::Range::isMergeable ( const Range & r) const
nodiscard

Returns true if the passed range can be combined to this range without having to bridge a gap.

◆ isOverlapped()

bool sf::Range::isOverlapped ( const Range & r) const
nodiscard

Returns if the passed range have some overlap.

◆ isWithinOther()

bool sf::Range::isWithinOther ( const Range & r) const
nodiscard

Returns true if the passed range is part of this range.

◆ isWithinSelf()

bool sf::Range::isWithinSelf ( const Range & r) const
nodiscard

Returns true if this range is part of the passed range.

◆ normalize()

void sf::Range::normalize ( )

Swaps start and stop if the order is wrong.

◆ offset()

Range sf::Range::offset ( size_type ofs) const
inlinenodiscard

Shifts the range using the passed offset.

Returns
The shifted range

◆ offsetBy()

Range & sf::Range::offsetBy ( size_type ofs)
inline

Shifts this range using the passed offset.

Parameters
ofsoffset
Returns
Itself

◆ operator bool()

sf::Range::operator bool ( ) const
inlineexplicit

Boolean operator for testing content of this instance.

◆ operator!=()

bool sf::Range::operator!= ( const Range & r) const
inline

Tests if the range start and stop members are not the same.

◆ operator&()

Range sf::Range::operator& ( const Range & r) const

And operator which is a subset of both range where elements of the one also exist in the other range.

◆ operator&=()

Range & sf::Range::operator&= ( const Range & r)
inline

And operator which is a subset of both range where elements of the one also exist in the other range.

◆ operator+()

Range sf::Range::operator+ ( const Range & r) const

Returns a new range which is a super Set of the two ranges.

A gap in between is bridged by the resulting.

◆ operator+=()

Range & sf::Range::operator+= ( const Range & r)
inline

Returns a new range which is a super Set of the two ranges.

A gap in between is bridged by the resulting.

◆ operator<()

bool sf::Range::operator< ( const Range & r) const
inline

Operator used for sorting. Depends only on the start position first and then the stop position. Empty ranges are always larger than non-empty ones to be able to move empty ones to the end of a vector.

◆ operator<=() [1/2]

bool sf::Range::operator<= ( const Range & r) const
delete

Not allowed operator.

◆ operator<=() [2/2]

bool sf::Range::operator<= ( const Range & r)
delete

Not allowed operator.

◆ operator=() [1/3]

Range & sf::Range::operator= ( const RANGE & r)
inline

Assignment operator allow derived classes to copy their data members.

◆ operator=() [2/3]

Range & sf::Range::operator= ( const Range & r)
inline

Assignment operator allow derived classes to copy their data members.

◆ operator=() [3/3]

Range & sf::Range::operator= ( Range && )
default

Move assignment operator is default.

◆ operator==()

bool sf::Range::operator== ( const Range & r) const
inline

Tests if the range start and stop members are the same.

◆ operator>() [1/2]

bool sf::Range::operator> ( const Range & r) const
delete

Not allowed operator.

◆ operator>() [2/2]

bool sf::Range::operator> ( const Range & r)
delete

Not allowed operator.

◆ operator>=() [1/2]

bool sf::Range::operator>= ( const Range & r) const
delete

Not allowed operator.

◆ operator>=() [2/2]

bool sf::Range::operator>= ( const Range & r)
delete

Not allowed operator.

◆ set()

Range & sf::Range::set ( const RANGE & r)

InitializeBase instance with other instance.

◆ setId()

Range & sf::Range::setId ( id_type id)
inline

Set the owner id of this range.

◆ split() [1/3]

size_type sf::Range::split ( size_type seg_sz,
const Range & req,
Vector & rl_dst )
static

Splits a range into segments bounded ranges according to the passed segment size.

The ID field of the range carries the segment index.

Parameters
seg_szSize of the segment.
reqRequested range.
rl_dstDestination list to receive the range(s) after splitting.
Returns
Amount ranges it was split into.

◆ split() [2/3]

size_type sf::Range::split ( size_type seg_sz,
const Vector & req,
Vector & rl )
static

Same as split but now for a complete vector of ranges.

Parameters
seg_szSize of the segment.
reqRequested ranges.
rlList where ranges are appended.
Returns
Amount ranges the request list was split into.

◆ split() [3/3]

size_type sf::Range::split ( size_type seg_sz,
Vector & rl_dst ) const
inline

Splits this range into segments bounded ranges according to the passed segment size.

The ID field of the range carries the segment index.

Parameters
seg_szSize of the segment.
rl_dstDestination list to receive the range(s) after splitting.
Returns
Amount ranges it was split into.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Range & r )
friend

Output stream operator for a range.

◆ operator>>

std::istream & operator>> ( std::istream & is,
Range & r )
friend

Input stream operator for a range.


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