diff --git a/Stdlib/Graph/BinaryTree.php b/Stdlib/Graph/BinaryTree.php new file mode 100644 index 000000000..4f481ea45 --- /dev/null +++ b/Stdlib/Graph/BinaryTree.php @@ -0,0 +1,67 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Datatypes; + +use phpOMS\Validation\Base\IbanEnum; + +/** + * Tree class. + * + * @category Framework + * @package phpOMS\Datatypes + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + * + * @todo : there is a bug with Hungary ibans since they have two k (checksums) in their definition + */ +class BinaryTree extends Tree +{ + public static function invert($list) : BinaryTree + { + if (empty($list->getNodes())) { + return $list; + } + + $left = $list->getLeft(); + $list->setLeft($list->invert($list->nodes[1])); + $list->setRight($list->invert($left)); + + return $list; + } + + public function getLeft() { + return $this->nodes[0]; + } + + public function getRight() { + return $this->nodes[1]; + } + + public function setLeft(BinaryTree $left) { + $this->nodes[0] = $left; + } + + public function setRight(BinaryTree $right) { + $this->nodes[1] = $right; + } + + public function inOrder() { + + } +} \ No newline at end of file diff --git a/Stdlib/Graph/Graph.php b/Stdlib/Graph/Graph.php new file mode 100644 index 000000000..e69de29bb diff --git a/Stdlib/Graph/Tree.php b/Stdlib/Graph/Tree.php new file mode 100644 index 000000000..9468fc5ee --- /dev/null +++ b/Stdlib/Graph/Tree.php @@ -0,0 +1,97 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Datatypes; + +use phpOMS\Validation\Base\IbanEnum; + +/** + * Tree class. + * + * @category Framework + * @package phpOMS\Datatypes + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + * + * @todo : there is a bug with Hungary ibans since they have two k (checksums) in their definition + */ +class Tree extends Graph +{ + private $nodes = []; + + public function getMaxDepth() : int + { + $depth = [0]; + + foreach($nodes as $node) { + $depth[] = $node->getMaxDepth(); + } + + return max($depth) + 1; + } + + public function getMinDepth() : int + { + $depth = [0]; + + foreach($nodes as $node) { + $depth[] = $node->getMinDepth(); + } + + return min($depth) + 1; + } + + public function postOrder() + { + + } + + public function preOrder() + { + + } + + public function levelOrder() + { + + } + + public function levelOrder2() + { + + } + + public function verticalOrder() + { + + } + + public function isLeaf() : bool + { + + } + + public function isSymmetric() : bool { + + } + + public function getDimension() : int + { + + } +} \ No newline at end of file diff --git a/Stdlib/Queue/PriorityMode.php b/Stdlib/Queue/PriorityMode.php new file mode 100644 index 000000000..9ddc1319b --- /dev/null +++ b/Stdlib/Queue/PriorityMode.php @@ -0,0 +1,39 @@ + + * @author Dennis Eichhorn + * @copyright 2013 Dennis Eichhorn + * @license OMS License 1.0 + * @version 1.0.0 + * @link http://orange-management.com + */ +namespace phpOMS\Stdlib\Queue; + +use phpOMS\Datatypes\Enum; + +/** + * Account type enum. + * + * @category Framework + * @package phpOMS\Stdlib + * @author OMS Development Team + * @author Dennis Eichhorn + * @license OMS License 1.0 + * @link http://orange-management.com + * @since 1.0.0 + */ +abstract class PrioirtyMode extends Enum +{ + const FIFO = 0; + const LIFO = 0; + const EARLIEST_DEADLINE = 0; + const SHORTEST_JOB = 0; + const HIGHEST = 0; + const LOWEST = 0; +} diff --git a/Stdlib/Queue/PriorityQueue.php b/Stdlib/Queue/PriorityQueue.php index 0ad22a04c..01150bde1 100644 --- a/Stdlib/Queue/PriorityQueue.php +++ b/Stdlib/Queue/PriorityQueue.php @@ -45,13 +45,15 @@ class PriorityQueue implements \Countable, \Serializable */ private $queue = []; + private $mode = 0; + /** * Constructor. * * @since 1.0.0 * @author Dennis Eichhorn */ - public function __construct() + public function __construct($mode = '') { } diff --git a/Utils/ArrayUtils.php b/Utils/ArrayUtils.php index 737c1c31d..20fceefa0 100644 --- a/Utils/ArrayUtils.php +++ b/Utils/ArrayUtils.php @@ -246,6 +246,18 @@ class ArrayUtils return trim($args[$key + 1], '" '); } + /** + * Flatten array + * + * Reduces multi dimensional array to one dimensional array. Flatten tries to maintain the index as far as possible. + * + * @param array $array Multi dimensional array to flatten + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function arrayFlatten(array $array) : array { @@ -265,6 +277,9 @@ class ArrayUtils return $flat; } + /** + * todo: what did i smoke? what is this? + */ public static function arraySum(array $array, int $start = 0, int $count = 0) { $count = $count === 0 ? count($array) : $count; @@ -281,6 +296,16 @@ class ArrayUtils return $sum; } + /** + * Sum multi dimensional array + * + * @param array $array Multi dimensional array to flatten + * + * @return mixed + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function arraySumRecursive(array $array) { return array_sum(self::arrayFlatten($array));