iterator

Class Deque<Item>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      class  Deque.iteratorLoop
      Iterator Class contains hasNext() and next() methods, which are used to instantiate an iterator object.
      class  Deque.Node
      Node class defines the structure of the linked list.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private int arraySize
      The size of the input array
      (package private) Deque.Node head
      The first node in the queue.
      private Item[] input
      The input array contains the data read from external file and manipulated.
      (package private) Deque.Node tail
      The last node in the queue.
      private int totalItems
      The total number of nodes in the array.
    • Constructor Summary

      Constructors 
      Constructor and Description
      Deque()
      Deque constructor intializes the linked list head and tail nodes to null.
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void addFirst(Item item)
      Items a generic item to the beginning of the queue.
      void addLast(Item item)
      Items a generic item to the end of the queue.
      Deque.Node createNode(Item item, Deque.Node nodeValue)
      Creates a new Node to be added to the queue.
      boolean isEmpty()
      Returns value indicating if the randomized queue is empty.
      java.util.Iterator<Item> iterator()
      The iterator method returns an object of the iterator class iteratorLoop
      void loop(Deque<Item> dq)
      loop iterates through the queue and prints out all the items in the list.
      static void main(java.lang.String[] args) 
      void printList()
      Prints the queue without an iterator.
      Item removeFirst()
      Removes the first node in the queue.
      Item removeLast()
      Removes the last node in the queue.
      int size()
      Returns the number of items on the randomized queue.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • arraySize

        private int arraySize
        The size of the input array
      • input

        private Item[] input
        The input array contains the data read from external file and manipulated.
      • totalItems

        private int totalItems
        The total number of nodes in the array.
      • head

        Deque.Node head
        The first node in the queue.
      • tail

        Deque.Node tail
        The last node in the queue.
    • Constructor Detail

      • Deque

        public Deque()
        Deque constructor intializes the linked list head and tail nodes to null.
    • Method Detail

      • isEmpty

        public boolean isEmpty()
        Returns value indicating if the randomized queue is empty.
      • size

        public int size()
        Returns the number of items on the randomized queue.
      • addFirst

        public void addFirst(Item item)
        Items a generic item to the beginning of the queue.
        Parameters:
        item - The generic item to be added to the queue.
      • addLast

        public void addLast(Item item)
        Items a generic item to the end of the queue.
        Parameters:
        item - The generic item to be added to the queue.
      • createNode

        public Deque.Node createNode(Item item,
                            Deque.Node nodeValue)
        Creates a new Node to be added to the queue.
        Parameters:
        item - The generic item to be added to the queue.
        nodeValue - The value that the .next pointer references.
      • printList

        public void printList()
        Prints the queue without an iterator.
      • removeFirst

        public Item removeFirst()
        Removes the first node in the queue.
      • removeLast

        public Item removeLast()
        Removes the last node in the queue.
      • iterator

        public java.util.Iterator<Item> iterator()
        The iterator method returns an object of the iterator class iteratorLoop
        Specified by:
        iterator in interface java.lang.Iterable<Item>
      • loop

        public void loop(Deque<Item> dq)
        loop iterates through the queue and prints out all the items in the list.
        Parameters:
        dq - A reference to a deque object.
      • main

        public static void main(java.lang.String[] args)