<commit_before><?php

/**
 * Hoa Framework
 *
 *
 * @license
 *
 * GNU General Public License
 *
 * This file is part of Hoa Open Accessibility.
 * Copyright (c) 2007, 2008 <NAME>. All rights reserved.
 *
 * HOA Open Accessibility is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * HOA Open Accessibility is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HOA Open Accessibility; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @category    Framework
 * @package     Hoa_Tree
 * @subpackage  Hoa_Tree_Abstract
 *
 */

/**
 * Hoa_Framework
 */
require_once 'Framework.php';

/**
 * Hoa_Tree_Exception
 */
import('Tree.Exception');

/**
 * Hoa_Visitor_Element
 */
import('Visitor.Element');

/**
 * Class Hoa_Tree_Abstract.
 *
 * Here is an abstract tree.
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2007, 2008 <NAME>.
 * @license     http://gnu.org/licenses/gpl.txt GNU GPL
 * @since       PHP 5
 * @version     0.1
 * @package     Hoa_Tree
 * @subpackage  Hoa_Tree_Abstract
 */

abstract class Hoa_Tree_Abstract
    implements Hoa_Visitor_Element,
               Iterator,
               SeekableIterator,
               Countable {

    /**
     * Node value.
     *
     * @var Hoa_Tree_Abstract mixed
     */
    protected $_value  = null;

    /**
     * List of childs.
     *
     * @var Hoa_Tree_Abstract array
     */
    protected $_childs = array();


    /**
     * Build a node. It can be a root, a node or a leaf of course.
     *
     * @access  public
     * @param   mixed   $value    Node value.
     * @return  void
     */
    public function __construct ( $value ) {

        $this->setValue($value);

        return;
    }

    /**
     * Set the node value.
     *
     * @access  public
     * @param   mixed   $value     Node value.
     * @return  mixed
     */
    public function setValue ( $value ) {

        $old          = $this->_value;
        $this->_value = $value;

        return $old;
    }

    /**
     * Get the node value.
     *
     * @access  public
     * @return  mixed
     */
    public function getValue ( ) {

        return $this->_value;
    }

    /**
     * Get the current child for the iterator.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function current ( ) {

        return current($this->_childs);
    }

    /**
     * Get the current child id for the iterator.
     *
     * @access  public
     * @return  int
     */
    public function key ( ) {

        return key($this->_childs);
    }

    /**
     * Advance the internal child pointer, and return the current child.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function next ( ) {

        return next($this->_childs);
    }

    /**
     * Rewind the internal child pointer, and return the first child.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function rewind ( ) {

        return rewind($this->_childs);
    }

    /**
     * Check if there is a current element after calls to the rewind or the next
     * methods.
     *
     * @access  public
     * @return  bool
     */
    public function valid ( ) {

        if(empty($this->_collection))
            return false;

        $key    = key($this->_collection);
        $return = (bool) next($this->_childs);
        prev($this->_collection);

        if(false === $return) {

            end($this->_childs);
            if($key === key($this->_childs))
                $return = true;
        }

        return $return;
    }<commit_msg>Oops, replace the rewind() function by reset().<commit_after><?php

/**
 * Hoa Framework
 *
 *
 * @license
 *
 * GNU General Public License
 *
 * This file is part of Hoa Open Accessibility.
 * Copyright (c) 2007, 2008 <NAME>. All rights reserved.
 *
 * HOA Open Accessibility is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * HOA Open Accessibility is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HOA Open Accessibility; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @category    Framework
 * @package     Hoa_Tree
 * @subpackage  Hoa_Tree_Abstract
 *
 */

/**
 * Hoa_Framework
 */
require_once 'Framework.php';

/**
 * Hoa_Tree_Exception
 */
import('Tree.Exception');

/**
 * Hoa_Visitor_Element
 */
import('Visitor.Element');

/**
 * Class Hoa_Tree_Abstract.
 *
 * Here is an abstract tree.
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2007, 2008 <NAME>.
 * @license     http://gnu.org/licenses/gpl.txt GNU GPL
 * @since       PHP 5
 * @version     0.1
 * @package     Hoa_Tree
 * @subpackage  Hoa_Tree_Abstract
 */

abstract class Hoa_Tree_Abstract
    implements Hoa_Visitor_Element,
               Iterator,
               SeekableIterator,
               Countable {

    /**
     * Node value.
     *
     * @var Hoa_Tree_Abstract mixed
     */
    protected $_value  = null;

    /**
     * List of childs.
     *
     * @var Hoa_Tree_Abstract array
     */
    protected $_childs = array();


    /**
     * Build a node. It can be a root, a node or a leaf of course.
     *
     * @access  public
     * @param   mixed   $value    Node value.
     * @return  void
     */
    public function __construct ( $value ) {

        $this->setValue($value);

        return;
    }

    /**
     * Set the node value.
     *
     * @access  public
     * @param   mixed   $value     Node value.
     * @return  mixed
     */
    public function setValue ( $value ) {

        $old          = $this->_value;
        $this->_value = $value;

        return $old;
    }

    /**
     * Get the node value.
     *
     * @access  public
     * @return  mixed
     */
    public function getValue ( ) {

        return $this->_value;
    }

    /**
     * Get the current child for the iterator.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function current ( ) {

        return current($this->_childs);
    }

    /**
     * Get the current child id for the iterator.
     *
     * @access  public
     * @return  int
     */
    public function key ( ) {

        return key($this->_childs);
    }

    /**
     * Advance the internal child pointer, and return the current child.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function next ( ) {

        return next($this->_childs);
    }

    /**
     * Rewind the internal child pointer, and return the first child.
     *
     * @access  public
     * @return  Hoa_Tree_Abstract
     */
    public function rewind ( ) {

        return reset($this->_childs);
    }

    /**
     * Check if there is a current element after calls to the rewind or the next
     * methods.
     *
     * @access  public
     * @return  bool
     */
    public function valid ( ) {

        if(empty($this->_collection))
            return false;

        $key    = key($this->_collection);
        $return = (bool) next($this->_childs);
        prev($this->_collection);

        if(false === $return) {

            end($this->_childs);
            if($key === key($this->_childs))
                $return = true;
        }

        return $return;
    }
{'fraction_non_alphanumeric': 0.10714720564957994, 'fraction_numerical': 0.007549007670765859, 'mean_word_length': 1.956803455723542, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365947', 'n_tokens_mistral': 2483, 'n_tokens_neox': 2371, 'n_words': 776}