2012-11-04 47 views
0

如何查找映射中兩個鍵值之間的鍵數?有什麼辦法可以使用迭代器來完成這個任務嗎?兩個鍵之間的鍵數

+1

我沒有使用過的地圖迭代不夠了解,但'的std :: distance'威力。 – chris

+2

你有沒有對此進行過解析,@ user1543957?如果是這樣,這將有助於知道你到目前爲止嘗試過什麼。使用此[編輯]鏈接添加更多詳細信息。祝你好運! – jmort253

回答

1

看一看地圖和一些STL algirhtims:

http://www.cplusplus.com/reference/stl/map/ 
    lower_bound Return iterator to lower bound (public member function) 
    upper_bound Return iterator to upper bound (public member function) 
    distance Calculates the number of elements between first and last. 
相關問題