use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.
the class AbstractIntObjectMap method toStringByValue.
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by value, according to natural ordering.
*/
public String toStringByValue() {
IntArrayList theKeys = new IntArrayList();
keysSortedByValue(theKeys);
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex)
buf.append(", ");
}
buf.append("]");
return buf.toString();
}
use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.
the class AbstractIntObjectMap method toString.
/**
* Returns a string representation of the receiver, containing
* the String representation of each key-value pair, sorted ascending by key.
*/
public String toString() {
IntArrayList theKeys = keys();
theKeys.sort();
StringBuffer buf = new StringBuffer();
buf.append("[");
int maxIndex = theKeys.size() - 1;
for (int i = 0; i <= maxIndex; i++) {
int key = theKeys.get(i);
buf.append(String.valueOf(key));
buf.append("->");
buf.append(String.valueOf(get(key)));
if (i < maxIndex)
buf.append(", ");
}
buf.append("]");
return buf.toString();
}
use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.
the class ObjectMatrix1D method viewSelection.
/**
*Constructs and returns a new <i>selection view</i> that is a matrix holding the cells matching the given condition.
*Applies the condition to each cell and takes only those cells where <tt>condition.apply(get(i))</tt> yields <tt>true</tt>.
*<p>
*<b>Example:</b>
*<br>
*<pre>
*// extract and view all cells with even value
*matrix = 0 1 2 3
*matrix.viewSelection(
* new ObjectProcedure() {
* public final boolean apply(Object a) { return a % 2 == 0; }
* }
*);
*-->
*matrix == 0 2
*</pre>
*For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>.
*The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.
*
*@param condition The condition to be matched.
*@return the new view.
*/
public ObjectMatrix1D viewSelection(cern.colt.function.ObjectProcedure condition) {
IntArrayList matches = new IntArrayList();
for (int i = 0; i < size; i++) {
if (condition.apply(getQuick(i)))
matches.add(i);
}
matches.trimToSize();
return viewSelection(matches.elements());
}
use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.
the class ObjectMatrix2D method viewSelection.
/**
*Constructs and returns a new <i>selection view</i> that is a matrix holding all <b>rows</b> matching the given condition.
*Applies the condition to each row and takes only those row where <tt>condition.apply(viewRow(i))</tt> yields <tt>true</tt>.
*To match columns, use a dice view.
*<p>
*<b>Example:</b>
*<br>
*<pre>
*// extract and view all rows which have a value < threshold in the first column (representing "age")
*final Object threshold = 16;
*matrix.viewSelection(
* new ObjectMatrix1DProcedure() {
* public final boolean apply(ObjectMatrix1D m) { return m.get(0) < threshold; }
* }
*);
*
*// extract and view all rows with RMS < threshold
*// The RMS (Root-Mean-Square) is a measure of the average "size" of the elements of a data sequence.
*matrix = 0 1 2 3
*final Object threshold = 0.5;
*matrix.viewSelection(
* new ObjectMatrix1DProcedure() {
* public final boolean apply(ObjectMatrix1D m) { return Math.sqrt(m.aggregate(F.plus,F.square) / m.size()) < threshold; }
* }
*);
*</pre>
*For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>.
*The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.
*
*@param condition The condition to be matched.
*@return the new view.
*/
public ObjectMatrix2D viewSelection(ObjectMatrix1DProcedure condition) {
IntArrayList matches = new IntArrayList();
for (int i = 0; i < rows; i++) {
if (condition.apply(viewRow(i)))
matches.add(i);
}
matches.trimToSize();
// take all columns
return viewSelection(matches.elements(), null);
}
use of cern.colt.list.IntArrayList in project tdq-studio-se by Talend.
the class ObjectMatrix3D method viewSelection.
/**
*Constructs and returns a new <i>selection view</i> that is a matrix holding all <b>slices</b> matching the given condition.
*Applies the condition to each slice and takes only those where <tt>condition.apply(viewSlice(i))</tt> yields <tt>true</tt>.
*To match rows or columns, use a dice view.
*<p>
*<b>Example:</b>
*<br>
*<pre>
*// extract and view all slices which have an aggregate sum > 1000
*matrix.viewSelection(
* new ObjectMatrix2DProcedure() {
* public final boolean apply(ObjectMatrix2D m) { return m.zSum > 1000; }
* }
*);
*</pre>
*For further examples, see the <a href="package-summary.html#FunctionObjects">package doc</a>.
*The returned view is backed by this matrix, so changes in the returned view are reflected in this matrix, and vice-versa.
*
*@param condition The condition to be matched.
*@return the new view.
*/
public ObjectMatrix3D viewSelection(ObjectMatrix2DProcedure condition) {
IntArrayList matches = new IntArrayList();
for (int i = 0; i < slices; i++) {
if (condition.apply(viewSlice(i)))
matches.add(i);
}
matches.trimToSize();
// take all rows and columns
return viewSelection(matches.elements(), null, null);
}
Aggregations