The dart:collection
library provides the advanced collection support for the Dart language, apart from the basic collections already provided by the dart:core
library.
It contains the DoubleLinkedQueue<E>
class which implements the abstract Queue<E>
class, using a doubly-linked list.
add()
methodThe DoubleLinkedQueue<E>
class contains the add()
method, which adds an element to the end of a queue.
A queue is a FIFO (First In First Out) data structure. In a queue, the element which is added first will be deleted first.
void add(
E value
)
E
as input and adds it to the end of the queue.We first import the dart:collection
library into our program.
import 'dart:collection'; void main() { var dayQueue = DoubleLinkedQueue<String>(); dayQueue.add("Sunday"); dayQueue.add("Monday"); dayQueue.add("Tuesday"); print('Printing Queue Elements'); print(dayQueue); }
DoubleLinkedQueue
class of type String
."Sunday"
, "Monday"
, and "Tuesday"
, using the add()
method.print()
function of the core
library.The program prints the output below and exits:
Printing Queue Elements
{Sunday, Monday, Tuesday}
RELATED TAGS
CONTRIBUTOR
View all Courses