자료구조 Ds\PriorityQueue::pop
(PECL ds >= 1.0.0)
Ds\PriorityQueue::pop — 우선 순위가 가장 높은 값을 제거하고 반환합니다.
설명
public Ds\PriorityQueue::pop(): mixed
큐의 맨 앞에 있는 값을 제거하고 반환합니다. 우선 순위가 가장 높은 값.
메모: 우선 순위가 같은 값은 FIFO(선입 선출)로 대체됩니다.
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
큐의 맨 앞에 있던 제거된 값입니다.
오류/예외
비어 있으면 UnderflowException이 발생합니다.
Examples
예제 #1 Ds\PriorityQueue::pop() 예제
<?php
$queue = new \Ds\PriorityQueue();
$queue->push("a", 5);
$queue->push("b", 15);
$queue->push("c", 10);
print_r($queue->pop());
print_r($queue->pop());
print_r($queue->pop());
?>
위의 예는 다음과 유사한 결과를 출력합니다.
string(1) "a" string(1) "b" string(1) "c"