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


Java SortedMap.putAll方法代码示例

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


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

示例1: getResults

import java.util.SortedMap; //导入方法依赖的package包/类
public SortedMap<String, T> getResults(final Comparator<Entry> comparator) {
    SortedMap<String, T> sm = new TreeMap<String, T>(new Comparator<String>() {
            public int compare(String o1, String o2) {
                T t1 = map.get(o1);
                T t2 = map.get(o2);
                int delta = comparator.compare(t1, t2);

                if (delta == 0) {
                    delta = o1.compareTo(o2);
                }

                return delta;
            }
        });
    sm.putAll(map);

    return sm;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Histogram.java

示例2: calculateStringToSignV1

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Calculates string to sign for signature version 1.
 *
 * @param parameters
 *            request parameters
 *
 * @return String to sign
 */
private String calculateStringToSignV1(Map<String, List<String>> parameters) {
    StringBuilder data = new StringBuilder();
    SortedMap<String, List<String>> sorted =
        new TreeMap<String, List<String>>(String.CASE_INSENSITIVE_ORDER);
    sorted.putAll(parameters);

    for (Map.Entry<String, List<String>> entry : sorted.entrySet()) {
        for (String value : entry.getValue()) {
            data.append(entry.getKey())
                .append(value);
        }
    }

    return data.toString();
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:24,代码来源:QueryStringSigner.java

示例3: toStringBuffer

import java.util.SortedMap; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static StringBuffer toStringBuffer(Map<String, Object> unsortedMap, int indent)
{      
    StringBuffer tabs = new StringBuffer();
    for (int i = 0; i < indent; i++)
    {
        tabs.append("\t");
    }
    
    StringBuffer sb = new StringBuffer();
    
    SortedMap<String, Object> map = new TreeMap<String, Object>();
    map.putAll(unsortedMap);
    
    for (Map.Entry<String, Object> entry : map.entrySet())
    {
        if (entry.getValue() instanceof Map)
        {
            sb.append(tabs).append(entry.getKey()).append(":").append(entry.getValue().getClass()).append("\n");
            sb.append(JSONtoFmModel.toStringBuffer((Map<String, Object>)entry.getValue(), indent+1));
        }
        else if (entry.getValue() instanceof List)
        {
            sb.append(tabs).append("[\n");
            List l = (List)entry.getValue();
            for (int i = 0; i < l.size(); i++)
            {
                sb.append(tabs).append(l.get(i)).append(":").append((l.get(i) != null) ? l.get(i).getClass() : "null").append("\n");
            }
            sb.append(tabs).append("]\n");
        }
        else
        {
            sb.append(tabs).append(entry.getKey()).append(":").append(entry.getValue()).append(":").append((entry.getValue() != null ? entry.getValue().getClass() : "null")).append("\n");         
        }
    }
    
    return sb;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:JSONtoFmModel.java

示例4: print

import java.util.SortedMap; //导入方法依赖的package包/类
private void print(PrintStream out, String indent, String attrName, Object attrValue) {
    if (attrValue instanceof Collection<?>) {
        out.println(indent + attrName);

        List<Object> values;
        if (attrValue instanceof List<?>) {
            values = new ArrayList<Object>((List<?>) attrValue);
        } else if (attrValue instanceof Set<?>) {
            values = new ArrayList<Object>((Set<?>) attrValue);
            Collections.sort(values, new ObjectComparator());
        } else {
            throw new RuntimeException("unsupported, " + attrValue.getClass().getName());
        }

        for (Object o : values) {
            out.println(indent + " " + render(o));
        }
    } else if (attrValue instanceof Map<?, ?>) {
        out.println(indent + attrName);

        SortedMap<Object, Object> map;
        if (attrValue instanceof SortedMap<?, ?>) {
            map = new TreeMap<Object, Object>((SortedMap<?, ?>) attrValue);
        } else {
            map = new TreeMap<Object, Object>(new ObjectComparator());
            map.putAll((Map<?, ?>) attrValue);
        }

        for (Map.Entry<Object, Object> entry : map.entrySet()) {
            out.println(indent + " " + render(entry.getKey()) + "\t" + render(entry.getValue()));
        }
    } else {
        out.println(indent + attrName + "\t" + render(attrValue));
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:36,代码来源:DumpCommand.java

示例5: create

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public <K extends Comparable<K>, V> SortedMap<K, V> create(Map<K, V> map) {
  SortedMap<K, V> result = Maps.newTreeMap();
  result.putAll(map);
  return result;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:7,代码来源:BenchmarkHelpers.java

示例6: create

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
<K extends Comparable<K>, V> SortedMap<K, V> create(Map<K, V> map) {
  SortedMap<K, V> result = Maps.newTreeMap();
  result.putAll(map);
  return result;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:7,代码来源:BenchmarkHelpers.java

示例7: difference

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Computes the difference between two sorted maps, using the comparator of
 * the left map, or {@code Ordering.natural()} if the left map uses the
 * natural ordering of its elements. This difference is an immutable snapshot
 * of the state of the maps at the time this method is called. It will never
 * change, even if the maps change at a later time.
 *
 * <p>Since this method uses {@code TreeMap} instances internally, the keys of
 * the right map must all compare as distinct according to the comparator
 * of the left map.
 *
 * <p><b>Note:</b>If you only need to know whether two sorted maps have the
 * same mappings, call {@code left.equals(right)} instead of this method.
 *
 * @param left the map to treat as the "left" map for purposes of comparison
 * @param right the map to treat as the "right" map for purposes of comparison
 * @return the difference between the two maps
 * @since 11.0
 */
public static <K, V> SortedMapDifference<K, V> difference(
    SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
  checkNotNull(left);
  checkNotNull(right);
  Comparator<? super K> comparator = orNaturalOrder(left.comparator());
  SortedMap<K, V> onlyOnLeft = Maps.newTreeMap(comparator);
  SortedMap<K, V> onlyOnRight = Maps.newTreeMap(comparator);
  onlyOnRight.putAll(right); // will whittle it down
  SortedMap<K, V> onBoth = Maps.newTreeMap(comparator);
  SortedMap<K, MapDifference.ValueDifference<V>> differences =
      Maps.newTreeMap(comparator);
  doDifference(left, right, Equivalence.equals(), onlyOnLeft, onlyOnRight, onBoth, differences);
  return new SortedMapDifferenceImpl<K, V>(onlyOnLeft, onlyOnRight, onBoth, differences);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:34,代码来源:Maps.java

示例8: difference

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Computes the difference between two sorted maps, using the comparator of
 * the left map, or {@code Ordering.natural()} if the left map uses the
 * natural ordering of its elements. This difference is an immutable snapshot
 * of the state of the maps at the time this method is called. It will never
 * change, even if the maps change at a later time.
 *
 * <p>Since this method uses {@code TreeMap} instances internally, the keys of
 * the right map must all compare as distinct according to the comparator
 * of the left map.
 *
 * <p><b>Note:</b>If you only need to know whether two sorted maps have the
 * same mappings, call {@code left.equals(right)} instead of this method.
 *
 * @param left the map to treat as the "left" map for purposes of comparison
 * @param right the map to treat as the "right" map for purposes of comparison
 * @return the difference between the two maps
 * @since 11.0
 */
public static <K, V> SortedMapDifference<K, V> difference(
    SortedMap<K, ? extends V> left, Map<? extends K, ? extends V> right) {
  checkNotNull(left);
  checkNotNull(right);
  Comparator<? super K> comparator = orNaturalOrder(left.comparator());
  SortedMap<K, V> onlyOnLeft = Maps.newTreeMap(comparator);
  SortedMap<K, V> onlyOnRight = Maps.newTreeMap(comparator);
  onlyOnRight.putAll(right); // will whittle it down
  SortedMap<K, V> onBoth = Maps.newTreeMap(comparator);
  SortedMap<K, MapDifference.ValueDifference<V>> differences = Maps.newTreeMap(comparator);
  doDifference(left, right, Equivalence.equals(), onlyOnLeft, onlyOnRight, onBoth, differences);
  return new SortedMapDifferenceImpl<K, V>(onlyOnLeft, onlyOnRight, onBoth, differences);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:33,代码来源:Maps.java

示例9: sortByValues

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * @param <K>
 * @param <V>
 * @param map
 * @param reverse
 * @return
 */
public static <K, V extends Comparable<V>> Map<K, V> sortByValues(Map<K, V> map, boolean reverse) {
    SortedMap<K, V> sorted = new TreeMap<K, V>(new MapValueComparator<K, V>(map, reverse));
    sorted.putAll(map);
    return (sorted);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:13,代码来源:CollectionUtil.java


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