Source of enqueue.cpp


  1: //  Created by Frank M. Carrano and Timothy M. Henry.
  2: //  Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.

  4: template<class ItemType>
  5: bool LinkedQueue<ItemType>::enqueue(const ItemType& newEntry)
  6: {
  7:    auto newNodePtr = std::make_shared<Node<ItemType>>(newEntry);
  8:    
  9:    // Insert the new node
 10:    if (isEmpty())
 11:       frontPtr = newNodePtr;        // The queue was empty
 12:    else
 13:       backPtr–>setNext(newNodePtr); // The queue was not empty
 14:    
 15:    backPtr = newNodePtr;            // New node is at back
 16:    return true;
 17: }  // end enqueue