The accumulator field is used with the following access patterns:
.remove(0)
.add(element)
.add(0)
.sublist(0,i).clear()
.get(0)
.get(i)
as one can see, except for the last item, these would all be better implemented using a Deque, but the random access isn't supported by a deque. I think it would be good to profile performance and observe how much compute is used in the accumulator .remove(0) and .add(0) calls, and if it's not insignificant, implement a Deque that has random access and use it.
The
accumulator
field is used with the following access patterns:as one can see, except for the last item, these would all be better implemented using a Deque, but the random access isn't supported by a deque. I think it would be good to profile performance and observe how much compute is used in the accumulator .remove(0) and .add(0) calls, and if it's not insignificant, implement a Deque that has random access and use it.