Share via


stack (STL/CLR)

템플릿 클래스는 마지막에 첫 번째 액세스 권한이 있는 다양한 길이의 요소 시퀀스를 제어하는 개체를 설명합니다. 컨테이너 어댑터를 stack 사용하여 기본 컨테이너를 푸시다운 스택으로 관리합니다.

아래 GValue 설명에서 후자는 ref 형식이 아니면 동일합니다 Value . 이 경우 Value^는 다음과 같습니다. 마찬가지로, GContainer 후자가 ref 형식이 아니면 동일합니다 Container . 이 경우 해당 형식입니다 Container^.

구문

template<typename Value,
    typename Container>
    ref class stack
        :   public
        System::ICloneable,
        Microsoft::VisualC::StlClr::IStack<GValue, GContainer>
    { ..... };

매개 변수

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

Container
기본 컨테이너의 형식입니다.

요구 사항

헤더:<cliext/stack>

네임스페이스:cliext

선언

형식 정의 설명
stack::const_reference 요소에 대한 상수 참조의 형식입니다.
stack::container_type 기본 컨테이너의 형식입니다.
stack::difference_type 두 요소 사이의 부호가 있는 거리의 형식입니다.
stack::generic_container 컨테이너 어댑터에 대한 제네릭 인터페이스의 형식입니다.
stack::generic_value 컨테이너 어댑터의 제네릭 인터페이스에 대한 요소의 형식입니다.
stack::reference 요소에 대한 참조의 형식입니다.
stack::size_type 두 요소 사이의 부호가 있는 거리의 형식입니다.
stack::value_type 요소의 형식입니다.
멤버 함수 설명
stack::assign 모든 요소를 바꿉니다.
stack::empty 요소가 있는지 여부를 테스트합니다.
stack::get_container 기본 컨테이너에 액세스합니다.
stack::pop 마지막 요소를 제거합니다.
stack::push 새 마지막 요소를 추가합니다.
stack::size 요소 수를 계산합니다.
stack::stack 컨테이너 개체를 만듭니다.
stack::top 마지막 요소에 액세스합니다.
stack::to_array 제어된 시퀀스를 새 배열에 복사합니다.
속성 설명
stack::top_item 마지막 요소에 액세스합니다.
연산자 설명
stack::operator= 제어되는 시퀀스를 바꿉니다.
operator!= (스택) 개체가 다른 stack 개체와 stack 같지 않은지 여부를 확인합니다.
operator< (스택) 개체가 다른 stack 개체보다 작은지 여부를 stack 확인합니다.
operator<= (스택) 개체가 다른 stack 개체보다 작거나 같은지 여부를 stack 확인합니다.
operator== (스택) 개체가 다른 stack 개체와 stack 같은지 여부를 확인합니다.
operator> (스택) 개체가 다른 stack 개체보다 큰지 여부를 stack 확인합니다.
operator>= (스택) 개체가 다른 stack 개체보다 크거나 같은지 여부를 stack 확인합니다.

인터페이스

인터페이스 설명
ICloneable 개체를 복제합니다.
IStack<Value, Container> 일반 컨테이너 어댑터를 유지 관리합니다.

설명

개체는 요소를 저장 Value 하고 필요에 따라 증가하는 형식 Container 의 기본 컨테이너를 통해 제어하는 시퀀스에 대한 스토리지를 할당하고 해제합니다. 이 개체는 마지막 요소만 푸시하고 터지는 것으로 액세스를 제한하여 마지막 선입선 실행 큐(LIFO 큐 또는 스택이라고도 함)를 구현합니다.

멤버

stack::assign

모든 요소를 바꿉니다.

구문

void assign(stack<Value, Container>% right);

매개 변수

right
삽입할 컨테이너 어댑터입니다.

설명

멤버 함수는 기본 컨테이너에 할당됩니다 right.get_container() . 스택의 전체 콘텐츠를 변경하는 데 사용합니다.

예시

// cliext_stack_assign.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign a repetition of values
    Mystack c2;
    c2.assign(c1);
    for each (wchar_t elem in c2.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c

stack::const_reference

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

구문

typedef value_type% const_reference;

설명

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

예시

// cliext_stack_const_reference.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

// display reversed contents " c b a"
    for (; !c1.empty(); c1.pop())
        {   // get a const reference to an element
        Mystack::const_reference cref = c1.top();
        System::Console::Write("{0} ", cref);
        }
    System::Console::WriteLine();
    return (0);
    }
c b a

stack::container_type

기본 컨테이너의 형식입니다.

구문

typedef Container value_type;

