当前位置: 首页>>代码示例>>Java>>正文


Java DoubleArrayList.setSize方法代码示例

本文整理汇总了Java中cern.colt.list.DoubleArrayList.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleArrayList.setSize方法的具体用法?Java DoubleArrayList.setSize怎么用?Java DoubleArrayList.setSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cern.colt.list.DoubleArrayList的用法示例。


在下文中一共展示了DoubleArrayList.setSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: values

import cern.colt.list.DoubleArrayList; //导入方法依赖的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(DoubleArrayList list) {
	list.setSize(distinct);
	double[] elements = list.elements();
	
	double[] val = values;
	byte[] stat = state;
	
	int j=0;
	for (int i = stat.length ; i-- > 0 ;) {
		if (stat[i]==FULL) elements[j++]=val[i];
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:OpenIntDoubleHashMap.java

示例2: keys

import cern.colt.list.DoubleArrayList; //导入方法依赖的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(DoubleProcedure)}.
 * <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(DoubleArrayList list) {
	list.setSize(distinct);
	double[] elements = list.elements();
	
	double[] tab = table;
	byte[] stat = state;
	
	int j=0;
	for (int i = tab.length ; i-- > 0 ;) {
		if (stat[i]==FULL) elements[j++]=tab[i];
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:23,代码来源:OpenDoubleIntHashMap.java

示例3: get

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
Fills the coordinates and values of cells having non-zero values into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists all have a new size, the number of non-zero values.
<p>
In general, fill order is <i>unspecified</i>.
This implementation fills like: <tt>for (index = 0..size()-1)  do ... </tt>.
However, subclasses are free to us any other order, even an order that may change over time as cell values are changed.
(Of course, result lists indexes are guaranteed to correspond to the same cell).
<p>
<b>Example:</b>
<br>
<pre>
0, 0, 8, 0, 7
-->
indexList  = (2,4)
valueList  = (8,7)
</pre>
In other words, <tt>get(2)==8, get(4)==7</tt>.

@param indexList the list to be filled with indexes, can have any size.
@param valueList the list to be filled with values, can have any size.
*/
public void getNonZeros(IntArrayList indexList, DoubleArrayList valueList, int maxCardinality) {
	boolean fillIndexList = indexList != null;
	boolean fillValueList = valueList != null;
	int card = cardinality(maxCardinality);
	if (fillIndexList) indexList.setSize(card);
	if (fillValueList) valueList.setSize(card);
	if (!(card<maxCardinality)) return;

	if (fillIndexList) indexList.setSize(0);
	if (fillValueList) valueList.setSize(0);
	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);
		}
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:43,代码来源:DoubleMatrix1D.java

示例4: setQuick

import cern.colt.list.DoubleArrayList; //导入方法依赖的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 &lt;= column &lt; columns() && 0 &lt;= row &lt; 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);
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:53,代码来源:RCMDoubleMatrix2D.java

示例5: pairsSortedByKey

import cern.colt.list.DoubleArrayList; //导入方法依赖的package包/类
/**
 * Fills all keys and values <i>sorted ascending by key</i> into the specified lists.
 * Fills into the lists, starting at index 0.
 * After this call returns the specified lists both have a new size that equals <tt>this.size()</tt>.
 * <p>
 * <b>Example:</b>
 * <br>
 * <tt>keys = (8,7,6), values = (1,2,2) --> keyList = (6,7,8), valueList = (2,2,1)</tt>
 *
 * @param keyList the list to be filled with keys, can have any size.
 * @param valueList the list to be filled with values, can have any size.
 */
public void pairsSortedByKey(final IntArrayList keyList, final DoubleArrayList valueList) {
	keys(keyList);
	keyList.sort();
	valueList.setSize(keyList.size());
	for (int i=keyList.size(); --i >= 0; ) {
		valueList.setQuick(i,get(keyList.getQuick(i)));
	}
}
 
开发者ID:dmcennis,项目名称:jAudioGIT,代码行数:21,代码来源:AbstractIntDoubleMap.java


注:本文中的cern.colt.list.DoubleArrayList.setSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。