Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
Klasa szablonu opisuje obiekt, który kontroluje różną sekwencję długości elementów, które mają dostęp pierwszy na pierwszym wyjęcie. Użyj adaptera queue
kontenera, aby zarządzać kontenerem bazowym jako kolejką.
W poniższym opisie GValue
parametr jest taki sam, jak Value
w przypadku, gdy ten ostatni jest typem ref, w takim przypadku jest Value^
to . Podobnie, GContainer
jest taki sam jak Container
, chyba że ten ostatni jest typem ref, w takim przypadku jest to Container^
.
Składnia
template<typename Value,
typename Container>
ref class queue
: public
System::ICloneable,
Microsoft::VisualC::StlClr::IQueue<GValue, GContainer>
{ ..... };
Parametry
Value
Typ elementu w kontrolowanej sekwencji.
Container
Typ kontenera bazowego.
Wymagania
Nagłówek:<cliext/queue>
Przestrzeń nazw: cliext
Ważne
Aby skompilować przykłady w tym temacie, upewnij się, że zainstalowano obsługę języka C++/CLI zgodnie z opisem w temacie Instalowanie obsługi języka C++/CLI w programie Visual Studio 2022. Dla typu projektu utwórz aplikację konsolową CLR (.NET Framework).
Deklaracje
Definicja typu | opis |
---|---|
queue::const_reference |
Typ stałego odwołania do elementu. |
queue::container_type |
Typ kontenera bazowego. |
queue::difference_type |
Typ odległości ze znakiem między dwoma elementami. |
queue::generic_container |
Typ interfejsu ogólnego dla karty kontenera. |
queue::generic_value |
Typ elementu dla interfejsu ogólnego dla karty kontenera. |
queue::reference |
Typ odwołania do elementu. |
queue::size_type |
Typ odległości ze znakiem między dwoma elementami. |
queue::value_type |
Typ elementu. |
Funkcja składowa | opis |
---|---|
queue::assign |
Zastępuje wszystkie elementy. |
queue::back |
Uzyskuje dostęp do ostatniego elementu. |
queue::empty |
Sprawdza, czy nie ma żadnych elementów. |
queue::front |
Uzyskuje dostęp do pierwszego elementu. |
queue::get_container |
Uzyskuje dostęp do bazowego kontenera. |
queue::pop |
Usuwa pierwszy element. |
queue::push |
Dodaje nowy ostatni element. |
queue::queue |
Konstruuje obiekt kontenera. |
queue::size |
Liczy liczbę elementów. |
queue::to_array |
Kopiuje kontrolowaną sekwencję do nowej tablicy. |
Właściwości | opis |
---|---|
queue::back_item |
Uzyskuje dostęp do ostatniego elementu. |
queue::front_item |
Uzyskuje dostęp do pierwszego elementu. |
Operator | opis |
---|---|
queue::operator= |
Zastępuje kontrolowaną sekwencję. |
operator!= (kolejka) |
Określa, czy queue obiekt nie jest równy innemu queue obiektowi. |
operator< (kolejka) |
Określa, czy queue obiekt jest mniejszy niż inny queue obiekt. |
operator<= (kolejka) |
Określa, czy queue obiekt jest mniejszy lub równy innemu queue obiektowi. |
operator== (kolejka) |
Określa, czy queue obiekt jest równy innemu queue obiektowi. |
operator> (kolejka) |
Określa, czy queue obiekt jest większy niż inny queue obiekt. |
operator>= (kolejka) |
Określa, czy queue obiekt jest większy lub równy innemu queue obiektowi. |
Interfejsy
Interfejs | opis |
---|---|
ICloneable | Duplikuj obiekt. |
IQueue<Value, Container> |
Obsługa ogólnej karty kontenera. |
Uwagi
Obiekt przydziela i zwalnia magazyn dla sekwencji, którą kontroluje za pośrednictwem bazowego kontenera typu Container
, który przechowuje Value
elementy i rośnie na żądanie. Obiekt ogranicza dostęp tylko do wypychania pierwszego elementu i wyskakującego ostatniego elementu, implementując kolejkę pierwszy na pierwszym wyjść (znaną również jako kolejka FIFO lub po prostu kolejka).
Elementy członkowskie
queue::assign
Zastępuje wszystkie elementy.
Składnia
void assign(queue<Value, Container>% right);
Parametry
right
Adapter kontenera do wstawienia.
Uwagi
Funkcja składowa przypisuje right.get_container()
do kontenera bazowego. Służy do zmiany całej zawartości kolejki.
Przykład
// cliext_queue_assign.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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
queue::back
Uzyskuje dostęp do ostatniego elementu.
Składnia
reference back();
Uwagi
Funkcja składowa zwraca odwołanie do ostatniego elementu kontrolowanej sekwencji, który nie może być żaden. Służy do uzyskiwania dostępu do ostatniego elementu, gdy wiadomo, że istnieje.
Przykład
// cliext_queue_back.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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("back() = {0}", c1.back());
// alter last item and reinspect
c1.back() = L'x';
for each (wchar_t elem in c1.get_container())
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
back() = c
a b x
queue::back_item
Uzyskuje dostęp do ostatniego elementu.
Składnia
property value_type back_item;
Uwagi
Właściwość uzyskuje dostęp do ostatniego elementu kontrolowanej sekwencji, który nie może być żaden. Służy do odczytywania lub zapisywania ostatniego elementu, gdy wiadomo, że istnieje.
Przykład
// cliext_queue_back_item.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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("back_item = {0}", c1.back_item);
// alter last item and reinspect
c1.back_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
back_item = c
a b x
queue::const_reference
Typ stałego odwołania do elementu.
Składnia
typedef value_type% const_reference;
Uwagi
Typ opisuje stałe odwołanie do elementu.
Przykład
// cliext_queue_const_reference.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue c1;
c1.push(L'a');
c1.push(L'b');
c1.push(L'c');
// display contents "a b c"
for (; !c1.empty(); c1.pop())
{ // get a const reference to an element
Myqueue::const_reference cref = c1.front();
System::Console::Write("{0} ", cref);
}
System::Console::WriteLine();
return (0);
}
a b c
queue::container_type
Typ kontenera bazowego.
Składnia
typedef Container value_type;
Uwagi
Typ jest synonimem parametru Container
szablonu .
Przykład
// cliext_queue_container_type.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue c1;
c1.push(L'a');
c1.push(L'b');
c1.push(L'c');
// display contents "a b c" using container_type
Myqueue::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
queue::difference_type
Typy podpisanej odległości między dwoma elementami.
Składnia
typedef int difference_type;
Uwagi
Typ opisuje prawdopodobnie ujemną liczbę elementów.
Przykład
// cliext_queue_difference_type.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue::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
queue::empty
Sprawdza, czy nie ma żadnych elementów.
Składnia
bool empty();
Uwagi
Funkcja składowa zwraca wartość true dla pustej kontrolowanej sekwencji. Jest to odpowiednik size() == 0
elementu . Służy do testowania, czy element queue
jest pusty.
Przykład
// cliext_queue_empty.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
queue::front
Uzyskuje dostęp do pierwszego elementu.
Składnia
reference front();
Uwagi
Funkcja składowa zwraca odwołanie do pierwszego elementu kontrolowanej sekwencji, który nie może być żaden. Służy do uzyskiwania dostępu do pierwszego elementu, gdy wiadomo, że istnieje.
Przykład
// cliext_queue_front.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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 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.get_container())
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
return (0);
}
a b c
front() = a
x b c
queue::front_item
Uzyskuje dostęp do pierwszego elementu.
Składnia
property value_type front_item;
Uwagi
Właściwość uzyskuje dostęp do pierwszego elementu kontrolowanej sekwencji, który nie może być żaden. Służy do odczytywania lub zapisywania pierwszego elementu, gdy wiadomo, że istnieje.
Przykład
// cliext_queue_front_item.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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("front_item = {0}", c1.front_item);
// alter last item and reinspect
c1.front_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
front_item = a
x b c
queue::generic_container
Typ interfejsu ogólnego dla karty kontenera.
Składnia
typedef Microsoft::VisualC::StlClr::IQueue<Value>
generic_container;
Uwagi
Typ opisuje ogólny interfejs dla tej klasy adaptera kontenera szablonu.
Przykład
// cliext_queue_generic_container.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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();
// construct a generic container
Myqueue::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
queue::generic_value
Typ elementu do użycia z interfejsem ogólnym kontenera.
Składnia
typedef GValue generic_value;
Uwagi
Typ opisuje obiekt typu GValue
, który opisuje przechowywaną wartość elementu do użycia z interfejsem ogólnym dla tej klasy kontenera szablonu. (GValue
jest value_type
albo jeśli value_type^
value_type
jest typem ref).
Przykład
// cliext_queue_generic_value.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue::generic_container^ gc1 = %c1;
for each (wchar_t elem in gc1->get_container())
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// display in order using generic_value
for (; !gc1->empty(); gc1->pop())
{
Myqueue::generic_value elem = gc1->front();
System::Console::Write("{0} ", elem);
}
System::Console::WriteLine();
return (0);
}
a b c
a b c
a b c
queue::get_container
Uzyskuje dostęp do bazowego kontenera.
Składnia
container_type^ get_container();
Uwagi
Funkcja składowa zwraca kontener źródłowy. Służy do obejścia ograniczeń narzuconych przez otokę kontenera.
Przykład
// cliext_queue_get_container.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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();
return (0);
}
a b c
queue::operator=
Zastępuje kontrolowaną sekwencję.
Składnia
queue <Value, Container>% operator=(queue <Value, Container>% right);
Parametry
right
Adapter kontenera do skopiowania.
Uwagi
Operator elementu członkowskiego kopiuje right
do obiektu, a następnie zwraca wartość *this
. Służy do zastępowania kontrolowanej sekwencji kopią kontrolowanej sekwencji w pliku right
.
Przykład
// cliext_queue_operator_as.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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
queue::pop
Usuwa pierwszy element.
Składnia
void pop();
Uwagi
Usuwa pierwszy element kontrolowanej sekwencji, który nie może być żaden.
Przykład
// cliext_queue_pop.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
b c
queue::push
Dodaje nowy ostatni element.
Składnia
void push(value_type val);
Uwagi
Funkcja składowa dodaje element z wartością val
na końcu kolejki. Służy do dołączania elementu do kolejki.
Przykład
// cliext_queue_push.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
queue::queue
Tworzy obiekt adaptera kontenera.
Składnia
queue();
queue(queue<Value, Container>% right);
queue(queue<Value, Container>^ right);
explicit queue(container_type% wrapped);
Parametry
right
Obiekt do skopiowania.
wrapped
Opakowany kontener do użycia.
Uwagi
Konstruktor:
queue();
Tworzy pusty opakowany kontener. Służy do określania pustej początkowej kontrolowanej sekwencji.
Konstruktor:
queue(queue<Value, Container>% right);
Tworzy opakowany kontener, który jest kopią right.get_container()
. Służy do określania początkowej kontrolowanej sekwencji, która jest kopią sekwencji kontrolowanej queue
przez obiekt right
.
Konstruktor:
queue(queue<Value, Container>^ right);
Tworzy opakowany kontener, który jest kopią right->get_container()
. Służy do określania początkowej kontrolowanej sekwencji, która jest kopią sekwencji kontrolowanej queue
przez obiekt *right
.
Konstruktor:
explicit queue(container_type wrapped);
używa istniejącego kontenera wrapped
jako opakowany kontener. Służy do konstruowania obiektu queue
z istniejącego kontenera.
Przykład
// cliext_queue_construct.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
#include <cliext/list>
typedef cliext::queue<wchar_t> Myqueue;
typedef cliext::list<wchar_t> Mylist;
typedef cliext::queue<wchar_t, Mylist> Myqueue_list;
int main()
{
// construct an empty container
Myqueue c1;
System::Console::WriteLine("size() = {0}", c1.size());
// construct from an underlying container
Mylist v2(5, L'x');
Myqueue_list c2(v2);
for each (wchar_t elem in c2.get_container())
System::Console::Write("{0} ", elem);
System::Console::WriteLine();
// construct by copying another container
Myqueue_list 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
Myqueue_list 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
queue::reference
Typ odwołania do elementu.
Składnia
typedef value_type% reference;
Uwagi
Typ opisuje odwołanie do elementu.
Przykład
// cliext_queue_reference.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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 back of queue and redisplay
Myqueue::reference ref = c1.back();
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
queue::size
Liczy liczbę elementów.
Składnia
size_type size();
Uwagi
Funkcja składowa zwraca długość kontrolowanej sekwencji. Służy do określania liczby elementów aktualnie w kontrolowanej sekwencji. Jeśli chodzi o to, czy sekwencja ma rozmiar niezerowy, zobacz empty()
.
Przykład
// cliext_queue_size.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
queue::size_type
Typ odległości ze znakiem między dwoma elementami.
Składnia
typedef int size_type;
Uwagi
Typ opisuje nieujemną liczbę elementów.
Przykład
// cliext_queue_size_type.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue::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
queue::to_array
Kopiuje kontrolowaną sekwencję do nowej tablicy.
Składnia
cli::array<Value>^ to_array();
Uwagi
Funkcja składowa zwraca tablicę zawierającą kontrolowaną sekwencję. Służy do uzyskiwania kopii kontrolowanej sekwencji w postaci tablicy.
Przykład
// cliext_queue_to_array.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
queue::value_type
Typ elementu.
Składnia
typedef Value value_type;
Uwagi
Typ jest synonimem parametru Value
szablonu .
Przykład
// cliext_queue_value_type.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue::value_type val = c1.front();
System::Console::Write("{0} ", val);
}
System::Console::WriteLine();
return (0);
}
a b c
operator!=
(kolejka)
Queue
nie jest równe porównanie.
Składnia
template<typename Value,
typename Container>
bool operator!=(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca !(left == right)
wartość . Służy do testowania, czy left
nie jest uporządkowane tak samo, jak right
w przypadku, gdy dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_ne.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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<
(kolejka)
Queue
mniejsze niż porównanie.
Składnia
template<typename Value,
typename Container>
bool operator<(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca wartość true, jeśli dla najniższej pozycji i
, dla której !(right[i] < left[i])
jest również prawdziwe, że left[i] < right[i]
. W przeciwnym razie zwraca wartość left->size() < right->size()
. Służy do testowania, czy left
jest uporządkowane przed right
, gdy dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_lt.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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<=
(kolejka)
Queue
mniejsze niż lub równe porównanie.
Składnia
template<typename Value,
typename Container>
bool operator<=(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca !(right < left)
wartość . Służy do testowania, czy left
nie są uporządkowane po right
tym, jak dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_le.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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==
(kolejka)
Queue
równe porównanie.
Składnia
template<typename Value,
typename Container>
bool operator==(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca wartość true tylko wtedy, gdy sekwencje kontrolowane przez left
i right
mają taką samą długość, a dla każdej pozycji i
, left[i] == right[i]
. Służy do testowania, czy left
jest uporządkowane tak samo, jak right
w przypadku, gdy dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_eq.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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>
(kolejka)
Queue
większe niż porównanie.
Składnia
template<typename Value,
typename Container>
bool operator>(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca right < left
wartość . Służy do testowania, czy left
jest uporządkowane po right
tym, jak dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_gt.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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>=
(kolejka)
Queue
większe niż lub równe porównanie.
Składnia
template<typename Value,
typename Container>
bool operator>=(queue<Value, Container>% left,
queue<Value, Container>% right);
Parametry
left
Pozostaw kontener do porównania.
right
Odpowiedni kontener do porównania.
Uwagi
Funkcja operatora zwraca !(left < right)
wartość . Służy do testowania, czy left
nie jest uporządkowane przed right
, gdy dwie kolejki są porównywane element według elementu.
Przykład
// cliext_queue_operator_ge.cpp
// compile with: /clr
#include "pch.h"
#include <cliext/queue>
typedef cliext::queue<wchar_t> Myqueue;
int main()
{
Myqueue 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
Myqueue 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