Range< T > Class Template Reference

#include <range.h>

Inheritance diagram for Range< T >:

Inheritance graph
[legend]
Collaboration diagram for Range< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T>
class Range< T >

Range object represents a range of values.

Range object always has a begin and an end (inclusive). Ranges can be compared, merged, and split. The underlying object type used for representing the begin/end values of the range are generally required to be of integer type, but any suitable user-defined type can also be used that satisfies the comparison operations used by this class.

Definition at line 45 of file range.h.


Comparing ranges

template<typename X>
bool operator< (const Range< X > &x) const
template<typename X>
bool operator> (const Range< X > &x) const
template<typename X>
bool operator== (const Range< X > &x) const
template<typename X>
bool operator!= (const Range< X > &x) const
std::ostream & operator<< (std::ostream &o, const Range &r)

Public Types

typedef T size_type

Public Member Functions

Construction
template<typename X, typename Y>
 Range (const X &begin, const Y &end)
template<typename X>
 Range (const Range< X > &x)
template<typename X, typename Y>
 Range (const std::pair< X, Y > r)
 Range (std::istream &i)
template<typename X>
Rangeoperator= (const Range< X > &x)
 Range (const T &t)
 Constructs lenght=1 range.
Accessors
begin () const
end () const
length () const
void begin (const T &b)
void end (const T &e)
Operations
template<typename X>
void merge (const Range< X > &x)
 Merge another range with current one.
template<typename X>
boost::logic::tribool erase (Range< X > *x)
 Erase target range from current one.
template<typename X>
bool contains (const Range< X > &x) const
 Check if *this contains.
template<typename X>
bool contains (const X &x) const
 Simplified version of the above, this method checks if a given value exists in this range.
template<typename X>
bool containsFull (const Range< X > &x) const
 Check if *this completely contains.
template<typename X>
bool borders (const Range< X > &x) const
 Check if.
Convenience methods for easier usage
template<typename X>
bool contains (const X &x, const X &y)
template<typename X>
bool containsFull (const X &x, const X &y)
template<typename X>
boost::logic::tribool erase (const X &x, const X &y)

Private Member Functions

 Range ()
 Default constructor behaviour cannot be defined and is forbidden.

Private Attributes

m_begin
m_end
 begin offset

Friends

class Range
 end offset Be-friend with all our instances

Member Typedef Documentation

template<typename T>
typedef T Range< T >::size_type
 

Definition at line 47 of file range.h.


Constructor & Destructor Documentation

template<typename T>
template<typename X, typename Y>
Range< T >::Range const X &  begin,
const Y &  end
[inline]
 

Definition at line 52 of file range.h.

template<typename T>
template<typename X>
Range< T >::Range const Range< X > &  x  )  [inline]
 

Definition at line 56 of file range.h.

template<typename T>
template<typename X, typename Y>
Range< T >::Range const std::pair< X, Y >  r  )  [inline]
 

Definition at line 61 of file range.h.

template<typename T>
Range< T >::Range std::istream &  i  )  [inline]
 

Definition at line 64 of file range.h.

template<typename T>
Range< T >::Range const T &  t  )  [inline, explicit]
 

Constructs lenght=1 range.

Definition at line 75 of file range.h.

template<typename T>
Range< T >::Range  )  [private]
 

Default constructor behaviour cannot be defined and is forbidden.

Referenced by Range< uint64_t >::contains(), Range< uint64_t >::containsFull(), and Range< uint64_t >::erase().


Member Function Documentation

template<typename T>
void Range< T >::begin const T &  b  )  [inline]
 

Definition at line 110 of file range.h.

template<typename T>
T Range< T >::begin  )  const [inline]
 

Definition at line 107 of file range.h.

Referenced by PartData::doGetRange(), Detail::UsedRange::UsedRange(), and Detail::UsedRange::~UsedRange().

template<typename T>
template<typename X>
bool Range< T >::borders const Range< X > &  x  )  const [inline]
 

Check if.

