I want to iterate over unique pairs in a HashSet, Ideally, I'd be able to make a copy of the iterator and when it has exhausted itself, iterate the iterator I am making copies of, but Iterators do not like being copied, and I suspect that there is a good reason for this, but I do not know what that is.
More specifically, what prevents this (below) behavior from being supported?
Iterator<Object> iter = myhash.iterator();
while(iter.hasNext()){
object=iter.next();
Iterator<Object> iterclone = iter.clone();
while(iterclone.hasNext()){
setOfObjectPairs.add(object,iterclone.next());
}
}
Edit: The point of doing this is to save the current state of the iterator, which is already pointing at the i-th element.