Example usage for com.google.common.collect Sets newTreeSet

List of usage examples for com.google.common.collect Sets newTreeSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newTreeSet.

Prototype

public static <E extends Comparable> TreeSet<E> newTreeSet() 

Source Link

Document

Creates a mutable, empty TreeSet instance sorted by the natural sort ordering of its elements.

Usage

From source file:indigo.impl.javaclass.JavaClassSpecification.java

public JavaClassSpecification(Class<?> javaClass) {
    super(javaClass.getName());
    this.javaClass = javaClass;
    this.dependenciesForPredicateName = Maps.newTreeMap();
    this.constrainedSets = Sets.newTreeSet();
    init();/*from  w w  w. ja  v a 2s . co m*/
}

From source file:de.xaniox.heavyspleef.core.flag.FlagManager.java

public FlagManager(JavaPlugin plugin, GamePropertyBundle defaults, boolean migrateManager) {
    this.plugin = plugin;
    this.defaults = defaults;
    this.flags = HashBiMap.create();
    this.disabledFlags = Sets.newHashSet();
    this.unloadedFlags = Lists.newArrayList();
    this.propertyBundles = Sets.newTreeSet();
    this.requestedProperties = new DefaultGamePropertyBundle(Maps.newEnumMap(GameProperty.class));
    this.migrateManager = migrateManager;
}

From source file:com.threerings.presents.tools.cpp.GenCPPReceiverTask.java

@Override
protected void generateDecoder(Class<?> receiver, File source, String rname, String rpackage,
        List<ServiceMethod> methods, ImportSet imports, String rcode) throws Exception {
    String dname = rname.replace("Receiver", "Decoder");

    Map<String, Object> ctx = Maps.newHashMap();
    List<String> namespaces = CPPUtil.makeNamespaces(receiver);
    ctx.put("receiverName", rname);
    ctx.put("decoderName", dname);
    ctx.put("namespaces", namespaces);
    ctx.put("namespace", CPPUtil.makeNamespace(receiver));
    ctx.put("package", rpackage);
    ctx.put("methods", MethodDescriptor.from(methods));
    ctx.put("receiverCode", rcode);
    ctx.put("argbuilder", new CPPArgBuilder());

    writeTemplate(DECODER_HEADER_TMPL, makePath(_cpproot, namespaces, dname, ".h"), ctx);

    Set<String> receiverHeaderIncludes = Sets.newTreeSet();
    Set<String> decoderImplIncludes = Sets.newTreeSet();
    for (ServiceMethod meth : methods) {
        for (Type type : meth.method.getGenericParameterTypes()) {
            CPPType cppType = new CPPType(type);
            if (cppType.primitive) {
                decoderImplIncludes.add("presents/box/Boxed" + cppType.interpreter + ".h");
            }/* w ww.j ava  2  s  . com*/
            while (cppType != null) {
                if (cppType.representationImport != null) {
                    receiverHeaderIncludes.add(cppType.representationImport);
                }
                cppType = cppType.dependent;
            }
        }
    }

    ctx.put("includes", decoderImplIncludes);
    writeTemplate(DECODER_CPP_TMPL, makePath(_cpproot, namespaces, dname, ".cpp"), ctx);
    ctx.put("includes", receiverHeaderIncludes);
    writeTemplate(RECEIVER_HEADER_TMPL, makePath(_cpproot, namespaces, rname, ".h"), ctx);

    super.generateDecoder(receiver, source, rname, rpackage, methods, imports, rcode);
}

From source file:com.gwtplatform.dispatch.rest.rebind.resource.AbstractResourceGenerator.java

@Override
public ResourceDefinition generate(ResourceContext context) throws UnableToCompleteException {
    setContext(context);/*from   w  ww .j  a  v a  2s.c  o m*/

    PrintWriter printWriter = tryCreate();
    if (printWriter != null) {
        imports = Sets.newTreeSet();
        imports.add(getResourceType().getQualifiedSourceName());

        generateMethods();

        mergeTemplate(printWriter);
        commit(printWriter);
    }

    return getResourceDefinition();
}

