简体   繁体   English

从特定键迭代树图到图的末尾

[英]Iterate a treemap from specific key to end of map

    TreeMap treemap=new TreeMap<String,double>();
    treemap.put("02.00", 7.5);
    treemap.put("03.30", 7.9);
    treemap.put("04.00", 8.0);
    treemap.put("05.30", 6.8);
    treemap.put("10.00", 9.01);
    treemap.put("11.30", 8.9);
    treemap.put("12.00", 9.30);
    System.out.println(treemap);
    double min=(double) Collections.min(treemap.values());

Treemap contains -- {02.00=7.5, 03.30=7.9, 04.00=8.0, 05.30=6.8, 10.00=9.01, 11.30=8.9, 12.00=9.30} min contains value : 6.8 树状图包含-{02.00 = 7.5,03.30 = 7.9,04.00 = 8.0,05.30 = 6.8,10.00 = 9.01,11.30 = 8.9,12.00 = 9.30} min包含值:6.8

Now i want to iterate key and value after 现在我想在之后迭代键和值

 treemap.put("05.30", 6.8);

ie,

  treemap.put("10.00", 9.01);
  treemap.put("11.30", 8.9);
  treemap.put("12.00", 9.30); 

and store last three map key and value in another treemap.. 并将最后三个映射键和值存储在另一个树形图中。

TreeMap的方法tailMap(K fromKey)返回一个SortedMap<K, V>其键大于/等于K。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM