当前位置: 首页>>代码示例>>Java>>正文


Java TreeMultimap.entries方法代码示例

本文整理汇总了Java中com.google.common.collect.TreeMultimap.entries方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMultimap.entries方法的具体用法?Java TreeMultimap.entries怎么用?Java TreeMultimap.entries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.TreeMultimap的用法示例。


在下文中一共展示了TreeMultimap.entries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitObjectLiteral

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
@Override
public String visitObjectLiteral(ObjectLiteral node, Void context) {
    StringBuilder builder = new StringBuilder("{");
    boolean first = true;
    TreeMultimap<String, Expression> sorted = TreeMultimap.create(
            Ordering.natural().nullsLast(),
            Ordering.usingToString().nullsLast()
    );
    sorted.putAll(node.values());
    for (Map.Entry<String, Expression> entry : sorted.entries()) {
        if (!first) {
            builder.append(", ");
        } else {
            first = false;
        }
        builder.append(formatIdentifier(entry.getKey()))
               .append("= ")
               .append(entry.getValue().accept(this, context));

    }
    return builder.append("}").toString();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:ExpressionFormatter.java

示例2: getRequestContextFromMap

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private InternalRequestContext getRequestContextFromMap(TreeMultimap<Calendar, ItemInfo> versionsItems,
        StoringRepo repo, InternalRequestContext requestContext, ModuleInfo originalModuleInfo,
        boolean searchForReleaseVersion) {
    RepositoryService repositoryService = ContextHelper.get().getRepositoryService();
    for (Map.Entry<Calendar, ItemInfo> entry : versionsItems.entries()) {
        ItemInfo item = entry.getValue();
        if (!item.isFolder()) {
            ModuleInfo itemModuleInfo = repositoryService.getItemModuleInfo(item.getRepoPath());
            boolean isIntegration = itemModuleInfo.isIntegration();
            boolean matchReleaseSearch = searchForReleaseVersion && !isIntegration;
            boolean matchIntegrationSearch = !searchForReleaseVersion && isIntegration;
            if (itemModuleInfo.isValid() && (matchReleaseSearch || matchIntegrationSearch)) {
                if (areModuleInfosTheSame(originalModuleInfo, itemModuleInfo) && isPropertiesMatch(item,
                        requestContext.getProperties())) {
                    return translateRepoRequestContext(requestContext, repo, item.getRelPath());
                }
            }
        }
    }

    return requestContext;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:23,代码来源:LocalLatestVersionResolver.java

示例3: destructiveUnionSloppy

import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
/**
 * Return a polygon which is the union of the given polygons; combines
 * vertices that form edges that are almost identical, as defined by
 * vertexMergeRadius. Note: clears the List!
 */
public static S2Polygon destructiveUnionSloppy(
    List<S2Polygon> polygons, S1Angle vertexMergeRadius) {
  // Effectively create a priority queue of polygons in order of number of
  // vertices. Repeatedly union the two smallest polygons and add the result
  // to the queue until we have a single polygon to return.

  // map: # of vertices -> polygon
  TreeMultimap<Integer, S2Polygon> queue = TreeMultimap.create();

  for (S2Polygon polygon : polygons) {
    queue.put(polygon.getNumVertices(), polygon);
  }
  polygons.clear();

  Set<Map.Entry<Integer, S2Polygon>> queueSet = queue.entries();
  while (queueSet.size() > 1) {
    // Pop two simplest polygons from queue.
    queueSet = queue.entries();
    Iterator<Map.Entry<Integer, S2Polygon>> smallestIter = queueSet.iterator();

    Map.Entry<Integer, S2Polygon> smallest = smallestIter.next();
    int aSize = smallest.getKey().intValue();
    S2Polygon aPolygon = smallest.getValue();
    smallestIter.remove();

    smallest = smallestIter.next();
    int bSize = smallest.getKey().intValue();
    S2Polygon bPolygon = smallest.getValue();
    smallestIter.remove();

    // Union and add result back to queue.
    S2Polygon unionPolygon = new S2Polygon();
    unionPolygon.initToUnionSloppy(aPolygon, bPolygon, vertexMergeRadius);
    int unionSize = aSize + bSize;
    queue.put(unionSize, unionPolygon);
    // We assume that the number of vertices in the union polygon is the
    // sum of the number of vertices in the original polygons, which is not
    // always true, but will almost always be a decent approximation, and
    // faster than recomputing.
  }

  if (queue.isEmpty()) {
    return new S2Polygon();
  } else {
    return queue.get(queue.asMap().firstKey()).first();
  }
}
 
开发者ID:rschreijer,项目名称:s2-geometry-library-java,代码行数:53,代码来源:S2Polygon.java


注:本文中的com.google.common.collect.TreeMultimap.entries方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。