List of usage examples for java.util ArrayDeque clear
public void clear()
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testPeekFirst() { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertNull(deque.peekFirst());/* www .j a v a2 s. c o m*/ deque.add(o1); assertEquals(o1, deque.peekFirst()); checkDequeSizeAndContent(deque, o1); deque.add(o2); assertEquals(o1, deque.peekFirst()); checkDequeSizeAndContent(deque, o1, o2); deque.addFirst(o3); assertEquals(o3, deque.peekFirst()); checkDequeSizeAndContent(deque, o3, o1, o2); deque.clear(); assertTrue(deque.isEmpty()); assertNull(deque.peekFirst()); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testFailFastIterator() { ArrayDeque<Object> deque = new ArrayDeque<>(asList(getFullNonNullElements())); Iterator<Object> it = deque.iterator(); it.next();/* w ww. java 2 s .c om*/ deque.removeFirst(); try { it.next(); } catch (ConcurrentModificationException e) { fail(); } deque.removeLast(); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.iterator(); it.next(); deque.clear(); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.iterator(); it.next(); deque.addFirst(new Object()); try { it.next(); } catch (ConcurrentModificationException e) { fail(); } deque.addLast(new Object()); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.iterator(); it.next(); it.next(); deque.removeFirst(); try { it.remove(); } catch (ConcurrentModificationException e) { fail(); } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.iterator(); it.next(); it.next(); deque.removeFirst(); deque.removeFirst(); try { it.remove(); fail(); } catch (ConcurrentModificationException expected) { } }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testFailFastDescendingIterator() { ArrayDeque<Object> deque = new ArrayDeque<>(asList(getFullNonNullElements())); Iterator<Object> it = deque.descendingIterator(); it.next();// w w w .j a va 2 s . c o m deque.removeLast(); try { it.next(); } catch (ConcurrentModificationException e) { fail(); } deque.removeFirst(); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.descendingIterator(); it.next(); deque.clear(); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.descendingIterator(); it.next(); deque.addLast(new Object()); try { it.next(); } catch (ConcurrentModificationException e) { fail(); } deque.addFirst(new Object()); try { it.next(); fail(); } catch (ConcurrentModificationException expected) { } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.descendingIterator(); it.next(); it.next(); deque.removeLast(); try { it.remove(); } catch (ConcurrentModificationException e) { fail(); } deque = new ArrayDeque<>(asList(getFullNonNullElements())); it = deque.descendingIterator(); it.next(); it.next(); deque.removeLast(); deque.removeLast(); try { it.remove(); fail(); } catch (ConcurrentModificationException expected) { } }
From source file:com.espertech.esper.core.EPRuntimeImpl.java
/** * Processing multiple filter matches for a statement. * @param handle statement handle/*from w w w.j a va2s. co m*/ * @param callbackList object containing callbacks * @param event to process * @param version filter version */ public void processStatementFilterMultiple(EPStatementHandle handle, ArrayDeque<FilterHandleCallback> callbackList, EventBean event, long version) { handle.getStatementLock().acquireWriteLock(services.getStatementLockFactory()); try { if (handle.isHasVariables()) { services.getVariableService().setLocalVersion(); } if (!handle.isCurrentFilter(version)) { callbackList.clear(); ArrayDeque<FilterHandle> callbackListNew = getCallbackList(event, handle.getStatementId()); for (FilterHandle callback : callbackListNew) { EPStatementHandleCallback handleCallbackFilter = (EPStatementHandleCallback) callback; callbackList.add(handleCallbackFilter.getFilterCallback()); } } if (isSubselectPreeval) { // sub-selects always go first for (FilterHandleCallback callback : callbackList) { if (callback.isSubSelect()) { callback.matchFound(event, callbackList); } } for (FilterHandleCallback callback : callbackList) { if (!callback.isSubSelect()) { callback.matchFound(event, callbackList); } } } else { // sub-selects always go last for (FilterHandleCallback callback : callbackList) { if (!callback.isSubSelect()) { callback.matchFound(event, callbackList); } } for (FilterHandleCallback callback : callbackList) { if (callback.isSubSelect()) { callback.matchFound(event, callbackList); } } } // internal join processing, if applicable handle.internalDispatch(this.engineFilterAndDispatchTimeContext); } catch (RuntimeException ex) { services.getExceptionHandlingService().handleException(ex, handle); } finally { handle.getStatementLock().releaseWriteLock(services.getStatementLockFactory()); } }