1515 * Licensed under the Apache License, Version 2.0 (the "License");
1616 * you may not use this file except in compliance with the License.
1717 * You may obtain a copy of the License at
18- *
18+ *
1919 * http://www.apache.org/licenses/LICENSE-2.0
20- *
20+ *
2121 * Unless required by applicable law or agreed to in writing, software
2222 * distributed under the License is distributed on an "AS IS" BASIS,
2323 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3030 * @since 2015-6-17 23:32:30
3131 * 各集合添加元素性能对比
3232 */
33+
34+ /**
35+ * 1. 了解常见集合,多种遍历方法
36+ * 2. 了解性能和线程安全问题
37+ * 3. 实现compare函数来排序
38+ *
39+ * 查看util包下的
40+ * 排序${@link org.javacore.collection.util.CollectionsT}
41+ * Iterator与ListIterator的区别${@link org.javacore.collection.util.IterAndListIterT}
42+ * Mao性能对比${@link org.javacore.collection.util.PerBtwnEmptyMapAndHashMapT}
43+ */
3344@ SuppressWarnings ("unchecked" )
3445public class PerBtwnAllCollectionsT {
35-
46+
3647 public static void main (String [] args ){
3748 // List Add对比
3849 printLists ();
@@ -53,7 +64,7 @@ private static void printLists(){
5364 a1 .add ("Map" );
5465 System .out .println ("ArrayList Elements:" );
5566 System .out .print ("\t " + a1 + "\n " );
56-
67+
5768 List <String > l1 = new LinkedList <String >();
5869 l1 .add ("List" );
5970 l1 .add ("Set" );
@@ -62,7 +73,7 @@ private static void printLists(){
6273 System .out .println ("LinkedList Elements:" );
6374 System .out .print ("\t " + l1 + "\n " );
6475 }
65-
76+
6677 /**
6778 * 比较Set的Add方法:注意元素的位置
6879 */
@@ -75,7 +86,7 @@ private static void printSets() {
7586 h1 .add ("Map" );
7687 System .out .println ("HashSet Elements:" );
7788 System .out .print ("\t " + h1 + "\n " );
78-
89+
7990 Set t1 = new TreeSet <String >();
8091 t1 .add ("List" );
8192 t1 .add ("Set" );
@@ -84,7 +95,7 @@ private static void printSets() {
8495 System .out .println ("TreeSet Elements:" );
8596 System .out .print ("\t " + t1 + "\n " );
8697 }
87-
98+
8899 /**
89100 * 比较Map的put方法:注意元素的位置
90101 */
@@ -96,14 +107,14 @@ private static void printMaps() {
96107 h1 .put ("Map" , "HashMap" );
97108 System .out .println ("HashMap Elements:" );
98109 System .out .print ("\t " + h1 + "\n " );
99-
110+
100111 Map <String , String > t1 = new TreeMap <String ,String >();
101112 t1 .put ("List" , "ArrayList" );
102113 t1 .put ("Set" , "HashSet" );
103114 t1 .put ("Queue" , "PriorityQueue" );
104115 t1 .put ("Map" , "HashMap" );
105116 System .out .println ("TreeMap Elements:" );
106117 System .out .print ("\t " + t1 + "\n " );
107-
118+
108119 }
109120}
0 commit comments