Imagine that there is a collection of integer values. For example, 1 5 8 3 0 15 7 . Is there any method that would move the values to some definitely number? For example, I want to move all values by 2 to the left. Then it will look like this: 8 3 0 15 7 1 5 .
|
nwith an offset numberdmay be quicker. So that the reading of theith element returns(i+d)%n'th element of the array. The offset by 2 to the left will be expressed only in a decrease ofdby 2 (you can still take the remainder of dividing bynin the result to avoid special effects from larged) - D-sidejava.utils.Collections.rotatemethod. For arrays of primitives like no, you can read about possible implementations here . - zRrr pm