protected void doRotate(int index, int len, int distance) {
        distance = distance % len;
        if (distance < 0) {
            distance += len;
        }
        if (distance == 0) {
            return;
        }
        assert(distance >= 0 && distance < len);

        int num = 0;
        for (int start=0; num != len; start++) {
            E elem = doGet(index+start);
            int i = start;
            do {
                i += distance;
                if (i >= len) {
                    i -= len;
                }
                elem = doReSet(index+i, elem);
                num++;
            } while (i != start);
        }
    }
Internal method to rotate specified elements in the list.
The distance argument can be positive or negative:
If it is positive, the elements are moved towards the end,
if negative, the elements are moved toward the beginning,
if distance is 0, the list is not changed.

@param index		index of first element to rotate
@param len		number of elements to rotate
@param distance	distance to move the elements
jphp-runtime/src/php/runtime/memory/support/IList.java