@Override public boolean topBoolean() { if (isEmpty()) throw new NoSuchElementException(); return getBoolean(size64() - 1); } @Override
@Override public boolean peekBoolean(int i) { return getBoolean(size64() - 1 - i); } /**
@Override public boolean popBoolean() { if (isEmpty()) throw new NoSuchElementException(); return removeBoolean(size64() - 1); } @Override
/** * Adds all of the elements in the specified collection to this list (optional * operation). */ @Override public boolean addAll(long 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()); return retVal; } /**
/** * Returns the hash code for this big list, which is identical to * {@link java.util.List#hashCode()}. * * @return the hash code for this big list. */ @Override public int hashCode() { BooleanIterator i = iterator(); int h = 1; long s = size64(); while (s-- != 0) { boolean k = i.nextBoolean(); h = 31 * h + ((k) ? 1231 : 1237); } return h; } @Override
/** * Removes a single instance of the specified element from this collection, if * it is present (optional operation). * <p> * This implementation delegates to {@code indexOf()}. * * @see BigList#remove(Object) */ @Override public boolean rem(boolean k) { long index = indexOf(k); if (index == -1) return false; removeBoolean(index); return true; } /**
/** * {@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 long from, final long to) { ensureIndex(to); BooleanBigListIterator i = listIterator(from); long 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(); } } /**
/** * {@inheritDoc} * * <p> * This implementation delegates to the type-specific version of * {@link #addAll(long, Collection)}. */ @Override public boolean addAll(final long index, final BooleanBigList l) { return addAll(index, (BooleanCollection) l); } /**
/** * {@inheritDoc} * * <p> * This implementation delegates to the corresponding type-specific method. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Boolean get(final long index) { return Boolean.valueOf(getBoolean(index)); } /**
@Override public void add(boolean k) { AbstractBooleanBigList.this.add(pos++, k); last = -1; } @Override
@Override public BooleanBigList subList(final long from, final long 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); } /**
/** * Returns true if this list contains the specified element. * <p> * This implementation delegates to {@code indexOf()}. * * @see BigList#contains(Object) */ @Override public boolean contains(final boolean k) { return indexOf(k) >= 0; } @Override
/** * {@inheritDoc} * * <p> * This implementation delegates to the corresponding type-specific method. * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public long lastIndexOf(final Object ok) { return lastIndexOf(((Boolean) (ok)).booleanValue()); } /**
/** * {@inheritDoc} * * <p> * This implementation delegates to the analogous method for big-array * fragments. */ @Override public void addElements(final long index, final boolean a[][]) { addElements(index, a, 0, BooleanBigArrays.length(a)); } /**
@Override public int compareTo(final BigList<? extends Boolean> list) { if (list instanceof BitVector) return compareTo((BitVector)list); return super.compareTo(list); }
/** * {@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(long index, final boolean a[][], long offset, long length) { ensureIndex(index); BooleanBigArrays.ensureOffsetLength(a, offset, length); while (length-- != 0) add(index++, BooleanBigArrays.get(a, offset++)); } /**
@Override public String toString() { final StringBuilder s = new StringBuilder(); final BooleanIterator i = iterator(); long n = size64(); boolean k; boolean first = true; s.append("["); while (n-- != 0) { if (first) first = false; else s.append(", "); k = i.nextBoolean(); s.append(String.valueOf(k)); } s.append("]"); return s.toString(); } /** A class implementing a sublist view. */