/** {@inheritDoc} */ public void shuffle(Random rand) { for (int i = 0; i < size; i++) { TFloatLink l = getLinkAt(rand.nextInt(size())); removeLink(l); add(l.getValue()); } }
public TFloatLinkedList(TFloatList list) { no_entry_value = list.getNoEntryValue(); // for (TFloatIterator iterator = list.iterator(); iterator.hasNext(); ) { float next = iterator.next(); add(next); } }
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; }
/** {@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()); } }
/** {@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(); } } }
/** {@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; }
/** {@inheritDoc} */ public void add(float[] vals) { for (float val : vals) { add(val); } }
/** {@inheritDoc} */ public void insert(int offset, float value) { TFloatLinkedList tmp = new TFloatLinkedList(); tmp.add(value); insert(offset, tmp); }
/** {@inheritDoc} */ public void add(float[] vals, int offset, int length) { for (int i = 0; i < length; i++) { float val = vals[offset + i]; add(val); } }