taller workshop

3
Main() package punto3y4; import java.util.ArrayList; import java.util.Deque; import java.util.Queue; import java.util.LinkedList; public class Ej { public static void main(String[] args) { Queue<PitchClassRepresentatives> Lista= new LinkedList<PitchClassRepresentatives>(); Lista.add(new PitchClassRepresentatives(0,"Do")); Lista.add(new PitchClassRepresentatives(1,"Reb")); Lista.add(new PitchClassRepresentatives(2,"Re")); Lista.add(new PitchClassRepresentatives(3,"Mib")); Lista.add(new PitchClassRepresentatives(4,"Mi")); Lista.add(new PitchClassRepresentatives(5,"Fa")); Lista.add(new PitchClassRepresentatives(6,"Solb")); Lista.add(new PitchClassRepresentatives(7,"Sol")); Lista.add(new PitchClassRepresentatives(8,"Lab")); Lista.add(new PitchClassRepresentatives(9,"La")); Lista.add(new PitchClassRepresentatives(10,"Sib")); Lista.add(new PitchClassRepresentatives(11,"Si")); long Tinicial=System.nanoTime(); Lista.clear(); long Tfinal=System.nanoTime(); System.out.println("El tiempo de Queu fue= "+(Tfinal-Tinicial)+ " nanosegundos" ); Deque<PitchClassRepresentatives> Lista1= new LinkedList<PitchClassRepresentatives>(); Lista1.add(new PitchClassRepresentatives(0,"Do")); Lista1.add(new PitchClassRepresentatives(1,"Reb")); Lista1.add(new PitchClassRepresentatives(2,"Re")); Lista1.add(new PitchClassRepresentatives(3,"Mib")); Lista1.add(new PitchClassRepresentatives(4,"Mi")); Lista1.add(new PitchClassRepresentatives(5,"Fa")); Lista1.add(new PitchClassRepresentatives(6,"Solb")); Lista1.add(new PitchClassRepresentatives(7,"Sol")); Lista1.add(new PitchClassRepresentatives(8,"Lab")); Lista1.add(new PitchClassRepresentatives(9,"La")); Lista1.add(new PitchClassRepresentatives(10,"Sib")); Lista1.add(new PitchClassRepresentatives(11,"Si")); long Tinicial1=System.nanoTime(); Lista1.clear(); long Tfinal1=System.nanoTime(); System.out.println("El tiempo de Deque fue= "+(Tfinal1-Tinicial1)+ " nanosegundos" );

Upload: eddie-jonathan-garcia-borbon

Post on 16-Nov-2015

212 views

Category:

Documents


0 download

DESCRIPTION

Taller Workshop

TRANSCRIPT

Main()

package punto3y4;import java.util.ArrayList;import java.util.Deque;import java.util.Queue;import java.util.LinkedList;

public class Ej {

public static void main(String[] args) {Queue Lista= new LinkedList();Lista.add(new PitchClassRepresentatives(0,"Do"));Lista.add(new PitchClassRepresentatives(1,"Reb"));Lista.add(new PitchClassRepresentatives(2,"Re"));Lista.add(new PitchClassRepresentatives(3,"Mib"));Lista.add(new PitchClassRepresentatives(4,"Mi"));Lista.add(new PitchClassRepresentatives(5,"Fa"));Lista.add(new PitchClassRepresentatives(6,"Solb"));Lista.add(new PitchClassRepresentatives(7,"Sol"));Lista.add(new PitchClassRepresentatives(8,"Lab"));Lista.add(new PitchClassRepresentatives(9,"La"));Lista.add(new PitchClassRepresentatives(10,"Sib"));Lista.add(new PitchClassRepresentatives(11,"Si"));long Tinicial=System.nanoTime();Lista.clear();long Tfinal=System.nanoTime();System.out.println("El tiempo de Queu fue= "+(Tfinal-Tinicial)+ " nanosegundos" );Deque Lista1= new LinkedList();Lista1.add(new PitchClassRepresentatives(0,"Do"));Lista1.add(new PitchClassRepresentatives(1,"Reb"));Lista1.add(new PitchClassRepresentatives(2,"Re"));Lista1.add(new PitchClassRepresentatives(3,"Mib"));Lista1.add(new PitchClassRepresentatives(4,"Mi"));Lista1.add(new PitchClassRepresentatives(5,"Fa"));Lista1.add(new PitchClassRepresentatives(6,"Solb"));Lista1.add(new PitchClassRepresentatives(7,"Sol"));Lista1.add(new PitchClassRepresentatives(8,"Lab"));Lista1.add(new PitchClassRepresentatives(9,"La"));Lista1.add(new PitchClassRepresentatives(10,"Sib"));Lista1.add(new PitchClassRepresentatives(11,"Si"));long Tinicial1=System.nanoTime();Lista1.clear();long Tfinal1=System.nanoTime();System.out.println("El tiempo de Deque fue= "+(Tfinal1-Tinicial1)+ " nanosegundos" );}

}

PicthClassRepressentatives()

package punto3y4;

import java.util.Collection;import java.util.Iterator;

public class PitchClassRepresentatives {private int NumeroRepresentativo;private String NotaMusical;public PitchClassRepresentatives(int numeroRepresentativo,String notaMusical) {super();NumeroRepresentativo = numeroRepresentativo;NotaMusical = notaMusical;}public PitchClassRepresentatives() {// TODO Auto-generated constructor stub}public int getNumeroRepresentativo() {return NumeroRepresentativo;}public void setNumeroRepresentativo(int numeroRepresentativo) {NumeroRepresentativo = numeroRepresentativo;}public String getNotaMusical() {return NotaMusical;}public void setNotaMusical(String notaMusical) {NotaMusical = notaMusical;}@Overridepublic String toString() {return "PitchClassRepresentatives [NumeroRepresentativo="+ NumeroRepresentativo + ", NotaMusical=" + NotaMusical + "]";}

}

11. Choose one of the classes that you should implement for the completion of the course

final project, implement the Class in Java (could be the same that you use for the Set

Exercises).

12. Create a Queue from objects from your class (at least 10).

13. Measure the time elapsed (See Appendix) for removing all the elements in the and

register it in the following table:

Final Projects NameFinal Project Class Name ChosenClass In the core collections hierarchyInterfaces Methods UsedElapsed Time

Music Theory Set-Class CalculatorPitchClassRepresentatives()Queueadd(),clear();16620 ns

Music Theory Set-Class CalculatorPitchClassRepresentatives()Dequeadd(),clear();7822 ns