mc2lib
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
mc2lib::sets::Relation< Ts > Class Template Reference

#include <sets.hpp>

Classes

class  R_impl
 

Public Types

typedef Ts::Element Element
 
typedef Ts::template MapContainer< Set< Ts > > Container
 
typedef std::pair< Element, ElementTuple
 
typedef std::vector< ElementPath
 
typedef unsigned Properties
 

Public Member Functions

 Relation ()
 
 Relation (Container r)
 
const Containerget () const
 
Properties props () const
 
Relationset_props (Properties props)
 
Relationadd_props (Properties props)
 
Relationunset_props (Properties props)
 
bool all_props (Properties all) const
 
bool any_props (Properties any) const
 
Properties clear_props ()
 
void Insert (const Element &e1, const Element &e2, bool assert_unique=false)
 
void Insert (const Element &e1, Element &&e2, bool assert_unique=false)
 
void Insert (const Element &e1, const Set< Ts > &e2s)
 
void Insert (const Element &e1, Set< Ts > &&e2s)
 
bool Erase (const Element &e1, const Element &e2, bool assert_exists=false)
 
void Erase (const Element &e1, const Set< Ts > &e2s)
 
std::size_t size () const
 
template<class Func >
Func for_each (Func func) const
 
Relation Eval () const
 
RelationEvalInplace ()
 
template<class FilterFunc >
Relation Filter (FilterFunc filterFunc) const
 
Relation Inverse () const
 
Relationoperator|= (const Relation &rhs)
 
Relationoperator-= (const Relation &rhs)
 
Relationoperator &= (const Relation &rhs)
 
void Clear ()
 
bool empty () const
 
bool operator== (const Relation &rhs) const
 
bool operator!= (const Relation &rhs) const
 
bool R (const Element &e1, const Element &e2, Path *path=nullptr) const
 
Set< Ts > Reachable (const Element &e) const
 
bool Irreflexive (Path *cyclic=nullptr) const
 
bool Acyclic (Path *cyclic=nullptr) const
 
bool Transitive () const
 
bool TotalOn (const Set< Ts > &on) const
 
bool ConnexOn (const Set< Ts > &on) const
 
bool WeakPartialOrder (const Set< Ts > &on) const
 
bool WeakTotalOrder (const Set< Ts > &on) const
 
bool StrictPartialOrder (const Set< Ts > &on) const
 
bool StrictTotalOrder (const Set< Ts > &on) const
 
bool InOn (const Element &e) const
 
bool InDomain (const Element &e) const
 
bool InRange (const Element &e) const
 
Set< Ts > On () const
 
Set< Ts > Domain () const
 
Set< Ts > Range () const
 
bool SubsetEq (const Relation &rhs) const
 
bool Subset (const Relation &rhs) const
 

Static Public Attributes

static constexpr Properties kNone = 0x0
 
static constexpr Properties kTransitiveClosure = 0x1
 
static constexpr Properties kReflexiveClosure = 0x2
 
static constexpr Properties kReflexiveTransitiveClosure
 

Protected Types

enum  SearchMode { SearchMode::kRelated, SearchMode::kRelatedVisitAll, SearchMode::kFindCycle }
 
typedef Ts::template MapContainer< bool > FlagSet
 

Protected Member Functions

bool Contains__ (const Element &e) const
 
void GetPath (Path *out, const Element *start, const Element *end, FlagSet *visiting, SearchMode mode=SearchMode::kRelated) const
 
bool Irreflexive (Properties local_props, Path *cyclic) const
 
bool R_search (const Element &e1, const Element *e2, Set< Ts > *visited, FlagSet *visiting=nullptr, Properties local_props=kNone, SearchMode mode=SearchMode::kRelated) const
 

Protected Attributes

Properties props_
 
Container rel_
 

Member Typedef Documentation

§ Container

template<class Ts>
typedef Ts::template MapContainer<Set<Ts> > mc2lib::sets::Relation< Ts >::Container

§ Element

template<class Ts>
typedef Ts::Element mc2lib::sets::Relation< Ts >::Element

§ FlagSet

template<class Ts>
typedef Ts::template MapContainer<bool> mc2lib::sets::Relation< Ts >::FlagSet
protected

§ Path

template<class Ts>
typedef std::vector<Element> mc2lib::sets::Relation< Ts >::Path

§ Properties

template<class Ts>
typedef unsigned mc2lib::sets::Relation< Ts >::Properties

Lazy operators as properties.

All in-place operators (e.g. |=) evaluate the current relation in place and clear properties.

