1. 程式人生 > >[C++] 與比較有關的事情

[C++] 與比較有關的事情

values nta 需要 csdn .com 比較 bin ffffff queue

1. multiset:

 multiset是允許元素重復的集合,並且可以實現定點刪除,我們往往用它來實現需要定點刪除的堆。

 定點刪除操作:通過find()或lowe_bound()或upper_bound()來確定叠代器的位置,然後調用erase()來刪除。

 multiset默認的是最小堆,當使用multiset<int, greater<int>> 來聲明時,是最大堆。

 multiset對比較的定義是:

  Binary predicate that, taking two values of the same type of those contained in the multiset, returns true

if the first argument goes before the second argument in the strict weak ordering it defines, and false otherwise.
This shall be a function pointer or a function object.

  若第一個參數和第二個參數以(Arg1, Arg2)遵循某個嚴格弱序時,返回true。

2. priority_queue:

  通常我們把它當做最小堆來用。

  此時聲明方式:priority_queue<int, vector<int>, greater<int>>

  默認則為最大堆。

3. 關於比較器:

  我去看看,再學習記錄

[C++] 與比較有關的事情