<commit_before>/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.util;

import java.lang.reflect.Array;

public abstract class AbstractCollection implements Collection {

protected AbstractCollection() {
}

public abstract Iterator iterator();

public abstract int size();

public boolean isEmpty() {
  return (size() == 0);
}

public boolean contains(Object o) {
  for (Iterator it = iterator(); it.hasNext(); ) {
    Object next = it.next();
    if (o == null ? next == null : o.equals(next)) {
      return true;
    }
  }
  return false;
}

public Object[] toArray() {
  Object[] objs = new Object[size()];
  Iterator it = iterator();
  for (int i = 0; i < objs.length; i++) {
    objs[i] = it.next();
  }
  return (objs);
}

public Object[] toArray(Object[] a) {
  final int len = size();
  if (a.length < len) {
    a = (Object[])Array.newInstance(a.getClass().getComponentType(), len);
  }
  Iterator i = iterator();
  for (int index = 0; i.hasNext(); ) {
    a[index] = i.next();
  }
  if (a.length > len) {
    a[len] = null;
  }
  return a;
}<commit_msg>Fix bug in toArray(Object[]) method.<commit_after>/*
 * Java core library component.
 *
 * Copyright (c) 1997, 1998
 *      Transvirtual Technologies, Inc.  All rights reserved.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file.
 */

package java.util;

import java.lang.reflect.Array;

public abstract class AbstractCollection implements Collection {

protected AbstractCollection() {
}

public abstract Iterator iterator();

public abstract int size();

public boolean isEmpty() {
  return (size() == 0);
}

public boolean contains(Object o) {
  for (Iterator it = iterator(); it.hasNext(); ) {
    Object next = it.next();
    if (o == null ? next == null : o.equals(next)) {
      return true;
    }
  }
  return false;
}

public Object[] toArray() {
  Object[] objs = new Object[size()];
  Iterator it = iterator();
  for (int i = 0; i < objs.length; i++) {
    objs[i] = it.next();
  }
  return (objs);
}

public Object[] toArray(Object[] a) {
  final int len = size();
  if (a.length < len) {
    a = (Object[])Array.newInstance(a.getClass().getComponentType(), len);
  }
  Iterator i = iterator();
  for (int index = 0; i.hasNext(); index++) {
    a[index] = i.next();
  }
  if (a.length > len) {
    a[len] = null;
  }
  return a;
}
{'fraction_non_alphanumeric': 0.15538945712037766, 'fraction_numerical': 0.00865460267505901, 'mean_word_length': 3.2383333333333333, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1785063', 'n_tokens_mistral': 854, 'n_tokens_neox': 822, 'n_words': 261}