Share via


priority_queue(STL/CLR)

템플릿 클래스는 액세스가 제한된 다양한 길이의 정렬된 요소 시퀀스를 제어하는 개체를 설명합니다. 컨테이너 어댑터를 priority_queue 사용하여 기본 컨테이너를 우선 순위 큐로 관리합니다.

아래 GValue 설명에서 후자가 ref 형식이 아니면 Value동일합니다. 이 경우 값입니다Value^. 마찬가지로, GContainer 후자가 ref 형식이 아니면 컨테이너동일합니다. 이 경우 컨테이너입니다Container^.

구문

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

매개 변수


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

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

요구 사항

헤더:<cliext/queue>

네임스페이스: cliext

선언

형식 정의 설명
priority_queue::const_reference(STL/CLR) 요소에 대한 상수 참조의 형식입니다.
priority_queue::container_type(STL/CLR) 기본 컨테이너의 형식입니다.
priority_queue::difference_type(STL/CLR) 두 요소 사이의 부호가 있는 거리의 형식입니다.
priority_queue::generic_container(STL/CLR) 컨테이너 어댑터에 대한 제네릭 인터페이스의 형식입니다.
priority_queue::generic_value(STL/CLR) 컨테이너 어댑터의 제네릭 인터페이스에 대한 요소의 형식입니다.
priority_queue::reference(STL/CLR) 요소에 대한 참조의 형식입니다.
priority_queue::size_type(STL/CLR) 두 요소 사이의 부호가 있는 거리의 형식입니다.
priority_queue::value_compare(STL/CLR) 두 요소에 대한 순서 지정 대리자입니다.
priority_queue::value_type(STL/CLR) 요소의 형식입니다.
멤버 함수 설명
priority_queue::assign(STL/CLR) 모든 요소를 바꿉니다.
priority_queue::empty(STL/CLR) 요소가 있는지 여부를 테스트합니다.
priority_queue::get_container(STL/CLR) 기본 컨테이너에 액세스합니다.
priority_queue::pop(STL/CLR) hghest 우선 순위 요소를 제거합니다.
priority_queue::priority_queue(STL/CLR) 컨테이너 개체를 만듭니다.
priority_queue::push(STL/CLR) 새 요소를 추가합니다.
priority_queue::size(STL/CLR) 요소 수를 계산합니다.
priority_queue::top(STL/CLR) 우선 순위가 가장 높은 요소에 액세스합니다.
priority_queue::to_array(STL/CLR) 제어된 시퀀스를 새 배열에 복사합니다.
priority_queue::value_comp(STL/CLR) 두 요소에 대한 순서 지정 대리자를 복사합니다.
속성 설명
priority_queue::top_item(STL/CLR) 우선 순위가 가장 높은 요소에 액세스합니다.
연산자 설명
priority_queue::operator=(STL/CLR) 제어되는 시퀀스를 바꿉니다.

인터페이스

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

설명

개체는 요소를 저장 Value 하고 필요에 따라 증가하는 형식Container의 기본 컨테이너를 통해 제어하는 시퀀스에 대한 스토리지를 할당하고 해제합니다. 우선 순위가 가장 높은 요소(최상위 요소)가 쉽게 액세스 가능하고 이동식이 가능한 힙으로 순서가 지정된 시퀀스를 유지합니다. 개체는 새 요소를 푸시하고 우선 순위가 가장 높은 요소만 팝하여 우선 순위 큐를 구현하도록 액세스를 제한합니다.

개체는 STL/CLR(priority_queue::value_compare) 형식의 저장된 대리자 개체를 호출하여 제어하는 시퀀스를 정렬합니다. priority_queue 생성할 때 저장된 대리자 개체를 지정할 수 있습니다. 대리자 개체를 지정하지 않으면 기본값은 비교 operator<(value_type, value_type)입니다. STL/CLR(멤버 함수 priority_queue::value_comp)()을 호출하여 이 저장된 개체에 액세스합니다.

이러한 대리자 개체는 priority_queue::value_type(STL/CLR) 형식의 값에 엄격한 약한 순서를 적용해야 합니다. 즉, 두 키 X 에 대해 다음을 Y수행합니다.

value_comp()(X, Y) 는 모든 호출에서 동일한 부울 결과를 반환합니다.

true value_comp()(Y, X) 이면 value_comp()(X, Y) false여야 합니다.

true X 이면 value_comp()(X, Y) 앞에 Y순서를 지정해야 합니다.

