STL Container | Type of Iterators Supported | |
vector | random access iterators | 元素严格有序(类似数组) |
deque | random access iterators | |
list | bidirectional iterators | 仅能通过某个 元素找到其直 接前驱和直接 后继(类似链 表) |
set | bidirectional iterators | |
multiset | bidirectional iterators | |
map | bidirectional iterators | |
multimap | bidirectional iterators | |
stack | no iterator support | |
queue | no iterator support | |
priority_queue | no iterator support |
类别 | 运算符 | 描述 |
All iterators | ++p | Preincrementan iterator. 前置自增 |
p++ | Postincrementan iterator. 后置自增 | |
Input iterators | *p | Dereference an iterator (used as rvalue).迭代器解引用(仅做右值) |
p1 == p2 | Evaluates true if p1 and p2 point to the same element. | |
p1 != p2 | Evaluates true if p1 and p2 point to different elements. | |
Output iterators | *p | Dereference an iterator (used as lvalue).迭代器解引用(仅做左值) |
Bidirectionliterators | --p | Predecrementan iterator. 前置自减 |
p-- | Postdecrementan iterator. 后置自减 | |
Random-access iterators | p += i | Increment iterator p by ipositions. |
p -= i | Decrement iterator p by i positions. | |
p + i | Returns an iterator ith position after p. | |
p - i | Returns an iterator ithposition before p. | |
p1 < p2 | Returns true if p1 is before p2. | |
p1 <= p2 | Returns true if p1 is before or equal to p2. | |
p1 > p2 | Returns true if p1 is after p2. | |
p1 >= p2 | Returns true if p1 is after p2 or equal to p2. | |
p[i] | Returns the element at the position p offset by i. |