Last Class. To organize data to be able to perform operations on those data efficiently. Data Structure Could be implemented in many different ways. The.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 The Collections API.
Advertisements

Introduction to Computation and Problem Solving Class 32: The Java® Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward.
Java Programming: Advanced Topics 1 Collections and Utilities.
Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
JAVA Programming (Session 7) When you are willing to make sacrifices for a great cause, you will never be alone. Instructor:
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
Collections CS3250. Sources  Slides by Professor Chuck Allison  Core Java, by Cay S. Horstmann and Gary Cornell  The Java Tutorial 
Collections Sets - no duplicates Lists - duplicates allowed Maps - key / value pairs A collection is an Object which contains other Objects. There are.
CSci 143 Sets & Maps Adapted from Marty Stepp, University of Washington
15-Jun-15 Lists in Java Part of the Collections Framework.
Sets and Maps Chapter 9. Chapter 9: Sets and Maps2 Chapter Objectives To understand the Java Map and Set interfaces and how to use them To learn about.
Algorithm Programming Containers in Java Bar-Ilan University תשס " ו by Moshe Fresko.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 8.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
Lists in Java Part of the Collections Framework. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection.
12-Jul-15 Lists in Java Part of the Collections Framework.
CSE 143 Lecture 7 Sets and Maps reading: ; 13.2 slides created by Marty Stepp
Chapter 19 Java Data Structures
Java's Collection Framework
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
CS Collection and Input/Output Classes CS 3331 Fall 2009.
Sets and Maps Part of the Collections Framework. The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities Chapter 4.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities.
CS2110: SW Development Methods Textbook readings: MSD, Chapter 8 (Sect. 8.1 and 8.2) But we won’t implement our own, so study the section on Java’s Map.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Collections F The limitations of arrays F Java Collection Framework hierarchy  Use the Iterator interface to traverse a collection  Set interface, HashSet,
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 22 Java Collections.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
Week 2 - Monday.  What did we talk about last time?  Exceptions  Threads  OOP  Interfaces.
Collections in Java. Kinds of Collections Collection --a group of objects, called elements –Set-- An unordered collection with no duplicates SortedSet.
1 Java's Collection Framework By Rick Mercer with help from The Java Tutorial, The Collections Trail, by Joshua BlockThe Collections Trail.
(c) University of Washington14-1 CSC 143 Java Collections.
Data structures and algorithms in the collection framework 1 Part 2.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSS446 Spring 2014 Nan Wang.  Java Collection Framework ◦ Set ◦ Map 2.
CS 46B: Introduction to Data Structures July 9 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Object Oriented Programming Ders 10: Data Structures Mustafa Emre İlal
Chapter 18 Java Collections Framework
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
1/20/03A2-1 CS494 Interfaces and Collection in Java.
Collections –data structures and Algorithms L. Grewe.
Arrays, ArrayLists, and Collections. Rationale Suppose we have a program to compute the average of three numbers. We could write a simple little method.
1 Java Collection: Data structure framework. 2 Background collections store and organize objects for efficient access Java collections: traditional data.
The Java Collections Framework Based on
3-February-2003cse Collections © 2003 University of Washington1 Java Collections CSE 403, Winter 2003 Software Engineering
Collections Mrs. C. Furman April 21, Collection Classes ArrayList and LinkedList implements List HashSet implements Set TreeSet implements SortedSet.
List Interface and Linked List Mrs. Furman March 25, 2010.
Priority Queues. Priority Queue ADT A priority queue stores a collection of entries Each entry is a pair (key, value) Main methods of the Priority Queue.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CMSC 202 Containers and Iterators. Container Definition A “container” is a data structure whose purpose is to hold objects. Most languages support several.
AD Lecture #3 Java Collection Framework 1.
Object Oriented Programming and Data Abstraction Rowan University Earl Huff.
1 Maps, Stacks and Queues Maps Reading:  2 nd Ed: 20.4, 21.2, 21.7  3 rd Ed: 15.4, 16.2, 16.7 Additional references: Online Java Tutorial at
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 21 Sets and Maps.
Sets and Maps Chapter 9. Chapter Objectives  To understand the Java Map and Set interfaces and how to use them  To learn about hash coding and its use.
Collections Dwight Deugo Nesa Matic
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
Lecture 9:FXML and Useful Java Collections Michael Hsu CSULA.
Java Collections Framework The client view. The Big Picture.
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
COMP2402 The Java Collections Framework II: Implementations and Algorithms Pat Morin.
Slides by Donald W. Smith
Using the Java Collection Libraries COMP 103 # T2
Chapter 19 Java Data Structures
Presentation transcript:

