From 741500da144b48d85d229e9dbaf3f590ed5f3f03 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Sat, 6 Dec 2014 00:16:41 +0000 Subject: [PATCH] Add example of cyclic reference calculation --- .../CalcEngine/CyclicReferenceStack.new.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Classes/PHPExcel/CalcEngine/CyclicReferenceStack.new.php diff --git a/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.new.php b/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.new.php new file mode 100644 index 00000000..e57512de --- /dev/null +++ b/Classes/PHPExcel/CalcEngine/CyclicReferenceStack.new.php @@ -0,0 +1,122 @@ +_stack); + } + + /** + * Push a new entry onto the stack + * + * @param mixed $value + */ + public function push($value) { + $this->_stack[] = $value; + } // function push() + + /** + * Pop the last entry from the stack + * + * @return mixed + */ + public function pop() { + return array_pop($this->_stack); + } // function pop() + + /** + * Test to see if a specified entry exists on the stack + * + * @param mixed $value The value to test + */ + public function onStack($value) { + return in_array($value, $this->_stack); + } + + /** + * Clear the stack + */ + public function clear() { + $this->_stack = array(); + } // function push() + + /** + * Return an array of all entries on the stack + * + * @return mixed[] + */ + public function showStack() { + return $this->_stack; + } + + public function setValueByKey($key, $value) { + $this->_values[$key] = $value; + } + + public function getValueByKey($key, &$value) { + if (isset($this->_values[$key])) { + $value = $this->_values[$key]; + return true; + } + return false; + } + + public function removeValueByKey($key) { + if (isset($this->_values[$key])) { + unset($this->_values[$key]); + } + } + + public function showValues() { + return $this->_values; + } + +} // class PHPExcel_CalcEngine_CyclicReferenceStack