21 #ifndef TULIP_SORTITERATOR_H
22 #define TULIP_SORTITERATOR_H
25 #include <tulip/Iterator.h>
26 #include <tulip/StableIterator.h>
27 #include <tulip/DoubleProperty.h>
32 #ifndef DOXYGEN_NOTFOR_DEVEL
34 LessThan(DoubleProperty* m): metric(m) {
36 DoubleProperty* metric;
37 bool operator() (node n1,node n2) {
38 return (metric->getNodeValue(n1) < metric->getNodeValue(n2));
42 struct LessThanEdgeTargetMetric {
43 LessThanEdgeTargetMetric(Graph *sg, DoubleProperty* metric):
44 metric(metric), sg(sg) {
46 bool operator() (edge e1,edge e2) {
47 return (metric->getNodeValue(sg->target(e1)) < metric->getNodeValue(sg->target(e2)));
50 DoubleProperty* metric;
53 #endif // DOXYGEN_NOTFOR_DEVEL
59 struct SortNodeIterator :
public StableIterator<tlp::node> {
61 SortNodeIterator(Iterator<tlp::node> *itIn, DoubleProperty* metric):StableIterator<tlp::node>(itIn) {
63 sort(sequenceCopy.begin(),sequenceCopy.end(),tmp);
64 copyIterator=sequenceCopy.begin();
67 ~SortNodeIterator() {}
73 struct SortTargetEdgeIterator :
public StableIterator<tlp::edge> {
75 SortTargetEdgeIterator(Iterator<tlp::edge> *itIn, Graph* sg, DoubleProperty* metric):StableIterator<tlp::edge>(itIn) {
76 LessThanEdgeTargetMetric tmp(sg,metric);
77 sort(sequenceCopy.begin(),sequenceCopy.end(),tmp);
78 copyIterator=sequenceCopy.begin();
81 ~SortTargetEdgeIterator() {}