Last Class

To organize data to be able to perform operations on those data efficiently. Data Structure Could be implemented in many different ways. The efficiency depend on the particular application.

It is a step-by-step procedure for solving a problem in a finite amount of time. Algorithm Its running time depend on the input size and on the input data The best case is the input that cause the lower running time and the worst case the input that cause the biggest running time.

By inspecting the pseudo code, we count the number of primitive operation to analyze the running time. Algorithm We compare two algorithm by their asymptotic behaviour of their running time when the size of the input grow.

Asymptotic Behaviour Big Oh define an asymptotically upper bound Big Omega define an asymptotically lower bound A function f(n) is Θ(g(n)) if it is both big Oh and big Omega.

Comming up

The Java Collections Framework Generic algorithms that work on one or more interfaces - regardless of implementation The JCF consists of: Interfaces The basic data types and their operations ( Set, List, Map,...) Implementations Classes that implement interfaces Different implementations have different performance ( tradeoffs ) Algorithms

Java generics Many classes, interfaces, and methods are generic They work on a variety of data types Each instance works for a specific data type ArrayList a = new ArrayList (); a.add("Hello"); a.add("World!"); System. out.println(a); ArrayList b = new ArrayList (); b.add(new Date(0)); b.add(new Date()); System. out.println(b);

The Java Collections Framework ( Interfaces ) CollectionMap SetListQueue SortedSet SortedMap Two hierarchies: Collection: − stores individual objects 1 generic parameter (type of object stored) Map: − stores key/value pairs 2 generic parameters (type of key and type of value)

Collection A group of objects − no particular order − possibly with duplicates Basic operations − size, isEmpty, contains, add, remove, iterator Bulk operations − containsAll, addAll, removeAll, retainAll, clear Array operations − toArray

11 1. Collection names = new ArrayList (); 2. names.add("sheldon"); 3. names.add("penny"); 4. System.out.println(names); 5. System.out.println(names.size()); // 2 6. System.out.println(names.contains("leonard")); // false 7. String[] newNames = {"howard","raj","wil","leslie","penny"}; 8. for (String s : newNames ) names.add(s); 9. names.addAll(Arrays.asList(newNames)); 10. System.out.println(names.size()); // ? System.out.println(names); // ? Collection (example)

12 // an example of the Collection iteration idiom public static void prettyPrintStrings(Collection c) { Iterator i = c.iterator(); while (i.hasNext()) { System.out.print("**" + i.next() + "**"); } System.out.println(); } Iterators All Collections have iterators − An iterator allows for listing the elements of a collection one by one

13 // an example of a method that operates on generic collections public static void prettyPrint(Collection c) { Iterator i = c.iterator(); while (i.hasNext()) { System.out.print("**" + i.next() + "**"); } System.out.println(); } Generic (example) If we don't care what kind of objects are in a Collection we can write a method that operates on generic collections

Collection Summary Sets, Lists, and Queues treat these differently For a Collection we cannot know −what happens to duplicate values −what order an iterator reports the elements in

Set All elements are unique − An element only occurs once in a set - even if added multiple times No order is associated with the elements − The order of elements in an iteration is unspecified Supports the same operations as Collection − size, isEmpty, contains, add, remove, iterator, containsAll, addAll, removeAll, retainAll, clear, toArray A mathematical set

