All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
cycle_start_from_last_change.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2013 Piotr Wygocki
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
15 #ifndef PAAL_CYCLE_START_FROM_LAST_CHANGE_HPP
16 #define PAAL_CYCLE_START_FROM_LAST_CHANGE_HPP
17 
18 #include "cycle_traits.hpp"
19 
20 namespace paal {
21 namespace data_structures {
22 
28 template <typename Cycle> class cycle_start_from_last_change {
29  public:
30  typedef typename cycle_traits<Cycle>::CycleElem CycleElem;
31  typedef typename cycle_traits<Cycle>::vertex_iterator vertex_iterator;
32 
39  : m_cycle(c), m_element(*c.vbegin()) {}
40 
47  void flip(const CycleElem &begin, const CycleElem &end) {
48  m_element = end;
49  m_cycle.flip(begin, end);
50  }
51 
57  vertex_iterator vbegin() const { return m_cycle.vbegin(m_element); }
58 
66  vertex_iterator vbegin(const CycleElem &ce) const {
67  return m_cycle.vbegin(ce);
68  }
69 
75  vertex_iterator vend() const { return m_cycle.vend(); }
76 
82  Cycle &get_cycle() { return m_cycle; }
83 
89  const Cycle &get_cycle() const { return m_cycle; }
90 
91  private:
92  Cycle &m_cycle;
93  CycleElem m_element;
94 };
95 }
96 }
97 
98 #endif // PAAL_CYCLE_START_FROM_LAST_CHANGE_HPP
vertex_iterator vbegin() const
vbegin starts from last flip
void flip(const CycleElem &begin, const CycleElem &end)
flip stores place of this flip
const Cycle & get_cycle() const
cycle getter const version
vertex_iterator vbegin(const CycleElem &ce) const
vbegin starts from ce
adopts any cycle to start (vbegin) i place of the last change(flip)
traits for Cycle concept