Opened 14 years ago

Closed 12 years ago

#2223 closed Feature Requests (duplicate)

Make images & views model Collection concept.

Reported by: john.femiani@… Owned by: Hailin Jin
Milestone: Boost 1.36.0 Component: gil USE GITHUB
Version: Boost 1.36.0 Severity: Problem
Keywords: Cc:

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; }

Change History (1)

comment:1 by Steven Watanabe, 12 years ago

Resolution: duplicate
Status: newclosed

Duplicates #2222.

Note: See TracTickets for help on using tickets.