How can I make a copy of an iterator in Java? -


we have list of elements , have simplistic collision detection check every object against every other object.

the check commutative, avoid repeating twice, in c++:

for (list<object>::iterator it0 = list.begin(); it0 != list.end(); ++it0) {     (list<object>::iterator it1 = it0; it1 != list.end(); ++it1)     {         test(*it0, *it1);     } } 

the key bit here copy

it1 = it0 

how write in java?

you cannot copy java iterators, you'll have without them:

for(int i=0; i<list.size(); i++){     for(int j=i; j<list.size(); j++){         test(list.get(i), list.get(j));     } } 

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -