rotate<T> method

List<T> rotate<T>(
  1. int amount,
  2. bool isRight
)

Implementation

List<T> rotate<T>(int amount, bool isRight) {
  List<T> target = List.from(this);

  if (isRight) {
    for (var i = 0; i < amount; i++) {
      target.insert(0, target.removeLast());
    }
  } else {
    for (var i = 0; i < amount; i++) {
      target.add(target.removeAt(0));
    }
  }
  return target;
}