From source file:edu.harvard.med.screensaver.model.libraries.PlateSize.java

public Set<WellName> getEdgeWellNames(int n) {
    Set<WellName> emptyWells = Sets.newTreeSet();
    for (int i = 0; i < n; ++i) {
        for (int row = 0; row < getRows(); ++row) {
            for (int col = 0; col < getColumns(); ++col) {
                if (row < n || row >= getRows() - n || col < n || col >= getColumns() - n) {
                    emptyWells.add(new WellName(row, col));
                }// ww  w  .j av a 2s.c  o  m
            }
        }
    }
    return emptyWells;
}

From source file:com.cloudera.science.pig.Combinatorial.java

@Override
public DataBag exec(Tuple input) throws IOException {
    try {/*from   ww  w  .  j  a  v  a2 s .co  m*/
        DataBag output = bagFactory.newDefaultBag();
        Object o = input.get(0);
        if (!(o instanceof DataBag)) {
            throw new IOException("Expected input to be a bag, but got: " + o.getClass().getName());
        }
        DataBag inputBag = (DataBag) o;
        Set<Comparable> uniqs = Sets.newTreeSet();
        for (Tuple t : inputBag) {
            if (t != null && t.get(0) != null) {
                uniqs.add((Comparable) t.get(0));
            }
        }
        if (uniqs.size() < arity) {
            return output;
        }
        List<Comparable> values = Lists.newArrayList(uniqs);
        Comparable[] subset = new Comparable[arity];

        process(values, subset, 0, 0, output);

        return output;
    } catch (ExecException e) {
        throw new IOException(e);
    }
}

From source file:eu.interedition.text.util.AbstractAnnotationRepository.java

@Override
public Iterable<Annotation> find(Criterion criterion) {
    final SortedSet<Annotation> result = Sets.newTreeSet();
    scroll(criterion, new AnnotationConsumer() {
        @Override/*from   ww  w  . j  a  v  a 2  s  .c o m*/
        public void consume(Annotation annotation) {
            result.add(annotation);
        }
    });
    return result;
}

From source file:de.tuberlin.uebb.jdae.transformation.DerivedEquation.java

public Collection<GlobalVariable> need() {
    if (set == null) {
        set = Sets.newTreeSet();
        for (int d = 0; d <= (maxOrder - minOrder); d++) {
            for (GlobalVariable v : eqn.need()) {
                set.add(v.der(d));/*from ww  w .  j  av a 2 s . com*/
            }
        }
    }
    return set;
}

From source file:org.geogit.api.porcelain.CheckoutOp.java

@Inject
public CheckoutOp() {
    paths = Sets.newTreeSet();
}

From source file:org.spdx.rdfparser.VerificationCodeGenerator.java

/**
 * Generate the SPDX Package Verification Code from an array of SPDXFiles
 * @param spdxFiles Files to generate the VerificationCode from
 * @param skippedFilePaths File path names to not include in the VerificationCode
 * @return VerificationCode based on all files in spdxFiles minus the skippedFilePaths
 * @throws NoSuchAlgorithmException/*from  www .  j av a 2s  .c o  m*/
 */
public SpdxPackageVerificationCode generatePackageVerificationCode(SpdxFile[] spdxFiles,
        String[] skippedFilePaths) throws NoSuchAlgorithmException {
    if (spdxFiles == null) {
        return null;
    }
    Set<String> skippedFilePathSet = Sets.newTreeSet();
    if (skippedFilePaths != null) {
        for (int i = 0; i < skippedFilePaths.length; i++) {
            if (skippedFilePaths[i] != null) {
                skippedFilePathSet.add(skippedFilePaths[i]);
            }
        }
    }
    List<String> fileChecksums = Lists.newArrayList();
    for (int i = 0; i < spdxFiles.length; i++) {
        if (spdxFiles[i] != null && spdxFiles[i].getName() != null
                && !skippedFilePathSet.contains(spdxFiles[i].getName())) {
            fileChecksums.add(spdxFiles[i].getSha1());
        }
    }
    return generatePackageVerificationCode(fileChecksums, skippedFilePaths);
}