<commit_before>package com.edinarobotics.zed.vision;

import com.sun.squawk.util.Arrays;
import com.sun.squawk.util.MathUtils;
import com.sun.squawk.util.StringTokenizer;

public class TargetCollection {
    private Target[] targets;
    
    public TargetCollection(String targetData) {
        if(!(targetData.equals(""))) {
            StringTokenizer targetTokenizer = new StringTokenizer(targetData, ":");
            targets = new Target[targetTokenizer.countTokens()];
            int currentTarget = 0;
            try {
                while(targetTokenizer.hasMoreTokens()) {
                    StringTokenizer targetDataTokenizer = new StringTokenizer(targetTokenizer.nextToken(), ",");
                    double x = Double.parseDouble(targetDataTokenizer.nextToken());
                    double y = Double.parseDouble(targetDataTokenizer.nextToken());
                    double distance = Double.parseDouble(targetDataTokenizer.nextToken());
                    boolean isCenter = targetDataTokenizer.nextToken().equals("1");

                    targets[currentTarget] = new Target(x, y, distance, isCenter);
                    currentTarget++;
                }
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    /**
     * Returns a copy of the internal Target array used by this TargetCollection.
     * @return A Target array equivalent to that used internally by TargetCollection.
     */
    public Target[] getTargets(){
        return (Target[])Arrays.copy(targets);
    }
    
    /**
     * Returns an array of all targets of the specified type.
     * If {@code centerTarget} is {@code true}, this method returns all center
     * (high) goals. If {@code centerTarget} is {@code false}, this method
     * returns all non-center (middle) goals.
     * @param centerTarget A boolean value indicating whether to return
     * high or medium Target objects.
     * @return An array of all targets meeting the specified criteria.
     */
    public Target[] filterByType(boolean centerTarget){
        int count = 0;
        for(int i = 0; i < targets.length; i++){
            Target target = targets[i];
            if(target.isCenter() == centerTarget){
                count++;
            }<commit_msg>Add additional constructors to TargetCollection.<commit_after>package com.edinarobotics.zed.vision;

import com.sun.squawk.util.Arrays;
import com.sun.squawk.util.MathUtils;
import com.sun.squawk.util.StringTokenizer;

public class TargetCollection {
    private Target[] targets;
    
    /**
     * Creates a new TargetCollection with Target objects created from the String,
     * {@code targetData}. The string has the format
     * "[x(double)],[y(double)],[distance(double)],[isCenter(1/0)]:[repeat]:[...]:".
     * @param targetData The Target data string to be parsed into a new TargetCollection.
     */
    public TargetCollection(String targetData) {
        if(!(targetData.equals(""))) {
            StringTokenizer targetTokenizer = new StringTokenizer(targetData, ":");
            targets = new Target[targetTokenizer.countTokens()];
            int currentTarget = 0;
            try {
                while(targetTokenizer.hasMoreTokens()) {
                    StringTokenizer targetDataTokenizer = new StringTokenizer(targetTokenizer.nextToken(), ",");
                    double x = Double.parseDouble(targetDataTokenizer.nextToken());
                    double y = Double.parseDouble(targetDataTokenizer.nextToken());
                    double distance = Double.parseDouble(targetDataTokenizer.nextToken());
                    boolean isCenter = targetDataTokenizer.nextToken().equals("1");

                    targets[currentTarget] = new Target(x, y, distance, isCenter);
                    currentTarget++;
                }
            }
            catch(Exception e) {
                e.printStackTrace();
            }
        }
    }
    
    /**
     * Constructs a new TargetCollection containing the Target
     * objects given in {@code targets}.
     * @param targets The Target objects to be stored in the new TargetCollection.
     */
    public TargetCollection(Target[] targets){
        this.targets = (Target[])Arrays.copy(targets);
    }
    
    /**
     * Clones a given TargetCollection.
     * @param targetCollection The TargetCollection instance to be cloned.
     */
    public TargetCollection(TargetCollection targetCollection){
        targets = targetCollection.getTargets();
    }
    
    /**
     * Returns a copy of the internal Target array used by this TargetCollection.
     * @return A Target array equivalent to that used internally by TargetCollection.
     */
    public Target[] getTargets(){
        return (Target[])Arrays.copy(targets);
    }
    
    /**
     * Returns an array of all targets of the specified type.
     * If {@code centerTarget} is {@code true}, this method returns all center
     * (high) goals. If {@code centerTarget} is {@code false}, this method
     * returns all non-center (middle) goals.
     * @param centerTarget A boolean value indicating whether to return
     * high or medium Target objects.
     * @return An array of all targets meeting the specified criteria.
     */
    public Target[] filterByType(boolean centerTarget){
        int count = 0;
        for(int i = 0; i < targets.length; i++){
            Target target = targets[i];
            if(target.isCenter() == centerTarget){
                count++;
            }
{'fraction_non_alphanumeric': 0.10016242555495398, 'fraction_numerical': 0.001804728388377549, 'mean_word_length': 2.3205512282804075, 'pattern_counts': {'":': 2, '<': 5, '<?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': '7483359', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1351, 'n_words': 408}