Skip to content
Snippets Groups Projects
Commit e0548e7f authored by Milan Straka's avatar Milan Straka
Browse files

Explicitly show how to iterate over the data in the comment.

parent 87bbc071
No related branches found
No related tags found
No related merge requests found
...@@ -5,8 +5,12 @@ vector<string> find_duplicates(DataGenerator& generator) { ...@@ -5,8 +5,12 @@ vector<string> find_duplicates(DataGenerator& generator) {
* Find duplicates in the given data. * Find duplicates in the given data.
* *
* The `generator` provides a forward iterator over strings * The `generator` provides a forward iterator over strings
* for traversing the data (so it can be iterated for example * for traversing the data, so it can be iterated for example
* using a `for` cycle). It can be traversed multiple times. * using a `for` cycle:
*
* for (const string& item : generator) {...}
*
* The `generator` can be traversed multiple times.
* *
* The goal is to return a vector of duplicated entries, * The goal is to return a vector of duplicated entries,
* reporting each duplicated entry only once, in the order * reporting each duplicated entry only once, in the order
......
...@@ -4,9 +4,12 @@ import sys ...@@ -4,9 +4,12 @@ import sys
def find_duplicates(data_generator): def find_duplicates(data_generator):
"""Find duplicates in the given data. """Find duplicates in the given data.
The data_generator is an `iterable` (it can be iterated over in a for cycle, The `data_generator` is an iterable over strings, so it can be
or passed to `iter` method to explicitly generate an iterator) returning iterated for example using a `for` cycle:
strings. It can be iterated multiple times.
for item in data_generator: ...
It can be iterated multiple times.
The goal is to return a list of duplicated entries, reporting each duplicated The goal is to return a list of duplicated entries, reporting each duplicated
entry only once, in the order of their first occurrence in the data. entry only once, in the order of their first occurrence in the data.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment