
aima.core.util.Converter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
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