concurrent_priority_queue 클래스

concurrent_priority_queue 클래스는 여러 스레드에서 동시에 항목을 푸시 및 팝할 수 있도록 허용하는 컨테이너입니다. 항목은 우선순위에 따라 팝되고, 우선순위는 템플릿 인수로 제공된 함수에 의해 결정됩니다.

구문

template <typename T,
    typename _Compare= std::less<T>,
    typename _Ax = std::allocator<T>
>,
    typename _Ax = std::allocator<T>> class concurrent_priority_queue;

매개 변수

T
우선 순위 큐에 저장될 요소의 데이터 형식입니다.

_비교
우선 순위 큐에서 두 요소 값의 상대적 순서를 결정하기 위해 정렬 키로 두 요소 값을 비교할 수 있는 함수 개체의 형식입니다. 이 인수는 선택 사항이며 기본값은 이진 조건자 less<T>입니다.

_도끼
동시 우선 순위 큐의 메모리 할당 및 할당 취소에 대한 세부 정보를 캡슐화하는, 저장된 할당자 개체를 나타내는 형식입니다. 이 인수는 선택 사항이며 기본값은 allocator<T>입니다.

멤버

공용 Typedefs

이름 설명
allocator_type 동시 우선 순위 큐의 할당자 클래스를 나타내는 형식입니다.
const_reference 동시 우선 순위 큐에 저장된 형식의 요소에 대한 const 참조를 나타내는 형식입니다.
reference 동시 우선 순위 큐에 저장된 형식의 요소에 대한 참조를 나타내는 형식입니다.
size_type 동시 우선 순위 큐에 있는 요소의 수를 세는 형식입니다.
value_type 동시 우선 순위 큐에 저장된 데이터 형식을 나타내는 형식입니다.

공용 생성자

속성 설명
concurrent_priority_queue 오버로드됨. 동시 우선 순위 큐를 생성합니다.

공용 메서드

이름 설명
clear 동시 우선 순위의 모든 요소를 지웁니다. 이 메서드는 동시성이 안전하지 않습니다.
empty 이 메서드가 호출될 때 동시 우선 순위 큐가 비어 있는지를 테스트합니다. 이 메서드는 동시성 안전입니다.
get_allocator 동시 우선 순위 큐를 생성하는 데 사용되는 할당자 복사본을 반환합니다. 이 메서드는 동시성 안전입니다.
push 오버로드됨. 동시 우선 순위 큐에 요소를 추가 합니다. 이 메서드는 동시성 안전입니다.
size 동시 우선 순위 큐에 있는 요소의 수를 반환합니다. 이 메서드는 동시성 안전입니다.
swap 두 개의 동시 우선 순위 큐의 내용을 바꿉니다. 이 메서드는 동시성이 안전하지 않습니다.
try_pop 큐가 비어 있지 않은 경우 큐에서 우선 순위가 가장 높은 요소를 제거하고 반환합니다. 이 메서드는 동시성 안전입니다.

Public 연산자

이름 설명
operator= 오버로드됨. 다른 concurrent_priority_queue 개체의 내용을 이 개체에 할당합니다. 이 메서드는 동시성이 안전하지 않습니다.

설명

클래스에 대한 concurrent_priority_queue 자세한 내용은 병렬 컨테이너 및 개체를 참조 하세요.

상속 계층 구조

concurrent_priority_queue

요구 사항

헤더: concurrent_priority_queue.h

네임스페이스: 동시성

clear

동시 우선 순위의 모든 요소를 지웁니다. 이 메서드는 동시성이 안전하지 않습니다.

void clear();

설명

clear 은 동시성 안전이 아닙니다. 이 메서드를 호출할 때 다른 스레드가 동시 우선 순위 큐에서 메서드를 호출하지 않는지 확인해야 합니다. clear 는 메모리를 해제하지 않습니다.

concurrent_priority_queue

동시 우선 순위 큐를 생성합니다.

explicit concurrent_priority_queue(
    const allocator_type& _Al = allocator_type());

explicit concurrent_priority_queue(
    size_type _Init_capacity,
    const allocator_type& _Al = allocator_type());

template<typename _InputIterator>
concurrent_priority_queue(_InputIterator _Begin,
    _InputIterator _End,
    const allocator_type& _Al = allocator_type());

concurrent_priority_queue(
    const concurrent_priority_queue& _Src);

concurrent_priority_queue(
    const concurrent_priority_queue& _Src,
    const allocator_type& _Al);

concurrent_priority_queue(
    concurrent_priority_queue&& _Src);

concurrent_priority_queue(
    concurrent_priority_queue&& _Src,
    const allocator_type& _Al);

매개 변수

_InputIterator
입력 반복기의 형식입니다.

_알
이 개체에 사용할 할당자 클래스입니다.

_Init_capacity
concurrent_priority_queue 개체의 초기 용량입니다.

_시작
복사할 요소의 범위에서 첫 번째 요소의 위치입니다.

_끝
복사할 요소의 범위를 벗어나는 첫 번째 요소의 위치입니다.

_Src
요소를 복사해 오거나 이동해 올 소스 concurrent_priority_queue 개체입니다.

설명

모든 생성자는 할당자 개체 _Al 를 저장하고 우선 순위 큐를 초기화합니다.

첫 번째 생성자는 빈 초기 우선 순위 큐를 지정하고 필요에 따라 할당자를 지정합니다.

두 번째 생성자는 초기 용량 _Init_capacity 이 있는 우선 순위 큐를 지정하고 필요에 따라 할당자를 지정합니다.

세 번째 생성자는 반복기 범위 [ _Begin, _End)에서 제공하는 값을 지정하고 필요에 따라 할당자를 지정합니다.

네 번째 및 다섯 번째 생성자는 우선 순위 큐 _Src의 복사본을 지정합니다.

여섯 번째 및 일곱 번째 생성자는 우선 순위 큐 _Src의 이동을 지정합니다.

empty

이 메서드가 호출될 때 동시 우선 순위 큐가 비어 있는지를 테스트합니다. 이 메서드는 동시성 안전입니다.

bool empty() const;

Return Value

true 함수가 호출 false 된 시점에 우선 순위 큐가 비어 있으면 그렇지 않습니다.

get_allocator

동시 우선 순위 큐를 생성하는 데 사용되는 할당자 복사본을 반환합니다. 이 메서드는 동시성 안전입니다.

allocator_type get_allocator() const;

Return Value

개체를 생성하는 데 사용되는 할당자의 복사본입니다 concurrent_priority_queue .

operator=

다른 concurrent_priority_queue 개체의 내용을 이 개체에 할당합니다. 이 메서드는 동시성이 안전하지 않습니다.

concurrent_priority_queue& operator= (const concurrent_priority_queue& _Src);

concurrent_priority_queue& operator= (concurrent_priority_queue&& _Src);

매개 변수

_Src
원본 concurrent_priority_queue 개체입니다.

Return Value

concurrent_priority_queue 개체에 대한 참조입니다.

push

동시 우선 순위 큐에 요소를 추가 합니다. 이 메서드는 동시성 안전입니다.

void push(const value_type& _Elem);

void push(value_type&& _Elem);

매개 변수

_Elem
동시 우선 순위 큐에 추가할 요소입니다.

size

동시 우선 순위 큐에 있는 요소의 수를 반환합니다. 이 메서드는 동시성 안전입니다.

size_type size() const;

Return Value

concurrent_priority_queue 개체의 요소 수입니다.

설명

반환된 크기는 함수 push에 대한 호출에 의해 추가된 모든 요소를 포함하도록 보장됩니다. 그러나 보류 중인 동시 작업의 결과를 반영하지 않을 수 있습니다.

swap

두 개의 동시 우선 순위 큐의 내용을 바꿉니다. 이 메서드는 동시성이 안전하지 않습니다.

void swap(concurrent_priority_queue& _Queue);

매개 변수

_큐
concurrent_priority_queue 콘텐츠를 교환할 개체입니다.

try_pop

큐가 비어 있지 않은 경우 큐에서 우선 순위가 가장 높은 요소를 제거하고 반환합니다. 이 메서드는 동시성 안전입니다.

bool try_pop(reference _Elem);

매개 변수

_Elem
큐가 비어있지 않은 경우 우선 순위가 가장 높은 요소로 채워지는 변수에 대한 참조입니다.

Return Value

true 값이 팝되었 false 으면 그렇지 않습니다.

참고 항목

concurrency 네임스페이스
병렬 컨테이너 및 개체