Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

Reverse.h
Go to the documentation of this file.
1 
33 #pragma once
34 
35 #include <type_traits>
36 
37 namespace ogdf {
38 
40 
45 template<typename T>
46 class Reverse {
49 
50 public:
52  explicit Reverse(T& container) : m_container(container) { }
53 
55  using iterator = typename std::conditional<std::is_const<T>::value,
56  typename T::const_reverse_iterator, typename T::reverse_iterator>::type;
57 
59  iterator begin() { return m_container.rbegin(); }
60 
62  iterator end() { return m_container.rend(); }
63 };
64 
66 
73 template<typename T>
74 Reverse<T> reverse(T& container) {
75  return Reverse<T>(container);
76 }
77 
78 }
ogdf::Reverse::Reverse
Reverse(T &container)
Creates a reverse iteration wrapper for container.
Definition: Reverse.h:52
ogdf
The namespace for all OGDF objects.
Definition: multilevelmixer.cpp:39
ogdf::Reverse
A wrapper class to easily iterate through a container in reverse.
Definition: Reverse.h:46
ogdf::Reverse::m_container
T & m_container
The container for which reverse iterators should be provided.
Definition: Reverse.h:48
ogdf::Reverse::iterator
typename std::conditional< std::is_const< T >::value, typename T::const_reverse_iterator, typename T::reverse_iterator >::type iterator
Provides a reverse iterator disguised a normal iterator.
Definition: Reverse.h:56
ogdf::Reverse::end
iterator end()
Returns a reverse iterator to the one-before-first element of m_container.
Definition: Reverse.h:62
ogdf::reverse
Reverse< T > reverse(T &container)
Provides iterators for container to make it easily iterable in reverse.
Definition: Reverse.h:74
backward::Color::type
type
Definition: backward.hpp:1716
ogdf::Reverse::begin
iterator begin()
Returns a reverse iterator to the last element of m_container.
Definition: Reverse.h:59