jeudi 25 août 2016

Read And Write Iterators - C++

I'm new to C++ (coming from C and Java) and wanted to write a simple Sudoku-Solver as an exercise. I was thinking about using iterators to iterate over the rows/columns/blocks of the Sudoku field and read this c++Reference page.

Now I have two questions:

  • To me it seems like there exists two kinds of iterators Input-(read only)/Output(write only)-iterators and there are different kinds of Input-Iterators (Contiguous/RandomAccess/etc). If I want to iterate over the Sudoku fields I want to be able to read and write elements. What iterator should my iterator extend?

  • I actually think that I need two iterators one to iterate over the different rows/columns/blocks and one to iterate over the elements over the elements in these rows/columns/blocks. What is a common naming convention to use here? I was thinking about RowIterator to iterate over the rows and RowElementIterator to iterate over the contained elements inside an object pointed to by RowIterator.

I was also hoping for a good introducing resource into C++ iterators.

Aucun commentaire:

Enregistrer un commentaire