Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Public Types | Public Member Functions | Private Attributes | Friends | List of all members
dev::RangeMask< T > Class Template Reference

Set of elements of a certain "ground range" representable by unions of ranges inside this ground range. More...

#include <RangeMask.h>

Classes

class  const_iterator
 

Public Types

using Range = std::pair< T, T >
 
using Ranges = std::vector< Range >
 

Public Member Functions

 RangeMask ()
 Constructs an empty range mask with empty ground range. More...
 
 RangeMask (T _begin, T _end)
 Constructs an empty range mask with ground range [_begin, _end). More...
 
 RangeMask (Range const &_c)
 Constructs an empty range mask with ground range _c. More...
 
RangeMask unionedWith (RangeMask const &_m) const
 
RangeMask operator+ (RangeMask const &_m) const
 
RangeMask lowest (decltype(T{}-T{}) _items) const
 
RangeMask operator~ () const
 
RangeMask inverted () const
 
RangeMaskinvert ()
 Changes the range mask to its complement relative to the ground range and returns a reference to itself. More...
 
template<class S >
RangeMask operator- (S const &_m) const
 
template<class S >
RangeMaskoperator-= (S const &_m)
 
RangeMaskoperator+= (RangeMask const &_m)
 
RangeMaskunionWith (RangeMask const &_m)
 
RangeMaskoperator+= (Range const &_m)
 
RangeMaskunionWith (Range const &_m)
 Modifies this range mask to also include the range _m, which has to be a subset of the ground range. More...
 
RangeMaskoperator+= (T _m)
 Adds the single element _i to the range mask. More...
 
RangeMaskunionWith (T _i)
 Adds the single element _i to the range mask. More...
 
bool contains (T _i) const
 
bool empty () const
 
bool full () const
 
void clear ()
 
void reset ()
 
std::pair< T, T > const & all () const
 
void extendAll (T _i)
 Extends the ground range to include _i. More...
 
const_iterator begin () const
 
const_iterator end () const
 
T next (T _t) const
 
size_t size () const
 
size_t firstOut () const
 
size_t lastIn () const
 

Private Attributes

UnsignedRange m_all
 The ground range. More...
 
std::map< T, Tm_ranges
 Mapping begin -> end containing the ranges. More...
 

Friends

template<class U >
std::ostream & operator<< (std::ostream &_out, RangeMask< U > const &_r)
 

Detailed Description

template<class T>
class dev::RangeMask< T >

Set of elements of a certain "ground range" representable by unions of ranges inside this ground range.

Ranges are given as pairs (begin, end), denoting the interval [begin, end), i.e. end is excluded. Supports set-theoretic operators, size and iteration.

Definition at line 46 of file RangeMask.h.

Member Typedef Documentation

template<class T>
using dev::RangeMask< T >::Range = std::pair<T, T>

Definition at line 51 of file RangeMask.h.

template<class T>
using dev::RangeMask< T >::Ranges = std::vector<Range>

Definition at line 52 of file RangeMask.h.

Constructor & Destructor Documentation

template<class T>
dev::RangeMask< T >::RangeMask ( )
inline

Constructs an empty range mask with empty ground range.

Definition at line 55 of file RangeMask.h.

Here is the caller graph for this function:

template<class T>
dev::RangeMask< T >::RangeMask ( T  _begin,
T  _end 
)
inline

Constructs an empty range mask with ground range [_begin, _end).

Definition at line 57 of file RangeMask.h.

template<class T>
dev::RangeMask< T >::RangeMask ( Range const &  _c)
inline

Constructs an empty range mask with ground range _c.

Definition at line 59 of file RangeMask.h.

Member Function Documentation

template<class T>
std::pair<T, T> const& dev::RangeMask< T >::all ( ) const
inline
Returns
the ground range.

Definition at line 153 of file RangeMask.h.

template<class T>
const_iterator dev::RangeMask< T >::begin ( ) const
inline

Definition at line 179 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
void dev::RangeMask< T >::clear ( )
inline

Definition at line 141 of file RangeMask.h.

template<class T>
bool dev::RangeMask< T >::contains ( T  _i) const
inline

Definition at line 123 of file RangeMask.h.

template<class T>
bool dev::RangeMask< T >::empty ( ) const
inline

