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

aima.core.util.Converter Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

There is a newer version: 3.0.0
Show newest version
package aima.core.util;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * @author Ravi Mohan
 * @author Mike Stampone
 */
public class Converter {

	/**
	 * Converts a Set into a List
	 * 
	 * @param set
	 *            a collection of unique objects
	 * 
	 * @return a new list containing the elements of the specified set, in the
	 *         order they are returned by the set's iterator.
	 */
	public List setToList(Set set) {
		List retVal = new ArrayList(set);
		return retVal;
	}

	/**
	 * Converts a List into a Set
	 * 
	 * @param l
	 *            a list of objects, possibly containing duplicates
	 * @return a new set containing the unique elements of the specified list.
	 */
	public Set listToSet(List l) {
		Set retVal = new HashSet(l);
		return retVal;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy