vector(STL/CLR)

템플릿 클래스는 임의 액세스 권한이 있는 다양한 길이의 요소 시퀀스를 제어하는 개체를 설명합니다. 컨테이너 vector 를 사용하여 연속 스토리지 블록으로 요소 시퀀스를 관리합니다. 블록은 요청 시 증가하는 배열로 구현됩니다.

아래 GValue 설명에서 후자가 ref 형식이 아니면 Value동일합니다. 이 경우 값입니다Value^.

구문

template<typename Value>
    ref class vector
        :   public
        System::ICloneable,
        System::Collections::IEnumerable,
        System::Collections::ICollection,
        System::Collections::Generic::IEnumerable<GValue>,
        System::Collections::Generic::ICollection<GValue>,
        System::Collections::Generic::IList<GValue>,
        Microsoft::VisualC::StlClr::IVector<GValue>
    { ..... };

매개 변수


제어되는 시퀀스의 요소 형식입니다.

요구 사항

헤더:<cliext/vector>

네임스페이스: cliext

선언

형식 정의 설명
vector::const_iterator(STL/CLR) 제어되는 시퀀스에 대한 상수 반복기의 형식입니다.
vector::const_reference(STL/CLR) 요소에 대한 상수 참조의 형식입니다.
vector::const_reverse_iterator(STL/CLR) 제어되는 시퀀스에 대한 상수 역방향 반복기의 형식입니다.
vector::difference_type(STL/CLR) 두 요소 사이의 부호가 있는 거리의 형식입니다.
vector::generic_container(STL/CLR) 컨테이너에 대한 제네릭 인터페이스의 형식입니다.
vector::generic_iterator(STL/CLR) 컨테이너의 제네릭 인터페이스에 대한 반복기의 형식입니다.
vector::generic_reverse_iterator(STL/CLR) 컨테이너의 제네릭 인터페이스에 대한 역방향 반복기의 형식입니다.
vector::generic_value(STL/CLR) 컨테이너의 제네릭 인터페이스에 대한 요소의 형식입니다.
vector::iterator(STL/CLR) 제어되는 시퀀스에 대한 반복기의 형식입니다.
vector::reference(STL/CLR) 요소에 대한 참조의 형식입니다.
vector::reverse_iterator(STL/CLR) 제어되는 시퀀스에 대한 반대 반복기의 형식입니다.
vector::size_type(STL/CLR) 두 요소 사이의 부호가 있는 거리의 형식입니다.
vector::value_type(STL/CLR) 요소의 형식입니다.
멤버 함수 설명
vector::assign(STL/CLR) 모든 요소를 바꿉니다.
vector::at(STL/CLR) 지정된 위치에 있는 요소에 액세스합니다.
vector::back(STL/CLR) 마지막 요소에 액세스합니다.
vector::begin(STL/CLR) 제어되는 시퀀스의 시작을 지정합니다.
vector::capacity(STL/CLR) 컨테이너에 할당된 스토리지의 크기를 보고합니다.
vector::clear(STL/CLR) 모든 요소를 제거합니다.
vector::empty(STL/CLR) 요소가 있는지 여부를 테스트합니다.
vector::end(STL/CLR) 제어되는 시퀀스의 끝을 지정합니다.
vector::erase(STL/CLR) 지정된 위치에 있는 요소를 제거합니다.
vector::front(STL/CLR) 첫 번째 요소에 액세스합니다.
vector::insert(STL/CLR) 지정된 위치에 요소를 추가합니다.
vector::pop_back(STL/CLR) 마지막 요소를 제거합니다.
vector::push_back(STL/CLR) 새 마지막 요소를 추가합니다.
vector::rbegin(STL/CLR) 제어되는 역방향 시퀀스의 시작을 지정합니다.
vector::rend(STL/CLR) 제어되는 역방향 시퀀스의 끝을 지정합니다.
vector::reserve(STL/CLR) 컨테이너의 최소 증가 용량을 보장합니다.
vector::resize(STL/CLR) 요소 수를 변경합니다.
vector::size(STL/CLR) 요소 수를 계산합니다.
vector::swap(STL/CLR) 두 컨테이너의 내용을 바꿉니다.
vector::to_array(STL/CLR) 제어된 시퀀스를 새 배열에 복사합니다.
vector::vector(STL/CLR) 컨테이너 개체를 만듭니다.
속성 설명
vector::back_item(STL/CLR) 마지막 요소에 액세스합니다.
vector::front_item(STL/CLR) 첫 번째 요소에 액세스합니다.
연산자 설명
vector::operator=(STL/CLR) 제어되는 시퀀스를 바꿉니다.
vector::operator(STL/CLR) 지정된 위치에 있는 요소에 액세스합니다.
operator!= (vector)(STL/CLR) 개체가 다른 vector 개체와 vector 같지 않은지 여부를 확인합니다.
연산자< (벡터)(STL/CLR) 개체가 다른 vector 개체보다 작은지 여부를 vector 확인합니다.
operator<= (vector)(STL/CLR) 개체가 다른 vector 개체보다 작거나 같은지 여부를 vector 확인합니다.
operator== (vector)(STL/CLR) 개체가 다른 vector 개체와 vector 같은지 여부를 확인합니다.
연산자> (벡터)(STL/CLR) 개체가 다른 vector 개체보다 큰지 여부를 vector 확인합니다.
operator>= (vector)(STL/CLR) 개체가 다른 vector 개체보다 크거나 같은지 여부를 vector 확인합니다.

인터페이스