§ Tuple

template<class Ts>
typedef std::pair<Element, Element> mc2lib::sets::Relation< Ts >::Tuple

Member Enumeration Documentation

§ SearchMode

template<class Ts>
enum mc2lib::sets::Relation::SearchMode
strongprotected

Search mode.

Enumerator
kRelated 

Check if two elements are related.

kRelatedVisitAll 

Check if two elements are related, but visit all elements.

kFindCycle 

Only find a cycle from a given element (node).

Constructor & Destructor Documentation

§ Relation() [1/2]

template<class Ts>
mc2lib::sets::Relation< Ts >::Relation ( )
inline

§ Relation() [2/2]

template<class Ts>
mc2lib::sets::Relation< Ts >::Relation ( Container  r)
inlineexplicit

Member Function Documentation

§ Acyclic()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Acyclic ( Path cyclic = nullptr) const
inline

§ add_props()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::add_props ( Properties  props)
inline

§ all_props()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::all_props ( Properties  all) const
inline

§ any_props()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::any_props ( Properties  any) const
inline

§ Clear()

template<class Ts>
void mc2lib::sets::Relation< Ts >::Clear ( )
inline

§ clear_props()

template<class Ts>
Properties mc2lib::sets::Relation< Ts >::clear_props ( )
inline

§ ConnexOn()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::ConnexOn ( const Set< Ts > &  on) const
inline

∀(x,y) ∈ on×on, x→y ∨ y→x ∨ x=y

§ Contains__()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Contains__ ( const Element e) const
inlineprotected
Returns
true if e in rel_.

§ Domain()

template<class Ts>
Set<Ts> mc2lib::sets::Relation< Ts >::Domain ( ) const
inline

§ empty()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::empty ( ) const
inline

§ Erase() [1/2]

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Erase ( const Element e1,
const Element e2,
bool  assert_exists = false 
)
inline

§ Erase() [2/2]

template<class Ts>
void mc2lib::sets::Relation< Ts >::Erase ( const Element e1,
const Set< Ts > &  e2s 
)
inline

§ Eval()

template<class Ts>
Relation mc2lib::sets::Relation< Ts >::Eval ( ) const
inline

Evaluated view of the relation, with properties evaluated.

Returns
Evaluated Relation.

§ EvalInplace()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::EvalInplace ( )
inline

Evaluate all properties in-place.

Returns
Reference to this object.

§ Filter()

template<class Ts>
template<class FilterFunc >
Relation mc2lib::sets::Relation< Ts >::Filter ( FilterFunc  filterFunc) const
inline

§ for_each()

template<class Ts>
template<class Func >
Func mc2lib::sets::Relation< Ts >::for_each ( Func  func) const
inline

Iterates over each tuple in the relation (uses properties).

Parameters
funcA function taking two parameters of type Element.

§ get()

template<class Ts>
const Container& mc2lib::sets::Relation< Ts >::get ( ) const
inline

Avoid accessing underlying container directly if possible! Uses of get() should be justified.

§ GetPath()

template<class Ts>
void mc2lib::sets::Relation< Ts >::GetPath ( Path out,
const Element start,
const Element end,
FlagSet visiting,
SearchMode  mode = SearchMode::kRelated 
) const
inlineprotected

Get path from start to end.

§ InDomain()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::InDomain ( const Element e) const
inline

§ InOn()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::InOn ( const Element e) const
inline

§ InRange()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::InRange ( const Element e) const
inline

§ Insert() [1/4]

template<class Ts>
void mc2lib::sets::Relation< Ts >::Insert ( const Element e1,
const Element e2,
bool  assert_unique = false 
)
inline

§ Insert() [2/4]

template<class Ts>
void mc2lib::sets::Relation< Ts >::Insert ( const Element e1,
Element &&  e2,
bool  assert_unique = false 
)
inline

§ Insert() [3/4]

template<class Ts>
void mc2lib::sets::Relation< Ts >::Insert ( const Element e1,
const Set< Ts > &  e2s 
)
inline

§ Insert() [4/4]

template<class Ts>
void mc2lib::sets::Relation< Ts >::Insert ( const Element e1,
Set< Ts > &&  e2s 
)
inline

§ Inverse()

template<class Ts>
Relation mc2lib::sets::Relation< Ts >::Inverse ( ) const
inline
Returns
R^-1 = {(y,x) | (x,y) ∈ R}

§ Irreflexive() [1/2]

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Irreflexive ( Path cyclic = nullptr) const
inline

