operator< (map) (STL/CLR)
列表小於比較。
template<typename Key,
typename Mapped>
bool operator<(map<Key, Mapped>% left,
map<Key, Mapped>% right);
參數
left
要比較的左邊容器。right
要比較的右邊容器。
備註
若在 !(right[i] < left[i]) 的最低位置 i,left[i] < right[i] 也為真,則運算子函式傳回 true。 否則,會傳回 left->size() < right->size()。您可用它來測試在兩個地圖逐一比較項目後,left 是否在 right 之前已排序。
範例
// cliext_map_operator_lt.cpp
// compile with: /clr
#include <cliext/map>
typedef cliext::map<wchar_t, int> Mymap;
int main()
{
Mymap c1;
c1.insert(Mymap::make_value(L'a', 1));
c1.insert(Mymap::make_value(L'b', 2));
c1.insert(Mymap::make_value(L'c', 3));
// display contents " [a 1] [b 2] [c 3]"
for each (Mymap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// assign to a new container
Mymap c2;
c2.insert(Mymap::make_value(L'a', 1));
c2.insert(Mymap::make_value(L'b', 2));
c2.insert(Mymap::make_value(L'd', 4));
// display contents " [a 1] [b 2] [d 4]"
for each (Mymap::value_type elem in c2)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
System::Console::WriteLine("[a b c] < [a b c] is {0}",
c1 < c1);
System::Console::WriteLine("[a b c] < [a b d] is {0}",
c1 < c2);
return (0);
}
需求
標頭: <cliext/map>
命名空間: cliext