MaximalElements< T, ARRAY, COMPARE, KEEP_DUPLICATES, MINIMAL > Class Template Reference

#include <partialorder.h>

Inheritance diagram for MaximalElements< T, ARRAY, COMPARE, KEEP_DUPLICATES, MINIMAL >:

Detailed Description

template<typename T, typename ARRAY = BaseArraySelector<>, typename COMPARE = DefaultCompare, Bool KEEP_DUPLICATES = false, Bool MINIMAL = false>
class maxon::MaximalElements< T, ARRAY, COMPARE, KEEP_DUPLICATES, MINIMAL >

MaximalElements finds the maximal elements of a set of values with a partial order. A maximal element of such a set is an element which is not less than any other element of the set. A partially ordered set may have more than one maximal element.

To use MaximalElements, add all values via the Append function. Afterwards, you can use MaximalElements like an array, it then will contain the maximal elements of all added values.

For comparison, MaximalElements uses the operator < on the values by default (or <= when KEEP_DUPLICATES is true), but you can override this with the #COMPARE parameter.

Template Parameters
TThe type of values. There has to be a partial order on T defined by COMPARE.
ARRAYAn array selector template to choose the array implementation to use.
COMPAREThe static LessThan function (or LessThanOrEqual when KEEP_DUPLICATES is true) of COMPARE is used for value comparisons.
KEEP_DUPLICATESIf true, elements of the set which are equal will be kept each in the array, otherwise only one of them will be in the array.
MINIMALIf true, find the minimal elements instead. Still only < or <= are used.
See also

Public Member Functions

const SuperGetUnderlyingArray () const
SuperGetUnderlyingArray ()
Result< void > Append (const T &value)
Result< void > Append (T &&value)

Private Types

using Super = typename ARRAY::template Type< T >
using Cmp = typename std::conditional< KEEP_DUPLICATES, COMPARE, maxon::details::LessThanOrEqualAsLessThan< COMPARE > >::type

Private Member Functions

template<typename A >
Result< void > AppendImpl (A &&value)

Member Typedef Documentation

◆ Super

using Super = typename ARRAY::template Type<T>

◆ Cmp

using Cmp = typename std::conditional<KEEP_DUPLICATES, COMPARE, maxon::details::LessThanOrEqualAsLessThan<COMPARE> >::type

Member Function Documentation

◆ GetUnderlyingArray() [1/2]

const Super& GetUnderlyingArray ( ) const

◆ GetUnderlyingArray() [2/2]

Super& GetUnderlyingArray ( )

◆ Append() [1/2]

Result<void> Append ( const T &  value)

◆ Append() [2/2]

Result<void> Append ( T &&  value)

◆ AppendImpl()

Result<void> AppendImpl ( A &&  value)