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> TreeSet<E> newTreeSet(Comparator<? super E> comparator) 

Source Link

Document

Creates a mutable, empty TreeSet instance with the given comparator.

Usage

From source file:co.cask.cdap.api.dataset.lib.IndexedTable.java

/**
 * Configuration time constructor.//  www  .  j a v  a  2 s  .c o  m
 * 
 * @param name the name of the table
 * @param table table to use as the table
 * @param index table to use as the index
 * @param columnsToIndex the names of the data columns to index
 */
public IndexedTable(String name, Table table, Table index, byte[][] columnsToIndex) {
    super(name, table, index);
    this.table = table;
    this.index = index;
    this.indexedColumns = Sets.newTreeSet(Bytes.BYTES_COMPARATOR);
    this.hasColumnWithDelimiter = hasDelimiterByte(columnsToIndex);
    Collections.addAll(this.indexedColumns, columnsToIndex);
}

From source file:edu.washington.cs.cupid.internal.CapabilityRegistry.java

@Override
public synchronized SortedSet<ICapability> getCapabilities() {
    SortedSet<ICapability> result = Sets.newTreeSet(CapabilityUtil.COMPARE_NAME);
    result.addAll(capabilities);/*from  w  w w  . j  av a 2 s  .c o  m*/
    return result;
}

From source file:com.android.sdklib.repository.targets.PlatformTarget.java

/**
 * Construct a new {@code PlatformTarget} based on the given package.
 *///from ww w  .ja  v a2  s.  co m
public PlatformTarget(@NonNull LocalPackage p, @NonNull AndroidSdkHandler sdkHandler, @NonNull FileOp fop,
        @NonNull ProgressIndicator progress) {
    mPackage = p;
    TypeDetails details = p.getTypeDetails();
    assert details instanceof DetailsTypes.PlatformDetailsType;
    mDetails = (DetailsTypes.PlatformDetailsType) details;

    File optionalDir = new File(p.getLocation(), "optional");
    if (optionalDir.isDirectory()) {
        File optionalJson = new File(optionalDir, "optional.json");
        if (optionalJson.isFile()) {
            mOptionalLibraries = getLibsFromJson(optionalJson);
        }
    }

    File buildProp = new File(getLocation(), SdkConstants.FN_BUILD_PROP);

    if (!fop.isFile(buildProp)) {
        String message = "Build properties not found for package " + p.getDisplayName();
        progress.logWarning(message);
        throw new IllegalArgumentException(message);
    }

    try {
        mBuildProps = ProjectProperties.parsePropertyStream(fop.newFileInputStream(buildProp),
                buildProp.getPath(), null);
    } catch (IOException ignore) {
    }
    if (mBuildProps == null) {
        mBuildProps = Maps.newHashMap();
    }
    mBuildToolInfo = sdkHandler.getLatestBuildTool(progress, getVersion().isPreview());

    mSkins = Sets.newTreeSet(PackageParserUtils.parseSkinFolder(getFile(IAndroidTarget.SKINS), fop));
}

From source file:com.google.gerrit.server.project.ProjectCacheImpl.java

@Override
public void remove(final Project p) {
    listLock.lock();/*from   w  ww .j  a  v a2  s  .c o  m*/
    try {
        SortedSet<Project.NameKey> n = Sets.newTreeSet(list.get(ListKey.ALL));
        n.remove(p.getNameKey());
        list.put(ListKey.ALL, Collections.unmodifiableSortedSet(n));
    } catch (ExecutionException e) {
        log.warn("Cannot list avaliable projects", e);
    } finally {
        listLock.unlock();
    }
    evict(p);
}

From source file:com.google.javascript.jscomp.MyFlowAnalysis.java

