日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

stl:queue 源码_C ++ STL中的queue :: empty()和queue :: size()

發(fā)布時(shí)間:2025/3/11 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 stl:queue 源码_C ++ STL中的queue :: empty()和queue :: size() 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

stl:queue 源碼

In C++ STL, Queue is a type of container that follows FIFO (First-in-First-out) elements arrangement i.e. the elements which inserts first will be removed first. In queue, elements are inserted at one end known as "back" and are deleted from another end known as "front".

在C ++ STL中,隊(duì)列是遵循FIFO ( 先進(jìn)先出 )元素排列的一種容器,即,首先插入的元素將被首先刪除。 在隊(duì)列中,元素被插入稱為“ back”的一端,并從稱為“ front”的另一端刪除。

1)C ++ STL queue :: empty()函數(shù) (1) C++ STL queue::empty() function)

empty() function checks weather a queue is an empty queue or not, if a queue is empty i.e. it has 0 elements, the function returns 1 (true) and if queue is not empty, the function returns 0 (false).

empty()函數(shù)檢查隊(duì)列是否為空隊(duì)列,如果隊(duì)列為空即具有0個(gè)元素,則該函數(shù)返回1(true),如果隊(duì)列不為空,則該函數(shù)返回0(false)。

Syntax:

句法:

queue_name.empty()

Parameters(s): None

參數(shù):無

Return type:

返回類型:

  • Returns 1, if queue is empty

    如果隊(duì)列為空,則返回1

  • Returns 0, if queue is not empty

    如果隊(duì)列不為空,則返回0

  • Program:

    程序:

    #include <iostream> #include <queue> using namespace std;//Main fubction int main() {// declaring two queuesqueue<int> Q1;queue<int> Q2;//inserting elements to Q1Q1.push(10);Q1.push(20);Q1.push(30);//checking if(Q1.empty())cout<<"Q1 is an empty queue"<<endl;elsecout<<"Q1 is not an empty queue"<<endl;if(Q2.empty())cout<<"Q2 is an empty queue"<<endl;elsecout<<"Q2 is not an empty queue"<<endl;return 0; }

    Output

    輸出量

    Q1 is not an empty queue Q2 is an empty queue .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}

    2)C ++ STL queue :: size()函數(shù) (2) C++ STL queue::size() function)

    size() returns the total number of elements of a queue or we can say it returns the size of a queue.

    size()返回隊(duì)列中元素的總數(shù),或者可以說它返回隊(duì)列的大小。

    Syntax:

    句法:

    queue_name.size()

    Parameter(s): None

    參數(shù):無

    Return: total number of elements/size of the queue

    返回:元素總數(shù)/隊(duì)列大小

    Program:

    程序:

    #include <iostream> #include <queue> using namespace std;//Main fubction int main() {// declaring two queuesqueue<int> Q1;queue<int> Q2;//inserting elements to Q1Q1.push(10);Q1.push(20);Q1.push(30);cout<<"size of Q1: "<<Q1.size()<<endl;cout<<"size of Q2: "<<Q2.size()<<endl;return 0; }

    Output

    輸出量

    size of Q1: 3 size of Q2: 0

    翻譯自: https://www.includehelp.com/stl/queue-empty-and-queue-size.aspx

    stl:queue 源碼

    創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

    總結(jié)

    以上是生活随笔為你收集整理的stl:queue 源码_C ++ STL中的queue :: empty()和queue :: size()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。