I have a TreeSet
and iterate through it. When iterating through it I have to compare each element with the remaining entries in this TreeSet
.
The problme is that I can't have an iterator which starts at a specific point.
TreeSet<Object> tree = new TreeSet<>();
Iterator<Object> i1= tree.iterator();
while (i1.hasNext()) {
element1 = i1.next();
ListIterator<String> i2 = // start at the point from 'i1'
while (i2.hasNext()) {
element2 = i2.next();
System.out.println("Interact: " + element1 + " " + element2 );
}
}
I need the TreeSet
because the inserting and sorting speed of it is perfect for what I do. I do need a solution without the use of a Libary.
How would you solve this?