Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Partition.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include "Stroika/Foundation/Math/Common.h"
#include "Stroika/Foundation/Traversal/Iterable.h"
#include "Partition.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 

Functions

template<Traversal::IRange RANGETYPE>
bool Stroika::Foundation::Traversal::IsPartition (const Iterable< RANGETYPE > &iterable)
 

Detailed Description

STATUS: PRELIMINARY DRAFT.

TODO:

Definition in file Partition.h.

Function Documentation

◆ IsPartition()

template<Traversal::IRange RANGETYPE>
bool Stroika::Foundation::Traversal::IsPartition ( const Iterable< RANGETYPE > &  iterable)

Checks if the given collection of ranges 'cover' an interval, with no overlap (sharing no points).

Note
Half open (Range) intervals are generally best candidates for creating partitions
Precondition
the Range elements RANGE_TYPE - must be natively sortable (note we do not require that they be given in order)
Example Usage
using RT = Range<double>;
EXPECT_TRUE (not IsPartition (Sequence<RT>{RT{1, 2}, RT{3, 4}}));
EXPECT_TRUE (IsPartition (Sequence<RT>{RT{1, 2}, RT{2, 4}}));
Example Usage (using integers)
using RT = Range<int, Explicit<int, ExplicitOpenness<Openness::eClosed, Openness::eOpen>>>; // half open intervals best for partitions
EXPECT_TRUE (not IsPartition (Sequence<RT>{RT{1, 2}, RT{3, 4}}));
EXPECT_TRUE (IsPartition (Sequence<RT>{RT{1, 2}, RT{2, 4}}));

Definition at line 47 of file Partition.inl.