java.util.Collections.checkedSortedMap()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中java.util.Collections.checkedSortedMap()方法的一些代码示例,展示了Collections.checkedSortedMap()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Collections.checkedSortedMap()方法的具体详情如下:
包路径:java.util.Collections
类名称:Collections
方法名:checkedSortedMap

Collections.checkedSortedMap介绍

[英]Returns a dynamically typesafe view of the specified sorted map. Trying to insert an element of the wrong type into this sorted map throws a ClassCastException. At creation time the types in m are not checked for correct type.
[中]返回指定排序映射的动态类型安全视图。尝试将错误类型的元素插入此排序映射会引发ClassCastException。在创建时,没有检查m中的类型是否正确。

代码示例

代码示例来源:origin: google/guava

@Override
 protected SortedMap<String, String> create(Entry<String, String>[] entries) {
  SortedMap<String, String> map = populate(new TreeMap<String, String>(), entries);
  return Collections.checkedSortedMap(map, String.class, String.class);
 }
})

代码示例来源:origin: wildfly/wildfly

classes.add(Collections.checkedQueue(new LinkedList<>(), Void.class).getClass());
classes.add(Collections.checkedSet(Collections.emptySet(), Void.class).getClass());
classes.add(Collections.checkedSortedMap(Collections.emptySortedMap(), Void.class, Void.class).getClass());
classes.add(Collections.checkedSortedSet(Collections.emptySortedSet(), Void.class).getClass());

代码示例来源:origin: protostuff/protostuff

PojoWithObjectMapFields fill()
{
  TreeMap<String, String> tm = new TreeMap<String, String>();
  tm.put("foo", "bar");
  EnumMap<GuitarPickup, Size> em = new EnumMap<GuitarPickup, Size>(
      GuitarPickup.class);
  em.put(GuitarPickup.CONTACT, Size.SMALL);
  emptyMap = Collections.emptyMap();
  singletonMap = Collections.singletonMap("key", "value");
  unmodifiableMap = Collections.unmodifiableMap(Collections
      .emptyMap());
  unmodifiableSortedMap = Collections.unmodifiableSortedMap(tm);
  synchronizedMap = Collections.synchronizedMap(em);
  synchronizedSortedMap = Collections.synchronizedSortedMap(tm);
  checkedMap = Collections.checkedMap(em, GuitarPickup.class,
      Size.class);
  checkedSortedMap = Collections.checkedSortedMap(tm, String.class,
      String.class);
  return this;
}

代码示例来源:origin: jtulach/bck2brwsr

public SortedMap<K,V> subMap(K fromKey, K toKey) {
  return checkedSortedMap(sm.subMap(fromKey, toKey),
              keyType, valueType);
}
public SortedMap<K,V> headMap(K toKey) {

代码示例来源:origin: com.google.guava/guava-testlib

@Override
 protected SortedMap<String, String> create(Entry<String, String>[] entries) {
  SortedMap<String, String> map = populate(new TreeMap<String, String>(), entries);
  return Collections.checkedSortedMap(map, String.class, String.class);
 }
})

代码示例来源:origin: org.apidesign.bck2brwsr/emul

public SortedMap<K,V> subMap(K fromKey, K toKey) {
  return checkedSortedMap(sm.subMap(fromKey, toKey),
              keyType, valueType);
}
public SortedMap<K,V> headMap(K toKey) {

代码示例来源:origin: jtulach/bck2brwsr

public SortedMap<K,V> headMap(K toKey) {
  return checkedSortedMap(sm.headMap(toKey), keyType, valueType);
}
public SortedMap<K,V> tailMap(K fromKey) {

代码示例来源:origin: org.apidesign.bck2brwsr/emul

public SortedMap<K,V> tailMap(K fromKey) {
    return checkedSortedMap(sm.tailMap(fromKey), keyType, valueType);
  }
}

代码示例来源:origin: jtulach/bck2brwsr

public SortedMap<K,V> tailMap(K fromKey) {
    return checkedSortedMap(sm.tailMap(fromKey), keyType, valueType);
  }
}

代码示例来源:origin: org.apidesign.bck2brwsr/emul

public SortedMap<K,V> headMap(K toKey) {
  return checkedSortedMap(sm.headMap(toKey), keyType, valueType);
}
public SortedMap<K,V> tailMap(K fromKey) {

代码示例来源:origin: org.wildfly/wildfly-clustering-marshalling-jboss

classes.add(Collections.checkedQueue(new LinkedList<>(), Void.class).getClass());
classes.add(Collections.checkedSet(Collections.emptySet(), Void.class).getClass());
classes.add(Collections.checkedSortedMap(Collections.emptySortedMap(), Void.class, Void.class).getClass());
classes.add(Collections.checkedSortedSet(Collections.emptySortedSet(), Void.class).getClass());

相关文章

Collections类方法