Data Structures & Algorithms Lecture Notes

18 February 2010 • Java Collections


Outline

Collections

Objectives

Collection Interface Hierarchy

collection interface hierarchy

Collection Interface

The Collection Interface

interface Collection<E> 
implements Iterable<E> {
   boolean     add(E e)*
   boolean     addAll(Collection<? extends E> c)*
   void        clear()*
   boolean     contains(Object o)
   boolean     containsAll(Collection<?> c)
   boolean     equals(Object o)
   int         hashCode()
   boolean     isEmpty()
   Iterator<E> iterator()
   boolean     remove(Object o)*
   boolean     removeAll(Collection<?> c)*
   boolean     retainAll(Collection<?> c)*
   int         size()
   Object[]    toArray()
   <T> T[]     toArray(T[] a)
  }

* Optional

Optional Methods

Group Methods

Group Method Examples

Group-Method Implementations

Collection Interface Hierarchy

collection interface hierarchy

List Interface

The List Interface

Indexible List Methods

Collection Interface Hierarchy

collection interface hierarchy

The Queue Interface

The Queue Interface

The Deque Interface

Collection Interface Hierarchy

collection interface hierarchy

The Iterator Interface

List Navigation

List Iterators

The List Iterator Interface

List Iterator Indexing

List Manipulations

Removing Elements

Better Iteration Code

The Iterable Interface

Interface Declarations

Implementation Hierarchy

collection implementation hierarchy

Abstract Implementations

Example

Linked Lists

Array Lists

Random-Access Iterators

Priority Queues

Where’s Stacks?

stacks

Summary

References


This page last modified on 17 February 2010.

Creative
    Commons License