Queue_linked.py - -Linked version of the Queue ADT-Authors...

This preview shows page 1 - 3 out of 5 pages.

""" ------------------------------------------------------- Linked version of the Queue ADT. ------------------------------------------------------- Authors: David Brown and Masoomeh Rudafshani IDs: 999999999 and 123456789 Emails: [email protected] and [email protected] ------------------------------------------------------- """ # pylint: disable=W0212 from copy import deepcopy class Node: def __init__(self, element): """ ------------------------------------------------------- Initializes a linked-list node that contains a copy of the given element and a link pointing to None. Use: node = Node(element) ------------------------------------------------------- Parameters: element - data value for node (?) Returns: a new Node object (Node) ------------------------------------------------------- """ self._data = deepcopy(element) self._next = None class Queue: def __init__(self): """ ------------------------------------------------------- Initializes an empty Queue. The data elements are stored in a linked-list data structure. Use: queue = Queue() ------------------------------------------------------- Returns: a new Queue object (Queue) ------------------------------------------------------- """ self._front = None self._rear = None self._count = 0 def isEmpty(self): """ ------------------------------------------------------- Determines if the Queue is empty. Use: b = queue.is_empty() ------------------------------------------------------- Returns: True if queue is empty, False otherwise. ------------------------------------------------------- """ return self._count == 0 def isFull(self): """
------------------------------------------------------- Determines if the queue is full. Use: b = queue.is_full() ------------------------------------------------------- Returns: True if queue is full, False otherwise. ------------------------------------------------------- """ return False def size(self): """ ------------------------------------------------------- Returns the number of elements in the queue. Use: n = queue.size() ------------------------------------------------------- Returns: the number of data elements in the queue. ------------------------------------------------------- """ return self._count def __len__(self): """ ------------------------------------------------------- Returns the length of the queue.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture