List of usage examples for java.util Deque getFirst
E getFirst();
From source file:Main.java
public static void main(String[] args) { Deque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(15);/*from w w w.j a v a 2 s.c o m*/ deque.add(30); deque.add(20); deque.add(18); System.out.println(deque); int retval = deque.getFirst(); System.out.println("Retrieved Element is = " + retval); }
From source file:Main.java
public static void main(String[] args) { Deque<String> deque = new LinkedList<>(); deque.addLast("Oracle"); deque.offerLast("Java"); deque.offerLast("CSS"); deque.offerLast("XML"); System.out.println("Deque: " + deque); // remove elements from the Deque until it is empty while (deque.peekFirst() != null) { System.out.println("Head Element: " + deque.peekFirst()); deque.removeFirst();//from w ww . j a va 2 s . c om System.out.println("Removed one element from Deque"); System.out.println("Deque: " + deque); } // the Deque is empty. Try to call its peekFirst(), // getFirst(), pollFirst() and removeFirst() methods System.out.println("deque.isEmpty(): " + deque.isEmpty()); System.out.println("deque.peekFirst(): " + deque.peekFirst()); System.out.println("deque.pollFirst(): " + deque.pollFirst()); String str = deque.getFirst(); System.out.println("deque.getFirst(): " + str); str = deque.removeFirst(); System.out.println("deque.removeFirst(): " + str); }
From source file:org.openscore.lang.compiler.scorecompiler.ExecutionPlanBuilder.java
public ExecutionPlan createFlowExecutionPlan(Flow compiledFlow) { ExecutionPlan executionPlan = new ExecutionPlan(); executionPlan.setName(compiledFlow.getName()); executionPlan.setLanguage(SLANG_NAME); executionPlan.setFlowUuid(compiledFlow.getId()); executionPlan.setBeginStep(FLOW_START_STEP_ID); //flow start step executionPlan.addStep(stepFactory.createStartStep(FLOW_START_STEP_ID, compiledFlow.getPreExecActionData(), compiledFlow.getInputs(), compiledFlow.getName())); //flow end step executionPlan.addStep(stepFactory.createEndStep(FLOW_END_STEP_ID, compiledFlow.getPostExecActionData(), compiledFlow.getOutputs(), compiledFlow.getResults(), compiledFlow.getName())); Map<String, Long> taskReferences = new HashMap<>(); for (Result result : compiledFlow.getResults()) { taskReferences.put(result.getName(), FLOW_END_STEP_ID); }/*from ww w . j a v a 2 s . c o m*/ Deque<Task> tasks = compiledFlow.getWorkflow().getTasks(); if (CollectionUtils.isEmpty(tasks)) { throw new RuntimeException("Flow: " + compiledFlow.getName() + " has no tasks"); } List<ExecutionStep> taskExecutionSteps = buildTaskExecutionSteps(tasks.getFirst(), taskReferences, tasks); executionPlan.addSteps(taskExecutionSteps); return executionPlan; }
From source file:io.cloudslang.lang.compiler.CompileAsyncLoopFlowTest.java
@Test public void testPreCompileAsyncLoopFlowNavigate() throws Exception { Deque<Task> tasks = getTasksAfterPrecompileFlow("/loops/async_loop/async_loop_navigate.sl"); assertEquals(2, tasks.size());//from w w w.j a v a 2 s.c om Task asyncTask = tasks.getFirst(); verifyAsyncLoopStatement(asyncTask); List<Output> aggregateValues = getAggregateOutputs(asyncTask); assertEquals(0, aggregateValues.size()); List<Output> publishValues = getPublishOutputs(asyncTask); assertEquals("aggregate list is not empty", 0, publishValues.size()); Map<String, String> expectedNavigationStrings = new HashMap<>(); expectedNavigationStrings.put("SUCCESS", "print_list"); expectedNavigationStrings.put("FAILURE", "FAILURE"); verifyNavigationStrings(expectedNavigationStrings, asyncTask); assertTrue(asyncTask.isAsync()); }
From source file:io.cloudslang.lang.compiler.CompileAsyncLoopFlowTest.java
@Test public void testPreCompileAsyncLoopFlowAggregateNavigate() throws Exception { Deque<Task> tasks = getTasksAfterPrecompileFlow("/loops/async_loop/async_loop_aggregate_navigate.sl"); assertEquals(2, tasks.size());//from www .ja v a2s . c o m Task asyncTask = tasks.getFirst(); verifyAsyncLoopStatement(asyncTask); List<Output> aggregateValues = getAggregateOutputs(asyncTask); assertEquals(2, aggregateValues.size()); assertEquals("${ map(lambda x:str(x['name']), branches_context) }", aggregateValues.get(0).getValue()); List<Output> publishValues = getPublishOutputs(asyncTask); assertEquals("aggregate list is not empty", 2, publishValues.size()); assertEquals("${name}", publishValues.get(0).getValue()); Map<String, String> expectedNavigationStrings = new HashMap<>(); expectedNavigationStrings.put("SUCCESS", "print_list"); expectedNavigationStrings.put("FAILURE", "FAILURE"); verifyNavigationStrings(expectedNavigationStrings, asyncTask); assertTrue(asyncTask.isAsync()); }
From source file:io.cloudslang.lang.compiler.scorecompiler.ExecutionPlanBuilder.java
public ExecutionPlan createFlowExecutionPlan(Flow compiledFlow) { ExecutionPlan executionPlan = new ExecutionPlan(); executionPlan.setName(compiledFlow.getName()); executionPlan.setLanguage(CLOUDSLANG_NAME); executionPlan.setFlowUuid(compiledFlow.getId()); executionPlan.setWorkerGroup(compiledFlow.getWorkerGroup()); executionPlan.setBeginStep(FLOW_START_STEP_ID); //flow start step executionPlan.addStep(stepFactory.createStartStep(FLOW_START_STEP_ID, compiledFlow.getPreExecActionData(), compiledFlow.getInputs(), compiledFlow.getName(), ExecutableType.FLOW)); //flow end step executionPlan.addStep(stepFactory.createEndStep(FLOW_END_STEP_ID, compiledFlow.getPostExecActionData(), compiledFlow.getOutputs(), compiledFlow.getResults(), compiledFlow.getName(), ExecutableType.FLOW)); Map<String, Long> stepReferences = getStepReferences(compiledFlow); Deque<Step> steps = compiledFlow.getWorkflow().getSteps(); if (CollectionUtils.isEmpty(steps)) { throw new RuntimeException("Flow: " + compiledFlow.getName() + " has no steps"); }/*from w w w. j a v a 2s . c om*/ List<ExecutionStep> stepExecutionSteps = buildStepExecutionSteps(steps.getFirst(), stepReferences, steps, compiledFlow); executionPlan.addSteps(stepExecutionSteps); return executionPlan; }
From source file:io.cloudslang.lang.compiler.CompileParallelLoopFlowTest.java
@Test public void testPreCompileParallelLoopFlowNavigate() throws Exception { Deque<Step> steps = getStepsAfterPrecompileFlow("/loops/parallel_loop/parallel_loop_navigate.sl"); assertEquals(2, steps.size());// w w w.ja va 2s . c o m Step parallelStep = steps.getFirst(); verifyParallelLoopStatement(parallelStep); List<Output> publishValues = getPublishOutputs(parallelStep); assertEquals(0, publishValues.size()); List<Map<String, String>> expectedNavigationStrings = new ArrayList<>(); Map<String, String> successMap = new HashMap<>(); successMap.put(ScoreLangConstants.SUCCESS_RESULT, "print_list"); Map<String, String> failureMap = new HashMap<>(); failureMap.put(ScoreLangConstants.FAILURE_RESULT, "FAILURE"); expectedNavigationStrings.add(successMap); expectedNavigationStrings.add(failureMap); verifyNavigationStrings(expectedNavigationStrings, parallelStep); assertTrue(parallelStep.isParallelLoop()); }
From source file:io.cloudslang.lang.compiler.CompileParallelLoopFlowTest.java
@Test public void testPreCompileParallelLoopFlowPublishNavigate() throws Exception { Deque<Step> steps = getStepsAfterPrecompileFlow("/loops/parallel_loop/parallel_loop_publish_navigate.sl"); assertEquals(2, steps.size());//from w ww . ja v a 2 s . c om Step parallelStep = steps.getFirst(); verifyParallelLoopStatement(parallelStep); List<Output> publishValues = getPublishOutputs(parallelStep); assertEquals(2, publishValues.size()); assertEquals("${ map(lambda x:str(x['name']), branches_context) }", publishValues.get(0).getValue().get()); List<Map<String, String>> expectedNavigationStrings = new ArrayList<>(); Map<String, String> successMap = new HashMap<>(); successMap.put(ScoreLangConstants.SUCCESS_RESULT, "print_list"); Map<String, String> failureMap = new HashMap<>(); failureMap.put(ScoreLangConstants.FAILURE_RESULT, "FAILURE"); expectedNavigationStrings.add(successMap); expectedNavigationStrings.add(failureMap); verifyNavigationStrings(expectedNavigationStrings, parallelStep); assertTrue(parallelStep.isParallelLoop()); }
From source file:ninja.undertow.NinjaUndertowContext.java
@Override public String getParameter(String name) { // Returns the value of a request parameter as a String, or null if the // parameter does not exist. Request parameters are extra information sent // with the request. For ninja (following servlet rule), parameters are contained in the // query string or posted form data. Deque<String> queryParameterValues = exchange.getQueryParameters().get(name); if (queryParameterValues != null && !queryParameterValues.isEmpty()) { return queryParameterValues.getFirst(); } else {/*from w ww . ja va 2s . c o m*/ // fallback to form data if (this.formData != null) { FormData.FormValue value = this.formData.getFirst(name); if (value != null) { return value.getValue(); } } } return null; }