本文整理匯總了Java中gnu.trove.set.hash.TIntHashSet.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntHashSet.contains方法的具體用法?Java TIntHashSet.contains怎麽用?Java TIntHashSet.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.hash.TIntHashSet
的用法示例。
在下文中一共展示了TIntHashSet.contains方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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);
}
}
示例3: 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;
}
示例4: 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);
}
}
}
示例5: 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;
}
}
示例6: 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();
}
示例7: simJaccard
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public double simJaccard(TIntHashSet s1, TIntHashSet s2) {
int com = 0;
if(s1==null||s2==null)
return 0;
TIntIterator it = s1.iterator();
for ( int i = s1.size(); i-- > 0; ) {
int v = it.next();
if(s2.contains(v))
com++;
}
double sim = com*1.0/(s1.size()+s2.size()-com);
return sim;
}
示例8: contained
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public boolean contained(TIntHashSet labelsOnPath, TIntHashSet prevLabels) {
if (labelsOnPath == null) return true;
for(TIntIterator iter = labelsOnPath.iterator(); iter.hasNext();) {
int thisL = iter.next();
if (prevLabels != null && prevLabels.contains(thisL)) continue;
return false;
}
return true;
}
示例9: update
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
public void update(ODLDatastore<? extends ODLTableDefinition> ds, TIntHashSet availableTableIds) {
String [] current = getSelected();
boolean hasSelected = current!=null && current.length==2;
topNode.removeAllChildren();
DefaultMutableTreeNode selNode=null;
for (ODLTableDefinition table : TableUtils.getAlphabeticallySortedTables(ds)) {
if(availableTableIds!=null && availableTableIds.contains(table.getImmutableId())==false){
continue;
}
DefaultMutableTreeNode tableNode = new DefaultMutableTreeNode(table.getName());
topNode.add(tableNode);
// is this the previously selected table?
boolean selTable = hasSelected && Strings.equalsStd(table.getName(), current[0]);
int nc = table.getColumnCount();
for (int i = 0; i < nc; i++) {
DefaultMutableTreeNode fieldNode = new DefaultMutableTreeNode(table.getColumnName(i));
if(selTable && Strings.equalsStd(table.getColumnName(i), current[1])){
selNode = fieldNode;
}
tableNode.add(fieldNode);
}
}
// hack otherwise update doesn't work...
DefaultTreeModel model = new DefaultTreeModel(topNode);
tree.setModel(model);
// ensure path is expanded otherwise child nodes will be invisible if top node is invisible
tree.expandPath(new TreePath(topNode.getPath()));
// also expand all tables
Enumeration<?>e= topNode.children();
while(e.hasMoreElements()){
DefaultMutableTreeNode node = (DefaultMutableTreeNode)e.nextElement();
tree.expandPath(new TreePath(node.getPath()));
}
// reselect if possible
if(selNode!=null){
tree.setSelectionPath(new TreePath(selNode.getPath()));
}
}
示例10: buildUnionTable
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Build a union from the input table adapters, recursively building adapters for each one.
*
* @param constituents
* @param destinationTableId
*/
private void buildUnionTable(List<AdaptedTableConfig> constituents, int destinationTableId) {
// Get combined table definition (can include field definitions from multiple constituent tables)
AdapterConfig combined = createUnionedSourcelessAdapter(constituents);
ODLTableDefinition combinedDfn = combined.createOutputDefinition().getTableAt(0);
// For each constituent table
ArrayList<ODLDatastore<? extends ODLTable>> built = new ArrayList<>();
for (AdaptedTableConfig atc : constituents) {
if(processedConfig!=null && processedConfig.getAdapterType() == ScriptAdapterType.PARAMETER && api.stringConventions().equalStandardised(atc.getName(), api.scripts().parameters().tableDefinition(true).getName())){
env.setFailed("Cannot union a parameter table.");
return;
}
// Create a modified adapter config with all combined field names in and uniform type,
// but those not included in the individual config are unsourced.
// The table source and filter must match the original constituent table
AdaptedTableConfig standardised = atc.createNoColumnsCopy();
DatastoreCopier.copyTableDefinition(combined.getTable(0), standardised);
// Add sources for all columns in the original adapter
TIntHashSet sourcedCols = new TIntHashSet();
for (AdapterColumnConfig col : atc.getColumns()) {
int indx = TableUtils.findColumnIndx(standardised, col.getName());
sourcedCols.add(indx);
AdapterColumnConfig stdCol = standardised.getColumn(indx);
stdCol.setSourceFields(col.getFrom(), col.getFormula(), col.isUseFormula());
// be sure to copy column flags as well (needed for group-by)
stdCol.setFlags(col.getFlags());
// and sort state
stdCol.setSortField(col.getSortField());
}
// Set any unsourced columns not in the original config to be optional
int nc = standardised.getColumnCount();
for(int col=0;col < nc;col++){
if(sourcedCols.contains(col)==false){
standardised.setColumnFlags(col, standardised.getColumnFlags(col)|TableFlags.FLAG_IS_OPTIONAL);
}
}
// build this adapter
AdapterConfig dummy = new AdapterConfig();
dummy.getTables().add(standardised);
AdapterBuilder builder = new AdapterBuilder(dummy, callerAdapters != null ? new StandardisedStringSet(false,callerAdapters) : new StandardisedStringSet(false), env,continueCb, builtAdapters);
try {
ODLDatastore<? extends ODLTable> constituentDs = builder.build();
if (constituentDs == null || report.isFailed()) {
throw new UnionTableException("Failed to build constituent table in unioned table.");
}
built.add(constituentDs);
} catch (Throwable e) {
throw new UnionTableException(e);
}
}
// Create union decorator and get the table out of it...
UnionDecorator<ODLTable> union = new UnionDecorator<>(built);
ODLTableDefinition destDfn = union.getTableAt(0);
// If we're adding source columns, we need to add them to the mapping here...
int firstExtraField = mapping.getFieldCount(destinationTableId);
for(int i = firstExtraField ; i<destDfn.getColumnCount();i++){
mapping.addMappedField(destinationTableId, destDfn.getColumnName(i), destDfn.getColumnType(i), i);
}
// 7th Feb 2015. True 2-way union decorators create an issue in group-bys as rowids aren't unique.
// We therefore just copy the union result over to a different table.
ODLDatastoreAlterable<ODLTableAlterable> ret = mapToNewEmptyTable(destinationTableId, destDfn);
DatastoreCopier.copyData(union.getTableAt(0), ret.getTableAt(0),false);
}
示例11: setFieldMapping
import gnu.trove.set.hash.TIntHashSet; //導入方法依賴的package包/類
/**
* Set mapping which defines a drawables table. Latitude, longitude and
* geometry and non-overlapping layer come directly from the input source
* table, everything else comes from a style function
*
* @param ml
* @param destinationTableId
* @param mapping
*/
private void setFieldMapping(MatchedLayer ml, int destinationTableId,ODLTableDefinition extraFields, AdapterMapping mapping) {
// get set of columns read directly from validated source and never
// controlled by styles
TIntHashSet fromSource = new TIntHashSet();
fromSource.add(DrawableObjectImpl.COL_LATITUDE);
fromSource.add(DrawableObjectImpl.COL_LONGITUDE);
fromSource.add(DrawableObjectImpl.COL_GEOMETRY);
fromSource.add(DrawableObjectImpl.COL_NOPL_GROUP_KEY);
// now set the source for each column as appropriate
for (int drawablesCol = 0; drawablesCol <= DrawableObjectImpl.COL_MAX; drawablesCol++) {
if (fromSource.contains(drawablesCol)) {
// Read directly from validated source table
mapping.setFieldSourceIndx(destinationTableId, drawablesCol, drawablesCol);
} else {
// Style formula based on unvalidated raw source table,
// defaulting to validated when formula unavailable empty
mapping.setFieldFormula(destinationTableId, drawablesCol, new StyleFunction(ml, drawablesCol));
}
}
// additional fields come from the raw...
int []extraSrcs = ml.source.extraFieldIndicesInRaw;
if(extraSrcs!=null && extraSrcs.length>0){
if(extraFields.getColumnCount()!= extraSrcs.length){
throw new RuntimeException();
}
for(int i =0 ; i < extraSrcs.length; i++){
final int finalI=i;
mapping.addMappedFormula(destinationTableId, extraFields.getColumnName(i), extraFields.getColumnType(i), new FunctionImpl() {
@Override
public Object execute(FunctionParameters parameters) {
TableParameters tp = (TableParameters)parameters;
return ml.source.raw.getValueById(tp.getRowId(), extraSrcs[finalI]);
}
@Override
public Function deepCopy() {
throw new IllegalArgumentException();
}
});
}
}
}