當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。