§ Irreflexive() [2/2]

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Irreflexive ( Properties  local_props,
Path cyclic 
) const
inlineprotected

Check that relation is irreflexive.

Parameters
local_propsCall specific properties.
cyclicOptional parameter, in which the cycle is returned, if result is false.
Returns
true if irreflexive, false otherwise.

§ On()

template<class Ts>
Set<Ts> mc2lib::sets::Relation< Ts >::On ( ) const
inline

§ operator &=()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::operator&= ( const Relation< Ts > &  rhs)
inline

Relation intersection

§ operator!=()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::operator!= ( const Relation< Ts > &  rhs) const
inline

§ operator-=()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::operator-= ( const Relation< Ts > &  rhs)
inline

Relation difference.

§ operator==()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::operator== ( const Relation< Ts > &  rhs) const
inline

§ operator|=()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::operator|= ( const Relation< Ts > &  rhs)
inline

Relation union.

§ props()

template<class Ts>
Properties mc2lib::sets::Relation< Ts >::props ( ) const
inline

§ R()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::R ( const Element e1,
const Element e2,
Path path = nullptr 
) const
inline

Check if (e1, e2) is in the relation. This effectively does a search if there is an edge from e1 to e2.

Parameters
e1first element.
e2second element
pathOptional; return path from e1 to e2.
Returns
true if (e1, e2) is in the relation.

§ R_search()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::R_search ( const Element e1,
const Element e2,
Set< Ts > *  visited,
FlagSet visiting = nullptr,
Properties  local_props = kNone,
SearchMode  mode = SearchMode::kRelated 
) const
inlineprotected

Check if two elements are related, i.e. there exists an edge or path from e1 to e2. This is implemented as a directed graph search.

Parameters
e1First element.
e2Second element.
visitedVisited element (node) set.
visitingCurrently visiting elements (nodes).
local_propsCall specific properties.
modeSearch mode.
Returns
true if there exists an edge or path, false otherwise.

§ Range()

template<class Ts>
Set<Ts> mc2lib::sets::Relation< Ts >::Range ( ) const
inline

§ Reachable()

template<class Ts>
Set<Ts> mc2lib::sets::Relation< Ts >::Reachable ( const Element e) const
inline

Returns all rechable elements from a start element without the start itself, but includes start if start can reach itself (e.g. through cycle).

Parameters
eStart element.
Returns
Set of reachable elements.

§ set_props()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::set_props ( Properties  props)
inline

§ size()

template<class Ts>
std::size_t mc2lib::sets::Relation< Ts >::size ( ) const
inline

Total size of the relation (i.e. number of tuples or edges); uses properties.

Returns
Total number of tuples (or edges).

§ StrictPartialOrder()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::StrictPartialOrder ( const Set< Ts > &  on) const
inline

§ StrictTotalOrder()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::StrictTotalOrder ( const Set< Ts > &  on) const
inline

§ Subset()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Subset ( const Relation< Ts > &  rhs) const
inline

§ SubsetEq()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::SubsetEq ( const Relation< Ts > &  rhs) const
inline

§ TotalOn()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::TotalOn ( const Set< Ts > &  on) const
inline

∀(x,y) ∈ on×on, x→y ∨ y→x

§ Transitive()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::Transitive ( ) const
inline

x→y ∧ y→z ⇒ x→z

§ unset_props()

template<class Ts>
Relation& mc2lib::sets::Relation< Ts >::unset_props ( Properties  props)
inline

§ WeakPartialOrder()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::WeakPartialOrder ( const Set< Ts > &  on) const
inline

§ WeakTotalOrder()

template<class Ts>
bool mc2lib::sets::Relation< Ts >::WeakTotalOrder ( const Set< Ts > &  on) const
inline

Member Data Documentation

§ kNone

template<class Ts>
constexpr Properties mc2lib::sets::Relation< Ts >::kNone = 0x0
static

§ kReflexiveClosure

template<class Ts>
constexpr Properties mc2lib::sets::Relation< Ts >::kReflexiveClosure = 0x2
static

§ kReflexiveTransitiveClosure

template<class Ts>
constexpr Properties mc2lib::sets::Relation< Ts >::kReflexiveTransitiveClosure
static

§ kTransitiveClosure

template<class Ts>
constexpr Properties mc2lib::sets::Relation< Ts >::kTransitiveClosure = 0x1
static

§ props_

template<class Ts>
Properties mc2lib::sets::Relation< Ts >::props_
protected

§ rel_

template<class Ts>
Container mc2lib::sets::Relation< Ts >::rel_
protected

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