/** * Adds the values in the array <tt>vals</tt> to the end of the * list, in order. * * @param vals an <code>long[]</code> value */ public void add(long[] vals) { add(vals, 0, vals.length); }
/** * Creates a new <code>TLongArrayList</code> instance whose * capacity is the greater of the length of <tt>values</tt> and * DEFAULT_CAPACITY and whose initial contents are the specified * values. * * @param values an <code>long[]</code> value */ public TLongArrayList(long[] values) { this(Math.max(values.length, DEFAULT_CAPACITY)); add(values); }
/** * Inserts <tt>value</tt> into the list at <tt>offset</tt>. All * values including and to the right of <tt>offset</tt> are shifted * to the right. * * @param offset an <code>int</code> value * @param value an <code>long</code> value */ public void insert(int offset, long value) { if (offset == _pos) { add(value); return; } ensureCapacity(_pos + 1); // shift right System.arraycopy(_data, offset, _data, offset + 1, _pos - offset); // insert _data[offset] = value; _pos++; }
/** * Inserts a slice of the array of <tt>values</tt> into the list * at <tt>offset</tt>. All values including and to the right of * <tt>offset</tt> are shifted to the right. * * @param offset an <code>int</code> value * @param values an <code>long[]</code> value * @param valOffset the offset in the values array at which to * start copying. * @param len the number of values to copy from the values array */ public void insert(int offset, long[] values, int valOffset, int len) { if (offset == _pos) { add(values, valOffset, len); return; } ensureCapacity(_pos + len); // shift right System.arraycopy(_data, offset, _data, offset + len, _pos - offset); // insert System.arraycopy(values, valOffset, _data, offset, len); _pos += len; }
/** * Searches the list for values satisfying <tt>condition</tt> in * the manner of the *nix <tt>grep</tt> utility. * * @param condition a condition to apply to each element in the list * @return a list of values which match the condition. */ public TLongArrayList grep(TLongProcedure condition) { TLongArrayList list = new TLongArrayList(); for (int i = 0; i < _pos; i++) { if (condition.execute(_data[i])) { list.add(_data[i]); } } return list; }
/** * Searches the list for values which do <b>not</b> satisfy * <tt>condition</tt>. This is akin to *nix <code>grep -v</code>. * * @param condition a condition to apply to each element in the list * @return a list of values which do not match the condition. */ public TLongArrayList inverseGrep(TLongProcedure condition) { TLongArrayList list = new TLongArrayList(); for (int i = 0; i < _pos; i++) { if (! condition.execute(_data[i])) { list.add(_data[i]); } } return list; }
@Before public void writeOut() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BitOutputStream bo = new BitOutputStream(baos); bo.writeBinary(initial_bitoffset, 0); for(int[] ids: IDS) { int previous = -1; byteOffsets.add(bo.getByteOffset()); bitOffsets.add(bo.getBitOffset()); //long byteOffset = bo.getByteOffset(); //byte bitOffset = bo.getBitOffset(); //System.err.println(ids.length + "@{"+byteOffset+","+bitOffset+"}"); for(int i : ids) { bo.writeDelta(i - previous); previous = i; } } bo.close(); bytes = baos.toByteArray(); }
@Before public void writeOut() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BitOutputStream bo = new BitOutputStream(baos); bo.writeBinary(initial_bitoffset, 0); for(int[] ids: IDS) { int previous = -1; byteOffsets.add(bo.getByteOffset()); bitOffsets.add(bo.getBitOffset()); //long byteOffset = bo.getByteOffset(); //byte bitOffset = bo.getBitOffset(); //System.err.println(ids.length + "@{"+byteOffset+","+bitOffset+"}"); for(int i : ids) { bo.writeGamma(i - previous); previous = i; } } bo.close(); bytes = baos.toByteArray(); }
@Before public void writeOut() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BitOutputStream bo = new BitOutputStream(baos); bo.writeBinary(initial_bitoffset, 0); for(int[] ids: IDS) { int previous = -1; byteOffsets.add(bo.getByteOffset()); bitOffsets.add(bo.getBitOffset()); //long byteOffset = bo.getByteOffset(); //byte bitOffset = bo.getBitOffset(); //System.err.println(ids.length + "@{"+byteOffset+","+bitOffset+"}"); for(int i : ids) { bo.writeGolomb(i - previous, b); previous = i; } } bo.close(); bytes = baos.toByteArray(); }