ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 }