ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDclStack Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilDclStack:

Public Member Functions

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

Protected Attributes

array $stack = array()
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

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

Member Function Documentation

◆ count()

ilDclStack::count ( )

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

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

70  : int
71  {
72  return count($this->stack);
73  }
+ Here is the caller graph for this function:

◆ debug()

ilDclStack::debug ( )

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

75  : void
76  {
77  echo "<pre>" . print_r($this->stack, 1) . "</pre>";
78  }

◆ isEmpty()

ilDclStack::isEmpty ( )

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

References count().

Referenced by pop(), and top().

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

◆ pop()

ilDclStack::pop ( )
Returns
?float|int|string

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

References count(), and isEmpty().

35  {
36  if (!$this->isEmpty()) {
37  $last_index = count($this->stack) - 1;
38  $elem = $this->stack[$last_index];
39  unset($this->stack[$last_index]);
40  $this->stack = array_values($this->stack); // re-index
41 
42  return $elem;
43  }
44 
45  return null;
46  }
+ Here is the call graph for this function:

◆ push()

ilDclStack::push (   $elem)
Parameters
float | int | string$elem

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

27  {
28  $this->stack[] = $elem;
29  }

◆ reset()

ilDclStack::reset ( )

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

65  : void
66  {
67  $this->stack = array();
68  }

◆ top()

ilDclStack::top ( )
Returns
?float|int|string

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

References count(), and isEmpty().

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

Field Documentation

◆ $stack

array ilDclStack::$stack = array()
protected

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


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