Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Loading...
Searching...
No Matches
ogdf::VComparer< E > Class Template Referenceabstract

Abstract base class for comparer classes. More...

#include <ogdf/basic/comparer.h>

Public Member Functions

 VComparer ()
 Initializes a comparer.
 
virtual ~VComparer ()
 
virtual int compare (const E &x, const E &y) const =0
 Compares x and y and returns the result as an integer.
 
virtual bool equal (const E &x, const E &y) const
 Returns true iff x = y.
 
virtual bool geq (const E &x, const E &y) const
 Returns true iff x >= y.
 
virtual bool greater (const E &x, const E &y) const
 Returns true iff x > y.
 
virtual bool leq (const E &x, const E &y) const
 Returns true iff x <= y.
 
virtual bool less (const E &x, const E &y) const
 Returns true iff x < y.
 

Detailed Description

template<class E>
class ogdf::VComparer< E >

Abstract base class for comparer classes.

The parameterized class VComparer is an abstract base class for encapsulating compare functions for type E. Implementations derive from this class and implement at least the compare() method.

The methods of this class are all virtual, which comes with a certain performance penalty. Its advantage is that if you require multiple Comparers for the same class E, functions using compareres on E are not generated multiple times, which means smaller code.

If size is not an issue, but speed is, use a Comparer with non-virtual functions. You may want to use the convenience classes StdComparer and TargetComparer, or the convenience macros OGDF_AUGMENT_COMPARER, OGDF_AUGMENT_STATICCOMPARER, OGDF_STD_COMPARER to obtain non-virtual classes with few effort.

Definition at line 254 of file comparer.h.

Constructor & Destructor Documentation

◆ VComparer()

template<class E >
ogdf::VComparer< E >::VComparer ( )
inline

Initializes a comparer.

Definition at line 257 of file comparer.h.

◆ ~VComparer()

template<class E >
virtual ogdf::VComparer< E >::~VComparer ( )
inlinevirtual

Definition at line 259 of file comparer.h.

Member Function Documentation

◆ compare()

template<class E >
virtual int ogdf::VComparer< E >::compare ( const E &  x,
const E &  y 
) const
pure virtual

Compares x and y and returns the result as an integer.

The returns value is

  • < 0 iff x < y,
  • = 0 iff x = y,
  • > 0 iff x > y

Implemented in ogdf::EdgeComparer, and ogdf::EdgeComparerSimple.

◆ equal()

template<class E >
virtual bool ogdf::VComparer< E >::equal ( const E &  x,
const E &  y 
) const
inlinevirtual

Returns true iff x = y.

Definition at line 282 of file comparer.h.

◆ geq()

template<class E >
virtual bool ogdf::VComparer< E >::geq ( const E &  x,
const E &  y 
) const
inlinevirtual

Returns true iff x >= y.

Definition at line 279 of file comparer.h.

◆ greater()

template<class E >
virtual bool ogdf::VComparer< E >::greater ( const E &  x,
const E &  y 
) const
inlinevirtual

Returns true iff x > y.

Definition at line 276 of file comparer.h.

◆ leq()

template<class E >
virtual bool ogdf::VComparer< E >::leq ( const E &  x,
const E &  y 
) const
inlinevirtual

Returns true iff x <= y.

Definition at line 273 of file comparer.h.

◆ less()

template<class E >
virtual bool ogdf::VComparer< E >::less ( const E &  x,
const E &  y 
) const
inlinevirtual

Returns true iff x < y.

Definition at line 270 of file comparer.h.


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