untested ArrayList rotating function
PHP Code:
//assuming that we already have a populated ArrayList
//passing a positive value to the second parameter causes items at the END of the array to be moved to the front of the array
//passing a negative value causes items at the beginning to be placed at the end
stock void ArrayList_Rotate(ArrayList list, int amount) {
if (list == null || amount == 0) return;
if (amount < 0) {
for (int i; i < amount; i++) {
list.Push(0);
list.SwapAt(0, list.Length-1);
list.Erase(0);
}
}
else { //amount is positive
for (int i; i < amount; i++) {
list.ShiftUp(0);
list.SwapAt(0, list.Length-1);
list.Erase(list.Length-1);
}
}
}
__________________