인터페이스 설명
ICloneable 개체를 복제합니다.
IEnumerable 요소를 시퀀스합니다.
ICollection 요소 그룹을 유지 관리합니다.
IEnumerable<T> 형식화된 요소를 통한 시퀀스입니다.
ICollection<T> 형식화된 요소 그룹을 유지 관리합니다.
IList<T> 형식화된 요소의 정렬된 그룹을 유지 관리합니다.
IVector<값> 일반 컨테이너를 유지 관리합니다.

설명

개체는 주문형으로 증가하는 값 요소의 저장된 배열을 통해 제어하는 시퀀스에 대한 스토리지를 할당하고 해제합니다. 증가는 새 요소를 추가 하는 비용이 상수 시간을 분할 상환 하는 방식으로 발생 합니다. 즉, 제어되는 시퀀스의 길이가 커지면 끝에 요소를 추가하는 비용은 평균적으로 증가하지 않습니다. 따라서 벡터는 템플릿 클래스 스택(STL/CLR)의 기본 컨테이너에 적합한 후보입니다.

A는 vector 임의 액세스 반복기를 지원합니다. 즉, 첫 번째(앞) 요소에 대해 0부터 마지막(뒤로) 요소까지 계산하는 숫자 위치가 지정된 요소를 직접 참조할 size() - 1 수 있습니다. 또한 벡터는 템플릿 클래스 priority_queue(STL/CLR)에 대한 기본 컨테이너에 적합한 후보임을 의미합니다.

벡터 반복기는 지정된 요소의 바이어스와 함께 연결된 벡터 개체에 핸들을 저장합니다. 연결된 컨테이너 개체에서만 반복기를 사용할 수 있습니다. 벡터 요소의 바이어스는 해당 위치와 동일합니다.

요소를 삽입하거나 지우면 지정된 위치에 저장된 요소 값이 변경될 수 있으므로 반복기가 지정한 값도 변경할 수 있습니다. (컨테이너는 삽입 전에 구멍을 만들거나 지우기 후 구멍을 채우기 위해 요소를 위아래로 복사해야 할 수 있습니다.) 그럼에도 불구하고 벡터 반복기는 해당 바이어스가 범위에 [0, size()]있는 한 유효합니다기본. 또한 올바른 반복기는 역참조 가능하지 기본 해당 바이어스가 같지 size()않은 한 해당 반복기를 사용하여 지정하는 요소 값에 액세스하거나 변경할 수 있습니다.

요소를 지우거나 제거하면 저장된 값에 대한 소멸자가 호출됩니다. 컨테이너를 삭제하면 모든 요소가 지워집니다. 따라서 요소 형식이 ref 클래스인 컨테이너는 컨테이너보다 더 오래 살 요소가 없도록 합니다. 그러나 핸들 컨테이너는 해당 요소를 삭제하지 않습니다.

멤버

vector::assign(STL/CLR)

모든 요소를 바꿉니다.

구문

void assign(size_type count, value_type val);
template<typename InIt>
    void assign(InIt first, InIt last);
void assign(System::Collections::Generic::IEnumerable<Value>^ right);

매개 변수

count
삽입할 요소의 수입니다.

first
삽입할 범위의 시작 부분입니다.

last
삽입할 범위의 끝입니다.

right
삽입할 열거형입니다.

val
삽입할 요소의 값입니다.

설명

첫 번째 멤버 함수는 제어된 시퀀스를 값 valcount 요소 반복으로 바꿉니다. 컨테이너를 모두 동일한 값을 갖는 요소로 채우는 데 사용합니다.

정수 형식인 경우 InIt 두 번째 멤버 함수는 .와 동일하게 assign((size_type)first, (value_type)last)동작합니다. 그렇지 않으면 제어되는 시퀀스를 시퀀스 [first, last)로 바꿉니다. 제어되는 시퀀스를 다른 시퀀스로 복사하는 데 사용합니다.

세 번째 멤버 함수는 제어되는 시퀀스를 열거자 권한으로 지정된 시퀀스로 바꿉니다. 제어되는 시퀀스를 열거자가 설명하는 시퀀스의 복사본으로 만드는 데 사용합니다.

예시

// cliext_vector_assign.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// assign a repetition of values
    cliext::vector<wchar_t> c2;
    c2.assign(6, L'x');
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign an iterator range
    c2.assign(c1.begin(), c1.end() - 1);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign an enumeration
    c2.assign(   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<wchar_t>^)%c1);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
x x x x x x
a b
a b c

vector::at(STL/CLR)

지정된 위치에 있는 요소에 액세스합니다.

구문

reference at(size_type pos);

매개 변수

pos
액세스할 요소의 위치입니다.

설명

멤버 함수는 위치 pos에서 제어되는 시퀀스의 요소에 대한 참조를 반환합니다. 해당 위치를 알고 있는 요소를 읽거나 쓰는 데 사용합니다.

예시

// cliext_vector_at.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c" using at
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1.at(i));
    System::Console::WriteLine();

// change an entry and redisplay
    c1.at(1) = L'x';
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1[i]);
    System::Console::WriteLine();
    return (0);
    }
a b c
a x c

vector::back(STL/CLR)

마지막 요소에 액세스합니다.

구문

reference back();

설명

멤버 함수는 제어되는 시퀀스의 마지막 요소에 대한 참조를 반환하며, 이 요소는 비어 있어야 합니다. 마지막 요소에 액세스하는 데 사용합니다.이 요소는 존재하는 것을 알고 있을 때 사용합니다.

예시

// cliext_vector_back.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect last item
    System::Console::WriteLine("back() = {0}", c1.back());

// alter last item and reinspect
    c1.back() = L'x';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
back() = c
a b x

vector::back_item(STL/CLR)

마지막 요소에 액세스합니다.

구문

property value_type back_item;

설명

