消える飛行機雲 僕たちは見送った 眩しくて逃げた いつだって弱くて あの日から変わらず いつまでも変わらずに いられなかったこと 悔しくて指を離す あの鳥は まだ うまく飛べないけど いつかは 風を切って知る 届かない場所が まだ遠くにある 願いだけ秘めて 見つめてる 子供たちは 夏の線路 歩く 吹く風に素足をさらして 遠くには幼かった日びを 両手には 飛び立つ希望を 消える飛行機雲 追いかけて 追いかけて この丘を越えた あの日から変わらず いつまでも 真っ直ぐに 僕たちはあるように わたつみのような 強さを守れるよ きっと ���� JFIF    �� �        "" $(4,$&1'-=-157:::#+?D?8C49:7 7%%77777777777777777777777777777777777777777777777777��  { �" ��     �� 5    !1AQa"q�2��BR��#b�������  ��  ��   ? ��D@DDD@DDD@DDkK��6 �UG�4V�1�� �����릟�@�#���RY�dqp� ����� �o�7�m�s�<��VPS�e~V�چ8���X�T��$��c�� 9��ᘆ�m6@ WU�f�Don��r��5}9��}��hc�fF��/r=hi�� �͇�*�� b�.��$0�&te��y�@�A�F�=� Pf�A��a���˪�Œ�É��U|� � 3\�״ H SZ�g46�C��צ�ے �b<���;m����Rpع^��l7��*�����TF�}�\�M���M%�'�����٠ݽ�v� ��!-�����?�N!La��A+[`#���M����'�~oR�?��v^)��=��h����A��X�.���˃����^Ə��ܯsO"B�c>; �e�4��5�k��/CB��.  �J?��;�҈�������������������~�<�VZ�ꭼ2/)Í”jC���ע�V�G�!���!�F������\�� Kj�R�oc�h���:Þ I��1"2�q×°8��Р@ז���_C0�ր��A��lQ��@纼�!7��F�� �]�sZ B�62r�v�z~�K�7�c��5�.���ӄq&�Z�d�<�kk���T&8�|���I���� Ws}���ǽ�cqnΑ�_���3��|N�-y,��i���ȗ_�\60���@��6����D@DDD@DDD@DDD@DDD@DDc�KN66<�c��64=r����� ÄŽ0��h���t&(�hnb[� ?��^��\��â|�,�/h�\��R��5�? �0�!צ܉-����G����٬��Q�zA���1�����V��� �:R���`�$��ik��H����D4�����#dk����� h�}����7���w%�������*o8wG�LycuT�.���ܯ7��I��u^���)��/c�,s�Nq�ۺ�;�ך�YH2���.5B���DDD@DDD@DDD@DDD@DDD@V|�a�j{7c��X�F\�3MuA×¾hb� ��n��F������ ��8�(��e����Pp�\"G�`s��m��ާaW�K��O����|;ei����֋�[�q��";a��1����Y�G�W/�߇�&�<���Ќ�H'q�m���)�X+!���=�m�ۚ丷~6a^X�)���,�>#&6G���Y��{����"" """ """ """ """ ""��at\/�a�8 �yp%�lhl�n����)���i�t��B�������������?��modskinlienminh.com - WSOX ENC ‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT h25jguaT5*!‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT h25jguaT5*!# Tree [![Integrate](https://github.com/nicmart/Tree/workflows/Integrate/badge.svg?branch=master)](https://github.com/nicmart/Tree/actions) [![Release](https://github.com/nicmart/Tree/workflows/Release/badge.svg?branch=master)](https://github.com/nicmart/Tree/actions) [![Latest Stable Version](https://poser.pugx.org/nicmart/tree/v/stable)](https://packagist.org/packages/nicmart/tree) [![Total Downloads](https://poser.pugx.org/nicmart/tree/downloads)](https://packagist.org/packages/nicmart/tree) [![License](https://poser.pugx.org/nicmart/tree/license)](https://packagist.org/packages/nicmart/tree) In Tree you can find a basic but flexible tree data structure for php together with and an handful Builder class, that enables you to build tree in a fluent way. ## The tree data structure The `Tree\Node\NodeInterface` interface abstracts the concept of a tree node. In `Tree` a Node has essentially two things: a set of children (that implements the same `NodeInterface` interface) and a value. On the other hand, the `Tree\Node\Node` gives a straight implementation for that interface. ### Creating a node ```php use Tree\Node\Node; $node = new Node('foo'); ``` ### Getting and setting the value of a node Each node has a value property, that can be any php value. ```php $node->setValue('my value'); echo $node->getValue(); //Prints 'my value' ``` ### Adding one or more children ```php $child1 = new Node('child1'); $child2 = new Node('child2'); $node ->addChild($child1) ->addChild($child2); ``` ### Removing a child ```php $node->removeChild($child1); ``` ### Getting the array of all children ```php $children = $node->getChildren(); ``` ### Overwriting the children set ```php $node->setChildren([new Node('foo'), new Node('bar')]); ``` ### Removing all children ```php $node->removeAllChildren(); ``` ### Getting if the node is a leaf or not A leaf is a node with no children. ```php $node->isLeaf(); ``` ### Getting if the node is a child or not A child is a node that has a parent. ```php $node->isChild(); ``` ### Getting the parent of a node Reference to the parent node is automatically managed by child-modifiers methods ```php $root->addChild($node = new Node('child')); $node->getParent(); // Returns $root ``` ### Getting the ancestors of a node ```php $root = (new Node('root')) ->addChild($child = new Node('child')) ->addChild($grandChild = new Node('grandchild')) ; $grandchild->getAncestors(); // Returns [$root, $child] ``` #### Related Methods - `getAncestorsAndSelf` retrieves ancestors of a node with the current node included. ### Getting the root of a node ```php $root = $node->root(); ``` ### Getting the neighbors of a node ```php $root = (new Node('root')) ->addChild($child1 = new Node('child1')) ->addChild($child2 = new Node('child2')) ->addChild($child3 = new Node('child3')) ; $child2->getNeighbors(); // Returns [$child1, $child3] ``` #### Related Methods - `getNeighborsAndSelf` retrieves neighbors of current node and the node itself. ### Getting the number of nodes in the tree ```php $node->getSize(); ``` ### Getting the depth of a node ```php $node->getDepth(); ``` ### Getting the height of a node ```php $node->getHeight(); ``` ## The Builder The builder provides a convenient way to build trees. It is provided by the ```Builder``` class, but you can implement your own builder making an implementation of the ```BuilderInterface```class. ### Example Let's see how to build the following tree, where the nodes label are represents nodes values: ``` A / \ B C /|\ D E F /| G H ``` And here is the code: ```php $builder = new Tree\Builder\NodeBuilder; $builder ->value('A') ->leaf('B') ->tree('C') ->tree('D') ->leaf('G') ->leaf('H') ->end() ->leaf('E') ->leaf('F') ->end() ; $nodeA = $builder->getNode(); ``` The example should be self-explanatory, but here you are a brief description of the methods used above. ### Builder::value($value) Set the value of the current node to ```$value``` ### Builder::leaf($value) Add to the current node a new child whose value is ```$value```. ### Builder::tree($value) Add to the current node a new child whose value is ```$value```, and set the new node as the builder current node. ### Builder::end() Returns to the context the builder was before the call to ```tree```method, i.e. make the builder go one level up. ### Builder::getNode() Returns the current node. ## Traversing a tree ### Yield You can obtain the yield of a tree (i.e. the list of leaves in a pre-order traversal) using the YieldVisitor. For example, if `$node` is the tree built above, then ```php use Tree\Visitor\YieldVisitor; $visitor = new YieldVisitor; $yield = $node->accept($visitor); // $yield will contain nodes B, G, H, E, F ``` ### Pre-order Traversal You can walk a tree in pre-order: ```php use Tree\Visitor\PreOrderVisitor; $visitor = new PreOrderVisitor; $yield = $node->accept($visitor); // $yield will contain nodes A, B, C, D, G, H, E, F ``` ### Post-order Traversal You can walk a tree in post-order: ```php use Tree\Visitor\PostOrderVisitor; $visitor = new PostOrderVisitor; $yield = $node->accept($visitor); // $yield will contain nodes B, G, H, D, E, F, C, A ``` ## Install The best way to install Tree is [through composer](http://getcomposer.org). Just create a composer.json file for your project: ```JSON { "require": { "nicmart/tree": "~0.2" } } ``` Then you can run these two commands to install it: $ curl -s http://getcomposer.org/installer | php $ php composer.phar install or simply run `composer install` if you have have already [installed the composer globally](http://getcomposer.org/doc/00-intro.md#globally). Then you can include the autoloader, and you will have access to the library classes: ```php