zoukankan
html css js c++ java
C# 集合类(二):Queue
Queue
:队列,表示对象的先进先出集合。Enqueue方法入队列,Dequeue方法出队列。
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Collections;
namespace
ConsoleApplication1
{
class
Program
{
static
void
Main(
string
[] args)
{
Queue qu
=
new
Queue();
Queue qu2
=
new
Queue();
foreach
(
int
i
in
new
int
[
4
]
{
1
,
2
,
3
,
4
}
)
{
qu.Enqueue(i);
//
入队
qu2.Enqueue(i);
}
foreach
(
int
i
in
qu)
{
Console.WriteLine(i);
//
遍历
}
qu.Dequeue();
//
出队
Console.WriteLine(
"
Dequeue
"
);
foreach
(
int
i
in
qu)
{
Console.WriteLine(i);
}
qu2.Peek();
//
返回位于 Queue 开始处的对象但不将其移除。
Console.WriteLine(
"
Peek
"
);
foreach
(
int
i
in
qu2)
{
Console.WriteLine(i);
}
}
}
}
查看全文
相关阅读:
时间日期date/cal
chown命令
su命令
which命令和bin目录
python基础之文件操作
python之模块之shutil模块
python基础之面向对象01
python基础之面向对象02
python基础之map/reduce/filter/sorted
python基础之模块之序列化
原文地址:https://www.cnblogs.com/wf225/p/1037811.html
最新文章
markdown 编辑器概述
Go 基础学习笔记(3)| 第一个程序 “helloworld”
Golang 基础学习笔记(2)| 如何安装Go工具
GO 基础学习笔记(1) | 简介
mkpasswd命令
Centos7部署kubernetes测试k8s应用(九)
Centos7部署Flannel网络(八)
Centos7部署kubernetes Proxy(七)
Centos7部署kubelet(六)
Centos7部署kubectl命令行工具(五)
热门文章
Centos7部署kubernetes API服务(四)
Centos7部署kubernetes-ETCD集群(三)
Centos7部署kubernetes集群CA证书创建和分发(二)
Centos7部署kubernetes准备工作(一)
+=运算符的问题
交换两个变量
打包/压缩
软硬链接
find命令
进程命令ps/top/kill
Copyright © 2011-2022 走看看