falocafe.blogg.se

Queue kotlin
Queue kotlin













queue kotlin

We can remove and get the First element from the Queue using removeFirst method or remove method. In the following example, we used addLast method, to add Jupiter to the end of our Queue. We can add element to the end of a Queue, using addLast method or add method. PlanetsQueue.addAll(listOf("Mercury", "Venus", "Earth")) We are creating a LinkedList with three planets to begin with. Creating a QueueĬonsider a Queue of planets as shown below. In this tutorial, we will see how to use LinkedList to perform operations on a Queue. Queue interface is extended by following sub interfaces.

queue kotlin

Queue implementation is provided by following classes. The most popular implementation of this interface is provided by LinkedList. The person who came in last, will be the last to get the ticket. The person who came in first, will be the first to get the ticket. Imagine going to a movie theater and purchasing a ticket. As a concept, Queue provides, a First in - First Out data structure.















Queue kotlin