diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-01 02:27:14 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-02 00:33:19 +0100 |
commit | 4a5928ee4ca55d22a0fa122886ecc7d6a55e9247 (patch) | |
tree | 7cb37d6262f12078dc1889aa3f834dce8e2290c1 /sw/inc | |
parent | efddd4b6e0e80bdbdb74ea43654d258dedb7d13d (diff) |
more testing and initial iterators
Diffstat (limited to 'sw/inc')
-rw-r--r-- | sw/inc/ring.hxx | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index 8b65d721e848..cec52844857c 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -21,12 +21,16 @@ #include <swdllapi.h> #include <swtypes.hxx> +#include <boost/iterator/iterator_facade.hpp> class Ring_node_traits; +class RingIterator; class SW_DLLPUBLIC Ring { friend class Ring_node_traits; + typedef RingIterator iterator; + typedef RingIterator const_iterator; Ring* pNext; Ring* pPrev; ///< In order to speed up inserting and deleting. @@ -44,6 +48,36 @@ public: sal_uInt32 numberOf() const; }; +class RingIterator : public boost::iterator_facade< + RingIterator + , Ring + , boost::forward_traversal_tag + > +{ + public: + RingIterator() + : m_pCurrent(nullptr) + , m_pStart(nullptr) + {} + explicit RingIterator(Ring* pRing, bool bStart = true) + : m_pCurrent(nullptr) + , m_pStart(pRing) + { + if(!bStart) + m_pCurrent = m_pStart; + } + private: + friend class boost::iterator_core_access; + void increment() + { m_pCurrent = m_pCurrent ? m_pCurrent->GetNext() : m_pStart->GetNext(); } + bool equal(RingIterator const& other) const + { return m_pCurrent == other.m_pCurrent && m_pStart == m_pStart; } + Ring& dereference() const + { return m_pCurrent ? *m_pCurrent : * m_pStart; } + Ring* m_pCurrent; + Ring* m_pStart; +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |