A queue is an ADT – Abstract Data Type or a linear data structure. It is a FIFO data structure because element inserted first will be removed first. FIFO stands for First-in-first-out. Queue use one end to insert data which is called REAR or tail and other end to remove the data which is called FRONT or head.
- enqueue(): Insert an item to the queue.
- dequeue(): Remove an item from the queue.
- peek(): Get the top data element of the queue, without removing it.
- isFull(): Check if queue is full.
- isEmpty(): Check if queue is empty.
- Overflow state: A queue is in overflow state if it does not contain enough space to accept an entity to be inserted.
- Underflow state: A queue is in underflow state if we want to operate stack with dequeue operation and the queue is empty.
Java Queue examples
- Java queue implementation
- Java dynamic queue implementation
- Java deque implementation
- Java deque implementation using doubly linked list
- Java PriorityQueue implementation