List of usage examples for java.util SortedSet toArray
Object[] toArray();
From source file:com.google.gwt.emultest.java.util.TreeSetTest.java
/** * Test method for 'java.util.SortedSet.last()'. * * @see java.util.SortedSet#last()/* ww w.j ava 2 s . c o m*/ */ public void testLastKey() { SortedSet<E> sortedSet = createNavigableSet(); // test with a single entry set sortedSet.add(getKeys()[0]); assertEquals(getKeys()[0], sortedSet.last()); // is it consistent with other methods assertEquals(sortedSet.toArray()[0], sortedSet.last()); assertEquals(getKeys()[0], sortedSet.first()); assertEquals(sortedSet.first(), sortedSet.last()); // test with two entry set sortedSet.add(getKeys()[1]); assertEquals(getKeys()[1], sortedSet.last()); assertFalse(getKeys()[0].equals(sortedSet.last())); // is it consistent with other methods assertEquals(sortedSet.toArray()[1], sortedSet.last()); assertEquals(getKeys()[0], sortedSet.first()); assertFalse(sortedSet.first().equals(sortedSet.last())); }
From source file:uk.ac.rdg.evoportal.pages.ScaleTestDetail.java
public ScaleTestDetail(PageParameters params) { String idStr = params.getString("id"); final long testID = Long.parseLong(idStr); ScaleTest scaleTest = ScaleTestsDataProvider.get(testID); int percentageDone = scaleTest.getPercentageDone(); String testName = scaleTest.getLabel(); int iterations = scaleTest.getIterations(); add(new Label("id", idStr)); add(new Label("name", testName)); add(new Label("its", Integer.toString(iterations))); add(new Label("pcDone", percentageDone + "%")); add(new TextArea("controlBlock", new Model<String>(scaleTest.getBPBlock()))); SortedSet<Integer> nodesSet = new TreeSet<Integer>(); List<ScaleTestComputeJob> results = scaleTest.getScaleTestComputeJobs(); double[][] runSeries = new double[2][results.size()]; int j = 0;/*from w w w . jav a2s . c o m*/ double testSize = (double) iterations; for (Iterator<ScaleTestComputeJob> i = results.iterator(); i.hasNext();) { ScaleTestComputeJob result = i.next(); int nodes = result.getNodes(); int duration = result.getDuration(); runSeries[0][j] = (double) nodes; runSeries[1][j] = (double) duration; // in seconds nodesSet.add(result.getNodes()); double m = ((double) duration / testSize); calc.putMultipler(nodes, m); j++; } List<Integer> iterationsChoices = Arrays.asList( new Integer[] { 100000, 200000, 300000, 400000, 500000, 1000000, 1200000, 1300000, 1400000, 1500000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000 }); Form calcForm = new Form("calcForm", new CompoundPropertyModel(calc)); calcForm.setVisible(false); // only render image if test is completed with all jobs stopped boolean isResultsReady = percentageDone == 100; if (isResultsReady) { DefaultXYDataset xyData = new DefaultXYDataset(); xyData.addSeries(testName, runSeries); JFreeChart scaleChart = ChartFactory.createScatterPlot("Scale test results for " + testName, "Number of nodes", "Time to run in seconds", xyData, PlotOrientation.VERTICAL, true, true, true); add(new ScaleTestResultsChart("chart", scaleChart, 600, 300)); calc.setIterations(iterationsChoices.get(0)); calc.setNodes(nodesSet.first()); calcForm.setVisible(true); } else { add(new Image("chart")); } final Label durationText = new Label("durationString"); durationText.setOutputMarkupId(true); DropDownChoice iterationsDropDown = new DropDownChoice("iterations", iterationsChoices); iterationsDropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(durationText); } }); DropDownChoice nodesDropDown = new DropDownChoice("nodes", Arrays.asList(nodesSet.toArray())); nodesDropDown.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.addComponent(durationText); } }); calcForm.add(iterationsDropDown); calcForm.add(nodesDropDown); calcForm.add(durationText); add(calcForm); ScaleTestComputeJobsDataProvider scaleTestComputeJobsDataProvider = new ScaleTestComputeJobsDataProvider( testID); add(new ScaleTestComputeJobsDataView("jobDetails", scaleTestComputeJobsDataProvider, testID)); if (!isResultsReady) { AjaxSelfUpdatingTimerBehavior timer = new AjaxSelfUpdatingTimerBehavior(Duration.seconds(15)) { @Override protected void onPostProcessTarget(AjaxRequestTarget target) { ScaleTest refreshedScaleTest = ScaleTestsDataProvider.get(testID); int pcDone = refreshedScaleTest.getPercentageDone(); get("pcDone").replaceWith(new Label("pcDone", pcDone + "%")); if (pcDone == 100) { setResponsePage(ScaleTestDetail.class, new PageParameters("id=" + testID)); } } }; add(timer); } }