List of usage examples for java.util ArrayDeque removeLastOccurrence
public boolean removeLastOccurrence(Object o)
From source file:Main.java
public static void main(String[] args) { ArrayDeque<Integer> deque = new ArrayDeque<Integer>(8); deque.add(3);/*from w w w . j a v a 2 s . c o m*/ deque.add(18); deque.add(25); deque.add(18); System.out.println(deque); deque.removeLastOccurrence(18); System.out.println(deque); }
From source file:com.google.gwt.emultest.java.util.ArrayDequeTest.java
public void testRemoveLastOccurrence() { Object o1 = new Object(); Object o2 = new Object(); Object o3 = new Object(); ArrayDeque<Object> deque = new ArrayDeque<>(); assertFalse(deque.removeLastOccurrence(o1)); deque.add(o1);//from ww w.j a v a2 s . co m assertTrue(deque.removeLastOccurrence(o1)); assertTrue(deque.isEmpty()); deque = new ArrayDeque<>(); deque.add(o1); deque.add(o2); deque.add(o3); assertTrue(deque.removeLastOccurrence(o2)); checkDequeSizeAndContent(deque, o1, o3); deque = new ArrayDeque<>(); deque.add(o1); deque.add(o2); deque.add(o3); deque.add(o1); deque.add(o2); deque.add(o3); assertTrue(deque.removeLastOccurrence(o2)); checkDequeSizeAndContent(deque, o1, o2, o3, o1, o3); assertTrue(deque.removeLastOccurrence(o2)); checkDequeSizeAndContent(deque, o1, o3, o1, o3); assertTrue(deque.removeLastOccurrence(o3)); checkDequeSizeAndContent(deque, o1, o3, o1); assertTrue(deque.removeLastOccurrence(o3)); checkDequeSizeAndContent(deque, o1, o1); assertFalse(deque.removeLastOccurrence(o3)); assertFalse(deque.removeLastOccurrence(null)); }