/**
 * Constructs a data flow analysis./*from  w  ww .  j a  va 2  s.  com*/
 * <p/>
 * <p>Typical usage
 * <pre>
 * DataFlowAnalysis dfa = ...
 * dfa.analyze();
 * </pre>
 * <p/>
 * {@link #analyze()} annotates the result to the control flow graph by
 * means of {@link com.google.javascript.jscomp.graph.DiGraph.DiGraphNode#setAnnotation} without any
 * modification of the graph itself. Additional calls to {@link #analyze()}
 * recomputes the analysis which can be useful if the control flow graph
 * has been modified.
 *
 * @param targetCfg The control flow graph object that this object performs
 *                  on. Modification of the graph requires a separate call to
 *                  {@link #analyze()}.
 * @see #analyze()
 */
MyFlowAnalysis(MyFlowGraph targetCfg, JoinOp<L> joinOp, WhereOp<L> whereOp) {
    this.cfg = targetCfg;
    this.joinOp = joinOp;
    this.whereOp = whereOp;
    Comparator<DiGraphNode<MyNode, Branch>> nodeComparator = cfg.getOptionalNodeComparator(isForward());
    if (nodeComparator != null) {
        this.orderedWorkSet = Sets.newTreeSet(nodeComparator);
    } else {
        this.orderedWorkSet = Sets.newLinkedHashSet();
    }
}

From source file:com.cloudera.exhibit.javascript.JSCalculator.java

ObsDescriptor toObsDescriptor(Object res) {
    if (res == null) {
        throw new IllegalStateException("Null return values are not permitted");
    } else if (res instanceof List) {
        return toObsDescriptor(((List) res).get(0));
    } else if (res instanceof Map) {
        Map<String, Object> mres = (Map<String, Object>) res;
        List<ObsDescriptor.Field> fields = Lists.newArrayList();
        for (String key : Sets.newTreeSet(mres.keySet())) {
            Object val = mres.get(key);
            ObsDescriptor.FieldType ft = null;
            if (val == null) {
                throw new IllegalStateException("Null value for key: " + key);
            } else if (val instanceof Number) {
                ft = ObsDescriptor.FieldType.DOUBLE;
            } else if (val instanceof String) {
                ft = ObsDescriptor.FieldType.STRING;
            } else if (val instanceof Boolean) {
                ft = ObsDescriptor.FieldType.BOOLEAN;
            }// w w  w.j a  va  2s  . co  m
            fields.add(new ObsDescriptor.Field(key, ft));
        }
        return new SimpleObsDescriptor(fields);
    } else if (res instanceof Number) {
        return SimpleObsDescriptor.of("res", ObsDescriptor.FieldType.DOUBLE);
    } else if (res instanceof String) {
        return SimpleObsDescriptor.of("res", ObsDescriptor.FieldType.STRING);
    } else if (res instanceof Boolean) {
        return SimpleObsDescriptor.of("res", ObsDescriptor.FieldType.BOOLEAN);
    } else {
        throw new IllegalStateException("Unsupported result type: " + res);
    }
}

From source file:org.obeonetwork.dsl.smartdesigner.design.actions.AbstractShadeGraphicalElement.java

/**
 * Construct the model to display in the tree of the dialog.
 * <p>//from w w  w  .  java  2 s.c om
 * The structure of the model is the following: Map<Architecture,
 * Map<MetaType,Set<GraphicalElement>>>
 * 
 * @param graphicalElements
 * @return
 */
private final Map<EObject, Map<EClass, Set<GraphicalElement>>> getModel(
        Map<EClass, List<GraphicalElement>> graphicalElements) {
    Map<EObject, Map<EClass, Set<GraphicalElement>>> result = Maps.newTreeMap(new Comparator<EObject>() {
        @Override
        public int compare(EObject o1, EObject o2) {
            return EMFUtil.retrieveNameFrom(o1).compareTo(EMFUtil.retrieveNameFrom(o2));
        }
    });

    Map<EClass, List<EClass>> architectures = this.getArchitectures();

    for (Entry<EClass, List<EClass>> architectureEntry : architectures.entrySet()) {
        Map<EClass, Set<GraphicalElement>> metaType = Maps.newTreeMap(new Comparator<EClass>() {
            @Override
            public int compare(EClass o1, EClass o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        for (EClass metaTypeEntry : architectureEntry.getValue()) {
            List<GraphicalElement> elements = graphicalElements.get(metaTypeEntry);
            if (elements != null) {
                Set<GraphicalElement> set = Sets.newTreeSet(new Comparator<GraphicalElement>() {
                    @Override
                    public int compare(GraphicalElement o1, GraphicalElement o2) {
                        return EMFUtil.retrieveNameFrom(o1.getSemanticElement())
                                .compareTo(EMFUtil.retrieveNameFrom(o2.getSemanticElement()));
                    }
                });
                set.addAll(elements);
                metaType.put(metaTypeEntry, set);
            }
        }
        result.put(architectureEntry.getKey(), metaType);
    }
    return result;
}