本文整理汇总了Java中cern.colt.list.IntArrayList.elements方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.elements方法的具体用法?Java IntArrayList.elements怎么用?Java IntArrayList.elements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cern.colt.list.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.elements方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNonZeros
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList) {
boolean fillIndexList = indexList != null;
boolean fillValueList = valueList != null;
if (fillIndexList)
indexList.clear();
else {
System.out.println("Wrong use");
return;
}
if (fillValueList)
valueList.clear();
else {
System.out.println("Wrong use");
return;
}
int[] index = elements.keys().elements();
double[] value = elements.values().elements();
indexList.elements(index);
valueList.elements(value);
// for (int i = 0; i < index.size(); ++i) {
// indexList.add(index.get(i));
// valueList.add(value.get(i));
// }
// int s = size;
// for (int i=0; i < s; i++) {
// double value = getQuick(i);
// if (value != 0) {
// if (fillIndexList) indexList.add(i);
// if (fillValueList) valueList.add(value);
// }
// }
}
示例2: keys
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Fills all keys contained in the receiver into the specified list.
* Fills the list, starting at index 0.
* After this call returns the specified list has a new size that equals <tt>this.size()</tt>.
* Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
* <p>
* This method can be used to iterate over the keys of the receiver.
*
* @param list the list to be filled, can have any size.
*/
public void keys(IntArrayList list) {
list.setSize(distinct);
int[] elements = list.elements();
int[] tab = table;
byte[] stat = state;
int j=0;
for (int i = tab.length ; i-- > 0 ;) {
if (stat[i]==FULL) elements[j++]=tab[i];
}
}
示例3: values
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Fills all values contained in the receiver into the specified list.
* Fills the list, starting at index 0.
* After this call returns the specified list has a new size that equals <tt>this.size()</tt>.
* Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
* <p>
* This method can be used to iterate over the values of the receiver.
*
* @param list the list to be filled, can have any size.
*/
public void values(IntArrayList list) {
list.setSize(distinct);
int[] elements = list.elements();
int[] val = values;
byte[] stat = state;
int j=0;
for (int i = stat.length ; i-- > 0 ;) {
if (stat[i]==FULL) elements[j++]=val[i];
}
}
示例4: values
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Fills all values contained in the receiver into the specified list.
* Fills the list, starting at index 0.
* After this call returns the specified list has a new size that equals <tt>this.size()</tt>.
* Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(DoubleProcedure)}.
* <p>
* This method can be used to iterate over the values of the receiver.
*
* @param list the list to be filled, can have any size.
*/
public void values(IntArrayList list) {
list.setSize(distinct);
int[] elements = list.elements();
int[] val = values;
byte[] stat = state;
int j=0;
for (int i = stat.length ; i-- > 0 ;) {
if (stat[i]==FULL) elements[j++]=val[i];
}
}
示例5: zDotProduct
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Returns the dot product of two vectors x and y, which is <tt>Sum(x[i]*y[i])</tt>.
* Where <tt>x == this</tt>.
* @param y the second vector.
* @param nonZeroIndexes the indexes of cells in <tt>y</tt>having a non-zero value.
* @return the sum of products.
*/
public double zDotProduct(DoubleMatrix1D y, int from, int length, IntArrayList nonZeroIndexes) {
// determine minimum length
if (from<0 || length<=0) return 0;
int tail = from+length;
if (size < tail) tail = size;
if (y.size < tail) tail = y.size;
length = tail-from;
if (length<=0) return 0;
// setup
int[] nonZeroIndexElements = nonZeroIndexes.elements();
int index = 0;
int s = nonZeroIndexes.size();
// skip to start
while ((index < s) && nonZeroIndexElements[index]<from) index++;
// now the sparse dot product
int i;
double sum = 0;
while ((--length >= 0) && (index < s) && ((i=nonZeroIndexElements[index]) < tail)) {
sum += getQuick(i) * y.getQuick(i);
index++;
}
return sum;
}
示例6: setQuick
import cern.colt.list.IntArrayList; //导入方法依赖的package包/类
/**
* Sets the matrix cell at coordinate <tt>[row,column]</tt> to the specified value.
*
* <p>Provided with invalid parameters this method may access illegal indexes without throwing any exception.
* <b>You should only use this method when you are absolutely sure that the coordinate is within bounds.</b>
* Precondition (unchecked): <tt>0 <= column < columns() && 0 <= row < rows()</tt>.
*
* @param row the index of the row-coordinate.
* @param column the index of the column-coordinate.
* @param value the value to be filled into the specified cell.
*/
public void setQuick(int row, int column, double value) {
int i=row;
int j=column;
int k=-1;
IntArrayList indexList = indexes[i];
if (indexList != null) k = indexList.binarySearch(j);
if (k>=0) { // found
if (value==0) {
DoubleArrayList valueList = values[i];
indexList.remove(k);
valueList.remove(k);
int s = indexList.size();
if (s>2 && s*3 < indexList.elements().length) {
indexList.setSize(s*3/2);
indexList.trimToSize();
indexList.setSize(s);
valueList.setSize(s*3/2);
valueList.trimToSize();
valueList.setSize(s);
}
}
else {
values[i].setQuick(k,value);
}
}
else { // not found
if (value==0) return;
k = -k-1;
if (indexList == null) {
indexes[i] = new IntArrayList(3);
values[i] = new DoubleArrayList(3);
}
indexes[i].beforeInsert(k,j);
values[i].beforeInsert(k,value);
}
}