Connecting Tech Pros Worldwide Help | Site Map

How to store range iterator?

  #1  
Old September 5th, 2006, 07:45 AM
toton
Guest
 
Posts: n/a
Hi,
I have a view class for a vector, which stores different range for a
few vectors, and provides a way to iterate over the range.
The range class takes a pair of iterator, as given in post
http://groups.google.com/group/comp....82fc1288b1231f

However, as the range class do not have a default ctor, and range is
not known when view class is constructed I can not initialize range
class at initialization list.Thus I need to store range class pointer
inside view class. When I want to set a new range for the view class, I
use,

void CC::setPtuRange(const PointRange& range){
if(!_reconstructedPoints)
_reconstructedPoints = new PointRange(range);
}
where _reconstructedPoints is a range class for CC (member variable).
Also I set it only once (but not at constructor). At constructor it is
initialized as NULL & destructor deleted.
Also when I return the range class, I use
PointRange CC::points()const{
return *_reconstructedPoints;
}
PointRange is typedef as
typedef PointBuffer::const_iterator PointIterator;
typedef range<PointIteratorPointRange
where PointBuffer is a vector<Point>
My questions are,
1) is it valid to return a value for the pointer with dereferencing
operator? Or I need to return a pointer directly?
2) can I also return a a reference? What is the best way to do it?
Thanks for any help .

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out a if an iterator is pointing to the very last (end) node? mailforpr@googlemail.com answers 16 October 7th, 2006 06:35 AM
range iterator toton answers 3 August 24th, 2006 02:15 PM
Teaching new tricks to an old dog (C++ -->Ada) Turamnvia Suouriviaskimatta answers 822 July 23rd, 2005 03:55 AM
No out_of_range exception for "iterator + n" vs. vector.at( n ) Mike Austin answers 13 July 22nd, 2005 09:49 PM