队列一个先进先出的对象集合

public class PlayChickTopicData : MonoBehaviour
{
Queue<TopicData> topicDatas = new Queue<TopicData>(); struct TopicData
{
public string topicData;
public bool select; public TopicData(string strTopic, bool select)
{
topicData = strTopic;
this.select = select;
}
} private void Start()
{
//入队
topicDatas.Enqueue(new TopicData("驾驶装有ABS 系统的机动车,制动过急时同样会发生侧滑。", false));
topicDatas.Enqueue(new TopicData("安装制动防爆死装置(ABS)的车辆,驾驶人发现汽车转向失效时,应轻踏制动踏板。", false));
topicDatas.Enqueue(new TopicData("驾驶有ABS 系统的机动车,在紧急制动的同时转向会发生侧滑。", true));
topicDatas.Enqueue(new TopicData("在坡道上掉头,每次停车时应用行车制动控制,不必使用驻车制动器。", false));
topicDatas.Enqueue(new TopicData("夜间在城市道路超车前要鸣喇叭(变换远近灯光)示意前车,待前车让行后从左侧超越。", false));
topicDatas.Enqueue(new TopicData("驾驶人持超过有效期的驾驶证可以在1年内驾驶机动车。查看本题分析", false));
topicDatas.Enqueue(new TopicData("立交桥上一般都是单向行驶,车辆不必减速行驶", false));
topicDatas.Enqueue(new TopicData("准驾车型为小型自动挡汽车的,可以驾驶低速载货汽车。", false));
topicDatas.Enqueue(new TopicData("行车中遇残疾人影响通行时,应主动减速礼让。", true));
topicDatas.Enqueue(new TopicData("因避让特种车辆而发生违法行为,被电子警察拍到时,可向交管部门复议。", true));
} private void Update()
{
//输出移除队首的元素 出队
if (Input.GetKeyDown(KeyCode.D))
{
if (topicDatas.Count > 0)
{
showQueue();
TopicData topicData = topicDatas.Dequeue();
UnityEngine.Debug.Log("题目"+ topicData.topicData);
UnityEngine.Debug.Log("正确答案:"+ topicData.select);
}
} //移除所有元素
if (Input.GetKeyDown(KeyCode.C))
{
topicDatas.Clear();
showQueue();
}
UnityEngine.Debug.Log(topicDatas.Count.ToString());
} void showQueue()
{
foreach (var value in topicDatas)
{
string str="";
str += value.topicData + " " + value.select + "|";
UnityEngine.Debug.Log(str );
}
} }

http://www.runoob.com/csharp/csharp-queue.html

Queue 队列的使用的更多相关文章

  1. C#基础---Queue(队列)的应用

       Queue队列,特性先进先出. 在一些项目中我们会遇到对一些数据的Check,如果数据不符合条件将会把不通过的信息返回到界面.但是对于有的数据可能会Check很多条件,如果一个数据一旦很多条件不 ...

  2. 第19章 queue队列容器

    /* 第19章 queue队列容器 19.1 queue技术原理 19.2 queue应用基础 19.3 本章小结 */ // 第19章 queue队列容器 // 19.1 queue技术原理 // ...

  3. atitit. java queue 队列体系and自定义基于数据库的队列总结o7t

    atitit. java queue 队列体系and自定义基于数据库的队列总结o7t 1. 阻塞队列和非阻塞队列 1 2. java.util.Queue接口, 1 3. ConcurrentLink ...

  4. C#部分---特殊集合:stack栈集合、queue队列集合、哈希表集合。

    1.stack栈集合:又名 干草堆集合 栈集合 特点:(1)一个一个赋值 一个一个取值(2)先进后出实例化 初始化 Stack st = new Stack(); //添加元素用push st.Pus ...

  5. 实现一个线程安全的Queue队列

    使用装饰者模式实现一个线程安全的Queue队列. public class SynchronizedQueue<E> implements Queue<E>, Serializ ...

  6. Python自动化运维之16、线程、进程、协程、queue队列

    一.线程 1.什么是线程 线程是操作系统能够进行运算调度的最小单位.它被包含在进程之中,是进程中的实际运作单位. 一条线程指的是进程中一个单一顺序的控制流,一个进程中可以并发多个线程,每条线程并行执行 ...

  7. Stack集合 Queue队列集合 Hashtable哈希表

    Stack集合 干草堆集合 栈集合 栈;stack,先进后出,一个一个赋值,一个一个取值,安装顺序来. 属性和方法 实例化 初始化 Stack st = new Stack(); 添加元素 个数 Co ...

  8. Python第十五天 datetime模块 time模块 thread模块 threading模块 Queue队列模块 multiprocessing模块 paramiko模块 fabric模块

    Python第十五天  datetime模块 time模块   thread模块  threading模块  Queue队列模块  multiprocessing模块  paramiko模块  fab ...

  9. python threading模块使用 以及python多线程操作的实践(使用Queue队列模块)

    今天花了近乎一天的时间研究python关于多线程的问题,查看了大量源码 自己也实践了一个生产消费者模型,所以把一天的收获总结一下. 由于GIL(Global Interpreter Lock)锁的关系 ...

  10. (8)进程---Queue队列

    # IPC Inter-Process Communication # 实现进程之间通信的两种机制: # 管道 Pipe 用的很少 # 队列 Queue 队列的特征:现进先出,栈属于后进后出 基本语法 ...

随机推荐

  1. linux 7.2安装扩展redis

    unzip phpredis-php7.zip cd phpredis-php7 /usr/local/php7./bin/phpize ./configure --with-php-config=/ ...

  2. go ethereum源码分析 PartIV Transaction相关

    核心数据结构: core.types.transaction.go type Transaction struct { data txdata // caches hash atomic.Value ...

  3. ECC算法软件保护中的应用

    椭圆曲线在软件注册保护的应用 我们知道将公开密钥算法作为软件注册算法的好处是Cracker很难通过跟踪验证算法得到注册机.下面,将简介一种利用Fp(a,b)椭圆曲线进行软件注册的方法. 软件作者按如下 ...

  4. explor img file

    1, get offset # parted bone-debian----4gb.img GNU Parted 3.1 Using /workspace/bone-debian----4gb.img ...

  5. io复用select方法编写的服务器

    摘要:io多路复用是通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般都是读就绪或者写就绪),就能通知应用程序进行相应的读写操作.select函数作为io多路复用的机制,第一个参数nfds是f ...

  6. 基于vue项目的组件中导入mui框架初始化滑动等效果时需移除严格模式的问题

    基于vue项目的组件中导入mui框架初始化滑动等效果时,控制台报错:Uncaught TypeError: 'caller', 'callee', and 'arguments' properties ...

  7. ftp远端上的文件下载

    用linux下的wge下t载比在window下一个个点方便多了,命令如下: wget ftp:// 110.110.110/\*.mseed --ftp-user=username --ftp-pas ...

  8. SQLZOO网页中SQL的答案(SELECT from world篇)

    SELECT from world篇 11. 题目: The CASE statement shown is used to substitute North America forCaribbean ...

  9. linux 清理缓存buff/cache

    清理缓存 echo 1 > /proc/sys/vm/drop_cachesecho 2 > /proc/sys/vm/drop_cachesecho 3 > /proc/sys/v ...

  10. Introduction to Unity UI

    https://www.raywenderlich.com/795-introduction-to-unity-ui-part-1 https://www.raywenderlich.com/794- ...