All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.artclod.common.collect.FList Maven / Gradle / Ivy

There is a newer version: 0.0.15
Show newest version
package com.artclod.common.collect;

import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;

import com.google.common.collect.Ordering;

public interface FList extends List, FCollection {

	public ImFList toIm();
	
	public FList filter(Predicate filter);

	public FList filterNot(Predicate filter);

	public  FList map(Function f);

	public  FList flatMap(Function> mapper);

	public String mkString(String sep);

	public String mkString(String start, String sep, String end);
	
	/**
	 * This is the same as {@link java.util.List#sort(Comparator)} but it returns the list.
	 * 
	 * @param c the comparator that should be used
	 * @return the current list
	 */
	public default FList sortBy(Comparator c) {
	    List.super.sort(c);
	    return this;
	}
	
	/**
	 * This method assumes the elements of the list are comparable and uses the "natural" comparator to sort them.
	 * Note that it is up to the user of this method to ensure the elements implement {@link java.lang.Comparable} no compile time guarantee is ensured.
	 * 
     * @return the current list (which will be sorted)
	 */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    default FList sort() {
        Ordering natural = Ordering.natural();
        return sortBy(natural);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy