14 typedef std::vector<Value> Container;
15 typedef typename Container::iterator ContainerIterator;
16 typedef typename Container::const_iterator ContainerConstIterator;
19 Iterator(
const ContainerIterator & other )
20 : ContainerIterator( other )
23 : ContainerIterator( image.m_data.begin() + image.index( x, y ) )
25 Iterator& operator=(
const ContainerIterator & other )
27 ContainerIterator::operator=( other );
40 : ContainerConstIterator( other )
43 : ContainerConstIterator( image.m_data.begin() + image.index( x, y ) )
45 ConstIterator& operator=(
const ContainerConstIterator & other )
47 ContainerConstIterator::operator=( other );
58 template <
typename TAccessor>
60 typedef TAccessor Accessor;
61 typedef typename Accessor::Argument ImageValue;
62 typedef typename Accessor::Value Value;
63 typedef typename Accessor::Reference Reference;
66 : Container::const_iterator( image.m_data.begin() + image.index( x, y ) ) {}
69 Value operator*()
const
70 {
return Accessor::access( Container::const_iterator::operator*() ); }
74 template <
typename TAccessor>
76 typedef TAccessor Accessor;
77 typedef typename Accessor::Argument ImageValue;
78 typedef typename Accessor::Value Value;
79 typedef typename Accessor::Reference Reference;
82 : Container::iterator( image.m_data.begin() + image.index( x, y ) ) {}
85 Value operator*()
const
86 {
return Accessor::access( Container::iterator::operator*() ); }
90 {
return Accessor::access( Container::iterator::operator*() ); }
98 Image2D(
int w,
int h, Value g = Value() );
101 void fill( Value g );
115 template <
typename Accessor>
116 GenericConstIterator< Accessor >
start(
int x = 0,
int y = 0 )
const
117 {
return GenericConstIterator< Accessor >( *
this, x, y ); }
119 template <
typename Accessor>
120 GenericConstIterator< Accessor >
begin()
const
121 {
return start< Accessor >( 0, 0 ); }
123 template <
typename Accessor>
124 GenericConstIterator< Accessor >
end()
const
125 {
return start< Accessor >( 0,
h() ); }
127 template <
typename Accessor>
128 GenericIterator< Accessor >
start(
int x = 0,
int y = 0 )
129 {
return GenericIterator< Accessor >( *
this, x, y ); }
131 template <
typename Accessor>
132 GenericIterator< Accessor >
begin()
133 {
return start< Accessor >( 0, 0 ); }
135 template <
typename Accessor>
136 GenericIterator< Accessor >
end()
137 {
return start< Accessor >( 0,
h() ); }
141 Value
at(
int i,
int j )
const;
145 Value&
at(
int i,
int j );
153 int index(
int i,
int j )
const;
163 : m_data( w*h, g ), m_width( w ), m_height( h )