<commit_before>package net.sf.kerner.utils.collections;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;

import net.sf.kerner.utils.StringUtils;
import net.sf.kerner.utils.collections.list.impl.ArrayListFactory;

public class CollectionUtils {

	private CollectionUtils() {
	}
	
	public static <C> Collection<C> append(Collection<? extends C> c1, Collection<? extends C> c2, CollectionFactory<C> factory){
		final Collection<C> result = factory.createCollection();
		result.addAll(c1);
		result.addAll(c2);
		return result;
	}
	
	public static <C> Collection<C> append(Collection<? extends C> c1, Collection<? extends C> c2){
		return append(c1, c2, new ArrayListFactory<C>());
	}
	
	public static String toString(Iterable<?> elements){
		final StringBuilder b = new StringBuilder();
		b.append(StringUtils.NEW_LINE_STRING);
		final Iterator<?> i = elements.iterator();
		while(i.hasNext()){
			b.append(i.next());
			if(i.hasNext())
				b.append(StringUtils.NEW_LINE_STRING);
		}
		return b.toString();
	}
	
	public static <T> T getHighest(Collection<? extends T> elements, Comparator<T> c){
		T result = null;
		
		for(T e : elements){
			if(result == null){
				result = e;
			} else {
				int i = c.compare(e, result);
				if(i > 0)
					result = e;
			}
		}
		<commit_msg>CollectionUtils#toString(): if param is empty, return empty string.<commit_after>package net.sf.kerner.utils.collections;

import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;

import net.sf.kerner.utils.StringUtils;
import net.sf.kerner.utils.collections.list.impl.ArrayListFactory;

public class CollectionUtils {

	private CollectionUtils() {
	}
	
	public static <C> Collection<C> append(Collection<? extends C> c1, Collection<? extends C> c2, CollectionFactory<C> factory){
		final Collection<C> result = factory.createCollection();
		result.addAll(c1);
		result.addAll(c2);
		return result;
	}
	
	public static <C> Collection<C> append(Collection<? extends C> c1, Collection<? extends C> c2){
		return append(c1, c2, new ArrayListFactory<C>());
	}
	
	public static String toString(Iterable<?> elements){
		if(!elements.iterator().hasNext())
			return "";
		final StringBuilder b = new StringBuilder();
		b.append(StringUtils.NEW_LINE_STRING);
		final Iterator<?> i = elements.iterator();
		while(i.hasNext()){
			b.append(i.next());
			if(i.hasNext())
				b.append(StringUtils.NEW_LINE_STRING);
		}
		return b.toString();
	}
	
	public static <T> T getHighest(Collection<? extends T> elements, Comparator<T> c){
		T result = null;
		
		for(T e : elements){
			if(result == null){
				result = e;
			} else {
				int i = c.compare(e, result);
				if(i > 0)
					result = e;
			}
		}
		
{'fraction_non_alphanumeric': 0.14113345521023765, 'fraction_numerical': 0.006581352833638025, 'mean_word_length': 4.231357552581262, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 37, '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': '1565180', 'n_tokens_mistral': 997, 'n_tokens_neox': 890, 'n_words': 221}