splitAt method

(Slice<T>, Slice<T>) splitAt(
  1. int index
)

Divides one mutable slice into a slice and a remainder slice at an index. The slice will contain all indices from [0, N) (excluding the index N itself) and the second slice will contain all indices from [N, len) (excluding the index len itself).

Implementation

(Slice<T>, Slice<T>) splitAt(int index) {
  assert(index >= 0 && index <= _end - _start, "Index out of bounds");
  return (
    Slice(_list, _start, _start + index),
    Slice(_list, _start + index, _end)
  );
}