Javatpoint Logo
Javatpoint Logo

Scala Queue

Queue implements a data structure that allows inserting and retrieving elements in a first-in-first-out (FIFO) manner.

In scala, Queue is implemented as a pair of lists. One is used to insert the elements and second to contain deleted elements. Elements are added to the first list and removed from the second list.


Scala Queue Example

Output:

Queue(1, 5, 6, 2, 3, 9, 5, 2, 5)
Queue(1, 5, 6, 2, 3, 9, 5, 2, 5)

Scala Queue Example 2

Output:

Queue Elements: 1 5 6 2 3 9 5 2 5 
First element in the queue: 1
Element added in the queue: 1 5 6 2 3 9 5 2 5 100 
Element deleted from this queue: (1,Queue(5, 6, 2, 3, 9, 5, 2, 5))
Next TopicScala Stream





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA