當前位置: 首頁>>代碼示例>>Java>>正文


Java TIntHashSet.toArray方法代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:24,代碼來源:GridNeighborhood.java

示例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]);
	}
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:17,代碼來源:LSHNearestNeighbours.java

示例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();
}
 
開發者ID:openimaj,項目名稱:openimaj,代碼行數:35,代碼來源:RandomData.java

示例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;
}
 
開發者ID:aherbert,項目名稱:GDSC-SMLM,代碼行數:30,代碼來源:ResultsMatchCalculator.java

示例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;
}
 
開發者ID:aherbert,項目名稱:GDSC,代碼行數:20,代碼來源:FindFociOptimiser.java

示例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;
}
 
開發者ID:aherbert,項目名稱:GDSC,代碼行數:21,代碼來源:FindFociOptimiser.java

示例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;
}
 
開發者ID:numenta,項目名稱:htm.java,代碼行數:13,代碼來源:ArrayUtils.java

示例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;
}
 
開發者ID:aherbert,項目名稱:GDSC-SMLM,代碼行數:13,代碼來源:TraceMolecules.java


注:本文中的gnu.trove.set.hash.TIntHashSet.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。