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 operators < and <= on the values by default, but you can override this with the #COMPARE parameter.

Template Parameters
TThe type of values. There has to be a partial order on T, given by the operators < and <=.
ARRAYAn array selector template to choose the array implementation to use.
COMPAREThe static LessThan and LessThanOrEqual functions found in COMPARE are used for the 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 < and <= are used.
See also
MinimalElements

Public Member Functions

const T & operator[] (Int index) const
 
const SuperGetUnderlyingArray () const
 
SuperGetUnderlyingArray ()
 
ResultMem Append (const T &value)
 
ResultMem 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
 

Member Typedef Documentation

◆ Super

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

◆ Cmp

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

Member Function Documentation

◆ operator[]()

const T& operator[] ( Int  index) const

◆ GetUnderlyingArray() [1/2]

const Super& GetUnderlyingArray ( ) const

◆ GetUnderlyingArray() [2/2]

Super& GetUnderlyingArray ( )

◆ Append() [1/2]

ResultMem Append ( const T &  value)

◆ Append() [2/2]

ResultMem Append ( T &&  value)