Sets, Lists, HashMaps
Sets
Set set = new HashSet(Arrays.asList(elements)); public TreeSet(Comparator comp) headSet(Object to) tailSet(Object from) subSet(Object from, Object to)
ArrayList,LinkedList
* can ONLY find index from either beginning and end
* ListIterator
HashMap
Map.Entry
Properties p = System.getProperties(); Iterator i = p.entrySet().iterator(); while(i.hasNext){ Map.Entry e = (MapEntry)i.next(); e.getKey(); e.getValue(); } public Set keySet(); public Collection values(); public Set entrySet();
Vector
-Use linkedList to add element in the middle
-Vector v =
new Vector(Arrays.asList(array));
-vector.removeAll(Collection c);
-vector.retainAll(Collection c);
-vector.containsAll(Collection c);
-Sort Vector:
Vector v1 = …;
Vector v2 = (Vector)v1.clone();
Collections.sort(v2);
-toArray: the smart way
Vector v = …
String[] array = new String[v.size()];
v.copyInto(array);
-Stack class inherits from Vector
•java.lang.ref
strong soft weak phantom
}