이 속성은 제어되는 시퀀스의 마지막 요소에 액세스합니다. 이 요소는 비어 있어야 합니다. 마지막 요소가 있다는 것을 알면 이 요소를 사용하여 마지막 요소를 읽거나 씁니다.

예시

// cliext_vector_back_item.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect last item
    System::Console::WriteLine("back_item = {0}", c1.back_item);

// alter last item and reinspect
    c1.back_item = L'x';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
back_item = c
a b x

vector::begin(STL/CLR)

제어되는 시퀀스의 시작을 지정합니다.

구문

iterator begin();

설명

멤버 함수는 제어되는 시퀀스의 첫 번째 요소를 지정하거나 빈 시퀀스의 끝 바로 너머를 지정하는 임의 액세스 반복기를 반환합니다. 이를 사용하여 제어되는 시퀀스의 시작을 지정 current 하는 반복기를 가져오지만 제어되는 시퀀스의 길이가 변경되면 해당 상태 변경될 수 있습니다.

예시

// cliext_vector_begin.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect first two items
    cliext::vector<wchar_t>::iterator it = c1.begin();
    System::Console::WriteLine("*begin() = {0}", *it);
    System::Console::WriteLine("*++begin() = {0}", *++it);

// alter first two items and reinspect
    *--it = L'x';
    *++it = L'y';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
*begin() = a
*++begin() = b
x y c

vector::capacity(STL/CLR)

컨테이너에 할당된 스토리지의 크기를 보고합니다.

구문

size_type capacity();

설명

멤버 함수는 제어되는 시퀀스를 보유하기 위해 현재 할당된 스토리지를 반환하며, 적어도 벡터::size(STL/CLR)()만큼 큰 값입니다. 이를 사용하여 컨테이너가 제어되는 시퀀스에 대한 스토리지를 다시 할당하기 전에 확장할 수 있는 양을 결정합니다.

예시

// cliext_vector_capacity.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1.at(i));
    System::Console::WriteLine();

// increase capacity
    cliext::vector<wchar_t>::size_type cap = c1.capacity();
    System::Console::WriteLine("capacity() = {0}, ok = {1}",
        cap, c1.size() <= cap);
    c1.reserve(cap + 5);
    System::Console::WriteLine("capacity() = {0}, ok = {1}",
        c1.capacity(), cap + 5 <= c1.capacity());
    return (0);
    }
a b c
capacity() = 4, ok = True
capacity() = 9, ok = True

vector::clear(STL/CLR)

모든 요소를 제거합니다.

구문

void clear();

설명

멤버 함수는 vector::erase(STL/CLR)(vector::begin(STL/CLR)(),vector::end(STL/CLR)())를 효과적으로 호출합니다. 제어된 시퀀스가 비어 있는지 확인하는 데 사용합니다.

예시

// cliext_vector_clear.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());

// add elements and clear again
    c1.push_back(L'a');
    c1.push_back(L'b');

    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
a b c
size() = 0
a b
size() = 0

vector::const_iterator(STL/CLR)

제어되는 시퀀스에 대한 상수 반복기의 형식입니다.

구문

typedef T2 const_iterator;

설명

형식은 제어되는 시퀀스에 대한 상수 임의 액세스 반복기 역할을 할 수 있는 지정되지 않은 형식 T2 의 개체를 설명합니다.

예시

// cliext_vector_const_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    cliext::vector<wchar_t>::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        System::Console::Write("{0} ", *cit);
    System::Console::WriteLine();
    return (0);
    }
a b c

vector::const_reference(STL/CLR)

요소에 대한 상수 참조의 형식입니다.

구문

typedef value_type% const_reference;

설명

이 형식은 요소에 대한 상수 참조를 설명합니다.

예시

// cliext_vector_const_reference.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    cliext::vector<wchar_t>::const_iterator cit = c1.begin();
    for (; cit != c1.end(); ++cit)
        {   // get a const reference to an element
        cliext::vector<wchar_t>::const_reference cref = *cit;
        System::Console::Write("{0} ", cref);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

vector::const_reverse_iterator(STL/CLR)

제어되는 시퀀스에 대한 상수 역방향 반복기의 형식입니다.

구문

typedef T4 const_reverse_iterator;

설명

이 형식은 제어되는 시퀀스에 대한 상수 역방향 반복기 역할을 할 수 있는 지정되지 않은 형식 T4 의 개체를 설명합니다.

예시

// cliext_vector_const_reverse_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c" reversed
    cliext::vector<wchar_t>::const_reverse_iterator crit = c1.rbegin();
    cliext::vector<wchar_t>::const_reverse_iterator crend = c1.rend();
    for (; crit != crend; ++crit)
        System::Console::Write("{0} ", *crit);
    System::Console::WriteLine();
    return (0);
    }
c b a

vector::difference_type(STL/CLR)

두 요소 사이의 부가된 거리 형식입니다.

구문

typedef int difference_type;

설명

형식은 서명된 요소 수를 설명합니다.

예시

// cliext_vector_difference_type.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// compute positive difference
    cliext::vector<wchar_t>::difference_type diff = 0;
    for (cliext::vector<wchar_t>::iterator it = c1.begin();
        it != c1.end(); ++it) ++diff;
    System::Console::WriteLine("end()-begin() = {0}", diff);

// compute negative difference
    diff = 0;
    for (cliext::vector<wchar_t>::iterator it = c1.end();
        it != c1.begin(); --it) --diff;
    System::Console::WriteLine("begin()-end() = {0}", diff);
    return (0);
    }
a b c
end()-begin() = 3
begin()-end() = -3

vector::empty(STL/CLR)

요소가 있는지 여부를 테스트합니다.

구문

bool empty();

설명

