Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE > Class Template Reference

A DisjointRange is NOT a range, but a collection of non-overlapping (except at the edges) Ranges. It its BOUNDs (GetBounds) form a Range. More...

#include <DisjointRange.h>

Inheritance diagram for Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >:
Stroika::Foundation::Traversal::DisjointDiscreteRange< T, RANGE_TYPE >

Public Types

using RangeType = RANGE_TYPE
 a Disjoint range collection of (disjoint) ranges of this type.
 
using value_type = typename RangeType::value_type
 Range::value_type is the type of the contained elements of the range (say range of integers, value_type=int)
 

Public Member Functions

 DisjointRange ()=default
 
nonvirtual Containers::Sequence< RangeTypeSubRanges () const
 
nonvirtual bool empty () const
 
nonvirtual void clear ()
 
nonvirtual bool Contains (value_type elt) const
 
nonvirtual RangeType GetBounds () const
 
nonvirtual RangeType Closure () const
 like GetBounds (), but always returns a closed range
 
constexpr bool operator== (const DisjointRange &rhs) const
 

Detailed Description

template<typename T, typename RANGE_TYPE = Range<T>>
class Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >

A DisjointRange is NOT a range, but a collection of non-overlapping (except at the edges) Ranges. It its BOUNDs (GetBounds) form a Range.

DiscreteRange<> is an immutable type (once constructed, will never change), except for allowing operator=.

Note
Comparisons: o operator==, operator!= supported, but this assumes operator== is defined on 'T'

Definition at line 48 of file DisjointRange.h.

Constructor & Destructor Documentation

◆ DisjointRange()

template<typename T , typename RANGE_TYPE = Range<T>>
Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::DisjointRange ( )
default

You can pass in empty Ranges, ranges out of order, and overlapping ranges, and the constructor always filters out empty ranges, and re-order so subranges well-ordered and disjoint.

Member Function Documentation

◆ SubRanges()

template<typename T , typename RANGE_TYPE >
auto Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::SubRanges ( ) const

A disjoint range is made up of a finite number of disjoint (non-overlapping) subranges, which are arranged following the natural ordering intrinsic to the value_type. This returns those subranges.

Definition at line 44 of file DisjointRange.inl.

◆ empty()

template<typename T , typename RANGE_TYPE >
bool Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::empty ( ) const

Containing no points (same as containing no subranges).

Definition at line 54 of file DisjointRange.inl.

◆ clear()

template<typename T , typename RANGE_TYPE >
void Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::clear ( )

Same as *this = DisjointRange ()

Definition at line 59 of file DisjointRange.inl.

◆ Contains()

template<typename T , typename RANGE_TYPE >
bool Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::Contains ( value_type  elt) const
See also
Range::Contains.

This returns true if r is contained in some sub-element range. This is only the smae as GetBounds().Contains() if SubRanges ().size () <= 1.

Definition at line 64 of file DisjointRange.inl.

◆ GetBounds()

template<typename T , typename RANGE_TYPE >
RANGE_TYPE Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::GetBounds ( ) const

if empty, returns empty range()

Note
the resulting BOUNDS should captures the openness flags from the LHS and RHS bounds

//

Definition at line 77 of file DisjointRange.inl.

◆ Closure()

template<typename T , typename RANGE_TYPE >
RANGE_TYPE Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::Closure ( ) const

like GetBounds (), but always returns a closed range

//

Definition at line 93 of file DisjointRange.inl.

◆ operator==()

template<typename T , typename RANGE_TYPE >
constexpr bool Stroika::Foundation::Traversal::DisjointRange< T, RANGE_TYPE >::operator== ( const DisjointRange< T, RANGE_TYPE > &  rhs) const
constexpr

This returns true if the constituent subranges are all equal. This amounts to checking if the 'covered points' are all equal.

Definition at line 361 of file DisjointRange.inl.


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