CSE 1030: The Collection Frameworks Mark Shtern
Summary Linked List Exceptions Checked/Unchecked Assertions Iterators
Final Exam Written Component Lab Component Static feature Non static feature Mixing static and non-static features Aggregation and Composition Inheritance Arrays, Linked List and Collection UML Lab Component API implementation
Nodes and Links in a Linked List Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Schema of an Insert Operation Add - “2” Pred Curr Head 1 3 Tail 2
Schema of a Remove Operation Pred Curr Head 1 2 3 Tail
Schema of a Contains Operation Curr Head 1 2 3 Tail
Implementation of Linked List
linked list Implement a linked list with the following methods Add Remove Contains Size The linked list should implement the following interfaces Iterable Serializable Cloneable
A Doubly Linked List Copyright © 2010 Pearson Addison-Wesley. All rights reserved.
Collection Map Set List
Implementing Classes List ArrayList, LinkedList Set HashSet, TreeSet Map HashMap, TreeMap
Default List ArrayList Set HashSet Map HashMap
Generics List bag = new ArrayList(); bag.add(“testing”); --------------------------------------------------------------- List <Date> bag = new ArrayList<Date>(); ---------------------------------------------------------------- <? extends P> or <? super C>
Searching and Sorting Collections sort (List<T> list) binarySearch(List<? Extends T> list, T x)
Example A student DB is a collection of type.lib.Student The DB supports Add/Edit/Delete student Query students by id, name, gpa and major Generate reports Class GPA report displays a course number and the average of all GPA grades awarded in the course Student statistic report shows number of students by major Develop the DB