<commit_before>module java::lang::Iterable
  #include Enumerable JRuby already does this
  
  def iterate
    it = iterator
    while it.next?
      ob = it.next
      yield(it,ob)
    end
  end
=begin comment
  JRuby already contains a similar expression
  def each
    it = iterator
    while it.next?
      yield it.next
    end
  end
=end

  def delete_if
    iterate do |it,ob|
      it.remove if yield(ob)
    end
    self
  end
  
  def reject!
    ret = nil
    iterate do |it,ob|
      if yield(ob)
        it.remove 
        ret = self
      end
    end
    ret
  end
  
  def clear
    iterate {|it, o| it.remove}
    self
  end
end<commit_msg>Iterable now supports returning an enumerator<commit_after>require 'jactive_support/java_ext/iterator'

module java::lang::Iterable
  #include Enumerable JRuby already does this
  
  def iterate
    return enum_for(:iterate) unless block_given?
    it = iterator
    while it.next?
      ob = it.next
      yield(it,ob)
    end
  end
=begin comment
  JRuby already contains a similar expression
  def each
    it = iterator
    while it.next?
      yield it.next
    end
  end
=end

  def delete_if
    return enum_for(:delete_if) unless block_given?
    iterate do |it,ob|
      it.remove if yield(ob)
    end
    self
  end
  
  def reject!
    return enum_for(:reject!) unless block_given?
    ret = nil
    iterate do |it,ob|
      if yield(ob)
        it.remove 
        ret = self
      end
    end
    ret
  end
  
  def clear
    iterate {|it, o| it.remove}
    self
  end
end
{'fraction_non_alphanumeric': 0.06692657569850552, 'fraction_numerical': 0.0, 'mean_word_length': 2.0861723446893787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3856609', 'n_tokens_mistral': 533, 'n_tokens_neox': 506, 'n_words': 166}