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

The following examples show how to use cern.colt.list.IntArrayList#clear() . 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: AbstractIntDoubleMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(key);
				return true;
			}
		}
	);
}
 
Example 2
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 3
Source File: AbstractIntObjectMap.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 4
Source File: AbstractIntObjectMap.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(final IntArrayList list) {
	list.clear();
	forEachKey(
		new IntProcedure() {
			public boolean apply(int key) {
				list.add(key);
				return true;
			}
		}
	);
}
 
Example 5
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 6
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 7
Source File: ObjectMatrix2D.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 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 fills like <tt>for (row = 0..rows-1) for (column = 0..columns-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>
2 x 3 matrix:
0, 0, 8
0, 7, 0
-->
rowList    = (0,1)
columnList = (2,1)
valueList  = (8,7)
</pre>
In other words, <tt>get(0,2)==8, get(1,1)==7</tt>.

@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 rowList, IntArrayList columnList, ObjectArrayList valueList) {
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int r = rows;
	int c = columns;
	for (int row=0; row < r; row++) {
		for (int column=0; column < c; column++) {
			Object value = getQuick(row,column);
			if (value != null) {
				rowList.add(row);
				columnList.add(column);
				valueList.add(value);
			}
		}
	}
}
 
Example 8
Source File: AbstractIntDoubleMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntDoubleProcedure condition = new IntDoubleProcedure() { // match even keys only
	public boolean apply(int key, double value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntDoubleProcedure condition, final IntArrayList keyList, final DoubleArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	forEachPair(
		new IntDoubleProcedure() {
			public boolean apply(int key, double value) {
				if (condition.apply(key,value)) {
					keyList.add(key);
					valueList.add(value);
				}
				return true;
			}
		}
	);
}
 
Example 9
Source File: AbstractIntDoubleMap.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntDoubleProcedure condition = new IntDoubleProcedure() { // match even keys only
	public boolean apply(int key, double value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntDoubleProcedure condition, final IntArrayList keyList, final DoubleArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	forEachPair(
		new IntDoubleProcedure() {
			public boolean apply(int key, double value) {
				if (condition.apply(key,value)) {
					keyList.add(key);
					valueList.add(value);
				}
				return true;
			}
		}
	);
}
 
Example 10
Source File: DoubleMatrix2D.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 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 fills like <tt>for (row = 0..rows-1) for (column = 0..columns-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>
2 x 3 matrix:
0, 0, 8
0, 7, 0
-->
rowList    = (0,1)
columnList = (2,1)
valueList  = (8,7)
</pre>
In other words, <tt>get(0,2)==8, get(1,1)==7</tt>.

@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 rowList, IntArrayList columnList, DoubleArrayList valueList) {
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int r = rows;
	int c = columns;
	for (int row=0; row < r; row++) {
		for (int column=0; column < c; column++) {
			double value = getQuick(row,column);
			if (value != 0) {
				rowList.add(row);
				columnList.add(column);
				valueList.add(value);
			}
		}
	}
}
 
Example 11
Source File: AbstractIntIntMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntIntProcedure condition = new IntIntProcedure() { // match even keys only
	public boolean apply(int key, int value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntIntProcedure condition, final IntArrayList keyList, final IntArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	forEachPair(
		new IntIntProcedure() {
			public boolean apply(int key, int value) {
				if (condition.apply(key,value)) {
					keyList.add(key);
					valueList.add(value);
				}
				return true;
			}
		}
	);
}
 
Example 12
Source File: AbstractIntObjectMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntObjectProcedure condition = new IntObjectProcedure() { // match even keys only
	public boolean apply(int key, Object value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntObjectProcedure condition, final IntArrayList keyList, final ObjectArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	forEachPair(
		new IntObjectProcedure() {
			public boolean apply(int key, Object value) {
				if (condition.apply(key,value)) {
					keyList.add(key);
					valueList.add(value);
				}
				return true;
			}
		}
	);
}
 
Example 13
Source File: DoubleMatrix2D.java    From database with GNU General Public License v2.0 4 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 fills like <tt>for (row = 0..rows-1) for (column = 0..columns-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>
2 x 3 matrix:
0, 0, 8
0, 7, 0
-->
rowList    = (0,1)
columnList = (2,1)
valueList  = (8,7)
</pre>
In other words, <tt>get(0,2)==8, get(1,1)==7</tt>.

@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 rowList, IntArrayList columnList, DoubleArrayList valueList) {
	rowList.clear(); 
	columnList.clear(); 
	valueList.clear();
	int r = rows;
	int c = columns;
	for (int row=0; row < r; row++) {
		for (int column=0; column < c; column++) {
			double value = getQuick(row,column);
			if (value != 0) {
				rowList.add(row);
				columnList.add(column);
				valueList.add(value);
			}
		}
	}
}
 
Example 14
Source File: OpenIntIntHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntIntProcedure condition = new IntIntProcedure() { // match even keys only
	public boolean apply(int key, int value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntIntProcedure condition, final IntArrayList keyList, final IntArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	for (int i = table.length ; i-- > 0 ;) {
		if (state[i]==FULL && condition.apply(table[i],values[i])) {
			keyList.add(table[i]);
			valueList.add(values[i]);
		}
	}
}
 
Example 15
Source File: ObjectMatrix1D.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 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 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, ObjectArrayList valueList) {
	boolean fillIndexList = indexList != null;
	boolean fillValueList = valueList != null;
	if (fillIndexList) indexList.clear(); 
	if (fillValueList) valueList.clear();
	int s = size;
	for (int i=0; i < s; i++) {
		Object value = getQuick(i);
		if (value != null) {
			if (fillIndexList) indexList.add(i);
			if (fillValueList) valueList.add(value);
		}
	}
}
 
Example 16
Source File: DoubleMatrix1D.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 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 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) {
	boolean fillIndexList = indexList != null;
	boolean fillValueList = valueList != null;
	if (fillIndexList) indexList.clear(); 
	if (fillValueList) valueList.clear();
	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);
		}
	}
}
 
