C
cai_xiaodong
I am very new to STL and generic programming. PLEASE help.
I have my own class looks like:
class pixelProperty {
public:
// get-functions here...
private:
Point mPosition;
int mCenterID;
Color mColor;
}
Basically the pixelProperty represents a 2D image data. To make it
more convenience for pixle random access, I would like to use the
Vector container in STL but with an "enhanced" iterator which give me
more convenience such as using a member function in the iterator,
myiterator::neighbor(x,y), which give me a 2d-style random access.
My questions are:
1) Can I acutally make my customer iterator by composition or inherit
from the vector::iterator (how about deriving from or composing the
vector container class - I read some posts in the forum but not fully
understand.... ) . if it is possible, could any one can be kind enough
to show me an example?
2) I would like to use a customer a random access iterator with the
STL algorithm (such as find()), take the pixelProperty as the data
type, how can I implement this STL-compatible iterator?
I really new to this area, any help will be greatly appreciated.
Thanks in advance.
Sheldon
I have my own class looks like:
class pixelProperty {
public:
// get-functions here...
private:
Point mPosition;
int mCenterID;
Color mColor;
}
Basically the pixelProperty represents a 2D image data. To make it
more convenience for pixle random access, I would like to use the
Vector container in STL but with an "enhanced" iterator which give me
more convenience such as using a member function in the iterator,
myiterator::neighbor(x,y), which give me a 2d-style random access.
My questions are:
1) Can I acutally make my customer iterator by composition or inherit
from the vector::iterator (how about deriving from or composing the
vector container class - I read some posts in the forum but not fully
understand.... ) . if it is possible, could any one can be kind enough
to show me an example?
2) I would like to use a customer a random access iterator with the
STL algorithm (such as find()), take the pixelProperty as the data
type, how can I implement this STL-compatible iterator?
I really new to this area, any help will be greatly appreciated.
Thanks in advance.
Sheldon