队列
1 import scala.collection.immutable.Queue 2 import scala.collection.mutable 3 4 object Test18_Queue { 5 def main(args: Array[String]): Unit = { 6 //创建一个可变队列 7 val queue = new mutable.Queue[String]() 8 queue.enqueue("a", "b", "c") 9 //入队 10 println(queue) 11 //出队,先进先出 12 println(queue.dequeue()) 13 println(queue) 14 println(queue.dequeue()) 15 println(queue) 16 17 queue.enqueue("d", "e") 18 println(queue.dequeue()) 19 20 //不可变队列 21 val queue1 = Queue("a", "b", "c") 22 val queue2 = queue1.enqueue("d") 23 println(queue1) 24 println(queue2) 25 } 26 }