ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilDclStack.php
Go to the documentation of this file.
1 <?php
2 
9 class ilDclStack
10 {
11 
15  protected $stack = array();
16 
17 
21  public function push($elem)
22  {
23  $this->stack[] = $elem;
24  }
25 
26 
30  public function pop()
31  {
32  if (!$this->isEmpty()) {
33  $last_index = count($this->stack) - 1;
34  $elem = $this->stack[$last_index];
35  unset($this->stack[$last_index]);
36  $this->stack = array_values($this->stack); // re-index
37  return $elem;
38  }
39 
40  return null;
41  }
42 
43 
47  public function top()
48  {
49  if (!$this->isEmpty()) {
50  return $this->stack[count($this->stack) - 1];
51  }
52 
53  return null;
54  }
55 
56 
60  public function isEmpty()
61  {
62  return !(bool) count($this->stack);
63  }
64 
65 
66  public function reset()
67  {
68  $this->stack = array();
69  }
70 
71 
75  public function count()
76  {
77  return count($this->stack);
78  }
79 
80 
81  public function debug()
82  {
83  echo "<pre>" . print_r($this->stack, 1) . "</pre>";
84  }
85 }
Class ilDclStack.
Create styles array
The data for the language used.