WC_Eval_Math_Stack

Class WC_Eval_Math_Stack.

Defined (1)

The class is defined in the following location(s).

/includes/libraries/class-wc-eval-math.php  
  1. class WC_Eval_Math_Stack { 
  2.  
  3. /** 
  4. * Stack array. 
  5. * @var array 
  6. */ 
  7. public $stack = array(); 
  8.  
  9. /** 
  10. * Stack counter. 
  11. * @var integer 
  12. */ 
  13. public $count = 0; 
  14.  
  15. /** 
  16. * Push value into stack. 
  17. * @param mixed $val 
  18. */ 
  19. public function push( $val ) { 
  20. $this->stack[ $this->count ] = $val; 
  21. $this->count++; 
  22.  
  23. /** 
  24. * Pop value from stack. 
  25. * @return mixed 
  26. */ 
  27. public function pop() { 
  28. if ( $this->count > 0 ) { 
  29. $this->count--; 
  30. return $this->stack[ $this->count ]; 
  31. return null; 
  32.  
  33. /** 
  34. * Get last value from stack. 
  35. * @param int $n 
  36. * @return mixed 
  37. */ 
  38. public function last( $n=1 ) { 
  39. $key = $this->count - $n; 
  40. return array_key_exists( $key, $this->stack ) ? $this->stack[ $key ] : null;