멤버 함수는 빈 제어되는 시퀀스에 대해 true를 반환합니다. 벡터::size(STL/CLR)() == 0와 동일합니다. 이 벡터를 사용하여 벡터가 비어 있는지 여부를 테스트합니다.

예시

// cliext_vector_empty.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());

// clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0}", c1.size());
    System::Console::WriteLine("empty() = {0}", c1.empty());
    return (0);
    }
a b c
size() = 3
empty() = False
size() = 0
empty() = True

vector::end(STL/CLR)

제어되는 시퀀스의 끝을 지정합니다.

구문

iterator end();

설명

멤버 함수는 제어되는 시퀀스의 끝 바로 다음을 가리키는 임의 액세스 반복기를 반환합니다. 제어되는 시퀀스의 끝을 지정 current 하는 반복기를 가져오는 데 사용하지만 제어되는 시퀀스의 길이가 변경되면 해당 상태 변경될 수 있습니다.

예시

// cliext_vector_end.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect last two items
    cliext::vector<wchar_t>::iterator it = c1.end();
    --it;
    System::Console::WriteLine("*-- --end() = {0}", *--it);
    System::Console::WriteLine("*--end() = {0}", *++it);

// alter first two items and reinspect
    *--it = L'x';
    *++it = L'y';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
*-- --end() = b
*--end() = c
a x y

vector::erase(STL/CLR)

지정된 위치에 있는 요소를 제거합니다.

구문

iterator erase(iterator where);
iterator erase(iterator first, iterator last);

매개 변수

first
지울 범위의 시작입니다.

last
지울 범위의 끝입니다.

where
지울 요소입니다.

설명

첫 번째 멤버 함수는 위치가 가리키는 제어되는 시퀀스의 요소를 제거합니다. 단일 요소를 제거하는 데 사용합니다.

두 번째 멤버 함수는 [first, last]의 범위에서 제어되는 시퀀스의 요소를 제거합니다. 0개 이상의 연속 요소를 제거하는 데 사용합니다.

두 멤버 함수는 제거된 요소 외에 첫 번째 요소를 다시 지정하는 반복기를 반환하고기본 이러한 요소가 없으면 벡터::end(STL/CLR)()를 반환합니다.

요소를 지우는 경우 요소 복사본 수는 지우기 끝과 시퀀스의 가까운 끝 사이의 요소 수에서 선형입니다. (시퀀스의 양쪽 끝에서 하나 이상의 요소를 지우는 경우 요소 복사본이 발생하지 않습니다.)

예시

// cliext_vector_erase.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// erase an element and reinspect
    System::Console::WriteLine("erase(begin()) = {0}",
        *c1.erase(c1.begin()));

// add elements and display " b c d e"
    c1.push_back(L'd');
    c1.push_back(L'e');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// erase all but end
    cliext::vector<wchar_t>::iterator it = c1.end();
    System::Console::WriteLine("erase(begin(), end()-1) = {0}",
        *c1.erase(c1.begin(), --it));
    System::Console::WriteLine("size() = {0}", c1.size());
    return (0);
    }
a b c
erase(begin()) = b
b c d e
erase(begin(), end()-1) = e
size() = 1

vector::front(STL/CLR)

첫 번째 요소에 액세스합니다.

구문

reference front();

설명

멤버 함수는 제어되는 시퀀스의 첫 번째 요소에 대한 참조를 반환하며, 이 요소는 비어 있어야 합니다. 첫 번째 요소가 있다는 것을 알면 이 요소를 사용하여 첫 번째 요소를 읽거나 씁니다.

예시

// cliext_vector_front.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect first item
    System::Console::WriteLine("front() = {0}", c1.front());

// alter first item and reinspect
    c1.front() = L'x';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
front() = a
x b c

vector::front_item(STL/CLR)

첫 번째 요소에 액세스합니다.

구문

property value_type front_item;

설명

이 속성은 비어 있어야 하는 제어된 시퀀스의 첫 번째 요소에 액세스합니다. 첫 번째 요소가 있다는 것을 알면 이 요소를 사용하여 첫 번째 요소를 읽거나 씁니다.

예시

// cliext_vector_front_item.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect first item
    System::Console::WriteLine("front_item = {0}", c1.front_item);

// alter first item and reinspect
    c1.front_item = L'x';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
front_item = a
x b c

vector::generic_container(STL/CLR)

컨테이너에 대한 제네릭 인터페이스의 형식입니다.

구문

typedef Microsoft::VisualC::StlClr::
    IVector<generic_value>
    generic_container;

설명

이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스를 설명합니다.

예시

// cliext_vector_generic_container.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct a generic container
    cliext::vector<wchar_t>::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// modify generic and display original
    gc1->insert(gc1->end(), L'd');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// modify original and display generic
    c1.push_back(L'e');

    System::Collections::IEnumerator^ enum1 =
        gc1->GetEnumerator();
    while (enum1->MoveNext())
        System::Console::Write("{0} ", enum1->Current);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a b c d
a b c d e

vector::generic_iterator(STL/CLR)

컨테이너에 대한 제네릭 인터페이스와 함께 사용할 반복기의 형식입니다.

구문

typedef Microsoft::VisualC::StlClr::Generic::
    ContainerRandomAccessIterator<generic_value>
    generic_iterator;

설명

이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스와 함께 사용할 수 있는 제네릭 반복기를 설명합니다.

예시

// cliext_vector_generic_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct a generic container
    cliext::vector<wchar_t>::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// modify generic and display original
    cliext::vector<wchar_t>::generic_iterator gcit = gc1->begin();
    cliext::vector<wchar_t>::generic_value gcval = *gcit;
    *++gcit = gcval;
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a a c

vector::generic_reverse_iterator(STL/CLR)

컨테이너의 제네릭 인터페이스와 함께 사용할 역방향 반복기의 형식입니다.

구문

typedef Microsoft::VisualC::StlClr::Generic::
    ReverseRandomAccessIterator<generic_value> generic_reverse_iterator;

설명

이 형식은 이 템플릿 컨테이너 클래스에 대한 제네릭 인터페이스와 함께 사용할 수 있는 제네릭 역방향 반복기를 설명합니다.

예시

// cliext_vector_generic_reverse_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct a generic container
    cliext::vector<wchar_t>::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// modify generic and display original
    cliext::vector<wchar_t>::generic_reverse_iterator gcit = gc1->rbegin();
    cliext::vector<wchar_t>::generic_value gcval = *gcit;
    *++gcit = gcval;
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a c c

vector::generic_value(STL/CLR)

컨테이너에 대한 제네릭 인터페이스와 함께 사용할 요소의 형식입니다.

구문

typedef GValue generic_value;

설명

이 형식은 이 템플릿 컨테이너 클래스의 제네릭 인터페이스와 함께 사용할 저장된 요소 값을 설명하는 형식 GValue 의 개체를 설명합니다.

예시

// cliext_vector_generic_value.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct a generic container
    cliext::vector<wchar_t>::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// modify generic and display original
    cliext::vector<wchar_t>::generic_iterator gcit = gc1->begin();
    cliext::vector<wchar_t>::generic_value gcval = *gcit;
    *++gcit = gcval;
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a a c

vector::insert(STL/CLR)

지정된 위치에 요소를 추가합니다.

구문

iterator insert(iterator where, value_type val);
void insert(iterator where, size_type count, value_type val);
template<typename InIt>
    void insert(iterator where, InIt first, InIt last);
void insert(iterator where,
    System::Collections::Generic::IEnumerable<Value>^ right);

매개 변수

count
삽입할 요소의 수입니다.

first
삽입할 범위의 시작 부분입니다.

last
삽입할 범위의 끝입니다.

right
삽입할 열거형입니다.

val
삽입할 요소의 값입니다.

where
컨테이너에서 이전에 삽입할 위치입니다.

설명

각 멤버 함수는 제어되는 시퀀스의 위치가 가리키는 요소 앞에 다시 기본 피연산자에서 지정한 시퀀스를 삽입합니다.

첫 번째 멤버 함수는 값 val 이 있는 요소를 삽입하고 새로 삽입된 요소를 지정하는 반복기를 반환합니다. 반복기가 지정한 위치 앞에 단일 요소를 삽입하는 데 사용합니다.

두 번째 멤버 함수는 value val의 count 요소 반복을 삽입합니다. 동일한 값의 모든 복사본인 0개 이상의 연속 요소를 삽입하는 데 사용합니다.

InIt가 정수 형식이면 세 번째 멤버 함수는 insert(where, (size_type)first, (value_type)last)와 동일하게 동작합니다. 그렇지 않으면 시퀀스 [, last)를first 삽입합니다. 다른 시퀀스에서 복사한 0개 이상의 연속 요소를 삽입하는 데 사용합니다.

네 번째 멤버 함수는 오른쪽에 지정된 시퀀스를 삽입합니다. 열거자가 설명하는 시퀀스를 삽입하는 데 사용합니다.

단일 요소를 삽입할 때 요소 복사본 수는 삽입 지점과 시퀀스의 가까운 끝 사이의 요소 수에서 선형입니다. (시퀀스의 양쪽 끝에 하나 이상의 요소를 삽입하는 경우 요소 복사본이 발생하지 않습니다.) 입력 반복기인 경우 InIt 세 번째 멤버 함수는 시퀀스의 각 요소에 대해 단일 삽입을 효과적으로 수행합니다. 그렇지 않으면 요소를 삽입할 N 때 요소 복사본 수가 선형 N 으로 표시되고 삽입 지점과 시퀀스의 가까운 끝 사이의 요소 수가 추가됩니다.

예시

// cliext_vector_insert.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// insert a single value using iterator
    cliext::vector<wchar_t>::iterator it = c1.begin();
    System::Console::WriteLine("insert(begin()+1, L'x') = {0}",
        *c1.insert(++it, L'x'));
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// insert a repetition of values
    cliext::vector<wchar_t> c2;
    c2.insert(c2.begin(), 2, L'y');
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// insert an iterator range
    it = c1.end();
    c2.insert(c2.end(), c1.begin(), --it);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// insert an enumeration
    c2.insert(c2.begin(),   // NOTE: cast is not needed
        (System::Collections::Generic::IEnumerable<wchar_t>^)%c1);
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
insert(begin()+1, L'x') = x
a x b c
y y
y y a x b
a x b c y y a x b

vector::iterator(STL/CLR)

제어되는 시퀀스에 대한 반복기의 형식입니다.

구문

typedef T1 iterator;

설명

형식은 제어되는 시퀀스에 대한 임의 액세스 반복기로 사용할 수 있는 지정되지 않은 형식 T1 의 개체를 설명합니다.

예시

// cliext_vector_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    cliext::vector<wchar_t>::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        System::Console::Write("{0} ", *it);
    System::Console::WriteLine();

// alter first element and redisplay
    it = c1.begin();
    *it = L'x';
    for (; it != c1.end(); ++it)
        System::Console::Write("{0} ", *it);
    System::Console::WriteLine();
    return (0);
    }
a b c
x b c

vector::operator=(STL/CLR)

제어되는 시퀀스를 바꿉니다.

구문

vector<Value>% operator=(vector<Value>% right);

매개 변수

right
복사할 컨테이너입니다.

설명

