我試圖構造一個元組(i, v)
,其中i
是int
和v
是double
的。該集不能包含具有相同值i
的兩個元組。元組的(I,V),使得所有元組有我的不同值
爲此,我認爲我應該使用std:tuple
的std::set
s。喜歡的東西:
#include <tuple>
#include <set>
using namespace std;
set<tuple<int, double>> mySet;
的std::set
類允許我指定一個比較,我想我應該利用這一點避免與i
相同的值不同的元組,但我不知道該怎麼辦呢?
見http://stackoverflow.com/questions/2620862/using-custom-stdset-comparator – LeartS
聽起來'地圖'給我。 –
@IgorTandetnik你是對的!我不知道'map'。但我仍然想了解如何使用'set' – becko