@Override public BooleanList subList(final int from, final int to) { ensureIndex(from); ensureIndex(to); if (from > to) throw new IndexOutOfBoundsException("Start index (" + from + ") is greater than end index (" + to + ")"); return new BooleanSubList(this, from, to); } /**
ensureIndex(index); return new BooleanListIterator() { int pos = index, last = -1;
/** * Adds all of the elements in the specified collection to this list (optional * operation). */ @Override public boolean addAll(int index, final Collection<? extends Boolean> c) { ensureIndex(index); final Iterator<? extends Boolean> i = c.iterator(); final boolean retVal = i.hasNext(); while (i.hasNext()) add(index++, (i.next()).booleanValue()); return retVal; } /**
/** * {@inheritDoc} * * <p> * This is a trivial iterator-based implementation. It is expected that * implementations will override this method with a more optimized version. */ @Override public void addElements(int index, final boolean a[], int offset, int length) { ensureIndex(index); if (offset < 0) throw new ArrayIndexOutOfBoundsException("Offset (" + offset + ") is negative"); if (offset + length > a.length) throw new ArrayIndexOutOfBoundsException( "End index (" + (offset + length) + ") is greater than array length (" + a.length + ")"); while (length-- != 0) add(index++, a[offset++]); } /**
/** * {@inheritDoc} * * <p> * This is a trivial iterator-based implementation. It is expected that * implementations will override this method with a more optimized version. */ @Override public void removeElements(final int from, final int to) { ensureIndex(to); BooleanListIterator i = listIterator(from); int n = to - from; if (n < 0) throw new IllegalArgumentException("Start index (" + from + ") is greater than end index (" + to + ")"); while (n-- != 0) { i.nextBoolean(); i.remove(); } } /**
@Override public boolean addAll(int index, final BooleanCollection c) { ensureIndex(index); final BooleanIterator i = c.iterator(); final boolean retVal = i.hasNext(); while (i.hasNext()) add(index++, i.nextBoolean()); return retVal; } /**