ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilDclStack Class Reference

Class ilDclStack. More...

+ Collaboration diagram for ilDclStack:

Public Member Functions

 push ($elem)
 
 pop ()
 
 top ()
 
 isEmpty ()
 
 reset ()
 
 count ()
 
 debug ()
 

Protected Attributes

 $stack = array()
 

Detailed Description

Member Function Documentation

◆ count()

ilDclStack::count ( )
Returns
int

Definition at line 76 of file class.ilDclStack.php.

Referenced by isEmpty(), pop(), and top().

77  {
78  return count($this->stack);
79  }
+ Here is the caller graph for this function:

◆ debug()

ilDclStack::debug ( )

Definition at line 82 of file class.ilDclStack.php.

83  {
84  echo "<pre>" . print_r($this->stack, 1) . "</pre>";
85  }

◆ isEmpty()

ilDclStack::isEmpty ( )
Returns
bool

Definition at line 61 of file class.ilDclStack.php.

References count().

Referenced by pop(), and top().

62  {
63  return !(bool) count($this->stack);
64  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop()

ilDclStack::pop ( )
Returns
null

Definition at line 30 of file class.ilDclStack.php.

References count(), and isEmpty().

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 
38  return $elem;
39  }
40 
41  return null;
42  }
+ Here is the call graph for this function:

◆ push()

ilDclStack::push (   $elem)
Parameters
$elem

Definition at line 21 of file class.ilDclStack.php.

22  {
23  $this->stack[] = $elem;
24  }

◆ reset()

ilDclStack::reset ( )

Definition at line 67 of file class.ilDclStack.php.

68  {
69  $this->stack = array();
70  }

◆ top()

ilDclStack::top ( )
Returns
null

Definition at line 48 of file class.ilDclStack.php.

References count(), and isEmpty().

49  {
50  if (!$this->isEmpty()) {
51  return $this->stack[count($this->stack) - 1];
52  }
53 
54  return null;
55  }
+ Here is the call graph for this function:

Field Documentation

◆ $stack

ilDclStack::$stack = array()
protected

Definition at line 15 of file class.ilDclStack.php.


The documentation for this class was generated from the following file: