How to store range iterator?

Discussion in 'C++' started by toton, Sep 5, 2006.

  1. toton

    toton Guest

    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...1231f?lnk=gst&q=range&rnum=2#a282fc1288b1231f

    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<PointIterator> PointRange
    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 .
     
    toton, Sep 5, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    46
    Views:
    1,340
    Antoon Pardon
    Jul 25, 2006
  2. toton

    range iterator

    toton, Aug 24, 2006, in forum: C++
    Replies:
    3
    Views:
    483
    toton
    Aug 24, 2006
  3. Lambda
    Replies:
    2
    Views:
    575
    James Kanze
    Jul 16, 2008
  4. Tomoyuki Kosimizu

    Range does not take an Range object.

    Tomoyuki Kosimizu, Nov 25, 2003, in forum: Ruby
    Replies:
    3
    Views:
    284
    Tomoyuki Kosimizu
    Nov 27, 2003
  5. David Bird
    Replies:
    1
    Views:
    476
    Tiago Macedo
    Jun 23, 2008
  6. Joey Zhou
    Replies:
    5
    Views:
    431
    Joey Zhou
    Apr 15, 2011
  7. it_says_BALLS_on_your forehead

    extract range of lines using range op bug?

    it_says_BALLS_on_your forehead, Mar 3, 2006, in forum: Perl Misc
    Replies:
    3
    Views:
    346
    it_says_BALLS_on_your forehead
    Mar 3, 2006
  8. Replies:
    2
    Views:
    425
Loading...