Deque (should be pronounced as "deck") is a collection implementing double-ended queues. Deques are similar to arrays, but they have efficient insertions and removal of elements at the beginning and at the end.
The indexing semantics are integer indices that are the same as arrays.
Now let's see a sample implementation of deque.
var colors: Deque = ["Yellow", "Orange"] print(colors) // [Yellow, Orange]
The above code implements a deque of colors with the strings yellow and orange.
Now let's see some operations or methods unique to deques.
colors.prepend("Blue") // Blue is added to the beginning
colors.append("White") // White is added to the end
let _ = colors.popFirst() // Blue is removed
let _ = colors.popLast() // White is removed print(colors) // [Yellow, Orange]