기존 Queue를 SplQueue로 대체하였으므로 삭제
This commit is contained in:
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace sammo;
|
|
||||||
|
|
||||||
//TODO: 참조 값을 SplQueue ( https://secure.php.net/manual/en/class.splqueue.php )를 이용하도록 변경
|
|
||||||
class Queue {
|
|
||||||
private $capacity;
|
|
||||||
private $size;
|
|
||||||
private $head;
|
|
||||||
private $tail;
|
|
||||||
private $arr;
|
|
||||||
|
|
||||||
function Queue($capacity) {
|
|
||||||
$this->capacity = $capacity;
|
|
||||||
$this->size = 0;
|
|
||||||
$this->head = 0;
|
|
||||||
$this->tail = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSize() {
|
|
||||||
return $this->size;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear() {
|
|
||||||
$this->size = 0;
|
|
||||||
$this->head = 0;
|
|
||||||
$this->tail = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function push($value) {
|
|
||||||
if($this->size >= $this->capacity) return;
|
|
||||||
$this->arr[$this->tail] = $value;
|
|
||||||
$this->tail = ($this->tail + 1) % $this->capacity;
|
|
||||||
$this->size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
function pop() {
|
|
||||||
if($this->size <= 0) return null;
|
|
||||||
$value = $this->arr[$this->head];
|
|
||||||
$this->head = ($this->head + 1) % $this->capacity;
|
|
||||||
$this->size--;
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user