コード例 #1
0
 /** {@inheritDoc} */
 public void shuffle(Random rand) {
   for (int i = 0; i < size; i++) {
     TFloatLink l = getLinkAt(rand.nextInt(size()));
     removeLink(l);
     add(l.getValue());
   }
 }
コード例 #2
0
 public TFloatLinkedList(TFloatList list) {
   no_entry_value = list.getNoEntryValue();
   //
   for (TFloatIterator iterator = list.iterator(); iterator.hasNext(); ) {
     float next = iterator.next();
     add(next);
   }
 }
コード例 #3
0
  static TFloatLinkedList link(float[] values, int valOffset, int len) {
    TFloatLinkedList ret = new TFloatLinkedList();

    for (int i = 0; i < len; i++) {
      ret.add(values[valOffset + i]);
    }

    return ret;
  }
コード例 #4
0
  /** {@inheritDoc} */
  public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {

    // VERSION
    in.readByte();

    // NO_ENTRY_VALUE
    no_entry_value = in.readFloat();

    // ENTRIES
    int len = in.readInt();
    for (int i = 0; i < len; i++) {
      add(in.readFloat());
    }
  }
コード例 #5
0
  /** {@inheritDoc} */
  public void fill(int fromIndex, int toIndex, float val) {
    if (fromIndex < 0) {
      throw new IndexOutOfBoundsException("begin index can not be < 0");
    }

    TFloatLink l = getLinkAt(fromIndex);
    if (toIndex > size) {
      for (int i = fromIndex; i < size; i++) {
        l.setValue(val);
        l = l.getNext();
      }
      for (int i = size; i < toIndex; i++) {
        add(val);
      }
    } else {
      for (int i = fromIndex; i < toIndex; i++) {
        l.setValue(val);
        l = l.getNext();
      }
    }
  }
コード例 #6
0
  /** {@inheritDoc} */
  public TFloatList subList(int begin, int end) {
    if (end < begin) {
      throw new IllegalArgumentException("begin index " + begin + " greater than end index " + end);
    }
    if (size < begin) {
      throw new IllegalArgumentException(
          "begin index " + begin + " greater than last index " + size);
    }
    if (begin < 0) {
      throw new IndexOutOfBoundsException("begin index can not be < 0");
    }
    if (end > size) {
      throw new IndexOutOfBoundsException("end index < " + size);
    }

    TFloatLinkedList ret = new TFloatLinkedList();
    TFloatLink tmp = getLinkAt(begin);
    for (int i = begin; i < end; i++) {
      ret.add(tmp.getValue()); // copy
      tmp = tmp.getNext();
    }

    return ret;
  }
コード例 #7
0
 /** {@inheritDoc} */
 public void add(float[] vals) {
   for (float val : vals) {
     add(val);
   }
 }
コード例 #8
0
 /** {@inheritDoc} */
 public void insert(int offset, float value) {
   TFloatLinkedList tmp = new TFloatLinkedList();
   tmp.add(value);
   insert(offset, tmp);
 }
コード例 #9
0
 /** {@inheritDoc} */
 public void add(float[] vals, int offset, int length) {
   for (int i = 0; i < length; i++) {
     float val = vals[offset + i];
     add(val);
   }
 }