BVB Source Codes

mars Show reverse_iterator.hpp Source code

Return Download mars: download reverse_iterator.hpp Source code - Download mars Source code - Type:.hpp
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga  2014-2014
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. //    (See accompanying file LICENSE_1_0.txt or copy at
  7. //          http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/intrusive for documentation.
  10. //
  11. /////////////////////////////////////////////////////////////////////////////
  12.  
  13. #ifndef BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP
  14. #define BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP
  15.  
  16. #ifndef BOOST_CONFIG_HPP
  17. #  include <boost/config.hpp>
  18. #endif
  19.  
  20. #if defined(BOOST_HAS_PRAGMA_ONCE)
  21. #  pragma once
  22. #endif
  23.  
  24. #include <boost/intrusive/detail/config_begin.hpp>
  25. #include <boost/intrusive/detail/iterator.hpp>
  26. #include <boost/intrusive/detail/mpl.hpp>
  27.  
  28. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  29. namespace intrusive {
  30.  
  31. template<class It>
  32. class reverse_iterator
  33. {
  34.    public:
  35.    typedef typename mars_boost::intrusive::iterator_traits<It>::pointer             pointer;
  36.    typedef typename mars_boost::intrusive::iterator_traits<It>::reference           reference;
  37.    typedef typename mars_boost::intrusive::iterator_traits<It>::difference_type     difference_type;
  38.    typedef typename mars_boost::intrusive::iterator_traits<It>::iterator_category   iterator_category;
  39.    typedef typename mars_boost::intrusive::iterator_traits<It>::value_type          value_type;
  40.  
  41.  
  42.    typedef It iterator_type;
  43.  
  44.    reverse_iterator()
  45.       : m_current()  //Value initialization to achieve "null iterators" (N3644)
  46.       {}
  47.  
  48.    explicit reverse_iterator(It r)
  49.       : m_current(r)
  50.    {}
  51.  
  52.    template<class OtherIt>
  53.    reverse_iterator( const reverse_iterator<OtherIt>& r
  54.                    , typename mars_boost::intrusive::detail::enable_if_convertible<OtherIt, It>::type* =0
  55.                    )
  56.       : m_current(r.base())
  57.    {}
  58.  
  59.    template<class OtherIt>
  60.    typename mars_boost::intrusive::detail::enable_if_convertible<OtherIt, It, reverse_iterator &>::type
  61.          operator=( const reverse_iterator<OtherIt>& r)
  62.    {  m_current = r.base();   return *this;  }
  63.  
  64.    It base() const
  65.    {  return m_current;  }
  66.  
  67.    reference operator*() const
  68.    {  It temp(m_current);   --temp; return *temp; }
  69.  
  70.    pointer operator->() const
  71.    {  It temp(m_current);   --temp; return iterator_arrow_result(temp); }
  72.  
  73.    reference operator[](difference_type off) const
  74.    {  return this->m_current[-off - 1];  }
  75.  
  76.    reverse_iterator& operator++()
  77.    {  --m_current;   return *this;   }
  78.  
  79.    reverse_iterator operator++(int)
  80.    {
  81.       reverse_iterator temp = *this;
  82.       --m_current;
  83.       return temp;
  84.    }
  85.  
  86.    reverse_iterator& operator--()
  87.    {
  88.       ++m_current;
  89.       return *this;
  90.    }
  91.  
  92.    reverse_iterator operator--(int)
  93.    {
  94.       reverse_iterator temp(*this);
  95.       ++m_current;
  96.       return temp;
  97.    }
  98.  
  99.    friend bool operator==(const reverse_iterator& l, const reverse_iterator& r)
  100.    {  return l.m_current == r.m_current;  }
  101.  
  102.    friend bool operator!=(const reverse_iterator& l, const reverse_iterator& r)
  103.    {  return l.m_current != r.m_current;  }
  104.  
  105.    friend bool operator<(const reverse_iterator& l, const reverse_iterator& r)
  106.    {  return l.m_current > r.m_current;  }
  107.  
  108.    friend bool operator<=(const reverse_iterator& l, const reverse_iterator& r)
  109.    {  return l.m_current >= r.m_current;  }
  110.  
  111.    friend bool operator>(const reverse_iterator& l, const reverse_iterator& r)
  112.    {  return l.m_current < r.m_current;  }
  113.  
  114.    friend bool operator>=(const reverse_iterator& l, const reverse_iterator& r)
  115.    {  return l.m_current <= r.m_current;  }
  116.  
  117.    reverse_iterator& operator+=(difference_type off)
  118.    {  m_current -= off; return *this;  }
  119.  
  120.    friend reverse_iterator operator+(reverse_iterator l, difference_type off)
  121.    {  l.m_current -= off;  return l;  }
  122.  
  123.    friend reverse_iterator operator+(difference_type off, reverse_iterator r)
  124.    {  return (r += off);   }
  125.  
  126.    reverse_iterator& operator-=(difference_type off)
  127.    {  m_current += off; return *this;  }
  128.  
  129.    friend reverse_iterator operator-(reverse_iterator l, difference_type off)
  130.    {  l.m_current += off;  return l;  }
  131.  
  132.    friend difference_type operator-(const reverse_iterator& l, const reverse_iterator& r)
  133.    {  return r.m_current - l.m_current;  }
  134.  
  135.    private:
  136.    It m_current;   // the wrapped iterator
  137. };
  138.  
  139. } //namespace intrusive {
  140. } //namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost {
  141.  
  142. #include <boost/intrusive/detail/config_end.hpp>
  143.  
  144. #endif //BOOST_INTRUSIVE_DETAIL_REVERSE_ITERATOR_HPP
  145.  
downloadreverse_iterator.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top