Set<String> set = new HashSet<String>(ls);System.out.println(set);[a, a, c][c, a]OverviewImplementationsHashSetTreeSetLinkedHashSetStores elements in an hashtableUses an hashing function, hence stored elements must override hashCode()Function example: 10(table size) % el.hashCode()No ordering garanteesConstant time for mutative operations and get. O(1)Tuning using load factor and initial capacityCharacteristicsStores its elements in a red-black treeOrders its elements based on their valueLog-time for most of the operationsElements should implement Comparable in order to benefit from SortedSet interfaceA Hashset with a linked list running through it, thus it preserves insertion orderElements must override hashCode()Similar performance with HashSet, but slowerEnumSetHigh-performance Set implementation for enum typesAll of the members of an enum set must be of the same enum type.Rich, typesafe replacement for traditional bit flagsCopyOnWriteArraySetEquivalent of CopyOnWriteArrayListMapWhat's ?A collection maps keys to values. A map cannot contain duplicate keysEach key can map to at most one value.OverviewHashMapTreeMapLinkedHashMapStores elements in an hashtableUses an hashing function, hence stored elements must override hashCode()Function example: 10(table size) % el.hashCode()No ordering garanteesConstant time for mutative operations and get. O(1)Tuning using load factor and initial capacityCharacteristicsStores its elements in a red-black treeOrders its elements based on their valueLog-time for most of the operationsElements should implement Comparable in order to benefit from SortedMap interfaceA Hashmap with a linked list running through it, thus it preserves insertion orderElements must override hashCode()Similar performance with HashMap, but slowerEnumMapHigh-performance Map implementation for mapping enum types to valuesAll of the keys of an enum map must be of the same enum type.IdentityHashMapuses == instead of equals V put(K key, V value); V get(Object key); V remove(Object key); boolean contains Key(Object key); boolean containsValue(Object value); int size(); boolean isEmpty();Basic operationsBulk operations void putAll(Map<? extends K, ? extends V> m); void clear();static <K, V> Map<K, V> newAttributeMap(Map<K, V>defaults, Map<K, V> overrides) { Map<K, V> result = new HashMap<K, V>(defaults); result.putAll(overrides); return result;}defcautionOverride equals and hashCodeCollection Views public Set<K> keySet(); public Collection<V> values(); public Set<Map.Entry<K,V>> entrySet();for (Map.Entry<KeyType, ValType> e : m.entrySet()) System.out.println(e.getKey() + ": " + e.getValue());for (Iterator<Type> it = m.keySet().iterator(); it.hasNext(); ) if (it.next().isBogus()) it.remove();IteratingdefCautionYou can only remove elements, no adding allowedpowerSet<Employee> simpleEmp = new HashSet<Employee>(managers.keySet());simpleEmp.removeAll(managers.values());m1.entrySet().removeAll(m2.entrySet());ImplementationsWeakHashMapstores only weak references to its keysIt is useful for implementing "registry-like" data structuresreduced memory footprint in time, because they are better garbage-collectedConcurentHashMap highly concurrent, high-performance implementation backed up by a hash tableQueueOverviewWhat's ?Ordered collection that has support for FIFO and priority queuesWhat's new?Implementations - queue implementation backed by a list

- a priority queue based on the heap data structure. Priority decided by element's natural order or provided Comparator.

— an optionally bounded FIFO blocking queue backed by linked nodes

— a bounded FIFO blocking queue backed by an array

— an unbounded blocking priority queue backed by a heap

— a time-based scheduling queue backed by a heap

— a simple rendezvous mechanism that uses the BlockingQueue interfaceLinkedListPriorityQueueLinkedBlockingQueueArrayBlockingQueuePriorityBlockingQueueDelayQueueSynchronousQueueDequeOverviewWhat's ?Ordered collection that has support for FIFO and LIFOWhat's new?Implementations - deque implementation backed by a list

- is the resizable array implementation. It's moreefficient than the LinkedList version

— adds all the specified elements to a Collection. The elements to be added may be specified individually or as an array.

— overwrites every element in a List with the specified value.

— copies the source List into the destination List.rotateswapreplaceAlladdAllfillcopyreverseSearchingint pos = Collections.binarySearch(list, key);binarySearchindexOfSubListlastIndexOfSubList— returns the index of the first sublist of one List that is equal to another.

— returns the index of the last sublist of one List that is equal to another.Composition — counts the number of times the specified element occurs in the specified collection

— determines whether two Collections are disjoint; that is, whether they contain no elements in commonfrequencydisjointmin & max- return the min/max value in the list. May use natural order or a provided one with ComparatorGeorgian ParvuQ&AFinal overview