70 #define OGDF_STD_COMPARER(type) \ 71 template<> class StdComparer<type> \ 74 static bool less (const type &x, const type &y) { return x < y; } \ 75 static bool leq (const type &x, const type &y) { return x <= y; } \ 76 static bool greater(const type &x, const type &y) { return x > y; } \ 77 static bool geq (const type &x, const type &y) { return x >= y; } \ 78 static bool equal (const type &x, const type &y) { return x == y; } \ 86 template<>
class StdComparer<bool> {
89 static bool less (
const bool &x,
const bool &y) {
return !x && y; }
90 static bool leq (
const bool &x,
const bool &y) {
return !x || y; }
91 static bool greater(
const bool &x,
const bool &y) {
return x && !y; }
92 static bool geq (
const bool &x,
const bool &y) {
return x || !y; }
93 static bool equal (
const bool &x,
const bool &y) {
return x == y; }
103 template<
class CONTENTTYPE,
class STATICCONTENTCOMPARER = StdComparer<CONTENTTYPE> >
155 #define OGDF_AUGMENT_COMPARER(type) \ 157 bool less(const type &x, const type &y) const { return compare(x,y) < 0; } \ 158 bool leq(const type &x, const type &y) const { return compare(x,y) <= 0; } \ 159 bool greater(const type &x, const type &y) const { return compare(x,y) > 0; } \ 160 bool geq(const type &x, const type &y) const { return compare(x,y) >= 0; } \ 161 bool equal(const type &x, const type &y) const { return compare(x,y) == 0; } 201 #define OGDF_AUGMENT_STATICCOMPARER(type) \ 203 static bool less(const type &x, const type &y) { return compare(x,y) < 0; } \ 204 static bool leq(const type &x, const type &y) { return compare(x,y) <= 0; } \ 205 static bool greater(const type &x, const type &y) { return compare(x,y) > 0; } \ 206 static bool geq(const type &x, const type &y) { return compare(x,y) >= 0; } \ 207 static bool equal(const type &x, const type &y) { return compare(x,y) == 0; } 243 virtual int compare(
const E &x,
const E &y)
const = 0;
246 virtual bool less(
const E &x,
const E &y)
const {
247 return compare(x,y) < 0;
251 virtual bool leq(
const E &x,
const E &y)
const {
252 return compare(x,y) <= 0;
256 virtual bool greater(
const E &x,
const E &y)
const {
257 return compare(x,y) > 0;
261 virtual bool geq(
const E &x,
const E &y)
const {
262 return compare(x,y) >= 0;
266 virtual bool equal(
const E &x,
const E &y)
const {
267 return compare(x,y) == 0;
277 template<
class X,
class Priority=
double>
305 bool operator<(const Prioritized<X,Priority>& P)
const {
return p<P.p; }
308 bool operator<=(const Prioritized<X,Priority>& P)
const {
return p<=P.p; }
337 template<
typename TYPE,
class COMPARER = StdComparer<TYPE>>
341 return COMPARER::less(x, y);
350 template<
typename TYPE,
class COMPARER = StdComparer<TYPE>>
354 return COMPARER::greater(x, y);
CONTENTTYPE * CONTENTPOINTER
void setItem(X item)
Sets value x.
A static comparer which compares the target of pointers ("content"), instead of the pointer's adresse...
static bool leq(const E &x, const E &y)
bool operator()(const TYPE &x, const TYPE &y) const
void setPriority(Priority pp)
Sets priority.
static bool greater(const Prioritized< X, Priority > &x, const Prioritized< X, Priority > &y)
static bool less(const E &x, const E &y)
#define OGDF_THROW(CLASS)
Replacement for throw.
Priority priority() const
Returns the key of the element.
bool operator()(const TYPE &x, const TYPE &y) const
#define OGDF_STD_COMPARER(type)
Generates a specialization of the standard static comparer for type based on compare operators...
bool operator!=(const Prioritized< X, Priority > &P) const
Comparison oprator based on the compare-operator for the key type (Priority)
Prioritized(const Prioritized &P)
Copy-constructor.
virtual bool less(const E &x, const E &y) const
Returns true iff x < y.
static bool greater(const CONTENTPOINTER &x, const CONTENTPOINTER &y)
Augments any data elements of type X with keys of type Priority. This class is also its own Comparer...
static bool geq(const Prioritized< X, Priority > &x, const Prioritized< X, Priority > &y)
bool operator>=(const Prioritized< X, Priority > &P) const
Comparison oprator based on the compare-operator for the key type (Priority)
Template for converting any StdComparer into a STL compatible compare functor.
Standard comparer (valid as a static comparer).
static bool equal(const CONTENTPOINTER &x, const CONTENTPOINTER &y)
bool operator==(const Prioritized< X, Priority > &P) const
Comparison oprator based on the compare-operator for the key type (Priority)
static bool geq(const E &x, const E &y)
virtual bool leq(const E &x, const E &y) const
Returns true iff x <= y.
Abstract base class for comparer classes.
static bool less(const bool &x, const bool &y)
static bool greater(const E &x, const E &y)
X item() const
Returns the data of the element.
Definition of exception classes.
virtual bool equal(const E &x, const E &y) const
Returns true iff x = y.
static bool equal(const Prioritized< X, Priority > &x, const Prioritized< X, Priority > &y)
Template for converting any StdComparer into a STL compatible compare functor.
static bool leq(const bool &x, const bool &y)
static bool equal(const bool &x, const bool &y)
static bool less(const Prioritized< X, Priority > &x, const Prioritized< X, Priority > &y)
virtual bool greater(const E &x, const E &y) const
Returns true iff x > y.
static bool leq(const CONTENTPOINTER &x, const CONTENTPOINTER &y)
static bool greater(const bool &x, const bool &y)
Exception thrown when a required standard comparer has not been specialized.
static bool equal(const E &x, const E &y)
static bool geq(const bool &x, const bool &y)
VComparer()
Initializes a comparer.
Prioritized()
Constructor of empty element. Be careful!
virtual bool geq(const E &x, const E &y) const
Returns true iff x >= y.
The namespace for all OGDF objects.
static bool less(const CONTENTPOINTER &x, const CONTENTPOINTER &y)
Prioritized(X xt, Priority pt)
Constructor using a key/value pair.
static bool geq(const CONTENTPOINTER &x, const CONTENTPOINTER &y)
bool operator>(const Prioritized< X, Priority > &P) const
Comparison oprator based on the compare-operator for the key type (Priority)
static bool leq(const Prioritized< X, Priority > &x, const Prioritized< X, Priority > &y)