Reference: The C++ Standard Library: A Tutorial and Reference
Wednesday, July 14, 2010
Insert Iterators
insert iterators are output iterators.
Reference: The C++ Standard Library: A Tutorial and Reference
by Nicolai M. Josuttis. Addison-Wesley, 1999. p. 271.
Reference: The C++ Standard Library: A Tutorial and Reference
Monday, July 12, 2010
Insert Iterators
An insert iterator implements its assignment operator to call the container's push_back(), push_front(), or insert() member function.
There are three kinds of insert iterators:
1) Front Inserter (front_inserter())
2) Back Inserter (back_inserter())
3) General Inserter (inserter())
They can be used on containers that have the corresponding member functions (push_front(), push_back(), and insert()).
Reference: The C++ Standard Library: A Tutorial and ReferenceSaturday, July 10, 2010
Insert Iterators
For an insert iterator, iter, the following are true:
1. *iter is a no-op that returns iter
2. iter = value; calls one of push_back(),
push_front(), or insert().
3. iter = value; behaves the same as
*iter = value; but *iter = value; is
the preferred syntax.
Reference: The C++ Standard Library: A Tutorial and ReferenceThursday, July 8, 2010
Inserting into a vector
Given a vector v, all of the following do the same thing:
by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 272.
back_inserter(v) = 42;
inserter(v, v.end()) = 42;
v.push_back(42);
Reference: The C++ Standard Library: A Tutorial and ReferenceTuesday, July 6, 2010
Iterator Categories
The Output Iterator (output_iterator_tag) category is the only iterator category not related to the other iterator categories by inheritance:
by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 284.
- Input Iterator (input_iterator_tag)
Forward Iterator (forward_iterator_tag)
Bidirectional Iterator (bidirectional_iterator_tag)
Random Access Iterator (random_access_iterator_tag)
Sunday, July 4, 2010
Struct Inheritance
Structs can inherit from structs. This is how the various interator categories inherit from each other. Structs can also inherit from classes.
Reference: The C++ Standard Library: A Tutorial and Reference
by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 284.
Reference: The C++ Standard Library: A Tutorial and Reference
Friday, July 2, 2010
Iterator Traits
The following are iterator traits: value_type, difference_type, iterator_category, pointer, reference.
Reference: The C++ Standard Library: A Tutorial and Reference
by Nicolai M. Josuttis. Addison-Wesley, 1999, p. 285.
Reference: The C++ Standard Library: A Tutorial and Reference
Subscribe to:
Posts (Atom)
