コード例 #1
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 /**
  * Returns a sublist of this list.
  *
  * @param begin low endpoint (inclusive) of the subList.
  * @param end high endpoint (exclusive) of the subList.
  * @return sublist of this list from begin, inclusive to end, exclusive.
  * @throws IndexOutOfBoundsException - endpoint out of range
  * @throws IllegalArgumentException - endpoints out of order (end > begin)
  */
 public LongSequence subList(int begin, int end) {
   if (end < begin)
     throw new IllegalArgumentException("end index " + end + " greater than begin index " + begin);
   if (begin < 0) throw new IndexOutOfBoundsException("begin index can not be < 0");
   if (end > data.length) throw new IndexOutOfBoundsException("end index < " + data.length);
   LongSequence list = new LongSequence(end - begin);
   for (int i = begin; i < end; i++) {
     list.add(data[i]);
   }
   return list;
 }
コード例 #2
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 /**
  * 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;
 }
コード例 #3
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
  /**
   * 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;
  }
コード例 #4
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 public LongSequence(long... values) {
   this(Math.max(values.length, DEFAULT_CAPACITY));
   add(values);
 }
コード例 #5
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 public LongSequence addAll(long... vals) {
   add(0, vals.length, vals);
   return this;
 }
コード例 #6
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 /**
  * 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 LongSequence add(long[] vals) {
   add(0, vals.length, vals);
   return this;
 }
コード例 #7
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 public LongSequence addIfMissing(long n) {
   if (lastIndexOf(pos, n) != -1) add(n);
   return this;
 }
コード例 #8
0
ファイル: LongSequence.java プロジェクト: oghenez/mycila
 public LongSequence addLast(long val) {
   add(val);
   return this;
 }