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

uk.ac.shef.dcs.sti.util.SubsetGenerator Maven / Gradle / Ivy

The newest version!
package uk.ac.shef.dcs.sti.util;

import com.google.common.collect.Sets;

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

/**
 * Created by zqz on 29/04/2015.
 */
public class SubsetGenerator {

    public static List generateSubsets(Set words){
        Set> subsets = Sets.powerSet(words);
        List result = new ArrayList<>();
        for(Set sub: subsets){
            List ordered = new ArrayList<>(sub);
            Collections.sort(ordered);
            String string = "";
            for(Integer a: ordered){
                string+=a+" ";
            }
            result.add(string.trim());
        }
        result.remove("");
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy