ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Queue.php
Go to the documentation of this file.
1 <?php
2 
21  private $input;
22  private $output;
23 
24  public function __construct($input = array()) {
25  $this->input = $input;
26  $this->output = array();
27  }
28 
32  public function shift() {
33  if (empty($this->output)) {
34  $this->output = array_reverse($this->input);
35  $this->input = array();
36  }
37  if (empty($this->output)) {
38  return NULL;
39  }
40  return array_pop($this->output);
41  }
42 
46  public function push($x) {
47  array_push($this->input, $x);
48  }
49 
53  public function isEmpty() {
54  return empty($this->input) && empty($this->output);
55  }
56 }
push($x)
Pushes an element onto the front of the queue.
Definition: Queue.php:46
A simple array-backed queue, based off of the classic Okasaki persistent amortized queue...
Definition: Queue.php:20
isEmpty()
Checks if it&#39;s empty.
Definition: Queue.php:53
__construct($input=array())
Definition: Queue.php:24
input
Definition: langcheck.php:166
shift()
Shifts an element off the front of the queue.
Definition: Queue.php:32
$x
Definition: complexTest.php:9