<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses('util.XPIterator');

  /**
   * Iterator over the keys of a Hashmap object
   *
   * Usage code snippet:
   * <code>
   *   // ...
   *   for ($i= $hash->iterator(); $i->hasNext(); ) {
   *     $key= $i->next();
   *     var_dump($key, $hash->get($key));
   *   }
   *   // ...
   * </code>
   *
   * @see      xp://util.Hashmap
   * @purpose  Iterator
   */
  class HashmapIterator extends Object implements XPIterator {
    public
      $_hash    = NULL,
      $_key     = FALSE;
  
    /**
     * Constructor
     *
     * @param   &array hash
     * @see     xp://util.Hashmap#iterator
     */
    public function __construct($hash) {
      $this->_hash= $hash;
      reset($this->_hash);
    }
  
    /**
     * Returns true if the iteration has more elements. (In other words, 
     * returns true if next would return an element rather than throwing 
     * an exception.)
     *
     * @return  bool
     */
    public function hasNext() {
      return !is_null($this->_key= key($this->_hash));
    }
    
    /**
     * Returns the next element in the iteration.
     *
     * @return  &mixed
     * @throws  util.NoSuchElementException when there are no more elements
     */
    public function next() {
      if (is_null($this->_key)) {
        throw(new NoSuchElementException('No more elements'));
      }
      next($this->_hash);
      return $this->_key;
    }
  } 
?><commit_msg>- fix: HashmapIterator::next did return the key instead of the value<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  uses('util.XPIterator');

  /**
   * Iterator over the keys of a Hashmap object
   *
   * Usage code snippet:
   * <code>
   *   // ...
   *   for ($i= $hash->iterator(); $i->hasNext(); ) {
   *     $key= $i->next();
   *     var_dump($key, $hash->get($key));
   *   }
   *   // ...
   * </code>
   *
   * @see      xp://util.Hashmap
   * @purpose  Iterator
   */
  class HashmapIterator extends Object implements XPIterator {
    public
      $_hash    = NULL,
      $_key     = FALSE;
  
    /**
     * Constructor
     *
     * @param   &array hash
     * @see     xp://util.Hashmap#iterator
     */
    public function __construct($hash) {
      $this->_hash= $hash;
      reset($this->_hash);
    }
  
    /**
     * Returns true if the iteration has more elements. (In other words, 
     * returns true if next would return an element rather than throwing 
     * an exception.)
     *
     * @return  bool
     */
    public function hasNext() {
      return !is_null($this->_key= key($this->_hash));
    }
    
    /**
     * Returns the next element in the iteration.
     *
     * @return  &mixed
     * @throws  util.NoSuchElementException when there are no more elements
     */
    public function next() {
      if (is_null($this->_key)) {
        throw(new NoSuchElementException('No more elements'));
      }
      next($this->_hash);
      return $this->_hash[$this->_key];
    }
  } 
?>
{'fraction_non_alphanumeric': 0.1465261771485018, 'fraction_numerical': 0.0, 'mean_word_length': 1.9183477425552353, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 32, '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': '1069172', 'n_tokens_mistral': 978, 'n_tokens_neox': 952, 'n_words': 250}