天天看點

find

1. std::find()

注意點:

#include <algorithm> // std::find

假如找不到,傳回last,而不是固定的end()!

2. string::find()

if (str.find("xxx") != string::npos)

從指定位置(index)開始find:str.find("xxx", 3)

3. STL find

包括map,set,stack,queue等

if (map.find(key) != map.end()) // 假如找到了key

注意:vector竟然沒有find() !!!