コード例 #1
0
ファイル: Graph.php プロジェクト: kirkbauer2/kirkxc
 /**
  * So called "re-plant" operation: change node parent
  *
  * @param \Includes\DataStructure\Graph $oldParent Replant from
  * @param \Includes\DataStructure\Graph $newParent Replant to
  *
  * @return void
  */
 public function replant(\Includes\DataStructure\Graph $oldParent, \Includes\DataStructure\Graph $newParent)
 {
     $oldParent->removeChild($this);
     $newParent->addChild($this);
 }
コード例 #2
0
ファイル: CommonGraph.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Remove child node
  *
  * @param \Includes\DataStructure\Graph $node Node to remove
  *
  * @return void
  */
 public function removeChild(\Includes\DataStructure\Graph $node)
 {
     foreach ($this->getChildren() as $index => $child) {
         if ($node->getKey() === $child->getKey()) {
             $node->setParent(null);
         }
     }
     parent::removeChild($node);
 }
コード例 #3
0
ファイル: Graph.php プロジェクト: kingsj/core
 /**
  * So called "re-plant" operation: change node parent
  *
  * @param self $oldParent Replant from
  * @param self $newParent Replant to
  *
  * @return void
  */
 public function replant(self $oldParent, self $newParent)
 {
     $oldParent->removeChild($this);
     $newParent->addChild($this);
 }