16a: Immutability / Graphs

ICS211, Fall 2012
Dr. Zach

(switch view)

Status check

Dangers of Mutability

public void setValue(int value) {
  if (value < 1 || value > 13) {
    throw new IllegalArgumentException("Value " + value +
        " out of valid 1 - 13 range.");
  }
  this.value = value;
}

public void setSuit(Suit suit) {
  this.suit = suit;
}

Mutable PlayingCard

Immutability and Lists/Arrays/Objects

Unchangeable CardProtector...

Unchangeable CardProtector...

Unchangeable CardProtector!

Immutability

Summary (last lecture + a half)

Graphs

Graphs

As a data structure

Adjacency Matrix

Digraph of 6 vertices

Adjacency Matrix Options

Uni graph of 6 vertices

Adjacency List

Adjacency List Options

Graphs as ADTs

Graphs in your future

Other Data Structures

(mostly uncommon or advanced)

Common Data Structures + ADTs

Many variations

For next time...