博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
stl中empty_C ++ STL中的array :: empty()示例
阅读量:2530 次
发布时间:2019-05-11

本文共 1824 字,大约阅读时间需要 6 分钟。

stl中empty

"array" is a container which is used to create/container which is used to create/contains the fixed size arrays, the "array" in C++ STL is "class" actually and they are more efficient, lightweight and very easy to use, understand, "array" class contains many inbuilt functions, thus the implementation of the operations are fast by using this rather that C-Style arrays.

“数组”是用于创建/包含用于创建/包含固定大小的数组的容器,C ++ STL中的“数组 实际上是“类” ,它们更高效,轻巧且非常易于使用,可以理解, “数组”类包含许多内置函数,因此使用此数组而不是C-Style数组可以快速实现操作。

To use "array" class and its function, we need to include "array" class and its function, we need to include "array" header.

要使用“数组”类及其功能,我们需要包括“数组”类及其功能,我们需要包括“数组”标头。

array :: empty()函数 (array::empty() function)

empty() function is used to check whether an array is empty or not. It returns 1 (true), if the array size is 0 and returns 0 (false), if array size is not zero.

empty()函数用于检查数组是否为空。 如果数组大小为0,则返回1(真),如果数组大小不为零,则返回0(假)。

Syntax:

句法:

array_name.empty();

Parameters:

参数:

There is no parameter to be passed.

没有要传递的参数。

Return type:

返回类型:

  • 1 (true) – if array is empty

    1(true)–如果数组为空

  • 0 (false) – if array is not empty

    0(假)–如果数组不为空

Example:

例:

Input:    arr1{} //an empty array    arr2{10,20,30} //array with 3 elements    Function calls:    arr1.empty()    arr2.empty()    Output:    1    0

Program:

程序:

#include 
#include
using namespace std;int main() {
//declaring two arrays array
arr1{
}; array
arr2{
}; array
arr3{
10, 20, 30}; array
arr4{ 10, 20, 30, 40, 50}; //printing arr_name.empty() value cout<<"arr1.empty(): "<
<

Output

输出量

arr1.empty(): 1arr2.empty(): 0arr3.empty(): 0arr4.empty(): 0arr1 is emptyarr2 is not emptyarr3 is not emptyarr4 is not empty

翻译自:

stl中empty

转载地址:http://azozd.baihongyu.com/

你可能感兴趣的文章
接口测试用例
查看>>
面试:用 Java 实现一个 Singleton 模式
查看>>
Sybase IQ导出文件的几种方式
查看>>
案例:手动输入一个字符串,打散放进一个列表,小写字母反序 大写字母保持不变...
查看>>
linux 系统下 tar 的压缩与解压缩命令
查看>>
阿里负载均衡,配置中间证书问题(在starcom申请免费DV ssl)
查看>>
转:How to force a wordbreaker to be used in Sharepoint Search
查看>>
MySQL存储过程定时任务
查看>>
Python中and(逻辑与)计算法则
查看>>
POJ 3267 The Cow Lexicon(动态规划)
查看>>
设计原理+设计模式
查看>>
音视频处理
查看>>
tomcat 7服务器跨域问题解决
查看>>
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
个人工作总结05(第二阶段)
查看>>
Java clone() 浅拷贝 深拷贝
查看>>
深入理解Java虚拟机&运行时数据区
查看>>
02-环境搭建
查看>>
spring第二冲刺阶段第七天
查看>>