설명

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

예시

// cliext_stack_container_type.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

// display contents " a b c" using container_type
    Mystack::container_type wc1 = c1.get_container();
    for each (wchar_t elem in wc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c

stack::difference_type

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

구문

typedef int difference_type;

설명

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

예시

// cliext_stack_difference_type.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// compute negative difference
    Mystack::difference_type diff = c1.size();
    c1.push(L'd');
    c1.push(L'e');
    diff -= c1.size();
    System::Console::WriteLine("pushing 2 = {0}", diff);

// compute positive difference
    diff = c1.size();
    c1.pop();
    c1.pop();
    c1.pop();
    diff -= c1.size();
    System::Console::WriteLine("popping 3 = {0}", diff);
    return (0);
    }
a b c
pushing 2 = -2
popping 3 = 3

stack::empty

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

구문

bool empty();

설명

멤버 함수는 빈 제어되는 시퀀스에 대해 true를 반환합니다. 이 값은 .에 해당합니다 size() == 0. 이 값을 사용하여 비어 있는지 여부를 테스트합니다 stack .

예시

// cliext_stack_empty.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

// display initial contents " a b c"
    for each (wchar_t elem in c1.get_container())
        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.pop();
    c1.pop();
    c1.pop();
    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

stack::generic_container

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

구문

typedef Microsoft::VisualC::StlClr::IStack<Value>
    generic_container;

설명

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

예시

// cliext_stack_generic_container.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// get interface to container
    Mystack::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1->get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

