Last active
August 24, 2016 13:24
-
-
Save zachflower/d7fcee049eea9971404a to your computer and use it in GitHub Desktop.
PHP implementation of a queue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// http://www.cplusplus.com/reference/queue/queue/ | |
class Queue { | |
private $_queue = array(); | |
public function size() { | |
return count($this->_queue); | |
} | |
public function front() { | |
return end($this->_queue); | |
} | |
public function back() { | |
return reset($this->_queue); | |
} | |
public function push($value = NULL) { | |
array_unshift($this->_queue, $value); | |
} | |
public function pop() { | |
return array_pop($this->_queue); | |
} | |
public function isEmpty() { | |
return empty($this->_queue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment