removeElement method

E removeElement()

Retrieves and removes the head of this queue.

Throws InvalidArgumentException if this queue is empty.

Example:

final queue = Queue<String>();
queue.offer('item');
final removed = queue.remove(); // 'item'

Implementation

E removeElement() {
  if (_elements.isEmpty) {
    throw InvalidArgumentException('Queue is empty');
  }
  return _elements.removeAt(0);
}