shift method

void shift(
  1. int amount
)

Shifts the order of the elements by the provided amount.

Implementation

void shift(int amount) {
  amount %= length;
  if (amount > 0) {
    insertAll(0, pluck(length - amount));
  } else if (amount < 0) {
    addAll(pluck(0, amount.abs()));
  }
}