/** * Returns the number of elements in this list. * * @return the number of elements in this list. */ public int size() { return content.size(); } /**
/** * Returns the number of elements in this list. * * @return the number of elements in this list. */ public int size() { return content.size(); } /**
/** * Returns a list which is a concatenation of <code>times</code> times the receiver. * @param times the number of times the receiver shall be copied. */ public AbstractDoubleList times(int times) { AbstractDoubleList newList = new DoubleArrayList(times*size()); for (int i=times; --i >= 0; ) { newList.addAllOfFromTo(this,0,size()-1); } return newList; } /**
/** * Returns a <code>java.util.ArrayList</code> containing all the elements in the receiver. */ public java.util.ArrayList toList() { int mySize = size(); java.util.ArrayList list = new java.util.ArrayList(mySize); for (int i=0; i < mySize; i++) list.add(new Double(get(i))); return list; } /**
/** * Returns a list which is a concatenation of <code>times</code> times the receiver. * @param times the number of times the receiver shall be copied. */ public AbstractDoubleList times(int times) { AbstractDoubleList newList = new DoubleArrayList(times*size()); for (int i=times; --i >= 0; ) { newList.addAllOfFromTo(this,0,size()-1); } return newList; } /**
/** * Returns a <code>java.util.ArrayList</code> containing all the elements in the receiver. */ public java.util.ArrayList toList() { int mySize = size(); java.util.ArrayList list = new java.util.ArrayList(mySize); for (int i=0; i < mySize; i++) list.add(new Double(get(i))); return list; } /**
/** * Returns a <code>java.util.ArrayList</code> containing all the elements in * the receiver. */ public java.util.ArrayList toList() { int mySize = size(); java.util.ArrayList list = new java.util.ArrayList(mySize); for (int i = 0; i < mySize; i++) list.add(new Double(get(i))); return list; }
/** * Returns a list which is a concatenation of <code>times</code> times the * receiver. * * @param times * the number of times the receiver shall be copied. */ public AbstractDoubleList times(int times) { AbstractDoubleList newList = new DoubleArrayList(times * size()); for (int i = times; --i >= 0;) { newList.addAllOfFromTo(this, 0, size() - 1); } return newList; }
/** * Replaces the part of the receiver starting at <code>from</code> (inclusive) with all the elements of the specified collection. * Does not alter the size of the receiver. * Replaces exactly <tt>Math.max(0,Math.min(size()-from, other.size()))</tt> elements. * * @param from the index at which to copy the first element from the specified collection. * @param other Collection to replace part of the receiver * @exception IndexOutOfBoundsException index is out of range (index < 0 || index >= size()). */ public void replaceFromWith(int from, java.util.Collection other) { checkRange(from,size()); java.util.Iterator e = other.iterator(); int index=from; int limit = Math.min(size()-from, other.size()); for (int i=0; i<limit; i++) set(index++,((Number) e.next()).doubleValue()); //delta } /**
/** * Replaces the part of the receiver starting at <code>from</code> (inclusive) with all the elements of the specified collection. * Does not alter the size of the receiver. * Replaces exactly <tt>Math.max(0,Math.min(size()-from, other.size()))</tt> elements. * * @param from the index at which to copy the first element from the specified collection. * @param other Collection to replace part of the receiver * @exception IndexOutOfBoundsException index is out of range (index < 0 || index >= size()). */ public void replaceFromWith(int from, java.util.Collection other) { checkRange(from,size()); java.util.Iterator e = other.iterator(); int index=from; int limit = Math.min(size()-from, other.size()); for (int i=0; i<limit; i++) set(index++,((Number) e.next()).doubleValue()); //delta } /**
/** * Reverses the elements of the receiver. Last becomes first, second last * becomes second first, and so on. */ public void reverse() { double tmp; int limit = size() / 2; int j = size() - 1; for (int i = 0; i < limit;) { // swap tmp = getQuick(i); setQuick(i++, getQuick(j)); setQuick(j--, tmp); } }
/** * Returns a string representation of the receiver, containing * the String representation of each element. */ public String toString() { return cern.colt.Arrays.toString(partFromTo(0, size()-1).elements()); } }
/** * Returns a string representation of the receiver, containing * the String representation of each element. */ public String toString() { return cern.colt.Arrays.toString(partFromTo(0, size()-1).elements()); } }
/** * Returns a string representation of the receiver, containing the String * representation of each element. */ public String toString() { return cern.colt.Arrays.toString(partFromTo(0, size() - 1).elements()); } }
/** * Removes from the receiver all elements that are contained in the specified list. * Tests for identity. * * @param other the other list. * @return <code>true</code> if the receiver changed as a result of the call. */ public boolean removeAll(AbstractDoubleList other) { if (other.size()==0) return false; //nothing to do int limit = other.size()-1; int j=0; for (int i=0; i<size ; i++) { if (other.indexOfFromTo(getQuick(i), 0, limit) < 0) setQuick(j++,getQuick(i)); } boolean modified = (j!=size); setSize(j); return modified; } /**
/** * Constructs a matrix from the values of the given list. * The values are copied. So subsequent changes in <tt>values</tt> are not reflected in the matrix, and vice-versa. * * @param values The values to be filled into the new matrix. * @return a new matrix. */ public DoubleMatrix1D make(cern.colt.list.AbstractDoubleList values) { int size = values.size(); DoubleMatrix1D vector = make(size); for (int i=size; --i >= 0; ) vector.set(i, values.get(i)); return vector; } /**
/** * Constructs a matrix from the values of the given list. * The values are copied. So subsequent changes in <tt>values</tt> are not reflected in the matrix, and vice-versa. * * @param values The values to be filled into the new matrix. * @return a new matrix. */ public DoubleMatrix1D make(cern.colt.list.AbstractDoubleList values) { int size = values.size(); DoubleMatrix1D vector = make(size); for (int i=size; --i >= 0; ) vector.set(i, values.get(i)); return vector; } /**
/** * Randomly permutes the part of the receiver between <code>from</code> (inclusive) and <code>to</code> (inclusive). * @param from the index of the first element (inclusive) to be permuted. * @param to the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException index is out of range (<tt>size()>0 && (from<0 || from>to || to>=size())</tt>). */ public void shuffleFromTo(int from, int to) { checkRangeFromTo(from, to, size()); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(cern.jet.random.Uniform.makeDefaultGenerator()); for (int i=from; i<to; i++) { int random = gen.nextIntFromTo(i, to); //swap(i, random) double tmpElement = getQuick(random); setQuick(random,getQuick(i)); setQuick(i,tmpElement); } } /**