RangeSet< T, MAP > Class Template Reference Data Structures

#include <rangemap.h>

Inheritance diagram for RangeSet< T, MAP >:

详细描述

template<typename T, typename MAP = BurstTrieMapSelector<>>
class maxon::RangeSet< T, MAP >

A RangeSet allows to add or remove a whole range of values to the set by a single operation (and a single entry in the set). Therefore, it is very useful for, e.g., selection sets where it is likely that contiguous ranges of indices are selected.

RangeSet is based on RangeMap , see there for more details.

RangeSet supports the usual iterators. They iterate through the map per range (not per each value of a range).

Template Parameters
T Type of keys. This must be an integral type.
MAP A map selector template to choose the underlying map implementation to use. This has to be an ordered map. Note that the default is the BurstTrieMap which only allows unsigned integral types.

Public Types

using  Super = RangeMap < T, UnitType , MAP >
using  Iterator = typename Super::KeyIterator
using  ConstIterator = typename Super::ConstKeyIterator

公共成员函数

HashInt   GetHashCode () const
Bool   operator== (const RangeSet &other) const
Bool   operator!= (const RangeSet &other) const
  RangeSet ()
  RangeSet ( RangeSet && src )
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( RangeSet )
Result < void >  CopyFrom (const RangeSet & src )
const Super GetMap () const
ResultMem   Insert (T value)
ResultMem   Insert (T minValue, T maxValue)
ResultMem   Insert (const typename Super::Range &range)
ResultMem   Erase (T value)
ResultMem   Erase (T minValue, T maxValue)
ResultMem   Erase (const typename Super::Range &range)
Bool   Contains (T value) const
Bool   Contains (T minValue, T maxValue)
Bool   Contains (const typename Super::Range &range)
Bool   FindRange (T value, typename Super::Range &rangeOut) const
ConstIterator   Begin () const
ConstIterator   End () const
Iterator   Begin ()
Iterator   End ()
void  重置 ()
void  Flush ()
Bool   IsEmpty () const
Bool   IsPopulated () const
Int   GetCount () const
Int   GetMemorySize () const
SFINAEHelper < String , K >::type  ToString (const FormatStatement *fmt=nullptr) const

静态公共成员函数

static Result < void >  DescribeIO (const DataSerializeInterface &stream)

私有成员函数

  MAXON_DISALLOW_COPY_AND_ASSIGN ( RangeSet )
-  Private Member Functions inherited from RangeMap< T, UnitType, BurstTrieMapSelector<> >
  RangeMap ()
  RangeMap ( RangeMap &&src)
  MAXON_OPERATOR_MOVE_ASSIGNMENT ( RangeMap )
Result < void >  CopyFrom (const RangeMap &src)
void  Flush ()
void  重置 ()
Int   GetCount () const
Bool   IsEmpty () const
Bool   IsPopulated () const
Int   GetMemorySize () const
ResultMem   Insert (T rMinValue, T rMaxValue, const UnitType &value)
ResultMem   Insert (T key, const UnitType &value)
ResultMem   Insert (const Range &range, const UnitType &value)
const UnitType FindValue (T key) const
const UnitType FindRange (T key, Range &rangeOut) const
ResultMem   Erase (T rMinValue, T rMaxValue)
ResultMem   Erase (T key)
ResultMem   Erase (const Range &range)
SFINAEHelper < String , T >::type  ToString (const FormatStatement *fmt=nullptr) const
Iterator   Begin ()
ConstIterator   Begin () const
Iterator   End ()
ConstIterator   End () const
KeyIterator   GetKeys ()
ConstKeyIterator   GetKeys () const
ValueIterator   GetValues ()
ConstValueIterator   GetValues () const
const MapType GetMap () const
HashInt   GetHashCode () const
Bool   operator== (const RangeMap &other) const
Bool   operator!= (const RangeMap &other) const
const MapType GetUnderlyingMap () const

Additional Inherited Members

-  Private Types inherited from RangeMap< T, UnitType, BurstTrieMapSelector<> >
using  MapType = typename BurstTrieMapSelector <> ::template Type< T, typename std::conditional< STD_IS_REPLACEMENT (same, UnitType , UnitType ), RangeSetPair < T >, Pair < T, UnitType > >::type >
using  Range = maxon::Range < T >
using  ValueType = typename MapType::ValueType
using  MapValue = typename MapType::ValueType
using  Iterator = typename MapType::template IteratorTemplate< false, EntryIteratorBase >
using  ConstIterator = typename MapType::template IteratorTemplate< true, EntryIteratorBase >
using  KeyIterator = typename MapType::template IteratorTemplate< false, KeyIteratorBase >
using  ConstKeyIterator = typename MapType::template IteratorTemplate< true, KeyIteratorBase >
using  ValueIterator = typename MapType::template IteratorTemplate< false, ValueIteratorBase >
using  ConstValueIterator = typename MapType::template IteratorTemplate< true, ValueIteratorBase >
-  Static Private Member Functions inherited from RangeMap< T, UnitType, BurstTrieMapSelector<> >
static Result < void >  DescribeIO (const DataSerializeInterface &stream)

Member Typedef Documentation

◆  Super

using Super = RangeMap <T, UnitType , MAP>

◆  Iterator

