getRear method

T getRear()

Returns the element at the rear (last) of the deque without removing it. Throws a StateError if the deque is empty.

Implementation

T getRear() {
  if (isEmpty) {
    throw StateError('Cannot get rear element from an empty Deque');
  }
  return _queue.last;
}