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


Java TIntHashSet.add方法代碼示例

本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet.add方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet.add方法的具體用法?Java TIntHashSet.add怎麽用?Java TIntHashSet.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnu.trove.set.hash.TIntHashSet的用法示例。


在下文中一共展示了TIntHashSet.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNeighborsAtRadius

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public TIntHashSet getNeighborsAtRadius(final int placeIndex, final int radius, final int xSize,
	final int ySize, final boolean isTorus) {
	final TIntHashSet currentNeigh = new TIntHashSet();
	currentNeigh.add(placeIndex);
	for ( int i = 0; i < radius; i++ ) {
		final TIntHashSet newNeigh = new TIntHashSet();
		TIntIterator it = currentNeigh.iterator();
		while (it.hasNext()) {
			newNeigh.addAll(getNeighborsAtRadius1(it.next(), xSize, ySize, isTorus));
		}
		currentNeigh.addAll(newNeigh);
	}
	currentNeigh.remove(placeIndex);
	return currentNeigh;

}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:17,代碼來源:GridHexagonalNeighborhoodVertical.java

示例2: getNeighborsAtRadius

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
@Override
protected TIntHashSet getNeighborsAtRadius(final int placeIndex, final int radius) {
	final int y = placeIndex / matrix.numCols;
	final int x = placeIndex - y * matrix.numCols;

	final TIntHashSet v = new TIntHashSet(radius << 2);
	int p;
	for ( int i = -radius; i < radius; i++ ) {
		p = matrix.getPlaceIndexAt(x - i, y - CmnFastMath.abs(i) + radius);
		if ( p != -1 ) {
			v.add(p);
		}
		p = matrix.getPlaceIndexAt(x + i, y + CmnFastMath.abs(i) - radius);
		if ( p != -1 ) {
			v.add(p);
		}
	}
	return v;
}
 
開發者ID:gama-platform,項目名稱:gama,代碼行數:20,代碼來源:GridVonNeumannNeighborhood.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: stripUnlearnedColumns

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
 * Removes the set of columns who have never been active from the set of
 * active columns selected in the inhibition round. Such columns cannot
 * represent learned pattern and are therefore meaningless if only inference
 * is required. This should not be done when using a random, unlearned SP
 * since you would end up with no active columns.
 *  
 * @param activeColumns An array containing the indices of the active columns
 * @return  a list of columns with a chance of activation
 */
public int[] stripUnlearnedColumns(Connections c, int[] activeColumns) {
    TIntHashSet active = new TIntHashSet(activeColumns);
    TIntHashSet aboveZero = new TIntHashSet();
    int numCols = c.getNumColumns();
    double[] colDutyCycles = c.getActiveDutyCycles();
    for(int i = 0;i < numCols;i++) {
        if(colDutyCycles[i] <= 0) {
            aboveZero.add(i);
        }
    }
    active.removeAll(aboveZero);
    TIntArrayList l = new TIntArrayList(active);
    l.sort();
    
    return Arrays.stream(activeColumns).filter(i -> c.getActiveDutyCycles()[i] > 0).toArray();
}
 
開發者ID:numenta,項目名稱:htm.java,代碼行數:27,代碼來源:SpatialPooler.java

示例5: testUniquenessAndDeterminance

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
@Test
public void testUniquenessAndDeterminance() {
    Random r = new FastRandom(42);
    TIntHashSet set = new TIntHashSet();
    
    TIntHashSet knownExpectedRepeats = new TIntHashSet();
    knownExpectedRepeats.addAll(new int[] { 9368, 149368, 193310, 194072, 202906, 241908, 249466, 266101, 276853, 289339, 293737 } );
    
    for(int i = 0;i < 300000;i++) {
        int rndInt = r.nextInt();
        if(set.contains(rndInt) && !knownExpectedRepeats.contains(i)) {
            fail();
        }
        set.add(rndInt);
    }
}
 
開發者ID:numenta,項目名稱:htm.java,代碼行數:17,代碼來源:FastRandomTest.java

示例6: 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

示例7: removeFilteredFluorophores

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
 * Remove all fluorophores which were not drawn
 * 
 * @param fluorophores
 * @param localisations
 * @return
 */
private List<? extends FluorophoreSequenceModel> removeFilteredFluorophores(
		List<? extends FluorophoreSequenceModel> fluorophores, List<LocalisationModel> localisations)
{
	if (fluorophores == null)
		return null;
	// movingMolecules will be created with an initial capacity to hold all the unique IDs
	TIntHashSet idSet = new TIntHashSet((movingMolecules != null) ? movingMolecules.capacity() : 0);
	for (LocalisationModel l : localisations)
		idSet.add(l.getId());
	List<FluorophoreSequenceModel> newFluorophores = new ArrayList<FluorophoreSequenceModel>(idSet.size());
	for (FluorophoreSequenceModel f : fluorophores)
	{
		if (idSet.contains(f.getId()))
			newFluorophores.add(f);
	}
	return newFluorophores;
}
 
開發者ID:aherbert,項目名稱:GDSC-SMLM,代碼行數:25,代碼來源:CreateData.java

