R
Robert Klemme
Vanessa said:I've been thinking about all the operation I have to do with my set andf
I've found out that
1) I've to read all the elements (in order) : I can do it with a
listiterator
2) Given the current element (pointed by the listIterator) (i-th element) I
have to find the previous element (that is NOT necessarly (i-1))
3) Given the current element (pointed by the listIterator) (i-th element) I
have to find the next element (that is NOT necessarly (i+1))
4) I've to do some operation with the 3 elements (modify the current
element)
5) I've to move "up" or "down" the current element
Maybe you should reveal more information how you find previous and next
elements. The best solution might be to create a temporary data
structure (maybe using a Map, SortedMap, SortedSet...), work on that and
create a new List after processing. Note also that you will run into
ConcurrentModificationException if you move elements around the list
while iterating with other methods than the ones provided by ListIterator.
Another thought: from what I read so far you have actually two orders:
one in the list and another one that defines "previous" and "next"
elements. Maybe that's another hint for finding a proper solution.
Kind regards
robert