Aracılığıyla paylaş


stack (STL/CLR)

Şablon sınıfı, son ilk çıkış erişimine sahip öğelerin değişen uzunlukta dizisini denetleen bir nesneyi açıklar. Kapsayıcı bağdaştırıcısını stack , temel alınan bir kapsayıcıyı aşağı itme yığını olarak yönetmek için kullanırsınız.

Aşağıdaki açıklamada, GValue ikincisi bir başvuru türü olmadığı sürece ile aynıdır Value ; bu durumda ise olur Value^. Benzer şekilde, GContainer ikincisi bir başvuru türü olmadığı sürece ile aynıdır Container ; bu Container^durumda olur.

Sözdizimi

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

Parametreler

Value
Denetlenen sıradaki öğenin türü.

Container
Temel alınan kapsayıcının türü.

Gereksinimler

Üst bilgi:<cliext/stack>

Ad alanı:cliext

Bildirimler

Tür tanımı Tanım
stack::const_reference Bir öğe için sabit bir başvuru türü.
stack::container_type Temel alınan kapsayıcının türü.
stack::difference_type İki öğe arasındaki işaretli mesafenin türü.
stack::generic_container Kapsayıcı bağdaştırıcısı için genel arabirimin türü.
stack::generic_value Kapsayıcı bağdaştırıcısının genel arabirimi için bir öğenin türü.
stack::reference Bir öğe için bir başvuru türü.
stack::size_type İki öğe arasındaki işaretli mesafenin türü.
stack::value_type Öğenin türü.
Üye işlevi Tanım
stack::assign Tüm öğeleri değiştirir.
stack::empty Bir öğe olup olmadığını sınar.
stack::get_container Temel kapsayıcıya erişir.
stack::pop Son öğeyi kaldırır.
stack::push Yeni bir son öğe ekler.
stack::size Öğe sayısını sayar.
stack::stack Bir kapsayıcı nesnesi oluşturur.
stack::top Son öğeye erişir.
stack::to_array Denetimli diziyi yeni bir diziye kopyalar.
Özellik Tanım
stack::top_item Son öğeye erişir.
Operator Tanım
stack::operator= Denetimli sıranın yerini alır.
operator!= (yığın) Bir nesnenin başka stack bir stack nesneye eşit olup olmadığını belirler.
operator< (yığın) Bir nesnenin başka stack bir stack nesneden küçük olup olmadığını belirler.
operator<= (yığın) Bir nesnenin başka bir nesneden küçük veya başka bir stackstack nesneye eşit olup olmadığını belirler.
operator== (yığın) Bir nesnenin başka stack bir stack nesneye eşit olup olmadığını belirler.
operator> (yığın) Bir nesnenin başka stack bir stack nesneden büyük olup olmadığını belirler.
operator>= (yığın) Bir nesnenin başka bir nesneden büyük veya başka bir stackstack nesneye eşit olup olmadığını belirler.

Arabirimler

Arabirim Tanım
ICloneable Nesneyi çoğaltma.
IStack<Value, Container> Genel kapsayıcı bağdaştırıcısını koruyun.

Açıklamalar

nesnesi, öğeleri depolayan Value ve isteğe bağlı olarak büyüyen temel kapsayıcı türü Container aracılığıyla denetlediği sıra için depolama ayırır ve serbesttir. nesnesi, erişimi yalnızca son öğeyi göndermeye ve alma işlemine kısıtlar ve bir son ilk çıkış kuyruğu (LIFO kuyruğu veya yığın olarak da bilinir) uygular.

Üyeler

stack::assign

Tüm öğeleri değiştirir.

Sözdizimi

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

Parametreler

right
Eklenecek kapsayıcı bağdaştırıcısı.

Açıklamalar

Üye işlevi, temel alınan kapsayıcıya atar right.get_container() . Yığının tüm içeriğini değiştirmek için bunu kullanırsınız.

Örnek

// 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

Bir öğe için sabit bir başvuru türü.

Sözdizimi

typedef value_type% const_reference;

