Ejemplo n.º 1
0
 /**
  * Fills a range in the list with the specified value.
  *
  * @param fromIndex the offset at which to start filling (inclusive)
  * @param toIndex the offset at which to stop filling (exclusive)
  * @param val the value to use when filling
  */
 public LongSequence fill(int fromIndex, int toIndex, long val) {
   if (toIndex > pos) {
     ensureCapacity(toIndex);
     pos = toIndex;
   }
   Arrays.fill(data, fromIndex, toIndex, val);
   return this;
 }
Ejemplo n.º 2
0
 /**
  * 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 LongSequence insert(int offset, long value) {
   if (offset == pos) {
     add(value);
     return this;
   }
   ensureCapacity(pos + 1);
   // shift right
   System.arraycopy(data, offset, data, offset + 1, pos - offset);
   // insert
   data[offset] = value;
   pos++;
   return this;
 }
Ejemplo n.º 3
0
  /**
   * 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 LongSequence insert(int offset, int valOffset, int len, long... values) {
    if (offset == pos) {
      add(valOffset, len, values);
      return this;
    }

    ensureCapacity(pos + len);
    // shift right
    System.arraycopy(data, offset, data, offset + len, pos - offset);
    // insert
    System.arraycopy(values, valOffset, data, offset, len);
    pos += len;
    return this;
  }
Ejemplo n.º 4
0
 public LongSequence appendFrom(long[] src, int srcOffset, int srcLen) {
   ensureCapacity(pos + srcLen);
   System.arraycopy(src, srcOffset, data, pos, srcLen);
   pos = pos + srcLen;
   return this;
 }
Ejemplo n.º 5
0
 /**
  * Adds a subset of the values in the array <tt>vals</tt> to the end of the list, in order.
  *
  * @param vals an <code>long[]</code> value
  * @param offset the offset at which to start copying
  * @param length the number of values to copy.
  */
 public LongSequence add(int offset, int length, long... vals) {
   ensureCapacity(pos + length);
   System.arraycopy(vals, offset, data, pos, length);
   pos += length;
   return this;
 }
Ejemplo n.º 6
0
 /**
  * Adds <tt>val</tt> to the end of the list, growing as needed.
  *
  * @param val an <code>long</code> value
  */
 public LongSequence add(long val) {
   ensureCapacity(pos + 1);
   data[pos++] = val;
   return this;
 }