Example 17
Source File: DoubleMatrix1D.java    From database with GNU General Public License v2.0 3 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 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) {
	boolean fillIndexList = indexList != null;
	boolean fillValueList = valueList != null;
	if (fillIndexList) indexList.clear(); 
	if (fillValueList) valueList.clear();
	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);
		}
	}
}
 
Example 18
Source File: OpenIntObjectHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntObjectProcedure condition = new IntObjectProcedure() { // match even keys only
	public boolean apply(int key, Object value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntObjectProcedure condition, final IntArrayList keyList, final ObjectArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	for (int i = table.length ; i-- > 0 ;) {
		if (state[i]==FULL && condition.apply(table[i],values[i])) {
			keyList.add(table[i]);
			valueList.add(values[i]);
		}
	}
}
 
Example 19
Source File: OpenDoubleIntHashMap.java    From database with GNU General Public License v2.0 3 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(DoubleProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
DoubleIntProcedure condition = new DoubleIntProcedure() { // match even values only
	public boolean apply(double key, int value) { return value%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final DoubleIntProcedure condition, final DoubleArrayList keyList, final IntArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	for (int i = table.length ; i-- > 0 ;) {
		if (state[i]==FULL && condition.apply(table[i],values[i])) {
			keyList.add(table[i]);
			valueList.add(values[i]);
		}
	}
}
 
Example 20
Source File: OpenIntDoubleHashMap.java    From jAudioGIT with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
Fills all pairs satisfying a given condition into the specified lists.
Fills into the lists, starting at index 0.
After this call returns the specified lists both have a new size, the number of pairs satisfying the condition.
Iteration order is guaranteed to be <i>identical</i> to the order used by method {@link #forEachKey(IntProcedure)}.
<p>
<b>Example:</b>
<br>
<pre>
IntDoubleProcedure condition = new IntDoubleProcedure() { // match even keys only
	public boolean apply(int key, double value) { return key%2==0; }
}
keys = (8,7,6), values = (1,2,2) --> keyList = (6,8), valueList = (2,1)</tt>
</pre>

@param condition    the condition to be matched. Takes the current key as first and the current value as second argument.
@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 pairsMatching(final IntDoubleProcedure condition, final IntArrayList keyList, final DoubleArrayList valueList) {
	keyList.clear();
	valueList.clear();
	
	for (int i = table.length ; i-- > 0 ;) {
		if (state[i]==FULL && condition.apply(table[i],values[i])) {
			keyList.add(table[i]);
			valueList.add(values[i]);
		}
	}
}