Professional Documents
Culture Documents
Solving
Class 32:
The Java Collections Framework
History
Collections Interfaces, 1
Collection Map
SortedSet
Iterator
ListIterator
4
Collections Interfaces, 2
Collections Interfaces, 3
Collection Implementations
Collection Implementations, 2
Implementations
Hash Resizable Balanced Linked
Table Array Tree List
Array- Linked-
List
List List
HashSet
Set
Ordered TreeMap
Map
8
4
Collection Implementations, 3
Implementation Choices
Collection Interface
11
Collection Interface, 2
// Modification Operations
boolean add(Object o);
boolean remove(Object o);
boolean addAll(Collection c);
boolean removeAll(Collection c);
boolean retainAll(Collection c);
void clear();
}
12
Bulk Operations
13
Bulk Constructors
14
Array Operations
15
Array Examples
16
List Interface
Views
18
Set Interface
19
SortedSet Interface
20
10
Iterator Interface
21
ListIterator Interface
22
11
Concurrent Modification
23
List Iterator
first last current next
24
12
List Iterator
first last current next
?
Link Link Link null
25
Map Interface
26
13
Map Interface, 2
// Modification Operations
void clear();
// Views
int hashCode();
27
28
14
Map Views
Maps also provide views. In fact they are crucial because a Map
does not provide an iterator() method.
They are two separate idioms for iterating over a Map, depending
on whether you want to iterate over the keys or the values:
Map m = ...;
{...}
{...}
29
SortedMap Interface
30
15
Optional Operations
31
Algorithms
16
Read-Only Collections
33
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the United States
and other countries. 17