@Test void addAll() { ConcurrentHashMap<Object, Object> localMap = new ConcurrentHashMap<>(); BlockingQueue<String> queue = new MapBasedLinkedBlockingQueue(localMap); assertTrue(queue.isEmpty()); assertTrue(queue.addAll(Arrays.asList("Baz", "Foo", "buz", "Bar"))); assertEquals(4, queue.size()); assertEquals(4, localMap.size()); assertEquals("Baz", queue.poll()); assertEquals("Foo", queue.poll()); assertEquals("buz", queue.poll()); assertEquals("Bar", queue.poll()); assertTrue(queue.isEmpty()); assertTrue(localMap.isEmpty()); }
@Override public boolean addAll(Collection<? extends T> collection) { boolean result = false; for (T t : collection) { boolean add = this.add(t); result = result || add; } return result; }
MapBasedLinkedBlockingQueue implements BlockingQueue<T> { @Override public boolean addAll(Collection<? extends T> collection) { boolean result = false; for (T t : collection) { boolean add = this.add(t); result = result || add; } return result; } }
MapBasedLinkedBlockingQueue implements BlockingQueue<T> { @Override public boolean addAll(Collection<? extends T> collection) { boolean result = false; for (T t : collection) { boolean add = this.add(t); result = result || add; } return result; } MapBasedLinkedBlockingQueue(ConcurrentMap<Long, T> internalMap); }
MapBasedLinkedBlockingQueue implements BlockingQueue<T> { @Override public boolean addAll(Collection<? extends T> collection) { boolean result = false; for (T t : collection) { boolean add = this.add(t); result = result || add; } return result; } MapBasedLinkedBlockingQueue(ConcurrentMap<Long, T> internalMap); @Override void put(T t); @Override boolean offer(T t, long l, TimeUnit timeUnit); @Override boolean offer(T t); @Override T take(); @Override T poll(long l, TimeUnit timeUnit); @Override int remainingCapacity(); @Override T poll(); @Override T element(); @Override T peek(); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> collection); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<T> iterator(); @Override Object[] toArray(); @Override T1[] toArray(T1[] t1s); @Override void clear(); @Override int drainTo(Collection<? super T> collection); @Override int drainTo(Collection<? super T> collection, int i); @Override boolean add(T t); @Override T remove(); @Override boolean addAll(Collection<? extends T> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection); }
MapBasedLinkedBlockingQueue implements BlockingQueue<T> { @Override public boolean addAll(Collection<? extends T> collection) { boolean result = false; for (T t : collection) { boolean add = this.add(t); result = result || add; } return result; } MapBasedLinkedBlockingQueue(ConcurrentMap<Long, T> internalMap); @Override void put(T t); @Override boolean offer(T t, long l, TimeUnit timeUnit); @Override boolean offer(T t); @Override T take(); @Override T poll(long l, TimeUnit timeUnit); @Override int remainingCapacity(); @Override T poll(); @Override T element(); @Override T peek(); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> collection); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); @Override Iterator<T> iterator(); @Override Object[] toArray(); @Override T1[] toArray(T1[] t1s); @Override void clear(); @Override int drainTo(Collection<? super T> collection); @Override int drainTo(Collection<? super T> collection, int i); @Override boolean add(T t); @Override T remove(); @Override boolean addAll(Collection<? extends T> collection); @Override boolean removeAll(Collection<?> collection); @Override boolean retainAll(Collection<?> collection);  }