for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace DataStructures\Lists;
use DataStructures\Lists\Interfaces\ListInterface;
abstract class ListAbstract implements ListInterface {
protected $size;
/**
* Binds to count() method. This is equal to make $this->tree->size().
*
* @return integer the tree size. 0 if it is empty.
*/
public function count() {
return $this->size;
}
* Returns the array size.
* @return int the length
public function size() : int {
* Checks if the list is empty.
* @return boolean true if is empty, else false.
public function empty() : bool {
return $this->size === 0;
* Adds at the end of the list new node containing
* the data to be stored.
* @param mixed $data The data
public function push($data) {
$this->insert($this->size, $data);
* Adds at the beginning a node in the list.
* @param mixed $data
* @return mixed the data stored.
public function unshift($data) {
$this->insert(0, $data);
* Deletes the first node of the list and returns it.
* @return mixed the data.
public function shift() {
return $this->delete(0);
* Removes and returns the last node in the list.
* @return mixed data in node.
public function pop() {
return $this->delete($this->size - 1);