# C++ Notes: STL: Iterator Operators

Assume C is a container class, containing elements of type T.

    bool b;
    int i;
    T value;
    C::iterator it, it1, it2;

Result | Operator | Description
--- | --- | ---
Operators for most iterators. Vectors, lists, arrays, ....
`value =` | `*it;` | Use dereference (*) op to get/set value.
`` | `++it;` | Points to next element. Value after update.
`` | `it++;` | Points to next element. Value before update.
`it1 =` | `it2;` | Assignment
`b =` | `it1 == it2;` | Equality comparison.
`b =` | `it1 != it2;` | Inequality.
Additional operators for bidirectional iterators. Vectors, lists, arrays, ...
`` | `--it;` | Predecrement.
`` | `it--;` | Postdecrement. May be less efficient than predecrement.
Additional operators for random-access iterators. Vectors and arrays, but not lists.
`it +=` | `i;` | Increments it by i positions.
`it -=` | `i;` | Decrements it by i positions.
`it1 =` | `it2 + i;` | Increments it by i positions.
`it1 =` | `it2 - i;` | Decrements it by i positions.
`value =` | `it[i];` | Returns reference to ith element after it.
`b =` | `it1 < it2;` | Comparison.
`b =` | `it1 <= it2;` | Comparison.
`b =` | `it1 > it2;` | Comparison.
`b =` | `it1 <= it2;` | Comparison.