/** * {@inheritDoc} * * <p> * * <p>This implementation iterates over the specified collection, checking each element returned * by the iterator in turn to see if it's contained in this collection. If all elements are so * contained <tt>true</tt> is returned, otherwise <tt>false</tt>. * * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @see #contains(int) */ public boolean containsAll(IntCollection c) { IntIterator e = c.iterator(); while (e.hasNext()) { if (!contains(e.next())) { return false; } } return true; }
/** * {@inheritDoc} * * <p> * * <p>This implementation iterates over the specified collection, and adds each object returned by * the iterator to this collection, in turn. * * <p> * * <p>Note that this implementation will throw an <tt>UnsupportedOperationException</tt> unless * <tt>add</tt> is overridden (assuming the specified collection is non-empty). * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} * @throws IllegalStateException {@inheritDoc} * @see #add(int) */ public boolean addAll(IntCollection c) { boolean modified = false; IntIterator e = c.iterator(); while (e.hasNext()) { if (add(e.next())) { modified = true; } } return modified; }
/** * {@inheritDoc} * * <p> * * <p>This implementation iterates over this collection, checking each element returned by the * iterator in turn to see if it's contained in the specified collection. If it's not so * contained, it's removed from this collection with the iterator's <tt>remove</tt> method. * * <p> * * <p>Note that this implementation will throw an <tt>UnsupportedOperationException</tt> if the * iterator returned by the <tt>iterator</tt> method does not implement the <tt>remove</tt> method * and this collection contains one or more elements not present in the specified collection. * * @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @see #remove(int) * @see #contains(int) */ public boolean retainAll(IntCollection c) { boolean modified = false; IntIterator e = iterator(); while (e.hasNext()) { if (!c.contains(e.next())) { e.remove(); modified = true; } } return modified; }