Açıklamalar

türü, bir öğeye sabit başvuruyu açıklar.

Örnek

// 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

Temel alınan kapsayıcının türü.

Sözdizimi

typedef Container value_type;

Açıklamalar

türü, şablon parametresi Containeriçin bir eş anlamlıdır.

Örnek

// 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

İki öğe arasındaki imzalı uzaklık türleri.

Sözdizimi

typedef int difference_type;

Açıklamalar

Türü, büyük olasılıkla negatif öğe sayısını açıklar.

Örnek

// 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

Bir öğe olup olmadığını sınar.

Sözdizimi

bool empty();

Açıklamalar

Üye işlevi boş denetimli bir dizi için true döndürür. ile eşdeğerdir size() == 0. Boş olup olmadığını stack test etmek için bunu kullanırsınız.

Örnek

// 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

Kapsayıcı bağdaştırıcısı için genel arabirimin türü.

Sözdizimi

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

Açıklamalar

türü, bu şablon kapsayıcı bağdaştırıcısı sınıfı için genel arabirimi açıklar.

Örnek

// 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

Kapsayıcının genel arabirimiyle kullanılacak bir öğenin türü.

Sözdizimi

typedef GValue generic_value;

Açıklamalar

türü, bu şablon kapsayıcı sınıfı için genel arabirimle kullanılmak üzere depolanan öğe değerini açıklayan türdeki GValue bir nesneyi açıklar. (GValue veya value_type^ bir başvuru türüysevalue_type.)value_type

Örnek

// 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

Temel kapsayıcıya erişir.

Sözdizimi

container_type^ get_container();

Açıklamalar

Üye işlevi, temel kapsayıcı için bir tanıtıcı döndürür. Kapsayıcı sarmalayıcısı tarafından uygulanan kısıtlamaları atlamak için bunu kullanırsınız.

Örnek

// 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=

Denetimli sıranın yerini alır.

Sözdizimi

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

Parametreler

right
Kopyalanacak kapsayıcı bağdaştırıcısı.

Açıklamalar

Üye işleci nesnesine kopyalanır right ve döndürür *this. Denetimli sırayı içindeki rightdenetimli sıranın bir kopyasıyla değiştirmek için kullanırsınız.

Örnek

// 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

Son öğeyi kaldırır.

Sözdizimi

void pop();

Açıklamalar

Üye işlevi, denetlenen dizinin boş olmayan son öğesini kaldırır. Bunu, arkadaki bir öğeye stack göre kısaltmak için kullanırsınız.

Örnek

// 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

Yeni bir son öğe ekler.

Sözdizimi

void push(value_type val);

Açıklamalar

üye işlevi, denetlenen sıranın sonuna değer val içeren bir öğe ekler. Bunu yığına başka bir öğe eklemek için kullanırsınız.

Örnek

// 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

Bir öğe için bir başvuru türü.

Sözdizimi

typedef value_type% reference;

Açıklamalar

türü, bir öğeye başvuruyu açıklar.

Örnek

// 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

Öğe sayısını sayar.

Sözdizimi

size_type size();

Açıklamalar

Üye işlevi, denetlenen sıranın uzunluğunu döndürür. Şu anda denetimli dizideki öğelerin sayısını belirlemek için bunu kullanırsınız. Tek ilgilendiğiniz dizinin sıfır olmayan boyuta sahip olup olmadığıysa, bkz stack::empty. .

Örnek

// 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

İki öğe arasındaki işaretli mesafenin türü.

Sözdizimi

typedef int size_type;

Açıklamalar

Türü negatif olmayan öğe sayısını açıklar.

Örnek

// 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

Kapsayıcı bağdaştırıcısı nesnesi oluşturur.

Sözdizimi

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

Parametreler

right
Kopyalanacak nesne.

wrapped
Kullanılacak sarmalanmış kapsayıcı.

Açıklamalar

Oluşturucu:

stack();

boş bir sarmalanmış kapsayıcı oluşturur. Boş bir ilk denetimli sıra belirtmek için bunu kullanırsınız.

