<commit_before>package etomica.atom;

import etomica.api.IAtom;
import etomica.api.IAtomList;
import etomica.api.IMolecule;
import etomica.api.ISpecies;

public class Molecule implements IMolecule, java.io.Serializable {

    public Molecule(ISpecies species) {
        this.species = species;
        childList = new AtomArrayList(species.getNumLeafAtoms());
    }
    
    /**
     * Returns a string of digits that uniquely identifies this atom.  String is
     * formed by concatenating the ordinal of this atom to the signature
     * given by the parent of this atom.  If atom has no parent, forms a string
     * from only the ordinal.
     */
    public String signature() {
        return species.getIndex()+" "+index;
    }

    /**
     * Returns a string formed by concatenating the signature of this atom
     * to a string that identifies it as a molecule.
     */
    public final String toString() {
        return "Molecule(" + getType().getIndex()+" "+index + ")";
    }

    /**
     * Adds the given Atom as a child of this Atom.  The given child Atom
     * should be parentless when this method is called.
     * @throws IllegalArgumentException if the given atom already has a parent.
     */
    public void addChildAtom(IAtom newChildAtom) {
        if(newChildAtom.getParentGroup() != null) {//new parent is null
            throw new IllegalArgumentException(newChildAtom+" is already the child of "+newChildAtom.getParentGroup());
        }

        newChildAtom.setParent(this);

        newChildAtom.setIndex(childList.getAtomCount());
        childList.add(newChildAtom);
    }
    
    /**
     * Removes the given child Atom from this AtomGroup.
     * @throws IllegalArgumentException if the given atom is not a child.
     */
    public void removeChildAtom(IAtom oldChildAtom) {
        for (int i=0; i<childList.getAtomCount(); i++) {
            if (childList.getAtom(i) == oldChildAtom) {
                oldChildAtom.setParent(null);
                childList.removeAndReplace(i);
                childList.maybeTrimToSize();
                if (childList.getAtomCount() > i) {
                    // reassign the old last Atom (which is now in the removed
                    // Atom's place) to have the old Atom's index.
                    ((IAtom)childList.getAtom(i)).setIndex(i);
                }
                return;
            }
        }
        throw new IllegalArgumentException(oldChildAtom+" is not a child");
    }

    /**
     * @return the childList
     */
    public final IAtomList getChildList() {
        return childList;
    }
    
    public final void setIndex(int newIndex) {<commit_msg>don't need to cast anymore<commit_after>package etomica.atom;

import etomica.api.IAtom;
import etomica.api.IAtomList;
import etomica.api.IMolecule;
import etomica.api.ISpecies;

public class Molecule implements IMolecule, java.io.Serializable {

    public Molecule(ISpecies species) {
        this.species = species;
        childList = new AtomArrayList(species.getNumLeafAtoms());
    }
    
    /**
     * Returns a string of digits that uniquely identifies this atom.  String is
     * formed by concatenating the ordinal of this atom to the signature
     * given by the parent of this atom.  If atom has no parent, forms a string
     * from only the ordinal.
     */
    public String signature() {
        return species.getIndex()+" "+index;
    }

    /**
     * Returns a string formed by concatenating the signature of this atom
     * to a string that identifies it as a molecule.
     */
    public final String toString() {
        return "Molecule(" + getType().getIndex()+" "+index + ")";
    }

    /**
     * Adds the given Atom as a child of this Atom.  The given child Atom
     * should be parentless when this method is called.
     * @throws IllegalArgumentException if the given atom already has a parent.
     */
    public void addChildAtom(IAtom newChildAtom) {
        if(newChildAtom.getParentGroup() != null) {//new parent is null
            throw new IllegalArgumentException(newChildAtom+" is already the child of "+newChildAtom.getParentGroup());
        }

        newChildAtom.setParent(this);

        newChildAtom.setIndex(childList.getAtomCount());
        childList.add(newChildAtom);
    }
    
    /**
     * Removes the given child Atom from this AtomGroup.
     * @throws IllegalArgumentException if the given atom is not a child.
     */
    public void removeChildAtom(IAtom oldChildAtom) {
        for (int i=0; i<childList.getAtomCount(); i++) {
            if (childList.getAtom(i) == oldChildAtom) {
                oldChildAtom.setParent(null);
                childList.removeAndReplace(i);
                childList.maybeTrimToSize();
                if (childList.getAtomCount() > i) {
                    // reassign the old last Atom (which is now in the removed
                    // Atom's place) to have the old Atom's index.
                    childList.getAtom(i).setIndex(i);
                }
                return;
            }
        }
        throw new IllegalArgumentException(oldChildAtom+" is not a child");
    }

    /**
     * @return the childList
     */
    public final IAtomList getChildList() {
        return childList;
    }
    
    public final void setIndex(int newIndex) {
{'fraction_non_alphanumeric': 0.08959429000751315, 'fraction_numerical': 0.0003756574004507889, 'mean_word_length': 2.2449725776965264, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7289244', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1482, 'n_words': 468}