Generic types Measuring Efficiency Minesweeper start-up Grader - - PowerPoint PPT Presentation

generic types measuring efficiency minesweeper start up
SMART_READER_LITE
LIVE PREVIEW

Generic types Measuring Efficiency Minesweeper start-up Grader - - PowerPoint PPT Presentation

Generic types Measuring Efficiency Minesweeper start-up Grader comments for JUnit and BigRational assignments should be in your repository. There seems to be a problem there with JUnit. Should be resolved this afternoon Details about


slide-1
SLIDE 1

Generic types Measuring Efficiency Minesweeper start-up

slide-2
SLIDE 2

Grader comments for JUnit and BigRational

assignments should be in your repository.

There seems to be a problem there with JUnit.

Should be resolved this afternoon

Details about Thursday's exam are in Day 10

PowerPoint Slides

slide-3
SLIDE 3

BallWorlds Exam Anything else

slide-4
SLIDE 4

Generic types in Java. Intro to Algorithm analysis Meet your Minesweeper partner, produce a

UML diagram for Minesweeper.

slide-5
SLIDE 5

Before Java 1.5 (still supported, but gives warnings): New version(generic):

<Integer> <Integer> is a “type is a “type argumen argument” ” to the class defini to the class definiti tion.

Explicit class cast Explicit class cast required. required. No class cast No class cast required. required.

automati automatic unboxing: c unboxing: Integer Integerint. int.

slide-6
SLIDE 6

Any class that implements Comparable contracts to provide a

compareTo compareTo method.

Therefore, we can write generic methods on Comparable

  • bjects. For example, in the Arrays class:

String is String is a a Comparable class. Comparable class. If it did not If it did not already already have have a compareTo a compareTo method, how would you write it? method, how would you write it?

slide-7
SLIDE 7

import java.util.Arrays; public class StringSort { public static void main(String[] args) { String [] toons = {"Mickey", "Minnie", "Donald", "Pluto", "Goofy"}; Arrays.sort(toons); for (String s:toons) System.out.println(s); } }

Output: Output: Donald Goofy Mickey Minnie Pluto

slide-8
SLIDE 8

What kinds of things should we measure? CPU time memory used disk transfers network bandwidth Mostly in this course, we focus on the first

two, and especially on CPU time.

slide-9
SLIDE 9

How can we measure running time? System.currentTimeMillis Run Sieve example. When do we really care about efficiency? Lots more on this after the break

slide-10
SLIDE 10

I had to make a

couple of adjustments, due to people who had to drop the course.

This included dissolving

the team of three in Section 01 and adding a team of three in Section 02.

Check out your

repository