map::to_array (STL/CLR)
將受控制的序列複製到新的陣列。
cli::array<value_type>^ to_array();
備註
成員函式傳回陣列,其中包含受控制的序列。 您可以用它來得到一份以陣列形式受控制序列。
範例
// cliext_map_to_array.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));
// copy the container and modify it
cli::array<Mymap::value_type>^ a1 = c1.to_array();
c1.insert(Mymap::make_value(L'd', 4));
for each (Mymap::value_type elem in c1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
// display the earlier array copy
for each (Mymap::value_type elem in a1)
System::Console::Write(" [{0} {1}]", elem->first, elem->second);
System::Console::WriteLine();
return (0);
}
需求
標頭: < cliext/地圖 >
Namespace: cliext