Definition at line 131 of file RangeMask.h.

template<class T>
const_iterator dev::RangeMask< T >::end ( ) const
inline

Definition at line 180 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
void dev::RangeMask< T >::extendAll ( T  _i)
inline

Extends the ground range to include _i.

Definition at line 155 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
size_t dev::RangeMask< T >::firstOut ( ) const
inline

Definition at line 203 of file RangeMask.h.

template<class T>
bool dev::RangeMask< T >::full ( ) const
inline

Definition at line 136 of file RangeMask.h.

template<class T>
RangeMask& dev::RangeMask< T >::invert ( )
inline

Changes the range mask to its complement relative to the ground range and returns a reference to itself.

Definition at line 95 of file RangeMask.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
RangeMask dev::RangeMask< T >::inverted ( ) const
inline
Returns
a copy of this range mask representing the complement relative to the ground range.

Definition at line 78 of file RangeMask.h.

Here is the caller graph for this function:

template<class T>
size_t dev::RangeMask< T >::lastIn ( ) const
inline

Definition at line 210 of file RangeMask.h.

template<class T>
RangeMask dev::RangeMask< T >::lowest ( decltype(T{}-T{})  _items) const
inline
Returns
a new range mask containing the smallest _items elements (not ranges).

Definition at line 66 of file RangeMask.h.

template<class T>
T dev::RangeMask< T >::next ( T  _t) const
inline
Returns
the smallest element in the range mask that is larger than _t or the end of the base range if such an element does not exist.

Definition at line 183 of file RangeMask.h.

Here is the caller graph for this function:

template<class T>
RangeMask dev::RangeMask< T >::operator+ ( RangeMask< T > const &  _m) const
inline

Definition at line 63 of file RangeMask.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
RangeMask& dev::RangeMask< T >::operator+= ( RangeMask< T > const &  _m)
inline

Definition at line 100 of file RangeMask.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
RangeMask& dev::RangeMask< T >::operator+= ( Range const &  _m)
inline

Definition at line 110 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
RangeMask& dev::RangeMask< T >::operator+= ( T  _m)
inline

Adds the single element _i to the range mask.

Definition at line 116 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
template<class S >
RangeMask dev::RangeMask< T >::operator- ( S const &  _m) const
inline

Definition at line 97 of file RangeMask.h.

template<class T>
template<class S >
RangeMask& dev::RangeMask< T >::operator-= ( S const &  _m)
inline

Definition at line 98 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
RangeMask dev::RangeMask< T >::operator~ ( ) const
inline
Returns
the complement of the range mask relative to the ground range.

Definition at line 75 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
void dev::RangeMask< T >::reset ( )
inline

Definition at line 146 of file RangeMask.h.

template<class T>
size_t dev::RangeMask< T >::size ( ) const
inline
Returns
the number of elements (not ranges) in the range mask.

Definition at line 195 of file RangeMask.h.

template<class T>
RangeMask dev::RangeMask< T >::unionedWith ( RangeMask< T > const &  _m) const
inline
Returns
the union with the range mask _m, taking also the union of the ground ranges.

Definition at line 62 of file RangeMask.h.

Here is the call graph for this function:

template<class T>
RangeMask& dev::RangeMask< T >::unionWith ( RangeMask< T > const &  _m)
inline

Definition at line 102 of file RangeMask.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<class T>
RangeMask& dev::RangeMask< T >::unionWith ( Range const &  _m)

Modifies this range mask to also include the range _m, which has to be a subset of the ground range.

template<class T>
RangeMask& dev::RangeMask< T >::unionWith ( T  _i)
inline

Adds the single element _i to the range mask.

Definition at line 118 of file RangeMask.h.

Here is the call graph for this function:

Friends And Related Function Documentation

template<class T>
template<class U >
std::ostream& operator<< ( std::ostream &  _out,
RangeMask< U > const &  _r 
)
friend

Member Data Documentation

template<class T>
UnsignedRange dev::RangeMask< T >::m_all
private

The ground range.

Definition at line 219 of file RangeMask.h.

template<class T>
std::map<T, T> dev::RangeMask< T >::m_ranges
private

Mapping begin -> end containing the ranges.

Definition at line 221 of file RangeMask.h.


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