Swift Queues

One thing after another

Steven Curtis
3 min readMay 9, 2024


Photo by Melanie Pongratz on Unsplash

I’ve previously written an article about stacks and I think that is a good starting place for today’s article on the queue data structure as implemented in Swift.

Here is a simple representation of the stack:

class Stack<T> {
var elements = [T]()
func pop () -> T? {
if let last = elements.last {
elements =…