Wednesday 25 July 2012

iterator Library

<iterator>





An inserter is an output iterator that expands the container it points to by calling push_back(), push_front(), or insert(). The container must support this operation. A stream iterator can be used to do formatted input or output using >> or <<
back_inserter(c); // An iterator that appends to container c
front_inserter(c); // Inserts at front of c
inserter(c, p); // Inserts in front of p
ostream_iterator<T>(out, cp); // Writes to ostream separated by char* cp (default " ")
istream_iterator<T>(in); // An input iterator that reads T objects from istream
The most common use is to copy to an empty vector, deque, or list. vector<int> from(10), to;
copy(from.begin(), from.end(), back_inserter(to));

No comments:

Post a Comment