本文整理了Java中java.util.TreeMap.<init>()
方法的一些代码示例,展示了TreeMap.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeMap.<init>()
方法的具体详情如下:
包路径:java.util.TreeMap
类名称:TreeMap
方法名:<init>
[英]Create a natural order, empty tree map whose keys must be mutually comparable and non-null.
[中]创建一个自然顺序的空树映射,其键必须相互比较且非空。
代码示例来源:origin: skylot/jadx
private void attachSourceLine(int decompiledLine, int sourceLine) {
if (lineMap.isEmpty()) {
lineMap = new TreeMap<>();
}
lineMap.put(decompiledLine, sourceLine);
}
代码示例来源:origin: bumptech/glide
private NavigableMap<Integer, Integer> getSizesForConfig(Bitmap.Config config) {
NavigableMap<Integer, Integer> sizes = sortedSizes.get(config);
if (sizes == null) {
sizes = new TreeMap<>();
sortedSizes.put(config, sizes);
}
return sizes;
}
代码示例来源:origin: apache/storm
public static TreeMap<Integer, Integer> integerDivided(int sum, int numPieces) {
int base = sum / numPieces;
int numInc = sum % numPieces;
int numBases = numPieces - numInc;
TreeMap<Integer, Integer> ret = new TreeMap<Integer, Integer>();
ret.put(base, numBases);
if (numInc != 0) {
ret.put(base + 1, numInc);
}
return ret;
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
Map<String, Integer> lookup =
new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
lookup.put("One", 1);
lookup.put("tWo", 2);
lookup.put("thrEE", 3);
System.out.println(lookup.get("Two"));
System.out.println(lookup.get("three"));
}
代码示例来源:origin: neo4j/neo4j
private Iterable<Map.Entry<Integer,String>> sortCreatedTokensById()
{
Map<Integer,String> sorted = new TreeMap<>();
for ( Map.Entry<String,Integer> entry : tokens.entrySet() )
{
sorted.put( entry.getValue(), entry.getKey() );
}
return sorted.entrySet();
}
代码示例来源:origin: stackoverflow.com
SortedMap<String, Double> myMap = new TreeMap<String, Double>();
myMap.put("a", 10.0);
myMap.put("b", 9.0);
myMap.put("c", 11.0);
myMap.put("d", 2.0);
sortedset.addAll(myMap.entrySet());
System.out.println(sortedset);
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public TreeMap<Integer, Double> computeDistributionFunction() {
TreeMap<Integer, Double> res = new TreeMap<>();
double accum = 0.0;
for (Integer bucket : hist.keySet()) {
accum += hist.get(bucket);
res.put(bucket, accum);
}
return res;
}
代码示例来源:origin: stackoverflow.com
HashMap<String, Double> map = new HashMap<String, Double>();
ValueComparator bvc = new ValueComparator(map);
TreeMap<String, Double> sorted_map = new TreeMap<String, Double>(bvc);
map.put("D", 67.3);
System.out.println("unsorted map: " + map);
sorted_map.putAll(map);
System.out.println("results: " + sorted_map);
if (base.get(a) >= base.get(b)) {
return -1;
} else {
代码示例来源:origin: apache/hive
private String propertiesToString(Map<String, String> props, List<String> exclude) {
String prop_string = "";
if (!props.isEmpty()) {
Map<String, String> properties = new TreeMap<String, String>(props);
List<String> realProps = new ArrayList<String>();
for (String key : properties.keySet()) {
if (properties.get(key) != null && (exclude == null || !exclude.contains(key))) {
realProps.add(" '" + key + "'='" +
HiveStringUtils.escapeHiveCommand(properties.get(key)) + "'");
}
}
prop_string += StringUtils.join(realProps, ", \n");
}
return prop_string;
}
代码示例来源:origin: Alluxio/alluxio
private Map<String, Capacity> getTierCapacityInternal() {
SortedMap<String, Capacity> tierCapacity = new TreeMap<>(getTierAliasComparator());
Map<String, Long> capacityBytesOnTiers = mStoreMeta.getCapacityBytesOnTiers();
Map<String, Long> usedBytesOnTiers = mStoreMeta.getUsedBytesOnTiers();
for (Map.Entry<String, Long> entry : capacityBytesOnTiers.entrySet()) {
tierCapacity.put(entry.getKey(),
new Capacity().setTotal(entry.getValue()).setUsed(usedBytesOnTiers.get(entry.getKey())));
}
return tierCapacity;
}
代码示例来源:origin: apache/hbase
private void printRow(TRowResult rowResult) {
// copy values into a TreeMap to get them in sorted order
TreeMap<String, TCell> sorted = new TreeMap<>();
for (Map.Entry<ByteBuffer, TCell> column : rowResult.columns.entrySet()) {
sorted.put(utf8(column.getKey().array()), column.getValue());
}
StringBuilder rowStr = new StringBuilder();
for (SortedMap.Entry<String, TCell> entry : sorted.entrySet()) {
rowStr.append(entry.getKey());
rowStr.append(" => ");
rowStr.append(utf8(entry.getValue().value.array()));
rowStr.append("; ");
}
System.out.println("row: " + utf8(rowResult.row.array()) + ", cols: " + rowStr);
}
代码示例来源:origin: stackoverflow.com
Map<String, Object> map = new TreeMap<String, Object>();
/* Add entries to the map in any order. */
...
/* Now, iterate over the map's contents, sorted by key. */
for (Map.Entry<String, ?> entry : map.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
代码示例来源:origin: stackoverflow.com
Map<String, String> map = new HashMap<String, String>();
Map<String, String> treeMap = new TreeMap<String, String>(map);
for (String str : treeMap.keySet()) {
System.out.println(str);
}
代码示例来源:origin: apache/storm
@Override
public void prepare(Map<String, Object> conf) {
toleranceCount = ObjectReader.getInt(conf.get(DaemonConfig.BLACKLIST_SCHEDULER_TOLERANCE_COUNT),
DEFAULT_BLACKLIST_SCHEDULER_TOLERANCE_COUNT);
resumeTime = ObjectReader.getInt(conf.get(DaemonConfig.BLACKLIST_SCHEDULER_RESUME_TIME), DEFAULT_BLACKLIST_SCHEDULER_RESUME_TIME);
String reporterClassName = ObjectReader.getString(conf.get(DaemonConfig.BLACKLIST_SCHEDULER_REPORTER),
LogReporter.class.getName());
reporter = (IReporter) initializeInstance(reporterClassName, "blacklist reporter");
nimbusMonitorFreqSecs = ObjectReader.getInt(conf.get(DaemonConfig.NIMBUS_MONITOR_FREQ_SECS));
blacklist = new TreeMap<>();
}
代码示例来源:origin: redisson/redisson
@Override
protected Map<Integer, TypeDefinition> resolveInitializationTypes(ArgumentHandler argumentHandler) {
SortedMap<Integer, TypeDefinition> namedTypes = new TreeMap<Integer, TypeDefinition>();
for (Map.Entry<String, TypeDefinition> entry : this.namedTypes.entrySet()) {
namedTypes.put(argumentHandler.named(entry.getKey()), entry.getValue());
}
return namedTypes;
}
代码示例来源:origin: hankcs/HanLP
@Override
public Map<String, Double> computeScore(String outerSentence)
{
TreeMap<String, Double> result = new TreeMap<String, Double>(Collections.reverseOrder());
T keyOuter = generateKey(outerSentence);
if (keyOuter == null) return result;
for (Map.Entry<T, Set<String>> entry : storage.entrySet())
{
T key = entry.getKey();
Double score = keyOuter.similarity(key);
for (String sentence : entry.getValue())
{
result.put(sentence, score);
}
}
return result;
}
代码示例来源:origin: hankcs/HanLP
/**
* 克隆一个状态<br>
* Constructs an MDAGNode possessing the same accept state status and outgoing transitions as another.
* @param node the MDAGNode possessing the accept state status and
* outgoing transitions that the to-be-created MDAGNode is to take on
*/
private MDAGNode(MDAGNode node)
{
isAcceptNode = node.isAcceptNode;
outgoingTransitionTreeMap = new TreeMap<Character, MDAGNode>(node.outgoingTransitionTreeMap);
//Loop through the nodes in this node's outgoing _transition set, incrementing the number of
//incoming transitions of each by 1 (to account for this newly created node's outgoing transitions)
for(Entry<Character, MDAGNode> transitionKeyValuePair : outgoingTransitionTreeMap.entrySet())
transitionKeyValuePair.getValue().incomingTransitionCount++;
/////
}
代码示例来源:origin: stackoverflow.com
Map<Float,String> mySortedMap = new TreeMap<Float,MyObject>();
// Put some values in it
mySortedMap.put(1.0f,"One");
mySortedMap.put(0.0f,"Zero");
mySortedMap.put(3.0f,"Three");
// Iterate through it and it'll be in order!
for(Map.Entry<Float,String> entry : mySortedMap.entrySet()) {
System.out.println(entry.getValue());
} // outputs Zero One Three
代码示例来源:origin: bumptech/glide
private NavigableMap<Integer, Integer> getSizesForAdapter(Class<?> arrayClass) {
NavigableMap<Integer, Integer> sizes = sortedSizes.get(arrayClass);
if (sizes == null) {
sizes = new TreeMap<>();
sortedSizes.put(arrayClass, sizes);
}
return sizes;
}
代码示例来源:origin: hankcs/HanLP
/**
* 分割Map,其中旧map直接被改变
* @param src
* @param rate
* @return
*/
public static Map<String, String[]> splitMap(Map<String, String[]> src, double rate)
{
assert 0 <= rate && rate <= 1;
Map<String, String[]> output = new TreeMap<String, String[]>();
for (Map.Entry<String, String[]> entry : src.entrySet())
{
String[][] array = spiltArray(entry.getValue(), rate);
output.put(entry.getKey(), array[0]);
entry.setValue(array[1]);
}
return output;
}
}
内容来源于网络,如有侵权,请联系作者删除!