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:
Collaboration diagram for sf::Range:

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.
 
Rangeoperator= (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.
 
Rangeassign (size_type start, size_type stop, id_type id=0)
 Assigns the data members.
 
Rangeassign (const Range &r)
 InitializeBase instance with other instance.
 
Rangeset (const RANGE &r)
 InitializeBase instance with other instance.
 
const RangecopyTo (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 RANGEgetBase () 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.
 
RangesetId (id_type id)
 Set the owner id of this range.
 
Rangeoperator= (const Range &r)
 Assignment operator allow derived classes to copy their data members.
 
Rangeoperator= (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.
 
Rangeoperator&= (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.
 
Rangeoperator+= (const Range &r)
 Returns a new range which is a super Set of the two ranges.
 
int exclude (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).
 
RangeoffsetBy (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

enum sf::Range::ECompare : int

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

Base function for comparing ranges.

◆ copyTo()

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

Copies the current instance to RANGE base struct.

◆ exclude()

int sf::Range::exclude ( 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.

◆ getBase()

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

Gets the underlying base structure.

◆ getId()

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

Returns the owner id of this range.

◆ getSize()

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

Returns the size of the range minimum is 1.

◆ getStart()

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

Const function to access the start of the range.

◆ getStop()

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

Const function to access the stop of the range.

◆ isEmpty()

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

Return true if the range is empty.

◆ isExtension()

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

Returns if the passed range an extension of this one.

◆ isInRange()

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

Check if idx is within this range.

◆ isMergeable()

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

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

Returns if the passed range have some overlap.

◆ isWithinOther()

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

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

◆ isWithinSelf()

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

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
inline

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 &&  )
inlinedefault

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]

static 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]

static 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]

Range::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.

Friends And Related Symbol Documentation

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