16 // Print the elements in a without printing any element twice public static void printWithoutDuplicates(T[] a) { Set s = new HashSet (); for (T x : a) { if (!s.contains(x)) { s.add(x); System.out.println(x); } Set (example) In what order are the elements printed?

17 // Print the elements in c without printing any element twice public static void printWithoutDups(Collection c) { Set s = new HashSet (); for (T x : c) { if (!s.contains(x)) { s.add(x); System.out.println(x); } Set (example for a Collection)

18 // Removes duplicate elements from an array // Extra array positions are set to null public static void removeDuplicates(T[] a) { Set s = new HashSet (); for (T x : a) { s.add(x); } s.toArray(a); } Set (example) In what order do elements appear in the output array? // Removes duplicate elements from an array // Extra array positions are set to null public static void removeDuplicates(T[] a) {…}

19 Implement the following function Input: an array a Output: print each element of a that occurs exactly once – Don't print any element not in a – Don't print any element that occurs more than once in a In-Class Exercise

20 // Sort a and remove any duplicate elements // Fill extra positions with null public static void sortAndRemoveDups(T[] a) { SortedSet s = new TreeSet (); for (T x : a) s.add(x); s.toArray(a); } SortedSet Just like Set, but elements are in sorted order We can use the natural ordering or define a Comparable object (more on this later) An iterator outputs the elements in sorted order

21 SortedSet snames = new TreeSet (); String[] names = hlprsw {"sheldon”,"penny“,"howard","raj","wil","leslie","penny"}; snames.addAll(names); System.out.println(snames); System.out.println(snames.subSet("leslie", "sheldon")); System.out.println(snames.headSet("penny")); System.out.println(snames.tailSet("penny")); SortedSet A SortedSet allows for range view − subSet(from,to), headSet(to), tailSet(from) − first(), last()

22 // Return a list of possible completions for a string s public void findCompletions(SortedSet words, String s) { SortedSet ts = words.tailSet(s); Iterator i = ts.iterator(); String w; while (i.hasNext() && (w = i.next()).startsWith(s)) System.out.println(w); } SortedSet SortedSet supports searches for elements not in the set − s.headSet(x).last() is the largest value less than x − s.tailSet(x).first() is the smallest value greater than or equal to x

Set Summary Elements are unique. No order is associated with the elements. Support the same operation that Collection SortedSet Summary Like Set, but elements are in sorted order Support range view operations supports searches for elements not in the set

List Represents a sequence of elements − Elements are stored in a specific order − Elements can occur more than once Positional access − get(i), set(i,x), add(i,x), add(x), remove(i), addAll(i,c) Searching and iteration − indexOf(o), lastIndexOf(o), listIterator(), listIterator(i) Range view −subList(i, j)

25 List l = new ArrayList (); String[] bus = {"Apple","Google","IBM","Microsoft","Oracle"}; for (String s : bus) l.add(s); System.out.println(l); l.add("Yahoo"); // append System.out.println(l); l.add(1, "Cognos"); // add as second element System.out.println(l); l.set(1, "Cisco"); // replace second element System.out.println(l.get(0) + " " + l.get(1) + " " + l.get(2)); System.out.println(l.subList(0,3)); List (example)

26 ListIterator it = l.listIterator(); while (it.hasNext()) System.out.print(it.next() + " "); System.out.println(); while (it.hasPrevious()) System.out.print(it.previous() + " "); ListIterator (example) ListIterators can iterate forward and backward − Forward: hasNext(), next() − Backward: hasPrevious, previous()

List Summary Like arrays −Store a sequence of elements in a particular order −Can be accessed by position −Elements can be modified Not Like arrays −Elements can be added at the end −Elements can be inserted in the middle and front Performance −An implementation can be fast at one or the other, but not both (more later)

