using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public static void QueueTest()
{
Queue queue = new Queue();
for (int i = 0; i < 10; i++)
{
queue.Enqueue("第" + (i + 1) + "个人");
}
//出队为队中数据进行服务
while (queue.Count != 0)
{
Debug.Log("为" + queue.Dequeue() + "服务");
}
}
void Start()
{
QueueTest();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public static void QueueTest()
{
Queue queue = new Queue();
for (int i = 0; i < 10; i++)
{
queue.Enqueue("第" + (i + 1) + "个人");
}
//出队为队中数据进行服务
while (queue.Count != 0)
{
if (queue.Peek().Equals("第5个人"))
{
Debug.Log("请准备!");
}
System.Object man = queue.Dequeue();
if (man.Equals("第5个人"))
{
Debug.Log("为" + man + "唱生日快乐歌");
}
else
{
Debug.Log("为" + man + "服务");
}
}
}
void Start()
{
QueueTest();
}
}