Oluşturucu:

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

, öğesinin bir kopyası right.get_container()olan sarmalanmış bir kapsayıcı oluşturur. bunu, nesnesi righttarafından denetlenen dizinin bir kopyası olan ilk denetimli diziyi stack belirtmek için kullanırsınız.

Oluşturucu:

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

, öğesinin bir kopyası right->get_container()olan sarmalanmış bir kapsayıcı oluşturur. bunu, nesnesi *righttarafından denetlenen dizinin bir kopyası olan ilk denetimli diziyi stack belirtmek için kullanırsınız.

Oluşturucu:

explicit stack(container_type% wrapped);

var olan kapsayıcıyı wrapped sarmalanmış kapsayıcı olarak kullanır. Varolan bir kapsayıcıdan oluşturmak stack için bunu kullanırsınız.

Örnek

// 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

Denetimli diziyi yeni bir diziye kopyalar.

Sözdizimi

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

Açıklamalar

üye işlevi, denetlenen diziyi içeren bir dizi döndürür. Denetimli sıranın bir kopyasını dizi biçiminde almak için bunu kullanırsınız.

Örnek

// 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

Son öğeye erişir.

Sözdizimi

reference top();

Açıklamalar

Üye işlevi, denetlenen dizinin son öğesine bir başvuru döndürür ve bu öğe boş olmamalıdır. Var olduğunu bildiğinizde son öğeye erişmek için bu öğeyi kullanırsınız.

Örnek

// 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

Son öğeye erişir.

Sözdizimi

property value_type top_item;

Açıklamalar

özelliği, denetlenen dizinin boş olmayan son öğesine erişir. Var olduğunu bildiğinizde son öğeyi okumak veya yazmak için bunu kullanırsınız.

Örnek

// 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

Öğenin türü.

Sözdizimi

typedef Value value_type;

Açıklamalar

türü, şablon parametresi Valueiçin bir eş anlamlıdır.

Örnek

// 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!= (yığın)

Stack eşit olmayan karşılaştırma.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi döndürür !(left == right). İki yığının öğeye göre karşılaştırıldığında olduğu gibi right sıralanıp left sıralı olmadığını test etmek için bunu kullanırsınız.

Örnek

// 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< (yığın)

Stack küçüktür karşılaştırması.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi, aynı zamanda doğru olduğu en düşük konum i için !(right[i] < left[i]) ise true left[i] < right[i]döndürür. Aksi takdirde döndürür left->size() < right->size(). İki yığının öğeye göre karşılaştırıldığında önce right sıralanıp sıralı olmadığını left test etmek için bunu kullanırsınız.

Örnek

// 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<= (yığın)

Stack küçük veya eşit karşılaştırma.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi döndürür !(right < left). İki yığın öğeye göre karşılaştırıldıktan sonra right sıralanıp left sıralı olmadığını test etmek için bunu kullanırsınız.

Örnek

// 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== (yığın)

Stack eşittir karşılaştırması.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi yalnızca tarafından left denetlenen ve right her konum ileft[i] == right[i]için aynı uzunluğa sahip olan diziler için true döndürür. İki yığının öğeye göre karşılaştırıldığında olduğu gibi right sıralanıp sıralı olmadığını left test etmek için bunu kullanırsınız.

Örnek

// 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> (yığın)

Stack karşılaştırmadan büyük.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi döndürür right < left. İki yığın öğeye göre karşılaştırıldıktan sonra right sıralanıp sıralı olmadığını left test etmek için bunu kullanırsınız.

Örnek

// 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>= (yığın)

Stack büyük veya eşit karşılaştırma.

Sözdizimi

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

Parametreler

left
Karşılaştırmak için sol kapsayıcı.

right
Karşılaştırmak için doğru kapsayıcı.

Açıklamalar

işleç işlevi döndürür !(left < right). İki yığının öğeye göre karşılaştırıldığında önce right sıralanıp left sıralı olmadığını test etmek için bunu kullanırsınız.

Örnek

// 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