28 String[] bus = {"Apple","Google","IBM","Microsoft","Oracle"}; List l2 = Arrays.asList(bus); System.out.println(l2); System.out.println(bus[1]); // "Google" l2.set(1, "Hewlett-Packard"); System.out.println(l2); System.out.println(bus[1]); // "Hewlett-Packard" Arrays as Lists An array can be made into a list in one line − Arrays.asList − Set methods modify the original array

List Algorithms A number of algorithms are implemented that apply to lists −Collections.sort, Collections.shuffle, −Collections.reverse, Collections.rotate, −Collections.swap, Collections.replaceAll, −Collections.fill,Collections.copy, −Collections.binarySearch, −Collections.indexOfSublist, −Collections.lastIndexOfSublist We will use these in examples later

Queue A queue stores elements for processing − Usually elements come out in the same order they went in (FIFO) − Add an element to the end of the queue and remove (or look at) an element at the front of the queue Two versions of each method: Throws ExceptionsReturns Special Value Insertadd(e)offer(e) Removeremove()poll() Examineelement()peek()

31 // An implementation of Unix 'tail' command // writes the last n lines of r onto w public static void tail(BufferedReader r, PrintWriter w, int n) { String line; Queue q = new LinkedList (); while ((line = r.readLine()) != null) { q.add(line); if (q.size() > n) q.remove(); } while (!q.isEmpty()) { w.println(q.remove()); } Queue (example)

Collection Exercises Write a function that takes a Collection of Strings and returns a List of strings in the collection whose length is greater than 5. Write a function that takes a Collection of Strings and prints them in sorted order, eliminating duplicates Write a function that takes a Collection of Strings, selects one at random and returns it

Maps A Map associates keys of type K onto values of type V −Similar to an array/list except that elements of type K are used for indexing, rather than integers Basic operations −put(k,v), get(k), remove(k), containsKey(k), containsValue(v), size(), isEmpty() Collection views −keySet(), values(), entrySet()

34 Map m = new HashMap (); m.put("GOOG", "Google Inc."); m.put("AAPL", "Apple Inc."); m.put("MSFT", "Microsoft Corporation"); m.put("ORCL", "Oracle Corporation"); m.put("CSCO", "Cisco Systems, Inc."); System.out.println("Stock symbol GOOG is for " + m.get("GOOG")); System.out.println("Stock symbol PLCS is for " + m.get("PLCS")); System.out.println("Symbols: " + m.keySet()); System.out.println("Companies: " + m.values()); System.out.println("Mappings: " + m.entrySet()); Map (example) - NASDAQ

Maps The keys in a map are all unique, values may not be unique To store multiple values for each key, associate a collection with each key −e.g. Map >

36 Map > m2 = new HashMap >(); m2.put("Shakespeare", new ArrayList ()); m2.get("Shakespeare").add("Romeo and Juliet"); m2.get("Shakespeare").add("Macbeth"); m2.put("Bacon", new ArrayList ()); m2.get("Bacon").add("New Atlantis"); m2.get("Bacon").add("The Comedy of Errors(?)"); System.out.println("William Shakespeare wrote: " + m2.get("Shakespeare")); System.out.println("Sir Francis Bacon wrote: " + m2.get("Bacon")); Storing Multiple Values per Key

In-Class Exercises Implement the following function.  Input: an array a  Output: print each element of a that occurs at most 10 times − Don't print any element not in a − Don't print any element that occurs more than 10 times

SortedMap Identical to a Map, except that keys are stored in sorted order Operations that use order − subMap(from,to), − headMap(to), − tailMap(from), − firstKey(), − lastKey()

Which Collection to use (not exact) Associating keys with values? − Yes (Map): Exact search only ? − No (Collection): Elements are ordered? o Yes: Map o No: Sorted Map − Yes: Sorted Order ? o Yes: SortedSet or SortedMap o No: List − No: Sorted ? o Yes: SortedSet or SortedMap o No: Set or Map

