Lecture 8 - Queue Implementation
Lecture 8 - Queue Implementation
Queue implementation
Java Queue Implementations
• java.util.LinkedList
• java.util.PriorityQueue
• LinkedList is a pretty standard queue implementation. Elements in the
queue are stored internally in a standard linked list data structure. This
makes it fast to insert elements at the end (tail) of the list, and remove
elements from the beginning (head) of the list.
Java Queue Implementations
The Java Queue interface, java.util.Queue represents a data structure designed to have elements inserted
at the end of the queue, and elements removed from the beginning of the queue. This is similar to how a
queue in a supermarket works. The Java Queue interface is a subtype of the Java Collection interface. It
represents an ordered sequence of objects just like a Java List, but its intended use is slightly different.
Because the Java Queue interface is a subtype of the Java Collection interface, all methods in the
Collection interface are also available in the Queue interface.
Java Queue Implementations
• Here are a few examples of how to create a Queue instance: