vector::vector (STL/CLR)
建構容器物件。
vector();
vector(vector<Value>% right);
vector(vector<Value>^ right);
explicit vector(size_type count);
vector(size_type count, value_type val);
template<typename InIt>
vector(InIt first, InIt last);
vector(System::Collections::Generic::IEnumerable<Value>^ right);
參數
count
若要插入的項目數目。第一個
若要插入範圍的開頭。last
若要插入範圍的結尾。right
物件,則要插入的範圍。val
若要插入之項目的值。
備註
建構函式:
vector();
初始化任何項目時受控制的序列。 您可以用它來指定空的初始受控制的序列。
建構函式:
vector(vector<Value>% right);
initializes the controlled sequence with the sequence [right.vector::begin (STL/CLR)(), right.vector::end (STL/CLR)()). 您會用它來指定初始的受控制的序列是一份受向量物件的順序, right。
建構函式:
vector(vector<Value>^ right);
initializes the controlled sequence with the sequence [right->vector::begin (STL/CLR)(), right->vector::end (STL/CLR)()). 您會用它來指定初始的受控制的序列的順序受其控制代碼是向量物件的複本right。
建構函式:
explicit vector(size_type count);
初始化受控制的序列的count每個項目值value_type()。 您用它來填滿容器元素全都具有預設值。
建構函式:
vector(size_type count, value_type val);
初始化受控制的序列的count每個項目值val。 您用它來填滿容器元素全都具有相同的值。
建構函式:
template<typename InIt>
vector(InIt first, InIt last);
初始化受控制序列的序列[first, last)。 您可以用它來建立受控制的序列的另一個序列的複本。
建構函式:
vector(System::Collections::Generic::IEnumerable<Value>^ right);
初始化受控制的序列的列舉值所指定的順序與right。 您可以用它來建立受控制的序列列舉值所描述的另一個序列的複本。
範例
// cliext_vector_construct.cpp
// compile with: /clr
#include <cliext/vector>
int main()
{
// construct an empty container
cliext::vector<wchar_t> c1;
System::Console::WriteLine("size() = {0}", c1.size());
// construct with a repetition of default values
cliext::vector<wchar_t> c2(3);
for each (wchar_t elem in c2)
System::Console::Write(" {0}", (int)elem);
System::Console::WriteLine();
// construct with a repetition of values
cliext::vector<wchar_t> c3(6, L'x');
for each (wchar_t elem in c3)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// construct with an iterator range
cliext::vector<wchar_t>::iterator it = c3.end();
cliext::vector<wchar_t> c4(c3.begin(), --it);
for each (wchar_t elem in c4)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// construct with an enumeration
cliext::vector<wchar_t> c5( // NOTE: cast is not needed
(System::Collections::Generic::IEnumerable<wchar_t>^)%c3);
for each (wchar_t elem in c5)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// construct by copying another container
cliext::vector<wchar_t> c7(c3);
for each (wchar_t elem in c7)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// construct by copying a container handle
cliext::vector<wchar_t> c8(%c3);
for each (wchar_t elem in c8)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
需求
標頭: < cliext/向量 >
Namespace: cliext