AMRange  201909
String localization library
Classes | Functions
AMRange.h File Reference
#include <set>
#include <algorithm>
Include dependency graph for AMRange.h:

Go to the source code of this file.

Classes

class  AMCore::AMRange< T >
 Range and set of range operations. More...
 

Functions

template<typename T >
AMRange< T > AMCore::intersect (const AMRange< T > &left, const AMRange< T > &right)
 intersect Intersection with right interval If ranges are in disjunction, returnned rage is empty More...
 
template<typename T >
AMRange< T > AMCore::operator+ (const AMRange< T > &left, const AMRange< T > &right)
 plus operator Cut part of range by intersect with right operand. If right range is inside left, returned range is left range. If ranges are in disjunction (and range will splitted to two), returned range is invalid. More...
 
template<typename T >
AMRange< T > AMCore::operator- (const AMRange< T > &left, const AMRange< T > &right)
 minus operator Cut part of range by intersect with right operand. If ranges are in disjunction, range is unchanged. If right range is inside left (and range will be splitted to two intervals), range become invalid. More...
 
template<typename T >
bool AMCore::isPacked (const std::set< AMRange< T > > &s)
 packed test Set of ranges is packed when, ranges has not intersections. E.q. Second range starts above first range end, third range start above second range end. Packed set of ranges also when, ranges are not splitted, E.q. range right bound not equal another range left bound More...
 
template<typename T >
bool AMCore::valid (const std::set< AMRange< T > > &s)
 valid test Set of ranges is valid when all range in are valid More...
 
template<typename T >
std::set< AMRange< T > > AMCore::pack (const std::set< AMRange< T > > &s)
 pack a set of ranges Set of ranges is packed when, ranges has not intersections. E.q. Second range starts above first range end, third range start above second range end. Packed set of ranges also when, ranges are not splitted, E.q. range right bound not equal another range left bound More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator+ (const std::set< AMRange< T > > &left, const std::set< AMRange< T > > &right)
 plus operator Adds two set of ranges. Sets of range must be valid. Result set of ranges is packed. More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator- (const std::set< AMRange< T > > &left, const std::set< AMRange< T > > &right)
 minus operator Subtracts two set of ranges. Sets of ranges must be valid. Result set of ranges is packed. More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator+ (const AMRange< T > &left, const std::set< AMRange< T > > &right)
 plus operator Adds range and set of ranges. Set of range mus be valid. Result set of ranges is packed. More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator- (const AMRange< T > &left, const std::set< AMRange< T > > &right)
 minus operator Subtracts range and set of ranges. Set of range mus be valid. Result set of ranges is packed. More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator+ (const std::set< AMRange< T > > &left, const AMRange< T > &right)
 plus operator Adds set of ranges and range Set of range must be valid. Result set of ranges is packed. More...
 
template<typename T >
std::set< AMRange< T > > AMCore::operator- (const std::set< AMRange< T > > &left, const AMRange< T > &right)
 minus operator Subtracts set of ranges and range Set of range must be valid. Result set of ranges is packed. More...
 

Detailed Description

Range and set of range operations

Author
Zdeněk Skulínek <me@zdenekskulinek.cz>

Function Documentation

◆ intersect()

template<typename T >
AMRange< T > AMCore::intersect ( const AMRange< T > &  left,
const AMRange< T > &  right 
)
inline

intersect Intersection with right interval If ranges are in disjunction, returnned rage is empty

Parameters
leftoperand
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::intersect(), and AMCore::intersect().

Referenced by AMCore::intersect().

◆ isPacked()

template<typename T >
bool AMCore::isPacked ( const std::set< AMRange< T > > &  s)

packed test Set of ranges is packed when, ranges has not intersections. E.q. Second range starts above first range end, third range start above second range end. Packed set of ranges also when, ranges are not splitted, E.q. range right bound not equal another range left bound

Parameters
sset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::isPacked().

Referenced by AMCore::isPacked().

◆ operator+() [1/4]

template<typename T >
AMRange< T > AMCore::operator+ ( const AMRange< T > &  left,
const AMRange< T > &  right 
)
inline

plus operator Cut part of range by intersect with right operand. If right range is inside left, returned range is left range. If ranges are in disjunction (and range will splitted to two), returned range is invalid.

Parameters
leftoperand
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator+().

Referenced by AMCore::operator+().

◆ operator+() [2/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator+ ( const AMRange< T > &  left,
const std::set< AMRange< T > > &  right 
)

plus operator Adds range and set of ranges. Set of range mus be valid. Result set of ranges is packed.

Parameters
leftrange
rightset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator+(), and AMCore::pack().

◆ operator+() [3/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator+ ( const std::set< AMRange< T > > &  left,
const AMRange< T > &  right 
)

plus operator Adds set of ranges and range Set of range must be valid. Result set of ranges is packed.

Parameters
leftset of ranges
rightrange
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator+(), and AMCore::pack().

◆ operator+() [4/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator+ ( const std::set< AMRange< T > > &  left,
const std::set< AMRange< T > > &  right 
)

plus operator Adds two set of ranges. Sets of range must be valid. Result set of ranges is packed.

Parameters
leftset of ranges
rightset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator+(), and AMCore::pack().

◆ operator-() [1/4]

template<typename T >
AMRange< T > AMCore::operator- ( const AMRange< T > &  left,
const AMRange< T > &  right 
)
inline

minus operator Cut part of range by intersect with right operand. If ranges are in disjunction, range is unchanged. If right range is inside left (and range will be splitted to two intervals), range become invalid.

Parameters
leftoperand
rightoperand
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator-().

Referenced by AMCore::operator-().

◆ operator-() [2/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator- ( const AMRange< T > &  left,
const std::set< AMRange< T > > &  right 
)

minus operator Subtracts range and set of ranges. Set of range mus be valid. Result set of ranges is packed.

Parameters
leftrange
rightset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator-().

◆ operator-() [3/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator- ( const std::set< AMRange< T > > &  left,
const AMRange< T > &  right 
)

minus operator Subtracts set of ranges and range Set of range must be valid. Result set of ranges is packed.

Parameters
leftset of ranges
rightrange
Exceptions
Thisfunction will not throw an exception.

References AMCore::operator-().

◆ operator-() [4/4]

template<typename T >
std::set< AMRange< T > > AMCore::operator- ( const std::set< AMRange< T > > &  left,
const std::set< AMRange< T > > &  right 
)

minus operator Subtracts two set of ranges. Sets of ranges must be valid. Result set of ranges is packed.

Parameters
leftset of ranges
rightset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::AMRange< T >::from, AMCore::AMRange< T >::nonEmpty(), AMCore::operator-(), AMCore::pack(), and AMCore::AMRange< T >::valid().

◆ pack()

template<typename T >
std::set< AMRange< T > > AMCore::pack ( const std::set< AMRange< T > > &  s)

pack a set of ranges Set of ranges is packed when, ranges has not intersections. E.q. Second range starts above first range end, third range start above second range end. Packed set of ranges also when, ranges are not splitted, E.q. range right bound not equal another range left bound

Parameters
sset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::pack(), and AMCore::AMRange< T >::valid().

Referenced by AMCore::operator+(), AMCore::operator-(), and AMCore::pack().

◆ valid()

template<typename T >
bool AMCore::valid ( const std::set< AMRange< T > > &  s)

valid test Set of ranges is valid when all range in are valid

Parameters
sset of ranges
Exceptions
Thisfunction will not throw an exception.

References AMCore::valid().

Referenced by AMCore::AMRange< T >::operator+=(), AMCore::AMRange< T >::operator-=(), and AMCore::valid().