C STLmap查詢和統計

2021-10-22 02:07:30 字數 618 閱讀 4878

功能描述:

*對map容器進行查詢資料以及統計資料

函式原型:

find

(key)

;//查詢key是否存在,若還在,返回改鍵的元素的迭代器,若不存在set.end();

count

(key)

;//統計key的元素個數

#include

#include

using

namespace std;

//map容器 查詢合同及

void

test01()

else

//統計

//map容器不允許插入重複值key元素,count統計而言 結果要麼是0要麼是1

//multimap的count統計可能大於1

int num = m.

count(3

);cout <<

"num="

<< num << endl;

}int

main()

總結:

查詢—find(返回的是迭代器)

統計—count(對於map,結果為0或者1)

C STL Map對映和Set集合

map 對映 可以理解為下標可以不為int型別的高階陣列 include mapa 是字串到數字的對映 應用 給英文本串,求星期幾 include include include using namespace std mapday int main set 集合 與數學上的集合意義相同 相同元素記...

Elasticsearch的查詢和統計

1.查詢所有 get fei search 2.id到排序 get fei search sort 3.只返回部分字段 get fei search source name price 4.條件查詢 get fei search 5.分頁查詢 get fei search from 1,size 3...

C STLmap的使用和特點 C STL相關

map是c 98中引入的二叉樹資料結構 1 map有四個引數 2 count 和find 函式傳入的引數都是key 3 finditer迭代器返回的是const int 4 在map中插入元素需要用make pair 5 insert有返回兩個引數第乙個是迭代器的位置,第二個表示插入是否成功 6 e...