Mutable Objects and Collections Objects stored in Sets or used as keys in Maps should not be changed − The object should not be modified in a way that changes the results of equals() or hashCode() − Ideally, they should be immutable (unmodifiable) Objects stored in SortedSets and used as keys in SortedMaps should not be changed in a way that modifies their order − The result of compareTo() should not change while the object is stored.

41 Set s = new Set (); Person p = new Person("John", "Doe"); s.add(p); p.changeLastName("Smith"); // Don't do this! Don’t do this p gets stored in s at a location that is defined by the contents (firstName and lastName) of p Changing the contents (lastName) of p means that p is no longer stored at the correct location in s.

equals, compareTo, and hashCode The equals() method can be overridden for any object − In this case, you must also override the hashCode() method to guarantee that: − a.compareTo(b) < 0 if a < b − a.compareTo(b) > 0 if a > b − a.compareTo(b) = 0 if a = b o If a.equals(b) then a.hashCode() = b.hashCode() Objects stored in SortedSets must implement the Comparable interface

Comparators To use something other than default ordering we can define a Comparator An object that implements the Comparator interface implements the compare(t1,t2) method that compares two elements of class T Most SortedSet implementations allow for the specification of a Comparator during initialization

44 public class ReverseStringComparator implements Comparator { public int compare(String a, String b) { int r = a.compareTo(b); if (r < 0) return 1; if (r > 0) return -1; return 0; }... SortedSet r = new TreeSet (new ReverseStringComparator()); Comparator (example)

Summary: JCF Interfaces Sets for representing mathematical sets −Unordered −No duplicates Lists for representing sequences −Order matters −Positional operators Maps for mapping keys onto values −keys form a Set Sorted versions of Set and Map −allows searching for elements/keys that are not present

In-Class Exercises Write an application that reads a text file and parses it into words − The application counts the number of occurrences of each word − The top 50 words, ordered in decreasing order by number of occurrences, are printed

47 Interface Implementation Technique Hash table ArrayTreeLinked list Hash table + Linked list SetHashSetTreeSetLinkedHashSet Sorted SetTreeSet ListArrayListLinkedList QueuePriorityQueueLinkedList MapHashMapTreeMapLinkedHashMap Sorted Map TreeMap Summary of Implementations Collection Map Set List Queue SortedSet SortedMap

48 HashSet and LinkedHashSet are both fast – add(x), remove(x), contains(x), size(), isEmpty() all execute in constant time on average Set: HashSet or LinkedHashSet LinkedHashSet remembers order elements are added – iteration reproduces this order

49 LinkedHashSet example // Print the elements in T without printing any element // twice, in order of first occurrence in a public static void printInOrderWithoutDups(T[] a) { Set s = new LinkedHashSet (); for (T x : a) { s.add(x); } for (T x : s) { System.out.println(x); }

50 HashMap and LinkedHashMap are both fast – put(k,v), get(k), remove(k), containsKey(k), size(), isEmpty() all execute in constant time on average – containsValue(v) is slow Map: HashMap or LinkedHashMap LinkedHashMap remembers order keys are added – keySet() is a LinkedHashSet

51 ArrayList – represents a list as an array – lookups are fast but modifications are slow – fast random-access ( get(i), set(i,x) ) – additions and removals can be slow ArrayList or LinkedList LinkedList – represents a list as a doubly-linked list – lookups are slow but modifications are fast – random-access can be slow ( get(i), set(i,x) ) – additions and removals are fast (constant time)

52 A list represented as an array – Usually the array has room for more elements ArrayList get(i), and set(i,x) are as fast as reading and writing a value in an array add(x) is usually fast – translates to set(size(),x); bcdea bcdexa

53 add(i,x) is slow when i << size() – elements have to be shifted to make room for x – requires moving size(x) - i array values ArrayList (Cont'd) bcdea bcdexa add(1,x)

remove(i) is slow when i << size() – elements have to be shifted. – requires moving size(x) – i – 1 array values ArrayList (Cont'd) bcdea bcdexa remove(1)

55 Fast when – a lot of random access is needed – additions and removals are at or near the end of the list. ArrayList summary Provides a fast implementation of – an array that can grow and shrink if needed – a stack push(x) → add(x) pop() → remove(size()-1);

Implements a List as a doubly-linked list – each node stores a reference to the next and previous element – has a pointer to the first and last elements LinkedList abcdef

57 get(i), set(i,x) are fast when i is small LinkedList(Cont'd) abcdef get(0) abcdef get(1)

add(i,x) are fast when i is small – find list node i-1 – modify next/previous at node i-1, i, and new node for x LinkedList(Cont'd) abcdef add(1,x) abcdef x

remove(i) is fast when i is small – find node i - 1 – modify next/previous at nodes i-1 and i+1 abcdef remove(1) abcdef LinkedList(Cont'd)

add(i,x), add(x), remove(i), get(i), set(i,x) are fast when i is large – if i > size() / 2 then we traverse the list backwards LinkedList(Cont'd) abcdef remove(4) abcdef

add(i,x), remove(i), get(i), set(i,x) must traverse – min{i, size()-i-1} elements Fast when i ~ 0 or i ~ size() Slow when i >> 0 and i << size() LinkedList(Cont'd) ab yz l.get(l.size()/2) m...

LinkedLists are good for implementing LinkedList(Cont'd) −Stacks −Queues −Dequeues

63 The ListIterator interface provides – hasNext(), next(), hasPrevious(), previous(), nextIndex(), previousIndex() These are fast (constant-time) for both ArrayList and LinkedList – remove(), set(x), add(x) These are fast for LinkedList These can be slow for ArrayList ListIterators

ArrayList – Fast to get to the location you want – Slow to insert or remove at that location except at the end (back). LinkedList versus ArrayList summary LinkedList – Slow to get to the location you want except at the front and back; or if you have an iterator at that location – Fast to insert or remove at that location

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void frontGets(List l, int n) { for (int i = 0; i < n; i++) { l.get(0); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void backGets(List l, int n) { for (int i = 0; i < n; i++) { l.get(l.size()-1); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void randomGets(List l, int n) { Random gen = new Random(); for (int i = 0; i < n; i++) { l.get(gen.nextInt(l.size())); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void insertAtBack(List l, int n) { l.clear(); for (int i = 0; i < n; i++) { l.add(new Integer(i)); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void insertAtFront(List l, int n) { l.clear(); for (int i = 0; i < n; i++) { l.add(0, new Integer(i)); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void insertInMiddle(List l, int n) { l.clear(); for (int i = 0; i < n; i++) { l.add(new Integer(i)); } for (int i = 0; i < n; i++) { l.add(n/2+i, new Integer(i)); }

Among ArrayList or LinkedList which type of implementation make this code faster? Excercises public static void insertInMiddle2(List l, int n) { l.clear(); for (int i = 0; i < n; i++) { l.add(new Integer(i)); } ListIterator li = l.listIterator(n/2); for (int i = 0; i < n; i++) { li.add(new Integer(i)); }

Unordered implementation of Set and Map – HashSet and HashMap summary SortedSet and SortedMap implementations – TreeSet and TreeMap Implementations of Set and Map that maintain insertion order – LinkedHashSet and LinkedHashMap List implementions – ArrayList: fast random access – LinkedList: fast insertion at an easy-to-get-to location

73 Interface Implementation Technique Hash table ArrayTreeLinked list Hash table + Linked list SetHashSetTreeSetLinkedHashSet Sorted SetTreeSet ListArrayListLinkedList QueuePriorityQueueLinkedList MapHashMapTreeMapLinkedHashMap Sorted Map TreeMap Summary of Implementations Collection Map Set List Queue SortedSet SortedMap

Next Class Array Based List Implementations