自己动手实现java数据结构(五)哈希表(6)
发布时间:2021-04-01 04:34 所属栏目:53 来源:网络整理
导读:哈希表简单的测试代码: 1 class MapTest { 2 main(String[] args){ 3 testJDKHashMap(); 4 5 System.out.println("=================================================" 6 7 testMyHashMap(); 8 9 10 testJDKHashMa
哈希表简单的测试代码: 1 class MapTest { 2 main(String[] args){ 3 testJDKHashMap(); 4 5 System.out.println("=================================================" 6 7 testMyHashMap(); 8 9 10 testJDKHashMap(){ 11 java.util.Map<Integer,String> map1 = new java.util.HashMap<>(1,212 System.out.println(map1.put(1,"aaa")); 13 System.out.println(map1.put(2,"bbb"14 System.out.println(map1.put(3,"ccc"15 System.out.println(map1.put(1,1)">16 System.out.println(map1.put(2,1)">17 System.out.println(map1.put(3,1)">18 System.out.println(map1.put(1,"111"19 System.out.println(map1.put(3,1)">20 System.out.println(map1.put(4,"ddd"21 System.out.println(map1.put(5,"eee"22 System.out.println(map1.put(6,"fff"23 System.out.println(map1.put(8,"ggg"24 System.out.println(map1.put(11,1)">25 System.out.println(map1.put(22,1)">26 System.out.println(map1.put(33,1)">27 System.out.println(map1.put(9,1)">28 System.out.println(map1.put(10,1)">29 System.out.println(map1.put(12,1)">30 System.out.println(map1.put(13,1)">31 System.out.println(map1.put(14,1)">32 33 System.out.println(map1.toString()); 34 System.out.println(map1.containsKey(135 System.out.println(map1.containsKey(1136 System.out.println(map1.containsValue("bbb"37 System.out.println(map1.containsValue("aaa"38 System.out.println(map1.size()); 39 System.out.println(map1.get(140 System.out.println(map1.get(241 System.out.println(map1.get(342 System.out.println(map1.remove(143 System.out.println(map1.remove(244 45 46 47 48 testMyHashMap(){ 49 com.xiongyx.datastructures.map.Map<Integer,String> map2 = new com.xiongyx.datastructures.map.HashMap<>(1,1)">50 System.out.println(map2.put(1,1)">51 System.out.println(map2.put(2,1)">52 System.out.println(map2.put(3,1)">53 System.out.println(map2.put(1,1)">54 System.out.println(map2.put(2,1)">55 System.out.println(map2.put(3,1)">56 System.out.println(map2.put(1,1)">57 System.out.println(map2.put(3,1)">58 System.out.println(map2.put(4,1)">59 System.out.println(map2.put(5,1)">60 System.out.println(map2.put(6,1)">61 System.out.println(map2.put(8,1)">62 System.out.println(map2.put(11,1)">63 System.out.println(map2.put(22,1)">64 System.out.println(map2.put(33,1)">65 System.out.println(map2.put(9,1)">66 System.out.println(map2.put(10,1)">67 System.out.println(map2.put(12,1)">68 System.out.println(map2.put(13,1)">69 System.out.println(map2.put(14,1)">70 71 System.out.println(map2.toString()); 72 System.out.println(map2.containsKey(173 System.out.println(map2.containsKey(1174 System.out.println(map2.containsValue("bbb"75 System.out.println(map2.containsValue("aaa"76 System.out.println(map2.size()); 77 System.out.println(map2.get(178 System.out.println(map2.get(279 System.out.println(map2.get(380 System.out.println(map2.remove(181 System.out.println(map2.remove(282 83 84 }View Code (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读