멤버 연산자는 개체에 바로 복사한 다음 반환합니다 *this. 제어되는 시퀀스를 오른쪽에 있는 제어된 시퀀스의 복사본으로 바꾸는 데 사용합니다.

예시

// cliext_vector_operator_as.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2 = c1;
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c

vector::operator(STL/CLR)

지정된 위치에 있는 요소에 액세스합니다.

구문

reference operator[](size_type pos);

매개 변수

pos
액세스할 요소의 위치입니다.

설명

멤버 연산자는 위치 pos의 요소에 대한 참조를 반환합니다. 해당 위치를 알고 있는 요소에 액세스하는 데 사용합니다.

예시

// cliext_vector_operator_sub.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c" using subscripting
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1[i]);
    System::Console::WriteLine();

// change an entry and redisplay
    c1[1] = L'x';
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1[i]);
    System::Console::WriteLine();
    return (0);
    }
a b c
a x c

vector::pop_back(STL/CLR)

마지막 요소를 제거합니다.

구문

void pop_back();

설명

멤버 함수는 제어되는 시퀀스의 마지막 요소를 제거합니다. 이 요소는 비어 있어야 합니다. 이 벡터를 사용하여 벡터를 뒤쪽의 한 요소씩 줄입니다.

예시

// cliext_vector_pop_back.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// pop an element and redisplay
    c1.pop_back();
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b

vector::push_back(STL/CLR)

새 마지막 요소를 추가합니다.

구문

void push_back(value_type val);

설명

멤버 함수는 제어되는 시퀀스의 끝에 값 val 이 있는 요소를 삽입합니다. 벡터에 다른 요소를 추가하는 데 사용합니다.

예시

// cliext_vector_push_back.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c

vector::rbegin(STL/CLR)

제어되는 역방향 시퀀스의 시작을 지정합니다.

구문

reverse_iterator rbegin();

설명

멤버 함수는 제어되는 시퀀스의 마지막 요소를 지정하거나 빈 시퀀스의 시작 부분 바로 너머를 지정하는 역방향 반복기를 반환합니다. 따라서 역방향 시퀀스를 지정합니다 beginning . 이를 사용하여 역순으로 표시되는 제어되는 시퀀스의 시작을 지정 current 하는 반복기를 가져오지만 제어되는 시퀀스의 길이가 변경되면 해당 상태 변경될 수 있습니다.

예시

// cliext_vector_rbegin.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect first two items in reversed sequence
    cliext::vector<wchar_t>::reverse_iterator rit = c1.rbegin();
    System::Console::WriteLine("*rbegin() = {0}", *rit);
    System::Console::WriteLine("*++rbegin() = {0}", *++rit);

// alter first two items and reinspect
    *--rit = L'x';
    *++rit = L'y';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
*rbegin() = c
*++rbegin() = b
a y x

vector::reference(STL/CLR)

요소에 대한 참조의 형식입니다.

구문

typedef value_type% reference;

설명

이 형식은 요소에 대한 참조를 설명합니다.

예시

// cliext_vector_reference.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    cliext::vector<wchar_t>::iterator it = c1.begin();
    for (; it != c1.end(); ++it)
        {   // get a reference to an element
        cliext::vector<wchar_t>::reference ref = *it;
        System::Console::Write("{0} ", ref);
        }
    System::Console::WriteLine();

// modify contents " a b c"
    for (it = c1.begin(); it != c1.end(); ++it)
        {   // get a reference to an element
        cliext::vector<wchar_t>::reference ref = *it;

        ref += (wchar_t)(L'A' - L'a');
        System::Console::Write("{0} ", ref);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c
A B C

vector::rend(STL/CLR)

제어되는 역방향 시퀀스의 끝을 지정합니다.

구문

reverse_iterator rend();

설명

멤버 함수는 제어되는 시퀀스의 시작 부분 바로 앞을 가리키는 역방향 반복기를 반환합니다. 따라서 역방향 시퀀스를 지정합니다 end . 이를 사용하여 제어되는 시퀀스의 끝을 역순으로 표시하는 current 반복기를 가져오지만 제어되는 시퀀스의 길이가 변경되면 해당 상태 변경될 수 있습니다.

예시

// cliext_vector_rend.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// inspect first two items
    cliext::vector<wchar_t>::reverse_iterator rit = c1.rend();
    --rit;
    System::Console::WriteLine("*-- --rend() = {0}", *--rit);
    System::Console::WriteLine("*--rend() = {0}", *++rit);

// alter first two items and reinspect
    *--rit = L'x';
    *++rit = L'y';
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
*-- --rend() = b
*--rend() = a
y x c

vector::reserve(STL/CLR)

컨테이너의 최소 증가 용량을 보장합니다.

구문

void reserve(size_type count);

매개 변수

count
컨테이너의 새 최소 용량입니다.

설명

멤버 함수는 capacity() 이제부터 최소한 개수를 반환하도록 합니다. 컨테이너가 지정된 크기로 커질 때까지 제어되는 시퀀스에 대한 스토리지를 다시 할당할 필요가 없도록 하는 데 사용합니다.

예시

// cliext_vector_reserve.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for (int i = 0; i < c1.size(); ++i)
        System::Console::Write("{0} ", c1.at(i));
    System::Console::WriteLine();

// increase capacity
    cliext::vector<wchar_t>::size_type cap = c1.capacity();
    System::Console::WriteLine("capacity() = {0}, ok = {1}",
        cap, c1.size() <= cap);
    c1.reserve(cap + 5);
    System::Console::WriteLine("capacity() = {0}, ok = {1}",
        c1.capacity(), cap + 5 <= c1.capacity());
    return (0);
    }
a b c
capacity() = 4, ok = True
capacity() = 9, ok = True

vector::resize(STL/CLR)

