Modify

Opened 9 years ago

Last modified 6 months ago

#2222 new Feature Requests

Make images & views model Collection concept.

Reported by: john.femiani@… Owned by: Stefan Seefeld
Milestone: To Be Determined Component: gil USE GITHUB
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc: mateusz@…

Description

It would be convenient if GIL views modeled ReversibleCollection concept. In fact they almost do already.

Without modeling this concept, it is hard to use an image view with boost::range algorithms.

Suggested patch:

  • image_view.hpp

     
    8282        typedef typename Loc::template axis<D>::iterator iterator;       // 1D iterator type along each dimension
    8383    };
    8484    typedef iterator_from_2d<Loc>                    iterator;       // 1D iterator type for each pixel left-to-right inside top-to-bottom
     85    typedef typename const_t::iterator               const_iterator;
     86    typedef typename const_t::reference              const_reference;
     87    typedef typename std::iterator_traits<iterator>::pointer pointer;
    8588    typedef std::reverse_iterator<iterator>          reverse_iterator;
    8689    typedef std::size_t                              size_type;
    8790
     
    111114
    112115    template <typename L2> friend void swap(image_view<L2>& x, image_view<L2>& y);
    113116
     117    ///\brief Exchanges the elements of the current view with those of \a other
     118    ///       in constant time.
     119    ///
     120    ///\note Required by concept
     121    ///      http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
     122    void swap(image_view<Loc>& other)
     123    {
     124        swap(*this, other);
     125    }
     126
     127
     128
     129    ///\brief Returns true if the view has no elements, false otherwise.
     130    ///
     131    ///\note Required by concept
     132    ///      http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
     133    bool empty() const
     134    {
     135        return width() > 0 && height() > 0;
     136    }
     137
     138    ///\brief Returns a reference to the first element in raster order.
     139    ///
     140    ///\note Required by concept
     141    ///      http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
     142    ///      since views model ForwardCollection
     143    reference front() const
     144    {
     145        return *begin();
     146    }
     147
     148    ///\brief Returns a reference to the last element in raster order.
     149    ///
     150    ///\note Required by concept
     151    ///      http://www.boost.org/doc/libs/1_35_0/libs/utility/Collection.html
     152    ///      since views model ReversibleCollection
     153    reference back() const
     154    {
     155        return *rbegin();
     156    }
     157
    114158    const point_t&   dimensions()            const { return _dimensions; }
    115159    const locator&   pixels()                const { return _pixels; }
    116160    x_coord_t        width()                 const { return dimensions().x; }

Attachments (0)

Change History (3)

comment:1 Changed 9 years ago by John Maddock

Component: NoneGIL
Milestone: Boost 1.36.0To Be Determined
Owner: set to Hailin Jin

comment:2 Changed 8 years ago by mloskot <mateusz@…>

Cc: mateusz@… added

comment:3 Changed 6 months ago by Stefan Seefeld

Owner: changed from Hailin Jin to Stefan Seefeld

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Stefan Seefeld.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.