20 #ifndef TULIP_SORTITERATOR_H
21 #define TULIP_SORTITERATOR_H
26 #include <tulip/Iterator.h>
27 #include <tulip/StableIterator.h>
28 #include <tulip/NumericProperty.h>
29 #include <tulip/Graph.h>
30 #include <tulip/Vector.h>
39 bool operator()(
const node &n1,
const node &n2)
const {
42 bool operator()(
const edge &e1,
const edge &e2)
const {
47 struct LessThanEdgeTargetMetric {
49 : metric(metric), sg(sg) {}
50 bool operator()(
const edge &e1,
const edge &e2)
const {
60 struct LessThanEdgeSourceMetric {
62 : metric(metric), sg(sg) {}
63 bool operator()(
const edge &e1,
const edge &e2)
const {
73 struct LessThanEdgeExtremitiesMetric {
75 : metric(metric), sg(sg) {}
76 bool operator()(
const edge &e1,
const edge &e2)
const {
77 std::pair<node, node> ends = sg->ends(e1);
96 bool ascendingOrder =
true)
101 if (!ascendingOrder) {
117 bool ascendingOrder =
true)
119 LessThan tmp(metric);
122 if (!ascendingOrder) {
141 LessThanEdgeTargetMetric tmp(sg, metric);
144 if (!ascendingOrder) {
163 LessThanEdgeSourceMetric tmp(sg, metric);
166 if (!ascendingOrder) {
185 LessThanEdgeExtremitiesMetric tmp(sg, metric);
188 if (!ascendingOrder) {
210 template <
typename T,
typename CompareFunction>
214 sort(this->
sequenceCopy.begin(), this->sequenceCopy.end(), compFunc);
238 template <
typename T,
typename CompareFunction>
259 template <
typename Container,
typename CompareFunction>
260 typename std::enable_if<has_const_iterator<Container>::value,
261 SortIterator<typename Container::value_type, CompareFunction>
263 CompareFunction &&compFunc) {
Interface all numerical properties. Property values are always returned as double.
virtual double getEdgeDoubleValue(const edge e) const =0
Returns the value associated with the edge e in this property.
virtual double getNodeDoubleValue(const node n) const =0
Returns the value associated with the node n in this property.
std::enable_if< has_const_iterator< Container >::value, StlIterator< typename Container::value_type, typename Container::const_iterator > * >::type stlIterator(const Container &stlContainer)
Convenient function for creating a StlIterator from a stl container.
SortIterator< T, CompareFunction > * sortIterator(Iterator< T > *it, CompareFunction &&compFunc)
Convenient function for creating a SortIterator.
Interface for Tulip iterators. Allows basic iteration operations only.
This Iterator sorts the edges in a sequence based on their values in a NumericProperty.
This Iterator sorts the edges based on the values of their extremities nodes in a NumericProperty.
Iterator that wraps an existing one and sorts its iterated elements based on comparison function.
This Iterator sorts the nodes in a sequence based on their values in a NumericProperty.
This Iterator sorts the edges based on the values of their source nodes in a NumericProperty.
This Iterator sorts the edges based on the values of their target nodes in a NumericProperty.
Stores the elements of an iterator and iterates a copy.
std::vector< tlp::node >::const_iterator copyIterator
STL const_iterator on the cloned sequence.
std::vector< tlp::node > sequenceCopy
A copy of the sequence of the elements to iterate.