요소 수를 변경합니다.

구문

void resize(size_type new_size);
void resize(size_type new_size, value_type val);

매개 변수

new_size
제어되는 시퀀스의 새 크기입니다.

val
패딩 요소의 값입니다.

설명

멤버 함수는 모두 vector::size(STL/CLR)()가 new_size 반환하도록 합니다. 제어되는 시퀀스를 더 길게 만들어야 하는 경우 첫 번째 멤버 함수는 값 value_type()이 있는 요소를 추가하고 두 번째 멤버 함수는 value val을 사용하여 요소를 추가합니다. 제어되는 시퀀스를 더 짧게 만들기 위해 두 멤버 함수는 마지막 요소 벡터::size(STL/CLR)() -new_size 시간을 효과적으로 지웁니다. 현재 제어되는 시퀀스를 트리밍하거나 패딩하여 제어되는 시퀀스의 크기 가 new_size 있는지 확인하는 데 사용합니다.

예시

// cliext_vector_resize.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
// construct an empty container and pad with default values
    cliext::vector<wchar_t> c1;
    System::Console::WriteLine("size() = {0}", c1.size());
    c1.resize(4);
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", (int)elem);
    System::Console::WriteLine();

// resize to empty
    c1.resize(0);
    System::Console::WriteLine("size() = {0}", c1.size());

// resize and pad
    c1.resize(5, L'x');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
size() = 0
0 0 0 0
size() = 0
x x x x x

vector::reverse_iterator(STL/CLR)

제어되는 시퀀스에 대한 반대 반복기의 형식입니다.

구문

typedef T3 reverse_iterator;

설명

이 형식은 제어된 시퀀스에 대해 반대 반복기로 사용될 수 있는 지정되지 않은 T3 형식의 개체를 설명합니다.

예시

// cliext_vector_reverse_iterator.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c" reversed
    cliext::vector<wchar_t>::reverse_iterator rit = c1.rbegin();
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("{0} ", *rit);
    System::Console::WriteLine();

// alter first element and redisplay
    rit = c1.rbegin();
    *rit = L'x';
    for (; rit != c1.rend(); ++rit)
        System::Console::Write("{0} ", *rit);
    System::Console::WriteLine();
    return (0);
    }
c b a
x b a

vector::size(STL/CLR)

요소 수를 계산합니다.

구문

size_type size();

설명

멤버 함수는 제어되는 시퀀스의 길이를 반환합니다. 이를 사용하여 현재 제어되는 시퀀스에 있는 요소 수를 확인합니다. 시퀀스의 크기가 0이 아닌지 여부만 중요하면 vector::empty(STL/CLR)()를 참조하세요.

예시

// cliext_vector_size.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    System::Console::WriteLine("size() = {0} starting with 3", c1.size());

// clear the container and reinspect
    c1.clear();
    System::Console::WriteLine("size() = {0} after clearing", c1.size());

// add elements and clear again
    c1.push_back(L'a');
    c1.push_back(L'b');
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
a b c
size() = 3 starting with 3
size() = 0 after clearing
size() = 2 after adding 2

vector::size_type(STL/CLR)

두 요소 사이의 부호가 있는 거리의 형식입니다.

구문

typedef int size_type;

설명

이 형식은 음수가 아닌 요소 수를 설명합니다.

예시

// cliext_vector_size_type.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// compute positive difference
    cliext::vector<wchar_t>::size_type diff = c1.end() - c1.begin();
    System::Console::WriteLine("end()-begin() = {0}", diff);
    return (0);
    }
a b c
end()-begin() = 3

vector::swap(STL/CLR)

두 컨테이너의 내용을 바꿉니다.

구문

void swap(vector<Value>% right);

매개 변수

right
콘텐츠와 바꿀 컨테이너입니다.

설명

멤버 함수는 제어된 시퀀스를 오른쪽 간에 *this교환합니다. 그것은 일정한 시간에 그렇게하고 예외를 throw하지 않습니다. 두 컨테이너의 콘텐츠를 빠르게 교환하는 방법으로 사용합니다.

예시

// cliext_vector_swap.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct another container with repetition of values
    cliext::vector<wchar_t> c2(5, L'x');
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// swap and redisplay
    c1.swap(c2);
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
x x x x x
x x x x x
a b c

vector::to_array(STL/CLR)

제어된 시퀀스를 새 배열에 복사합니다.

구문

cli::array<Value>^ to_array();

설명

멤버 함수는 제어되는 시퀀스를 포함하는 배열을 반환합니다. 이를 사용하여 배열 형식으로 제어된 시퀀스의 복사본을 가져옵니다.

예시

// cliext_vector_to_array.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// copy the container and modify it
    cli::array<wchar_t>^ a1 = c1.to_array();

    c1.push_back(L'd');
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// display the earlier array copy
    for each (wchar_t elem in a1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c d
a b c

vector::value_type(STL/CLR)

요소의 형식입니다.

구문

typedef Value value_type;

설명

형식은 템플릿 매개 변수 의 동의어입니다.

예시

// cliext_vector_value_type.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c" using value_type
    for (cliext::vector<wchar_t>::iterator it = c1.begin();
        it != c1.end(); ++it)
        {   // store element in value_type object
        cliext::vector<wchar_t>::value_type val = *it;

        System::Console::Write("{0} ", val);
        }
    System::Console::WriteLine();
    return (0);
    }
a b c

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
삽입할 요소의 수입니다.

first
삽입할 범위의 시작 부분입니다.

last
삽입할 범위의 끝입니다.

right
삽입할 개체 또는 범위입니다.

val
삽입할 요소의 값입니다.

설명

생성자:

vector();