示例8: datastoreStructureChanged

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
@Override
public void datastoreStructureChanged() {
	TIntHashSet selectableTableIds = new TIntHashSet();
	ODLTableReadOnly table = api.getMapDataApi().getUnfilteredActiveTable();
	if (table != null) {
		int n = table.getRowCount();
		for (int i = 0; i < n; i++) {
			long id = table.getRowId(i);
			if (id != -1) {
				selectableTableIds.add(TableUtils.getTableId(id));
			}
		}
	}

	fieldSelector.update(api.getMapDataApi().getGlobalDatastore(), selectableTableIds);
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:17,代碼來源:FillPlugin.java

示例9: createOutputDefinition

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public void createOutputDefinition(ODLTableDefinitionAlterable ret){
	if(ret.getColumnCount()!=0){
		throw new RuntimeException();
	}
	
	DatastoreCopier.copyTableDefinition(this, ret,false);
	
	// remove sort columns from the definition
	TIntHashSet sortCols = new TIntHashSet();
	int n = getColumnCount();
	for(int i =0 ; i<n;i++){
		if(getColumn(i).getSortField() != SortField.NO){
			sortCols.add(i);
		}
	}
	for(int i = n-1;i>=0 ; i--){
		if(sortCols.contains(i)){
			ret.deleteColumn(i);
		}
	}
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:22,代碼來源:AdaptedTableConfig.java

示例10: 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

示例11: toHashSet

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
    * Retrieves all of indices of element that is true into a HashSet.
    * @return
    */
public TIntHashSet toHashSet()
   {
       TIntHashSet res = new TIntHashSet();
       for (int i = 0, e = size(); i < e; i++)
           if (get(i)) res.add(i);
       return res;
   }
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:12,代碼來源:BitMap.java

示例12: handlePhyRegUse

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private void handlePhyRegUse(int phyReg, MachineInstr mi)
{
    if (phyRegDef[phyReg] == null && phyRegUses[phyReg] == null)
    {
        OutParamWrapper<Integer> x = new OutParamWrapper<>(0);
        MachineInstr lastPartialDef = findLastPartialDef(phyReg, x);
        int partDefReg = x.get();
        if (lastPartialDef != null)
        {
            lastPartialDef.addOperand(MachineOperand.createReg(phyReg, true, true));
            phyRegDef[phyReg] = lastPartialDef;
            TIntHashSet processed = new TIntHashSet();
            for (int sub : regInfo.getSubRegisters(phyReg))
            {
                if (processed.contains(sub)) continue;
                if (sub == partDefReg || regInfo.isSubRegister(partDefReg, sub))
                    continue;
                lastPartialDef.addOperand(MachineOperand.createReg(sub, false, true));
                phyRegDef[sub] = lastPartialDef;
                for (int ss : regInfo.getSubRegisters(sub))
                    processed.add(ss);
            }
        }
    }
    phyRegUses[phyReg] = mi;

    for (int subReg : regInfo.get(phyReg).subRegs)
    {
        phyRegUses[subReg] = mi;
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:32,代碼來源:LiveVariables.java

示例13: freeAfterRevisonParsing

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
@Override
public void freeAfterRevisonParsing() {
	pageIdRevList = new TIntHashSet(pageIdRevMap.keySet().size());
	for (Integer key : pageIdRevMap.keySet()) {
		pageIdRevList.add(key);
	}

	pageIdRevMap.clear();
}
 
開發者ID:dkpro,項目名稱:dkpro-jwpl,代碼行數:10,代碼來源:DumpVersionTroveIntKey.java

示例14: sample

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
 * Returns a random, sorted, and  unique array of the specified sample size of
 * selections from the specified list of choices.
 *
 * @param sampleSize the number of selections in the returned sample
 * @param choices    the list of choices to select from
 * @param random     a random number generator
 * @return a sample of numbers of the specified size
 */
int[] sample(int sampleSize, TIntArrayList choices, Random random) {
    TIntHashSet temp = new TIntHashSet();
    int upperBound = choices.size();
    for (int i = 0; i < sampleSize; i++) {
        int randomIdx = random.nextInt(upperBound);
        while (temp.contains(choices.get(randomIdx))) {
            randomIdx = random.nextInt(upperBound);
        }
        temp.add(choices.get(randomIdx));
    }
    TIntArrayList al = new TIntArrayList(temp);
    al.sort();
    return al.toArray();
}
 
開發者ID:numenta,項目名稱:htm.java-examples,代碼行數:24,代碼來源:FoxEatsDemo.java

示例15: processEnterMethod4loopConsistency

import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
private void processEnterMethod4loopConsistency(int m, int t) {
    Stack<Record> stack = stacks.get(t);
    if (stack == null) {
        stack = new Stack<Record>();
        stacks.put(t, stack);
    }
    stack.add(new MethRecord(m));
    if (!visited4loops.contains(m)) {
        visited4loops.add(m);
        SootMethod mthd = (SootMethod)domM.get(m);
        // Perform a slightly eager computation to map each loop header
        // to its body (in terms of <code>DomB</code>).
        ICFG cfg = SootUtilities.getCFG(mthd);
        CFGLoopFinder finder = new CFGLoopFinder();
        finder.visit(cfg);
        for (Block head : finder.getLoopHeads()) {
            TIntHashSet S = new TIntHashSet();
            int bh = domB.indexOf(head);
            assert (bh != -1);
            loopHead2body.put(bh, S);
            Set<Block> loopBody = finder.getLoopBody(head);
            for (Block bb : loopBody) {
                int b2 = domB.indexOf(bb);
                assert (b2 != -1);
                S.add(b2);
            }
        }
    }
}
 
開發者ID:petablox-project,項目名稱:petablox,代碼行數:30,代碼來源:DynamicAnalysis.java


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