true XY 이면 !value_comp()(X, Y) && !value_comp()(Y, X) 동일한 순서를 가지고 있다고 합니다.

제어되는 시퀀스에서 key_comp()(Y, X) 앞에 오는 Y 모든 요소 X 의 경우 false입니다. (기본 대리자 개체의 경우 키 값이 감소하지 않습니다.)

따라서 우선 순위가 가장 높은 요소는 다른 요소 앞에 정렬되지 않은 요소 중 하나입니다.

기본 컨테이너는 힙으로 정렬된 요소를 유지합니다.

컨테이너는 임의 액세스 반복기를 지원해야 합니다.

동일한 순서를 가진 요소는 푸시된 것과 다른 순서로 팝될 수 있습니다. (순서가 안정적이지 않습니다.)

따라서 기본 컨테이너의 후보는 deque(STL/CLR)벡터(STL/CLR)를 포함합니다.

멤버

priority_queue::assign(STL/CLR)

모든 요소를 바꿉니다.

구문

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

매개 변수

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

설명

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

예시

// cliext_priority_queue_assign.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue c2;
    c2.assign(c1);
    for each (wchar_t elem in c2.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
c a b
c a b

priority_queue::const_reference(STL/CLR)

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

구문

typedef value_type% const_reference;

설명

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

예시

// cliext_priority_queue_const_reference.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
        Mypriority_queue::const_reference cref = c1.top();
        System::Console::Write("{0} ", cref);
        }
    System::Console::WriteLine();
    return (0);
    }
c b a

priority_queue::container_type(STL/CLR)

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

구문

typedef Container value_type;

설명

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

예시

// cliext_priority_queue_container_type.cpp
// compile with: /clr
#include <cliext/queue>

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

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

priority_queue::difference_type(STL/CLR)

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

구문

typedef int difference_type;

설명

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

예시

// cliext_priority_queue_difference_type.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue::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);
    }
c a b
pushing 2 = -2
popping 3 = 3

priority_queue::empty(STL/CLR)

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

구문

bool empty();

설명

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

예시

// cliext_priority_queue_empty.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b
size() = 3
empty() = False
size() = 0
empty() = True

priority_queue::generic_container(STL/CLR)

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

구문

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

설명

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

예시

// cliext_priority_queue_generic_container.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue::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);
    }
c a b
c a b
d c b a
e d b a c

priority_queue::generic_value(STL/CLR)

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

구문

typedef GValue generic_value;

설명

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

예시