는 요소 없이 제어되는 시퀀스를 초기화합니다. 이를 사용하여 빈 초기 제어 시퀀스를 지정합니다.

생성자:

vector(vector<Value>% right);

는 시퀀스 [right.begin(), right.end())를 사용하여 제어되는 시퀀스를 초기화합니다. 벡터 개체 오른쪽에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 데 사용합니다.

생성자:

vector(vector<Value>^ right);

는 시퀀스 [right->begin(), right->end())를 사용하여 제어되는 시퀀스를 초기화합니다. 핸들이 올바른 벡터 개체에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 데 사용합니다.

생성자:

explicit vector(size_type count);

각각 값value_type()이 있는 count 요소를 사용하여 제어되는 시퀀스를 초기화합니다. 컨테이너를 기본값이 있는 요소로 채우는 데 사용합니다.

생성자:

vector(size_type count, value_type val);

는 각각 value val을 사용하여 count 요소를 사용하여 제어되는 시퀀스를 초기화합니다. 컨테이너를 모두 동일한 값을 갖는 요소로 채우는 데 사용합니다.

생성자:

template<typename InIt>

vector(InIt first, InIt last);

는 시퀀스 [first, last)를 사용하여 제어되는 시퀀스를 초기화합니다. 제어된 시퀀스를 다른 시퀀스의 복사본으로 만드는 데 사용합니다.

생성자:

vector(System::Collections::Generic::IEnumerable<Value>^ 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);
    }
size() = 0
0 0 0
x x x x x x
x x x x x
x x x x x x
x x x x x x
x x x x x x

operator!= (vector)(STL/CLR)

비교가 같지 않은 벡터입니다.

구문

template<typename Value>
    bool operator!=(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 .를 반환합니다 !(left == right). 두 벡터를 요소별로 비교할 때 왼쪽이 오른쪽같은 순서가 아닌지 테스트하는 데 사용합니다.

예시

// cliext_vector_operator_ne.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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);
    }
a b c
a b d
[a b c] != [a b c] is False
[a b c] != [a b d] is True

operator< (벡터) (STL/CLR)

비교보다 작은 벡터입니다.

구문

template<typename Value>
    bool operator<(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 true인 가장 낮은 위치에 i 대해 !(right[i] < left[i]) true를 반환합니다 left[i] < right[i]. 그렇지 않으면 left->size() < right->size() 두 벡터가 요소별로 비교될 때 왼쪽이 오른쪽 앞에 정렬되는지 여부를 테스트하는 데 사용합니다.

예시

// cliext_vector_operator_lt.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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);
    }
a b c
a b d
[a b c] < [a b c] is False
[a b c] < [a b d] is True

operator<= (벡터) (STL/CLR)

비교보다 작거나 같은 벡터입니다.

구문

template<typename Value>
    bool operator<=(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 .를 반환합니다 !(right < left). 두 벡터를 요소별로 비교할 때 왼쪽이 오른쪽의 순서가 지정되지 않는지 여부를 테스트하는 데 사용합니다.

예시

// cliext_vector_operator_le.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] <= [a b c] is {0}",
        c1 <= c1);
    System::Console::WriteLine("[a b d] <= [a b c] is {0}",
        c2 <= c1);
    return (0);
    }
a b c
a b d
[a b c] <= [a b c] is True
[a b d] <= [a b c] is False

operator== (vector)(STL/CLR)

벡터 같음 비교입니다.

구문

template<typename Value>
    bool operator==(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 왼쪽과 오른쪽으로 제어되는 시퀀스의 길이가 같고 각 위치에 left[i] ==iright[i]대해 true를 반환합니다. 두 벡터를 요소별로 비교할 때 왼쪽이 오른쪽같은 순서인지 여부를 테스트하는 데 사용합니다.

예시

// cliext_vector_operator_eq.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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);
    }
a b c
a b d
[a b c] == [a b c] is True
[a b c] == [a b d] is False

operator> (벡터) (STL/CLR)

비교보다 큰 벡터입니다.

구문

template<typename Value>
    bool operator>(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 .를 반환합니다 right<left. 두 벡터가 요소별로 비교될 때 왼쪽 순서가 오른쪽인지 여부를 테스트하는 데 사용합니다.

예시

// cliext_vector_operator_gt.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    System::Console::WriteLine("[a b c] > [a b c] is {0}",
        c1 > c1);
    System::Console::WriteLine("[a b d] > [a b c] is {0}",
        c2 > c1);
    return (0);
    }
a b c
a b d
[a b c] > [a b c] is False
[a b d] > [a b c] is True

operator>= (벡터) (STL/CLR)

비교보다 크거나 같은 벡터입니다.

구문

template<typename Value>
    bool operator>=(vector<Value>% left,
        vector<Value>% right);

매개 변수

left
비교할 왼쪽 컨테이너입니다.

right
비교할 오른쪽 컨테이너입니다.

설명

연산자 함수는 .를 반환합니다 !(left < right). 두 벡터를 요소별로 비교할 때 왼쪽이 오른쪽 앞에 정렬되지 않는지 여부를 테스트하는 데 사용합니다.

예제

// cliext_vector_operator_ge.cpp
// compile with: /clr
#include <cliext/vector>

int main()
    {
    cliext::vector<wchar_t> c1;
    c1.push_back(L'a');
    c1.push_back(L'b');
    c1.push_back(L'c');

// display contents " a b c"
    for each (wchar_t elem in c1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// assign to a new container
    cliext::vector<wchar_t> c2;
    c2.push_back(L'a');
    c2.push_back(L'b');
    c2.push_back(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2)
        System::Console::Write("{0} ", elem);
    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);
    }
a b c
a b d
[a b c] >= [a b c] is True
[a b c] >= [a b d] is False