List of usage examples for java.util ArrayDeque clear
public void clear()
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(1);//from w ww . j a v a2 s.c om deque.add(2); deque.add(10); System.out.println(deque); // finding size of this deque int retval = deque.size(); System.out.println("Deque consists of " + retval + " elements"); deque.clear(); retval = deque.size(); System.out.println("Now, deque consists of " + retval + " elements"); }
From source file:com.facebook.litho.ComponentsPools.java
@ThreadSafe(enableChecks = false) public static void release(ArrayDeque deque) { if (!ComponentsConfiguration.usePooling) { return;//from w ww . j a v a2 s . co m } deque.clear(); sArrayDequePool.release(deque); }
From source file:io.cloudslang.worker.execution.services.ExecutionServiceImpl.java
private void dumpBusEvents(Execution execution) throws InterruptedException { ArrayDeque<ScoreEvent> eventsQueue = execution.getSystemContext().getEvents(); if (eventsQueue == null) { return;//from w ww. j a va2 s .c o m } for (ScoreEvent eventWrapper : eventsQueue) { eventBus.dispatch(eventWrapper); } eventsQueue.clear(); }
From source file:com.espertech.esper.core.service.StatementResultServiceImpl.java
public void execute() { ArrayDeque<UniformPair<EventBean[]>> dispatches = lastResults.get(); UniformPair<EventBean[]> events = EventBeanUtility.flattenList(dispatches); if (ExecutionPathDebugLog.isDebugEnabled && log.isDebugEnabled()) { ViewSupport.dumpUpdateParams(".execute", events); }/*from w w w . j a v a 2 s.com*/ if ((ThreadingOption.isThreadingEnabled) && (threadingService.isOutboundThreading())) { threadingService.submitOutbound(new OutboundUnitRunnable(events, this)); } else { processDispatch(events); } dispatches.clear(); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testElement() { Object o1 = new Object(); Object o2 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); try {/* w w w. j a v a 2 s. co m*/ deque.element(); fail(); } catch (NoSuchElementException expected) { } deque.add(o1); assertEquals(o1, deque.element()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o1, deque.element()); checkDequeSizeAndContent(deque, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); try { deque.element(); fail(); } catch (NoSuchElementException expected) { } }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testGetLast() { Object o1 = new Object(); Object o2 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); try {//from w w w .j ava2 s. co m deque.getLast(); fail(); } catch (NoSuchElementException expected) { } deque.add(o1); assertEquals(o1, deque.getLast()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o2, deque.getLast()); checkDequeSizeAndContent(deque, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); try { deque.getLast(); fail(); } catch (NoSuchElementException expected) { } }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testGetFirst() { Object o1 = new Object(); Object o2 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); try {/*from w ww . j a v a 2 s . co m*/ deque.getFirst(); fail(); } catch (NoSuchElementException expected) { } deque.add(o1); assertEquals(o1, deque.getFirst()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o1, deque.getFirst()); checkDequeSizeAndContent(deque, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); try { deque.getFirst(); fail(); } catch (NoSuchElementException expected) { } }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testPeek() { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertNull(deque.peek());//from w w w. j ava 2 s . co m deque.add(o1); assertEquals(o1, deque.peek()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o1, deque.peek()); checkDequeSizeAndContent(deque, o1, o2); deque.addFirst(o3); assertEquals(o3, deque.peek()); checkDequeSizeAndContent(deque, o3, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); assertNull(deque.peek()); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testContains() { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertFalse(deque.contains(o3));/*w ww . jav a2s . c o m*/ assertFalse(deque.contains(null)); assertTrue(deque.add(o1)); assertTrue(deque.add(o2)); assertTrue(deque.add(o1)); assertTrue(deque.add(o3)); assertTrue(deque.contains(o1)); assertTrue(deque.contains(o2)); assertTrue(deque.contains(o3)); assertFalse(deque.contains(null)); deque.clear(); assertTrue(deque.isEmpty()); assertFalse(deque.contains(o1)); assertFalse(deque.contains(o2)); assertFalse(deque.contains(o3)); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testPeekLast() { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertNull(deque.peekLast());//from ww w. j av a2 s .c om deque.add(o1); assertEquals(o1, deque.peekLast()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o2, deque.peekLast()); checkDequeSizeAndContent(deque, o1, o2); deque.addFirst(o3); assertEquals(o2, deque.peekLast()); checkDequeSizeAndContent(deque, o3, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); assertNull(deque.peekLast()); }