// cliext_priority_queue_generic_value.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue::generic_container^ gc1 = %c1;
    for each (wchar_t elem in gc1->get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

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

priority_queue::get_container(STL/CLR)

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

구문

container_type get_container();

설명

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

예시

// cliext_priority_queue_get_container.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b

priority_queue::operator=(STL/CLR)

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

구문

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

매개 변수

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

설명

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

예시

// cliext_priority_queue_operator_as.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue c2;
    c2 = c1;
    for each (wchar_t elem in c2.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();
    return (0);
    }
c a b
c a b

priority_queue::pop(STL/CLR)

가장 높은 성향 요소를 제거합니다.

구문

void pop();

설명

멤버 함수는 제어되는 시퀀스의 우선 순위가 가장 높은 요소를 제거합니다. 이 요소는 비어 있어야 합니다. 이 값을 사용하여 큐를 뒤에서 한 요소씩 줄입니다.

예시

// cliext_priority_queue_pop.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b
b a

priority_queue::priority_queue(STL/CLR)

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

구문

priority_queue();
priority_queue(priority_queue<Value, Container> right);
priority_queue(priority_queue<Value, Container> right);
explicit priority_queue(value_compare^ pred);
priority_queue(value_compare^ pred, container_type% cont);
template<typename InIt>
    priority_queue(InIt first, InIt last);
template<typename InIt>
    priority_queue(InIt first, InIt last,
        value_compare^ pred);
template<typename InIt>
    priority_queue(InIt first, InIt last,
        value_compare^ pred, container_type% cont);

매개 변수

계속
복사할 컨테이너입니다.

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

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

Pred
제어되는 시퀀스에 대한 조건자 순서 지정

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

설명

생성자:

priority_queue();

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

생성자:

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

는 정렬 조건right.value_comp()자를 사용하여 복사본right.get_container()인 래핑된 컨테이너를 만듭니다. 이를 사용하여 동일한 순서 조건자를 사용하여 큐 개체 오른쪽에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정할 수 있습니다.

생성자:

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

는 정렬 조건right->value_comp()자를 사용하여 복사본right->get_container()인 래핑된 컨테이너를 만듭니다. 이를 사용하여 동일한 순서 조건자를 사용하여 큐 개체 *right에 의해 제어되는 시퀀스의 복사본인 초기 제어 시퀀스를 지정합니다.

생성자:

explicit priority_queue(value_compare^ pred);

는 정렬 조건 자가 미리 지정된 빈 래핑된 컨테이너를 만듭니다. 지정된 순서 조건자를 사용하여 빈 초기 제어 시퀀스를 지정하는 데 사용합니다.

생성자:

priority_queue(value_compare^ pred, container_type cont);

는 정렬 조건자가 미리 지정된 빈 래핑된 컨테이너를 만든 다음, 지정된 순서 조건자를 사용하여 기존 컨테이너에서 초기 제어 시퀀스를 지정하는 데 사용하는 cont모든 요소를 푸시합니다.

생성자:

template<typename InIt> priority_queue(InIt first, InIt last);

는 기본 순서 조건자를 사용하여 빈 래핑된 컨테이너를 만든 다음 시퀀스 [first, last)를 푸시합니다. 지정된 순서 조건자를 사용하여 지정된 eqeuence에서 초기 제어 시퀀스를 지정하는 데 사용합니다.

생성자:

template<typename InIt> priority_queue(InIt first, InIt last, value_compare^ pred);

는 정렬 조건 자가 미리 지정된 빈 래핑된 컨테이너를 만든 다음 시퀀스 [first, last)를 푸시합니다. 지정된 순서 조건자를 사용하여 지정된 seqeuence에서 초기 제어 시퀀스를 지정하는 데 사용합니다.

생성자:

template<typename InIt> priority_queue(InIt first, InIt last, value_compare^ pred, container_type% cont);

는 정렬 조건자가 미리 지정된 빈 래핑된 컨테이너를 만든 다음 cont모든 요소와 시퀀스 [first, last)를 푸시합니다. 이를 사용하여 지정된 순서 조건자를 사용하여 기존 컨테이너에서 초기 제어 시퀀스와 지정된 seqeuence를 지정할 수 있습니다.

예시

// cliext_priority_queue_construct.cpp
// compile with: /clr
#include <cliext/queue>
#include <cliext/deque>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
typedef cliext::deque<wchar_t> Mydeque;
int main()
    {
// construct an empty container
    Mypriority_queue c1;
    Mypriority_queue::container_type^ wc1 = c1.get_container();
    System::Console::WriteLine("size() = {0}", c1.size());

    c1.push(L'a');
    c1.push(L'b');
    c1.push(L'c');
    for each (wchar_t elem in wc1)
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an ordering rule
    Mypriority_queue c2 = cliext::greater<wchar_t>();
    System::Console::WriteLine("size() = {0}", c2.size());

    for each (wchar_t elem in wc1)
        c2.push(elem);
    for each (wchar_t elem in c2.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an ordering rule by copying an underlying container
    Mypriority_queue c2x =
        gcnew Mypriority_queue(cliext::greater<wchar_t>(), *wc1);
   for each (wchar_t elem in c2x.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an iterator range
    Mypriority_queue c3(wc1->begin(), wc1->end());
    for each (wchar_t elem in c3.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an iterator range and an ordering rule
    Mypriority_queue c4(wc1->begin(), wc1->end(),
        cliext::greater<wchar_t>());
    for each (wchar_t elem in c4.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct with an iterator range, another container, and an ordering rule
    Mypriority_queue c5(wc1->begin(), wc1->end(),
        cliext::greater<wchar_t>(), *wc1);
    for each (wchar_t elem in c5.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    // construct from a generic container
    Mypriority_queue c6(c3);
    for each (wchar_t elem in c6.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

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

    // construct with an ordering rule, by copying an underlying container
    Mypriority_queue c8 =
        gcnew Mypriority_queue(cliext::greater<wchar_t>(), *wc1);
    for each (wchar_t elem in c8.get_container())
        System::Console::Write("{0} ", elem);
    System::Console::WriteLine();

    return (0);
    }
size() = 0
c a b
size() = 0
a c b
a c b
c a b
a c b
a a b c c b
c a b
c a b
a c b

priority_queue::push(STL/CLR)

새 요소를 추가합니다.

구문

void push(value_type val);

설명

멤버 함수는 값 val 이 있는 요소를 제어되는 시퀀스에 삽입하고 제어되는 시퀀스를 다시 정렬하여 힙 분야를 기본. 큐에 다른 요소를 추가하는 데 사용합니다.

예시

// cliext_priority_queue_push.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b

priority_queue::reference(STL/CLR)

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

구문

typedef value_type% reference;

설명

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

예시

// cliext_priority_queue_reference.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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 priority_queue and redisplay
    Mypriority_queue::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);
    }
c a b
x a b

priority_queue::size(STL/CLR)

요소 수를 계산합니다.

구문

size_type size();

설명

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

예시

// cliext_priority_queue_size.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b
size() = 3 starting with 3
size() = 2 after popping
size() = 4 after adding 2

priority_queue::size_type(STL/CLR)

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

구문

typedef int size_type;

설명

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

예시

// cliext_priority_queue_size_type.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
    Mypriority_queue::size_type diff = c1.size();
    c1.pop();
    c1.pop();
    diff -= c1.size();
    System::Console::WriteLine("size difference = {0}", diff);
    return (0);
    }
c a b
size difference = 2

priority_queue::to_array(STL/CLR)

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

구문

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

설명

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

예시

// cliext_priority_queue_to_array.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
d c b a
c a b

priority_queue::top(STL/CLR)

우선 순위가 가장 높은 요소에 액세스합니다.

구문

reference top();

설명

멤버 함수는 제어되는 시퀀스의 최상위(가장 높은 우선 순위) 요소에 대한 참조를 반환하며, 이 요소는 비어 있어야 합니다. 우선 순위가 가장 높은 요소에 액세스하는 데 사용합니다.

예시

// cliext_priority_queue_top.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }

priority_queue::top_item(STL/CLR)

우선 순위가 가장 높은 요소에 액세스합니다.

구문

property value_type back_item;

설명

이 속성은 비어 있어야 하는 제어되는 시퀀스의 최상위(가장 높은 우선 순위) 요소에 액세스합니다. 우선 순위가 가장 높은 요소를 읽거나 쓰는 데 사용합니다.

예시

// cliext_priority_queue_top_item.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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);
    }
c a b
top_item = c
x a b

priority_queue::value_comp(STL/CLR)

두 요소에 대한 순서 지정 대리자를 복사합니다.

구문

value_compare^ value_comp();

설명

멤버 함수는 제어되는 시퀀스를 정렬하는 데 사용되는 순서 지정 대리자를 반환합니다. 두 값을 비교하는 데 사용합니다.

예시

// cliext_priority_queue_value_comp.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue c1;
    Mypriority_queue::value_compare^ vcomp = c1.value_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        vcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        vcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        vcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Mypriority_queue c2 = cliext::greater<wchar_t>();
    vcomp = c2.value_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        vcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        vcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        vcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

priority_queue::value_compare(STL/CLR)

두 값에 대한 순서 지정 대리자입니다.

구문

binary_delegate<value_type, value_type, int> value_compare;

설명

형식은 첫 번째 인수가 두 번째 인수 앞에 정렬되는지 여부를 결정하는 대리자의 동의어입니다.

예시

// cliext_priority_queue_value_compare.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue c1;
    Mypriority_queue::value_compare^ vcomp = c1.value_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        vcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        vcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        vcomp(L'b', L'a'));
    System::Console::WriteLine();

    // test a different ordering rule
    Mypriority_queue c2 = cliext::greater<wchar_t>();
    vcomp = c2.value_comp();

    System::Console::WriteLine("compare(L'a', L'a') = {0}",
        vcomp(L'a', L'a'));
    System::Console::WriteLine("compare(L'a', L'b') = {0}",
        vcomp(L'a', L'b'));
    System::Console::WriteLine("compare(L'b', L'a') = {0}",
        vcomp(L'b', L'a'));
    return (0);
    }
compare(L'a', L'a') = False
compare(L'a', L'b') = True
compare(L'b', L'a') = False

compare(L'a', L'a') = False
compare(L'a', L'b') = False
compare(L'b', L'a') = True

priority_queue::value_type(STL/CLR)

요소의 형식입니다.

구문

typedef Value value_type;

설명

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

예제

// cliext_priority_queue_value_type.cpp
// compile with: /clr
#include <cliext/queue>

typedef cliext::priority_queue<wchar_t> Mypriority_queue;
int main()
    {
    Mypriority_queue 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
        Mypriority_queue::value_type val = c1.top();

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