Parameters:
x borders with *this. Bordering is defined if
x begins right after *this's end, or *this's begin starts right after
x's end.
x Range to be checked against bordering
Returns:
True if
Parameters:
x borders with *this.

Definition at line 237 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::contains const X &  x,
const X &  y
[inline]
 

Definition at line 252 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::contains const X &  x  )  const [inline]
 

Simplified version of the above, this method checks if a given value exists in this range.

Parameters:
x Value to check
Returns:
True if the value is within this range

Definition at line 209 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::contains const Range< X > &  x  )  const [inline]
 

Check if *this contains.

Parameters:
x. A range is considered to contain another range if it even partially overlaps with another range. To check if another range is completely contained within current range, use containsFull() method.
x Range to be checked against current range.
Returns:
True if containment is true, false otherwise.

Definition at line 190 of file range.h.

Referenced by Range< uint64_t >::contains(), and Range< uint64_t >::erase().

template<typename T>
template<typename X>
bool Range< T >::containsFull const X &  x,
const X &  y
[inline]
 

Definition at line 256 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::containsFull const Range< X > &  x  )  const [inline]
 

Check if *this completely contains.

Parameters:
x 
x Range to be checked against current range
Returns:
True if
Parameters:
x is completely within *this.

Definition at line 220 of file range.h.

Referenced by Range< uint64_t >::containsFull().

template<typename T>
void Range< T >::end const T &  e  )  [inline]
 

Definition at line 114 of file range.h.

template<typename T>
T Range< T >::end  )  const [inline]
 

Definition at line 108 of file range.h.

Referenced by PartData::doGetRange(), PartData::getLock(), PartData::getRange(), Detail::UsedRange::UsedRange(), and Detail::UsedRange::~UsedRange().

template<typename T>
template<typename X>
boost::logic::tribool Range< T >::erase const X &  x,
const X &  y
[inline]
 

Definition at line 260 of file range.h.

template<typename T>
template<typename X>
boost::logic::tribool Range< T >::erase Range< X > *  x  )  [inline]
 

Erase target range from current one.

Parameters:
x Pointer to range to be erased. If range splitting happened, it will be modified to contain the second half of the resulting two ranges.
Returns:
True if *this was truncated. False if this range was completely cleared out by
Parameters:
x. boost::indeterminate if *this was split into two, and
x contains the second half.

Definition at line 159 of file range.h.

Referenced by Range< uint64_t >::erase().

template<typename T>
T Range< T >::length  )  const [inline]
 

Definition at line 109 of file range.h.

template<typename T>
template<typename X>
void Range< T >::merge const Range< X > &  x  )  [inline]
 

Merge another range with current one.

Parameters:
x Range to merge into current one.
Note:
Implies that *this contains()
Parameters:
x. Does nothing if that is not true.

Definition at line 132 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::operator!= const Range< X > &  x  )  const [inline]
 

Definition at line 93 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::operator< const Range< X > &  x  )  const [inline]
 

Definition at line 81 of file range.h.

template<typename T>
template<typename X>
Range& Range< T >::operator= const Range< X > &  x  )  [inline]
 

Definition at line 70 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::operator== const Range< X > &  x  )  const [inline]
 

Definition at line 89 of file range.h.

template<typename T>
template<typename X>
bool Range< T >::operator> const Range< X > &  x  )  const [inline]
 

Definition at line 85 of file range.h.


Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< std::ostream &  o,
const Range< T > &  r
[friend]
 

Definition at line 96 of file range.h.

template<typename T>
friend class Range [friend]
 

end offset Be-friend with all our instances

Definition at line 272 of file range.h.


Member Data Documentation

template<typename T>
T Range< T >::m_begin [private]
 

Definition at line 268 of file range.h.

Referenced by Range< uint64_t >::erase(), Range< uint64_t >::merge(), Range< uint64_t >::operator=(), and Range< uint64_t >::operator==().

template<typename T>
T Range< T >::m_end [private]
 

begin offset

Definition at line 269 of file range.h.

Referenced by Range< uint64_t >::erase(), Range< uint64_t >::merge(), Range< uint64_t >::operator=(), and Range< uint64_t >::operator==().


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