teaching machines

CS 245 Lecture 12 – Generic Sorted List

October 10, 2013 by . Filed under cs245, fall 2013, lectures.

Agenda

What Does This Do?

What happens when someone calls Main.print?

class Foo {
  public String toString() {
    return "yargles";
  }
}

class Main {
  ...
  public void print(Foo f) {
    System.out.println(f.toString());
  }
}

Program This

You have a sorted array of ints, but it’s not filled to capacity. Someone hands you another int. How can you insert it and keep the list sorted? Write something down.

Code

Haiku

generic love
Don’t lower standards
Wait for her to define them
Love T, for some T