using Iterator = typename Super::KeyIterator

◆  ConstIterator

using ConstIterator = typename Super::ConstKeyIterator

构造函数 & 析构函数文档编制

◆  RangeSet() [1/2]

RangeSet ( )

◆  RangeSet() [2/2]

RangeSet ( RangeSet < T, MAP > &&  src )

成员函数文档编制

◆  GetHashCode()

HashInt GetHashCode ( ) const

◆  operator==()

Bool operator== ( const RangeSet < T, MAP > &  other ) const

◆  operator!=()

Bool operator!= ( const RangeSet < T, MAP > &  other ) const

◆  MAXON_OPERATOR_MOVE_ASSIGNMENT()

MAXON_OPERATOR_MOVE_ASSIGNMENT ( RangeSet < T, MAP >  )

◆  CopyFrom()

Result <void> CopyFrom ( const RangeSet < T, MAP > &  src )

◆  GetMap()

const Super & GetMap ( ) const

◆  Insert() [1/3]

ResultMem Insert ( value )

Adds the given value to this set.

参数
[in] value Value to add.
返回
False if a memory allocation failed.

◆  Insert() [2/3]

ResultMem Insert ( minValue ,
maxValue  
)

Adds the range minValue ... maxValue to this set, i.e., all values within that range will be contained in this set afterwards. If minValue 大于 maxValue , nothing happens.

参数
[in] minValue Lower boundary of the range to add.
[in] maxValue Upper boundary of the range to add.
返回
False if a memory allocation failed.

◆  Insert() [3/3]

ResultMem Insert ( const typename Super::Range range )

Adds the given range to this set, i.e., all values within that range will be contained in this set afterwards. If the range is empty, nothing happens.

参数
[in] range The range to add.
返回
False if a memory allocation failed.

◆  Erase() [1/3]

ResultMem Erase ( value )

Removes a single value from this set.

参数
[in] value Value to remove.
返回
False if a memory allocation failed.

◆  Erase() [2/3]

ResultMem Erase ( minValue ,
maxValue  
)

Removes the range minValue ... maxValue from this set, i.e., all values within that range won't be contained in this set afterwards. If minValue 大于 maxValue , nothing happens.

参数
[in] minValue Lower boundary of the range to remove.
[in] maxValue Upper boundary of the range to remove.
返回
False if a memory allocation failed.

◆  Erase() [3/3]

ResultMem Erase ( const typename Super::Range range )

Removes the given range from this set, i.e., all values within that range won't be contained in this set afterwards. If the range is empty, nothing happens.

参数
[in] range The range to remove.
返回
False if a memory allocation failed.

◆  Contains() [1/3]

Bool Contains ( value ) const

Checks if this set contains value .

参数
[in] value The value to check.
返回
True if this set contains value .

◆  Contains() [2/3]

Bool Contains ( minValue ,
maxValue  
)

Checks if this set contains all values of the range minValue ... maxValue .

参数
[in] minValue Lower boundary of the range to remove.
[in] maxValue Upper boundary of the range to remove.
返回
True if this set contains all values of minValue ... maxValue .

◆  Contains() [3/3]

Bool Contains ( const typename Super::Range range )

Checks if this set contains all values of the given range , i.e., if range is a subset of this set.

参数
[in] range The range to check.
返回
True if this set contains all values of range .

◆  FindRange()

Bool FindRange ( value ,
typename Super::Range rangeOut  
) const

Finds the contiguous range of values of this set which contains value . If such a range exists, rangeOut is set to the range and true is returned, otherwise false is returned.

参数
[in] value The value to check.
[out] rangeOut If a range containing value is found, rangeOut is set to this range.
返回
True if a range could be found.

◆  Begin() [1/2]

ConstIterator Begin ( ) const

◆  End() [1/2]

ConstIterator End ( ) const

◆  Begin() [2/2]

Iterator Begin ( )

◆  End() [2/2]

Iterator End ( )

◆  MAXON_DISALLOW_COPY_AND_ASSIGN()

MAXON_DISALLOW_COPY_AND_ASSIGN ( RangeSet < T, MAP >  )
private

◆  Reset()

void Reset

Resets the map. This removes all entries and frees any memory held by the map, so the map will be in a state as if it had been newly constructed.

另请参阅
Flush()

◆  Flush()

void Flush

Flushes the map. This removes all entries. Depending on the underlying map, memory may still be held for later re-use.

另请参阅
Reset()

◆  IsEmpty()

Bool IsEmpty

Checks if the RangeMap is empty. This is the same as GetCount() == 0

返回
True if this RangeMap does not contain any elements.

◆  IsPopulated()

Bool IsPopulated

Checks if the RangeMap is populated. This is the same as GetCount() != 0

返回
True if this RangeMap contains any elements.

◆  GetCount()

Int GetCount

Returns the number of entries in this map. Each contiguous key range where the keys are mapped to the same value requires a single entry.

返回
Number of entries.

◆  GetMemorySize()

Int GetMemorySize

Calculates the memory usage for this map. Keys and Values must have a public member GetMemorySize that return the element size.

返回
Memory size in bytes.

◆  ToString()

SFINAEHelper < String , K>::type ToString

◆  DescribeIO()

static Result <void> DescribeIO static