generic types measuring efficiency minesweeper start up
play

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


  1. Generic types Measuring Efficiency Minesweeper start-up

  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

  3. � BallWorlds � Exam � Anything else

  4. � Generic types in Java. � Intro to Algorithm analysis � Meet your Minesweeper partner, produce a UML diagram for Minesweeper.

  5. � Before Java 1.5 (still supported, but gives warnings) : Explicit class cast Explicit class cast required. required. � New version(generic): <Integer> is a “type <Integer> is a “type argumen argument” ” to the class defini to the class definiti tion. No class cast No class cast required. required. automati automatic unboxing: c unboxing: Integer Integer � int. int.

  6. � Any class that implements Comparable contracts to provide a compareTo compareTo method. 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? � Therefore, we can write generic methods on Comparable objects. For example, in the Arrays class:

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

  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.

  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

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend