Logo

Programming-Idioms

History of Idiom 7 > diff from v63 to v64

Edit summary for version 64 by no:
New Cpp implementation by user [no]

Version 63

2017-07-30, 16:13:03

Version 64

2019-09-26, 14:35:42

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Idiom #7 Iterate over list indexes and values

Print each index i with its value x from an array-like collection items

Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Imports
#include <iostream>
Code
for (std::size_t ix = 0; ix < items.size(); ++ix) {
  std::cout << "Item " << ix << " = " << items[ix] << std::endl;
}