I need some container to keep elements so, if I’ll try to get the size()+i element, i’ll get element number i. Or with iterator, which starts from the beginning of container after it tries to get the last element? What are the best practicies in both cases? I mean performance and easy useability.
Share
For the first part, just ask for
n % list.size()perhaps?For the iterator part, create a class that wraps an iterator, and when next() returns null, just have it reset the iterator.