作者 crossoverJie

:bulb: 添加源码注释

@@ -2,6 +2,7 @@ package com.crossoverjie.cim.common.data.construct; @@ -2,6 +2,7 @@ package com.crossoverjie.cim.common.data.construct;
2 2
3 import org.junit.Test; 3 import org.junit.Test;
4 4
  5 +import java.util.SortedMap;
5 import java.util.TreeMap; 6 import java.util.TreeMap;
6 7
7 public class SortArrayMapTest { 8 public class SortArrayMapTest {
@@ -170,4 +171,21 @@ public class SortArrayMapTest { @@ -170,4 +171,21 @@ public class SortArrayMapTest {
170 System.out.println("耗时 " + (end -star)); 171 System.out.println("耗时 " + (end -star));
171 System.out.println(treeMap.size()); 172 System.out.println(treeMap.size());
172 } 173 }
  174 +
  175 + @Test
  176 + public void add8(){
  177 +
  178 + TreeMap<Long,String> map = new TreeMap<Long, String>() ;
  179 + map.put(100L,"127.0.0.100");
  180 + map.put(10L,"127.0.0.10");
  181 + map.put(8L,"127.0.0.8");
  182 + map.put(1000L,"127.0.0.1000");
  183 +
  184 + SortedMap<Long, String> last = map.tailMap(101L);
  185 + if (!last.isEmpty()) {
  186 + System.out.println(last.get(last.firstKey()));
  187 + }else {
  188 + System.out.println(map.firstEntry().getValue());
  189 + }
  190 + }
173 } 191 }