removeElement method

E removeElement()

Retrieves and removes the head of this queue.

Throws NoGuaranteeException if this queue is empty.

Example:

final queue = LinkedQueue<String>();
queue.offer('item');
final removed = queue.removeElement(); // 'item'

Implementation

E removeElement() {
  if (_head == null) {
    throw NoGuaranteeException('Queue is empty');
  }

  final data = _head!.data;
  _removeNode(_head!);
  return data;
}