mutable struct Queue front::LinkedList rear::LinkedList size::Int end function push!(q::Queue, elm) if q.rear == nothing q.front = q.rear = ListNode(elm, nothing) q.size = 1 else node = ListNode(elm, nothing) q.rear.next = node q.rear = node q.size += 1 end end function pop!(q::Queue) if q.front == nothing error("empty queue") else x = q.front.data q.front = q.front.next if q.front == nothing q.rear = nothing end q.size -= 1 return x end end function isempty(q::Queue) return q.size == 0 end q = Queue(nothing, nothing, 0) push!(q, 1) push!(q, 2) push!(q, 3) println(pop!(q)) println(q)