Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

NodeComparer.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <ogdf/basic/basic.h>
36 #include <ogdf/basic/NodeArray.h>
37 
38 namespace ogdf {
39 
43 template<class sorterType>
45 {
46 public:
47  explicit NodeComparer(NodeArray<sorterType> &valArray, bool ascending = true)
48  : m_valArray(&valArray)
49  {
50  if (ascending)
51  {
52  m_smaller = -1;
53 #if 0
54  m_greater = 1;
55 #endif
56  }//if
57  else
58  {
59  m_smaller = 1;
60 #if 0
61  m_greater = -1;
62 #endif
63  }
64 
65  }//constructor
66 
67  int compare(const node &v1, const node &v2) const
68  {
69  if ((*m_valArray)[v1] < (*m_valArray)[v2]) return m_smaller;
70  else if ((*m_valArray)[v1] > (*m_valArray)[v2]) return -m_smaller;//m_greater;
71  else return 0;
72  }
73 
74  void init(NodeArray<sorterType> &valArray) {m_valArray = &valArray;}
75 
77 
78 private:
80  int m_smaller;
81 #if 0
82  int m_greater;
83 #endif
84 
85 };//NodeComparer
86 
87 }//namespace
NodeArray< sorterType > * m_valArray
Definition: NodeComparer.h:79
int compare(const node &v1, const node &v2) const
Definition: NodeComparer.h:67
#define OGDF_AUGMENT_COMPARER(type)
Add this macro to your class to turn it into a full comparer.
Definition: comparer.h:155
void init(NodeArray< sorterType > &valArray)
Definition: NodeComparer.h:74
NodeComparer(NodeArray< sorterType > &valArray, bool ascending=true)
Definition: NodeComparer.h:47
Class for the representation of nodes.
Definition: Graph_d.h:167
Declaration and implementation of NodeArray class.
Basic declarations, included by all source files.
The namespace for all OGDF objects.