On the slides on iteration, I showed you Python code for generating the sequence of all strings of length at most len over the alphabet {a,b,c,d} in lexicographically sorted order. The implementation of this iterator relied on Python’s support for coroutines — functions that can be interrupted and resumed. C++ and Java do not have support for coroutines built into the language. Provide C++ or Java code that implements an iterator object to iterate over the same sequence of strings. Note that both Java and C++ (via add-on libraries) provide support for threads, which are more general than coroutines and, thus, can be used to simulate coroutines. Do not use these facilities in your implementation but provide an implementation of a single-threaded iterator object. The detailed requirements are as follows:
0 comments