Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Stream Iterator (CGAL_Istream_iterator)

Definition

The class CGAL_Istream_iterator<T,Stream> is an input iterator adaptor for the input stream class Stream and value type T. It is particularly useful for classes that are similar but not compatible to istream.

#include <CGAL/IO/Istream_iterator.h>

Creation

CGAL_Istream_iterator<T,Stream> i;
creates an end-of-stream iterator i. This is a past-the-end iterator, and it is useful when constructing a range.

CGAL_Istream_iterator<T,Stream> i ( Stream& s);
creates an input iterator i reading from s. When s reaches end of stream, this iterator will compare equal to an end-of-stream iterator created using the default constructor.

Operations

i fulfills the requirements for an input iterator.

Example

The following program reads points from a CGAL_Window_stream until the right mouse button gets clicked.

#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/IO/Istream_iterator.h>
#include <CGAL/IO/Window_stream.h>
#include <iostream.h>
#include <algo.h>

typedef CGAL_Point_2< CGAL_Cartesian< double > >           Point;
typedef CGAL_Istream_iterator< Point, CGAL_Window_stream>  Iterator;

int main () {
    CGAL_Window_stream window( 512, 512);
    window.init( -1.0, 1.0, -1.0);
    copy( Iterator(window), Iterator(), ostream_iterator<Point>(cout,"\n"));
    return 0;
}


Next: Class declaration of CGAL_Verbose_ostream
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. 22 January 1999.