Open Search
    RangeSet< T, MAP > Class Template Reference

    #include <rangemap.h>

    Inheritance diagram for RangeSet< T, MAP >:

    Detailed Description

    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
    TType of keys. This must be an integral type.
    MAPA 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
     

    Public Member Functions

    HashInt GetHashCode () const
     
    UniqueHash GetUniqueHashCode () 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 SuperGetMap () 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 Reset ()
     
    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 Public Member Functions

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

    Private Member Functions

     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 Reset ()
     
    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 UnitTypeFindValue (T key) const
     
    const UnitTypeFindRange (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 MapTypeGetMap () const
     
    HashInt GetHashCode () const
     
    UniqueHash GetUniqueHashCode () const
     
    Bool operator== (const RangeMap &other) const
     
    Bool operator!= (const RangeMap &other) const
     
    const MapTypeGetUnderlyingMap () const
     

    Additional Inherited Members

    - Private Types inherited from RangeMap< T, UnitType, BurstTrieMapSelector<> >
    using MapType = typename MAP::template Type< T, Tuple< T, UnitType > >
     
    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

    Constructor & Destructor Documentation

    ◆ RangeSet() [1/2]

    RangeSet ( )

    ◆ RangeSet() [2/2]

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

    Member Function Documentation

    ◆ GetHashCode()

    HashInt GetHashCode ( ) const

    ◆ GetUniqueHashCode()

    UniqueHash GetUniqueHashCode ( ) 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.

    Parameters
    [in]valueValue to add.
    Returns
    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 is greater than maxValue, nothing happens.

    Parameters
    [in]minValueLower boundary of the range to add.
    [in]maxValueUpper boundary of the range to add.
    Returns
    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.

    Parameters
    [in]rangeThe range to add.
    Returns
    False if a memory allocation failed.

    ◆ Erase() [1/3]

    ResultMem Erase ( value)

    Removes a single value from this set.

    Parameters
    [in]valueValue to remove.
    Returns
    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 is greater than maxValue, nothing happens.

    Parameters
    [in]minValueLower boundary of the range to remove.
    [in]maxValueUpper boundary of the range to remove.
    Returns
    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.

    Parameters
    [in]rangeThe range to remove.
    Returns
    False if a memory allocation failed.

    ◆ Contains() [1/3]

    Bool Contains ( value) const

    Checks if this set contains value.

    Parameters
    [in]valueThe value to check.
    Returns
    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.

    Parameters
    [in]minValueLower boundary of the range to remove.
    [in]maxValueUpper boundary of the range to remove.
    Returns
    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.

    Parameters
    [in]rangeThe range to check.
    Returns
    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.

    Parameters
    [in]valueThe value to check.
    [out]rangeOutIf a range containing value is found, rangeOut is set to this range.
    Returns
    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.

    See also
    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.

    See also
    Reset()

    ◆ IsEmpty()

    Bool IsEmpty

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

    Returns
    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

    Returns
    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.

    Returns
    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.

    Returns
    Memory size in bytes.

    ◆ ToString()

    SFINAEHelper<String, K>::type ToString

    ◆ DescribeIO()

    static Result<void> DescribeIO
    static