cern.colt.list.IntArrayList Java Examples

The following examples show how to use cern.colt.list.IntArrayList. 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: DoubleMatrix3D.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
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 fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-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).
For an example, see {@link DoubleMatrix2D#getNonZeros(IntArrayList,IntArrayList,DoubleArrayList)}.

@param sliceList the list to be filled with slice indexes, can have any size.
@param rowList the list to be filled with row indexes, can have any size.
@param columnList the list to be filled with column indexes, can have any size.
@param valueList the list to be filled with values, can have any size.
*/
public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) {
	sliceList.clear(); 
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int s = slices;
	int r = rows;
	int c = columns;
	for (int slice=0; slice < s; slice++) {
		for (int row=0; row < r; row++) {
			for (int column=0; column < c; column++) {
				double value = getQuick(slice,row,column);
				if (value != 0) {
					sliceList.add(slice);
					rowList.add(row);
					columnList.add(column);
					valueList.add(value);
				}
			}
		}
	}
}
 
Example #2
Source File: AbstractIntIntMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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();
}
 
Example #3
Source File: AbstractIntDoubleMap.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
	String tmp = theKeys.toString() + "\n";
	theKeys.sort();

	StringBuffer buf = new StringBuffer(tmp);
	//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();
}
 
Example #4
Source File: AbstractIntDoubleMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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();
	String tmp = theKeys.toString() + "\n";
	theKeys.sort();

	StringBuffer buf = new StringBuffer(tmp);
	//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();
}
 
Example #5
Source File: AbstractIntDoubleMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Returns a string representation of the receiver, containing
 * the String representation of each key-value pair, sorted ascending by value.
 */
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();
}
 
Example #6
Source File: AbstractIntIntMap.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #7
Source File: AbstractIntObjectMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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();
}
 
Example #8
Source File: AbstractIntObjectMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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();
}
 
Example #9
Source File: DoubleMatrix3D.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
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 fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-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).
For an example, see {@link DoubleMatrix2D#getNonZeros(IntArrayList,IntArrayList,DoubleArrayList)}.

@param sliceList the list to be filled with slice indexes, can have any size.
@param rowList the list to be filled with row indexes, can have any size.
@param columnList the list to be filled with column indexes, can have any size.
@param valueList the list to be filled with values, can have any size.
*/
public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, DoubleArrayList valueList) {
	sliceList.clear(); 
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int s = slices;
	int r = rows;
	int c = columns;
	for (int slice=0; slice < s; slice++) {
		for (int row=0; row < r; row++) {
			for (int column=0; column < c; column++) {
				double value = getQuick(slice,row,column);
				if (value != 0) {
					sliceList.add(slice);
					rowList.add(row);
					columnList.add(column);
					valueList.add(value);
				}
			}
		}
	}
}
 
Example #10
Source File: ObjectMatrix3D.java    From jAudioGIT with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
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 fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-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).
For an example, see {@link ObjectMatrix2D#getNonZeros(IntArrayList,IntArrayList,ObjectArrayList)}.

@param sliceList the list to be filled with slice indexes, can have any size.
@param rowList the list to be filled with row indexes, can have any size.
@param columnList the list to be filled with column indexes, can have any size.
@param valueList the list to be filled with values, can have any size.
*/
public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, ObjectArrayList valueList) {
	sliceList.clear(); 
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int s = slices;
	int r = rows;
	int c = columns;
	for (int slice=0; slice < s; slice++) {
		for (int row=0; row < r; row++) {
			for (int column=0; column < c; column++) {
				Object value = getQuick(slice,row,column);
				if (value != null) {
					sliceList.add(slice);
					rowList.add(row);
					columnList.add(column);
					valueList.add(value);
				}
			}
		}
	}
}
 
Example #11
Source File: ObjectMatrix3D.java    From database with GNU General Public License v2.0 6 votes vote down vote up
/**
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 fill like: <tt>for (slice = 0..slices-1) for (row = 0..rows-1) for (column = 0..colums-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).
For an example, see {@link ObjectMatrix2D#getNonZeros(IntArrayList,IntArrayList,ObjectArrayList)}.

@param sliceList the list to be filled with slice indexes, can have any size.
@param rowList the list to be filled with row indexes, can have any size.
@param columnList the list to be filled with column indexes, can have any size.
@param valueList the list to be filled with values, can have any size.
*/
public void getNonZeros(IntArrayList sliceList, IntArrayList rowList, IntArrayList columnList, ObjectArrayList valueList) {
	sliceList.clear(); 
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int s = slices;
	int r = rows;
	int c = columns;
	for (int slice=0; slice < s; slice++) {
		for (int row=0; row < r; row++) {
			for (int column=0; column < c; column++) {
				Object value = getQuick(slice,row,column);
				if (value != null) {
					sliceList.add(slice);
					rowList.add(row);
					columnList.add(column);
					valueList.add(value);
				}
			}
		}
	}
}
 
Example #12
Source File: Tools.java    From first-stories-twitter with MIT License 6 votes vote down vote up
/**
 * Computes the cosine similarity between a possible Neighbour (possibly smaller dimension vector) and a new
 * Tweet that arrives which might have a bigger vector.
 * @param possibleNeighbour The old tweet, usually located in bucket.
 * @param newTweet The new arriving tweet.
 * @return NearNeighbour The cosine similarity along with the possible neighbour
 */
public NearNeighbour computeCosineSimilarity(Tweet possibleNeighbour, Tweet newTweet) {
    SparseVector possibleNeighbourVect = possibleNeighbour.getSparseVector();
    SparseVector newTweetVect = newTweet.getSparseVector();
    IntArrayList nonZeroIndeces = new IntArrayList(possibleNeighbourVect.cardinality());
    DoubleArrayList dblZeroIndeces = new DoubleArrayList(possibleNeighbourVect.cardinality());
    possibleNeighbourVect.getNonZeros(nonZeroIndeces, dblZeroIndeces);
    double dotProductValue = newTweetVect.zDotProduct(possibleNeighbourVect, 0, possibleNeighbourVect.size(), nonZeroIndeces);

    //colt norm2 needs sqrt
    //here divide by zero will give NaN BUG if vectors are consisted ONLY of 0s !
    Double cosSim = new Double(dotProductValue / getNorm2(possibleNeighbourVect, newTweetVect));
    if (cosSim.isNaN()) {
        System.exit(1);
    }

    NearNeighbour nearN = new NearNeighbour(cosSim, possibleNeighbour);
    return nearN;

}
 
Example #13
Source File: IntBuffer3D.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs and returns a new buffer with the given target.
 * @param target the target to flush to.
 * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target.
 */
public IntBuffer3D(IntBuffer3DConsumer target, int capacity) {
	this.target = target;
	this.capacity = capacity;
	this.xElements = new int[capacity];
	this.yElements = new int[capacity];
	this.zElements = new int[capacity];
	this.xList = new IntArrayList(xElements);
	this.yList = new IntArrayList(yElements);
	this.zList = new IntArrayList(zElements);
	this.size = 0;
}
 
Example #14
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 #15
Source File: IntBuffer3D.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs and returns a new buffer with the given target.
 * @param target the target to flush to.
 * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target.
 */
public IntBuffer3D(IntBuffer3DConsumer target, int capacity) {
	this.target = target;
	this.capacity = capacity;
	this.xElements = new int[capacity];
	this.yElements = new int[capacity];
	this.zElements = new int[capacity];
	this.xList = new IntArrayList(xElements);
	this.yList = new IntArrayList(yElements);
	this.zList = new IntArrayList(zElements);
	this.size = 0;
}
 
Example #16
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 #17
Source File: AbstractDoubleIntMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 DoubleArrayList keyList, final IntArrayList valueList) {
	/*
	keys(keyList); 
	values(valueList);
	
	final double[] k = keyList.elements();
	final int[] v = valueList.elements();
	cern.colt.Swapper swapper = new cern.colt.Swapper() {
		public void swap(int a, int b) {
			int t1;	double t2;
			t1 = v[a]; v[a] = v[b]; v[b] = t1;
			t2 = k[a]; k[a] = k[b];	k[b] = t2;
		}
	}; 

	cern.colt.function.IntComparator comp = new cern.colt.function.IntComparator() {
		public int compare(int a, int b) {
			return k[a]<k[b] ? -1 : k[a]==k[b] ? 0 : 1;
		}
	};
	cern.colt.MultiSorting.sort(0,keyList.size(),comp,swapper);
	*/	
	

	
	// this variant may be quicker
	//cern.colt.map.OpenDoubleIntHashMap.hashCollisions = 0;
	//System.out.println("collisions="+cern.colt.map.OpenDoubleIntHashMap.hashCollisions);
	keys(keyList);
	keyList.sort();
	valueList.setSize(keyList.size());
	for (int i=keyList.size(); --i >= 0; ) {
		valueList.setQuick(i,get(keyList.getQuick(i)));
	}
	//System.out.println("collisions="+cern.colt.map.OpenDoubleIntHashMap.hashCollisions);
	
}
 
Example #18
Source File: AbstractDoubleIntMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new DoubleProcedure() {
			public boolean apply(double key) {
				list.add(get(key));
				return true;
			}
		}
	);
}
 
Example #19
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 #20
Source File: AbstractIntDoubleMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(key);
				return true;
			}
		}
	);
}
 
Example #21
Source File: AbstractIntIntMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(get(key));
				return true;
			}
		}
	);
}
 
Example #22
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 #23
Source File: QuantileFinderTest.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Finds the first and last indexes of a specific element within a sorted list.
 * @return int[]
 * @param list cern.colt.list.DoubleArrayList
 * @param element the element to search for
 */
protected static IntArrayList binaryMultiSearch(DoubleArrayList list, double element) {
	int index = list.binarySearch(element);
	if (index<0) return null; //not found

	int from = index-1;
	while (from>=0 && list.get(from)==element) from--;
	from++;
	
	int to = index+1;
	while (to<list.size() && list.get(to)==element) to++;
	to--;
	
	return new IntArrayList(new int[] {from,to});
}
 
Example #24
Source File: DynamicBin1D.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Returns a String representation of the receiver.
 */
public synchronized String toString() {
	StringBuffer buf = new StringBuffer(super.toString());
	DoubleArrayList distinctElements = new DoubleArrayList();
	IntArrayList frequencies = new IntArrayList();
	frequencies(distinctElements,frequencies);
	if (distinctElements.size() < 100) { // don't cause unintended floods
		buf.append("Distinct elements: "+distinctElements+"\n");
		buf.append("Frequencies: "+frequencies+"\n");
	}
	else {
		buf.append("Distinct elements & frequencies not printed (too many).");
	}
	return buf.toString();
}
 
Example #25
Source File: AbstractDoubleIntMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new DoubleProcedure() {
			public boolean apply(double key) {
				list.add(get(key));
				return true;
			}
		}
	);
}
 
Example #26
Source File: AbstractIntIntMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(key);
				return true;
			}
		}
	);
}
 
Example #27
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.
 */
protected double zDotProduct(DoubleMatrix1D y, IntArrayList nonZeroIndexes) {
	return zDotProduct(y,0,size,nonZeroIndexes);
	/*
	double sum = 0;
	int[] nonZeroIndexElements = nonZeroIndexes.elements();
	for (int index=nonZeroIndexes.size(); --index >= 0; ) {
		int i = nonZeroIndexElements[index];
		sum += getQuick(i) * y.getQuick(i);
	}
	return sum;
	*/
}
 
Example #28
Source File: AbstractIntIntMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(get(key));
				return true;
			}
		}
	);
}
 
Example #29
Source File: IntBuffer2D.java    From jAudioGIT with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructs and returns a new buffer with the given target.
 * @param target the target to flush to.
 * @param capacity the number of points the buffer shall be capable of holding before overflowing and flushing to the target.
 */
public IntBuffer2D(IntBuffer2DConsumer target, int capacity) {
	this.target = target;
	this.capacity = capacity;
	this.xElements = new int[capacity];
	this.yElements = new int[capacity];
	this.xList = new IntArrayList(xElements);
	this.yList = new IntArrayList(yElements);
	this.size = 0;
}
 
Example #30
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.
 */
protected double zDotProduct(DoubleMatrix1D y, IntArrayList nonZeroIndexes) {
	return zDotProduct(y,0,size,nonZeroIndexes);
	/*
	double sum = 0;
	int[] nonZeroIndexElements = nonZeroIndexes.elements();
	for (int index=nonZeroIndexes.size(); --index >= 0; ) {
		int i = nonZeroIndexElements[index];
		sum += getQuick(i) * y.getQuick(i);
	}
	return sum;
	*/
}