本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet.toArray方法的具體用法?Java TIntHashSet.toArray怎麽用?Java TIntHashSet.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.hash.TIntHashSet
的用法示例。
在下文中一共展示了TIntHashSet.toArray方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeNeighborsFrom
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private void computeNeighborsFrom(final int placeIndex, final int begin, final int end) {
for (int i = begin; i <= end; i++) {
// final int previousIndex = i == 1 ? 0 :
// neighborsIndexes[placeIndex].get(i - 2);
final int previousIndex = i == 1 ? 0 : neighborsIndexes[placeIndex][i - 2];
final TIntHashSet list = getNeighborsAtRadius(placeIndex, i);
final int[] listArray = list.toArray();
final int size = listArray.length;
// final int size = list.size();
// final int[] listArray = new int[size];
// for ( int j = 0; j < size; j++ ) {
// listArray[j] = list.get(j);
// }
final int[] newArray = new int[neighbors[placeIndex].length + size];
if (neighbors[placeIndex].length != 0) {
java.lang.System.arraycopy(neighbors[placeIndex], 0, newArray, 0, neighbors[placeIndex].length);
}
java.lang.System.arraycopy(listArray, 0, newArray, neighbors[placeIndex].length, size);
neighbors[placeIndex] = newArray;
// neighborsIndexes[placeIndex].add(previousIndex + size);
addToNeighborsIndex(placeIndex, previousIndex + size);
}
}
示例2: searchKNN
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
@Override
public void searchKNN(OBJECT[] qus, int K, int[][] argmins, float[][] mins) {
// loop on the search data
for (int i = 0; i < qus.length; i++) {
final TIntHashSet pl = search(qus[i]);
// now sort the selected points by distance
final int[] ids = pl.toArray();
final List<OBJECT> vectors = new ArrayList<OBJECT>(ids.length);
for (int j = 0; j < ids.length; j++) {
vectors.add(data.get(ids[j]));
}
exactNN(vectors, ids, qus[i], K, argmins[i], mins[i]);
}
}
示例3: getUniqueRandomIntsS
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Returns an array of N unique pseudorandom, uniformly
* distributed int values between min (inclusive) and
* max (exclusive).
*
* Internally this method uses a hashset to store numbers.
* The hashset is continually filled with random numbers in the
* range min->max until its size is N.
*
* @param N number of unique random numbers
* @param min minimum value
* @param max maximum value
* @param rnd random generator to use
* @return array of N unique ints
*/
public static int [] getUniqueRandomIntsS(int N, int min, int max, Random rnd) {
int rng = max-min;
if (rng < N)
throw new IllegalArgumentException("Cannot generate more random numbers than the range allows");
TIntHashSet set = new TIntHashSet(N);
for (int i=0; i<N; i++) {
while (true) {
int r = rnd.nextInt(rng) + min;
if (!set.contains(r)) {
set.add(r);
break;
}
}
}
return set.toArray();
}
示例4: getTimepoints
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Merge the time points from each map into a single sorted list of unique time points
*
* @param actualCoordinates
* @param predictedCoordinates
* @return a list of time points
*/
private static int[] getTimepoints(TIntObjectHashMap<ArrayList<Coordinate>> actualCoordinates,
TIntObjectHashMap<ArrayList<Coordinate>> predictedCoordinates)
{
//int[] set = SimpleArrayUtils.merge(actualCoordinates.keys(), predictedCoordinates.keys(), true);
// Do inline to avoid materialising the keys arrays
final TIntHashSet hashset = new TIntHashSet(Math.max(actualCoordinates.size(), predictedCoordinates.size()));
final TIntProcedure p = new TIntProcedure()
{
public boolean execute(int value)
{
hashset.add(value);
return true;
}
};
actualCoordinates.forEachKey(p);
predictedCoordinates.forEachKey(p);
int[] set = hashset.toArray();
Arrays.sort(set);
return set;
}
示例5: createSortArray
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private int[] createSortArray()
{
double[] values = splitValues(mySortMethod);
TIntHashSet set = new TIntHashSet(values.length);
for (double v : values)
{
int method = (int) v;
if (method >= 0 && method <= FindFoci.SORT_AVERAGE_INTENSITY_MINUS_MIN)
set.add(method);
}
if (set.isEmpty())
{
Utils.log("%s Warning : Sort method : No values, setting to default %d", TITLE, FindFoci.SORT_INTENSITY);
return new int[] { FindFoci.SORT_INTENSITY }; // Default
}
int[] array = set.toArray();
Arrays.sort(array);
return array;
}
示例6: createCentreArray
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private int[] createCentreArray()
{
double[] values = splitValues(myCentreMethod);
TIntHashSet set = new TIntHashSet(values.length);
for (double v : values)
{
int method = (int) v;
if (method >= 0 && method <= FindFoci.CENTRE_GAUSSIAN_ORIGINAL)
set.add(method);
}
if (set.isEmpty())
{
Utils.log("%s Warning : Centre method : No values, setting to default %d", TITLE,
FindFoci.CENTRE_MAX_VALUE_SEARCH);
return new int[] { FindFoci.CENTRE_MAX_VALUE_SEARCH }; // Default
}
int[] array = set.toArray();
Arrays.sort(array);
return array;
}
示例7: unique
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Returns a sorted unique array of integers
*
* @param nums an unsorted array of integers with possible duplicates.
* @return
*/
public static int[] unique(int[] nums) {
TIntHashSet set = new TIntHashSet(nums);
int[] result = set.toArray();
Arrays.sort(result);
return result;
}
示例8: convert
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private int[] convert(double[] intervals)
{
TIntHashSet set = new TIntHashSet(intervals.length);
for (double d : intervals)
set.add((int) Math.round(d));
set.remove(0); // Do not allow zero
int[] values = set.toArray();
Arrays.sort(values);
return values;
}