offer method

bool offer(
  1. E element
)

Inserts the specified element into this queue.

Returns true if the element was added successfully. This implementation always returns true since the queue is unbounded.

Example:

final queue = LinkedQueue<int>();
final success = queue.offer(42);
print(success); // true

Implementation

bool offer(E element) {
  final newNode = _QueueNode<E>(element);

  if (_tail == null) {
    _head = _tail = newNode;
  } else {
    _tail!.next = newNode;
    newNode.prev = _tail;
    _tail = newNode;
  }

  _size++;
  return true;
}