Java Code Examples for cern.colt.list.IntArrayList#elements()

The following examples show how to use cern.colt.list.IntArrayList#elements() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OpenIntIntHashMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 2
Source File: OpenIntIntHashMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 3
Source File: OpenIntDoubleHashMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 4
Source File: OpenDoubleIntHashMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 5
Source File: OpenIntObjectHashMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 6
Source File: DoubleMatrix1D.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 7
Source File: OpenIntIntHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 8
Source File: OpenIntIntHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 9
Source File: OpenIntDoubleHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 10
Source File: OpenDoubleIntHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 11
Source File: OpenIntObjectHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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];
	}
}
 
Example 12
Source File: DoubleMatrix1D.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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;
}
 
Example 13
Source File: RCMDoubleMatrix2D.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
	}
}
 
Example 14
Source File: RCMDoubleMatrix2D.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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);
	}
}