protected BooleanListBitVector(final int capacity) { this(new BooleanBigArrayBigList(capacity)); }
@Override public void add(boolean k) { BooleanBigArrayBigList.this.add(pos++, k); last = -1; } @Override
@Override public BooleanBigListIterator listIterator(final long index) { ensureIndex(index); return new BooleanBigListIterator() { long pos = index, last = -1;
@Override public boolean rem(final boolean k) { final long index = indexOf(k); if (index == -1) return false; removeBoolean(index); assert size <= BooleanBigArrays.length(a); return true; } @Override
@Override public void add(final long index, final boolean k) { ensureIndex(index); grow(size + 1); if (index != size) BooleanBigArrays.copy(a, index, a, index + 1, size - index); BooleanBigArrays.set(a, index, k); size++; assert size <= BooleanBigArrays.length(a); } @Override
/** * Compares this type-specific big-array list to another one. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a type-specific big-array list. * @return true if the argument contains the same elements of this type-specific * big-array list. */ public boolean equals(final BooleanBigArrayBigList l) { if (l == this) return true; long s = size64(); if (s != l.size64()) return false; final boolean[][] a1 = a; final boolean[][] a2 = l.a; while (s-- != 0) if (BooleanBigArrays.get(a1, s) != BooleanBigArrays.get(a2, s)) return false; return true; } /**
/** * Trims this big-array big list so that the capacity is equal to the size. * * @see java.util.ArrayList#trimToSize() */ public void trim() { trim(0); } /**
@Override public void set(boolean k) { if (last == -1) throw new IllegalStateException(); BooleanBigArrayBigList.this.set(last, k); } @Override
@Override public void remove() { if (last == -1) throw new IllegalStateException(); BooleanBigArrayBigList.this.removeBoolean(last); /* * If the last operation was a next(), we are removing an element *before* us, * and we must decrease pos correspondingly. */ if (last < pos) pos--; last = -1; } };
/** * Wraps a given big array into a big-array big list. * * @param a * a big array to wrap. * @return a new big-array big list wrapping the given array. */ public static BooleanBigArrayBigList wrap(final boolean a[][]) { return wrap(a, BooleanBigArrays.length(a)); } /**
@Override public boolean add(final boolean k) { grow(size + 1); BooleanBigArrays.set(a, size++, k); assert size <= BooleanBigArrays.length(a); return true; } @Override
/** * Adds elements to this type-specific list using optimized system calls. * * @param index * the index at which to add elements. * @param a * the big array containing the elements. * @param offset * the offset of the first element to add. * @param length * the number of elements to add. */ @Override public void addElements(final long index, final boolean a[][], final long offset, final long length) { ensureIndex(index); BooleanBigArrays.ensureOffsetLength(a, offset, length); grow(size + length); BooleanBigArrays.copy(this.a, index, this.a, index + length, size - index); BooleanBigArrays.copy(a, offset, this.a, index, length); size += length; } @Override
/** * Compares this big list to another big list. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a big list. * @return a negative integer, zero, or a positive integer as this big list is * lexicographically less than, equal to, or greater than the argument. */ public int compareTo(final BooleanBigArrayBigList l) { final long s1 = size64(), s2 = l.size64(); final boolean a1[][] = a, a2[][] = l.a; boolean e1, e2; int r, i; for (i = 0; i < s1 && i < s2; i++) { e1 = BooleanBigArrays.get(a1, i); e2 = BooleanBigArrays.get(a2, i); if ((r = (Boolean.compare((e1), (e2)))) != 0) return r; } return i < s2 ? -1 : (i < s1 ? 1 : 0); } private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
@Override public BooleanListBitVector copy() { return new BooleanListBitVector(new BooleanBigArrayBigList(list)); }
/** * Creates a new big-array big list and fills it with the elements returned by * an iterator.. * * @param i * an iterator whose returned elements will fill the array list. */ public BooleanBigArrayBigList(final Iterator<? extends Boolean> i) { this(); while (i.hasNext()) this.add((i.next()).booleanValue()); } /**
@Override public BooleanBigArrayBigList clone() { BooleanBigArrayBigList c = new BooleanBigArrayBigList(size); BooleanBigArrays.copy(a, 0, c.a, 0, size); c.size = size; return c; } /**
/** * Creates a new big-array big list and fills it with the elements returned by a * type-specific iterator.. * * @param i * a type-specific iterator whose returned elements will fill the * array list. */ public BooleanBigArrayBigList(final BooleanIterator i) { this(); while (i.hasNext()) this.add(i.nextBoolean()); } /**
/** * Wraps a given big array into a big-array list of given size. * * @param a * a big array to wrap. * @param length * the length of the resulting big-array list. * @return a new big-array list of the given size, wrapping the given big array. */ public static BooleanBigArrayBigList wrap(final boolean a[][], final long length) { if (length > BooleanBigArrays.length(a)) throw new IllegalArgumentException("The specified length (" + length + ") is greater than the array size (" + BooleanBigArrays.length(a) + ")"); final BooleanBigArrayBigList l = new BooleanBigArrayBigList(a, false); l.size = length; return l; } /**
/** * Creates a new big-array big list and fills it with a given type-specific * collection. * * @param c * a type-specific collection that will be used to fill the array * list. */ public BooleanBigArrayBigList(final BooleanCollection c) { this(c.size()); for (BooleanIterator i = c.iterator(); i.hasNext();) add(i.nextBoolean()); } /**