Files
core/f_func/class._Queue.php
T
Hide_D 373bcde70b e_lib 코드들을 composer로 이동
func_http 삭제. guzzle로 대체

php 파일에서 include, require 앞에 있는 구문들을 전부 뒤로 이동.
2018-01-28 21:38:04 +09:00

44 lines
945 B
PHP

<?php
require(__dir__.'/../vendor/autoload.php');
class _Queue {
private $capacity;
private $size;
private $head;
private $tail;
private $arr;
public function Queue($capacity) {
$this->capacity = $capacity;
$this->size = 0;
$this->head = 0;
$this->tail = 0;
}
public function getSize() {
return $this->size;
}
public function clear() {
$this->size = 0;
$this->head = 0;
$this->tail = 0;
}
public function push($value) {
if($this->size >= $this->capacity) return;
$this->arr[$this->tail] = $value;
$this->tail = ($this->tail + 1) % $this->capacity;
$this->size++;
}
public function pop() {
if($this->size <= 0) return null;
$value = $this->arr[$this->head];
$this->head = ($this->head + 1) % $this->capacity;
$this->size--;
return $value;
}
}