// modify original and display generic
    c1.push(L'e');
    for each (wchar_t elem in gc1->get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b c
a b c d
a b c d e

stack::generic_value

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

구문

typedef GValue generic_value;

설명

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

예시

// cliext_stack_generic_value.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// get interface to container
    Mystack::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1->get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// display in reverse using generic_value
    for (; !gc1->empty(); gc1->pop())
        {
        Mystack::generic_value elem = gc1->top();

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

stack::get_container

기본 컨테이너에 액세스합니다.

구문

container_type^ get_container();

설명

멤버 함수는 기본 컨테이너에 대한 핸들을 반환합니다. 컨테이너 래퍼에 의해 부과된 제한을 우회하는 데 사용합니다.

예시

// cliext_stack_get_container.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

// display contents " a b c" using container_type
    Mystack::container_type wc1 = c1.get_container();
    for each (wchar_t elem in wc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c

stack::operator=

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

구문

stack<Value, Container>% operator=(stack<Value, Container>% right);

매개 변수

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

설명

멤버 연산자는 개체에 복사한 다음 반환합니다 right*this. 이를 사용하여 제어되는 시퀀스를 right의 제어되는 시퀀스 복사본으로 대체합니다.

예시

// cliext_stack_operator_as.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

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

stack::pop

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

구문

void pop();

설명

멤버 함수는 제어되는 시퀀스의 마지막 요소를 제거합니다. 이 요소는 비어 있어야 합니다. 이 값을 사용하여 뒷면의 stack 요소를 한 개씩 줄입니다.

예시

// cliext_stack_pop.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

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

stack::push

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

구문

void push(value_type val);

설명

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

예시

// cliext_stack_push.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

stack::reference

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

구문

typedef value_type% reference;

설명

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

예시

// cliext_stack_reference.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// modify top of stack and redisplay
    Mystack::reference ref = c1.top();
    ref = L'x';
    for each (wchar_t elem in c1.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
a b c
a b x

stack::size

요소 수를 계산합니다.

구문

size_type size();

설명

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

예시

// cliext_stack_size.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// pop an item and reinspect
    c1.pop();
    System::Console::WriteLine("size() = {0} after popping", c1.size());

// add two elements and reinspect
    c1.push(L'a');
    c1.push(L'b');
    System::Console::WriteLine("size() = {0} after adding 2", c1.size());
    return (0);
    }
a b c
size() = 3 starting with 3
size() = 2 after popping
size() = 4 after adding 2

stack::size_type

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

구문

typedef int size_type;

설명

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

예시

// cliext_stack_size_type.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// compute positive difference
    Mystack::size_type diff = c1.size();
    c1.pop();
    c1.pop();
    diff -= c1.size();
    System::Console::WriteLine("size difference = {0}", diff);
    return (0);
    }
a b c
size difference = 2

stack::stack

컨테이너 어댑터 개체를 생성합니다.

구문

stack();
stack(stack<Value, Container>% right);
stack(stack<Value, Container>^ right);
explicit stack(container_type% wrapped);

매개 변수

right
복사할 개체입니다.

wrapped
사용할 래핑된 컨테이너입니다.

설명

생성자:

stack();

는 빈 래핑된 컨테이너를 만듭니다. 이를 사용하여 빈 초기 제어 시퀀스를 지정합니다.

생성자:

stack(stack<Value, Container>% right);

는 .의 right.get_container()복사본인 래핑된 컨테이너를 만듭니다. 개체right에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 stack 데 사용합니다.

생성자:

stack(stack<Value, Container>^ right);

는 .의 right->get_container()복사본인 래핑된 컨테이너를 만듭니다. 개체*right에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정하는 stack 데 사용합니다.

생성자:

explicit stack(container_type% wrapped);

는 기존 컨테이너 wrapped 를 래핑된 컨테이너로 사용합니다. 이를 사용하여 기존 컨테이너에서 생성 stack 합니다.

예시

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

typedef cliext::stack<wchar_t> Mystack;
typedef cliext::vector<wchar_t> Myvector;
typedef cliext::stack<wchar_t, Myvector> Mystack_vec;
int main()
    {
// construct an empty container
    Mystack c1;
    System::Console::WriteLine("size() = {0}", c1.size());

// construct from an underlying container
    Myvector v2(5, L'x');
    Mystack_vec c2(v2);
    for each (wchar_t elem in c2.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct by copying another container
    Mystack_vec c3(c2);
    for each (wchar_t elem in c3.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

// construct by copying another container through handle
    Mystack_vec c4(%c2);
    for each (wchar_t elem in c4.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
size() = 0
x x x x x
x x x x x
x x x x x

stack::to_array

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

구문

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

설명

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

예시

// cliext_stack_to_array.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

    c1.push(L'd');
    for each (wchar_t elem in c1.get_container())
        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

stack::top

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

구문

reference top();

설명

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

예시

// cliext_stack_top.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

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

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

stack::top_item

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

구문

property value_type top_item;

설명

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

예시

// cliext_stack_top_item.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

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

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

stack::value_type

요소의 형식입니다.

구문

typedef Value value_type;

설명

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

예시

// cliext_stack_value_type.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

// display reversed contents " a b c" using value_type
    for (; !c1.empty(); c1.pop())
        {   // store element in value_type object
        Mystack::value_type val = c1.top();

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

operator!= (스택)

Stack 비교가 같지 않습니다.

구문

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

매개 변수

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

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

설명

연산자 함수는 .를 반환합니다 !(left == right). 두 스택이 요소별로 비교될 때와 right 같은 순서가 지정되지 않았는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_stack_operator_ne.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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< (스택)

Stack 보다 작습니다.

구문

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

매개 변수

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

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

설명

연산자 함수는 true인 가장 낮은 위치에 i 대해 !(right[i] < left[i]) true left[i] < right[i]를 반환합니다. 그 외의 경우 left->size() < right->size()를 반환합니다. 두 스택을 요소별로 비교하기 전에 right 순서가 지정되는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_stack_operator_lt.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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<= (스택)

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

구문

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

매개 변수

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

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

설명

연산자 함수는 .를 반환합니다 !(right < left). 두 스택이 요소별로 비교된 후 right 정렬되지 않는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_stack_operator_le.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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== (스택)

Stack 같음 비교입니다.

구문

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

매개 변수

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

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

설명

연산자 함수는 시퀀스가 제어되고 left 길이가 같고 right 각 위치에 ileft[i] == right[i]대해 true를 반환합니다. 두 스택이 요소별로 비교될 때와 right 동일한 순서가 지정되는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_stack_operator_eq.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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> (스택)

Stack 비교보다 큼.

구문

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

매개 변수

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

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

설명

연산자 함수는 .를 반환합니다 right < left. 두 스택이 요소별로 비교된 후 right 순서가 지정되는지 여부를 left 테스트하는 데 사용합니다.

예시

// cliext_stack_operator_gt.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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>= (스택)

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

구문

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

매개 변수

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

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

설명

연산자 함수는 .를 반환합니다 !(left < right). 두 스택이 요소별로 비교될 때 이전에 right 순서가 지정되지 않았는지 여부를 left 테스트하는 데 사용합니다.

예제

// cliext_stack_operator_ge.cpp
// compile with: /clr
#include <cliext/stack>

typedef cliext::stack<wchar_t> Mystack;
int main()
    {
    Mystack c1;
    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');

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

// assign to a new container
    Mystack c2;
    c2.push(L'a');
    c2.push(L'b');
    c2.push(L'd');

// display contents " a b d"
    for each (wchar_t elem in c2.get_container())
        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