当前位置: 首页>>代码示例>>Java>>正文


Java IntSet.contains方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntSet.contains方法的典型用法代码示例。如果您正苦于以下问题:Java IntSet.contains方法的具体用法?Java IntSet.contains怎么用?Java IntSet.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.ints.IntSet的用法示例。


在下文中一共展示了IntSet.contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: greedySolve

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public double greedySolve(Mat mat) {
    double sum = 0.0;
    IntSet available = new IntRBTreeSet();
    for(int i = 0; i < mat.M(); i++) {
        available.add(i);
    }
    for(int i = 0; i < mat.N(); i++) {
        double best = Double.NEGATIVE_INFINITY;
        for(ME me : mat.row(i)) {
            if(available.contains(me.j) && me.v > best) {
                best = me.v;
                available.remove(me.j);
            }
        }
        sum += Math.max(best, 0.0);
    }
    return sum;
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:19,代码来源:MunkResTest.java

示例2: DepTree

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public DepTree(TypedDependency root, Collection<TypedDependency> tds,
    List<? extends HasWord> sentence, int[] remapping, IntSet stack) {
    this.map = new HashMap<>();
    int t = root.dep().index();
    node = sentence.get(t - 1).word();
    //tag = root.dep().tag();
    tag = root.dep().label().tag();
    this.idx = remapping[t - 1];
    if (!stack.contains(t)) {
        IntSet stack2 = new IntRBTreeSet(stack);
        stack2.add(t);
        for (TypedDependency td : tds) {
            if (td.gov().index() == t && td.dep().index() != t) {
                map.put(td.reln().getShortName(), new DepTree(td, tds, sentence, remapping, stack2));
            }
        }
    }
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:19,代码来源:SultanModified.java

示例3: generateRandomKeys

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public static KeyTestInfo generateRandomKeys(Random random, int maxNumKeys) {
  int maxKeyOrValue = maxNumKeys << 2;
  int[] keysAndValues = new int[maxNumKeys * 3];
  int[] nonKeys = new int[maxNumKeys];
  IntSet keySet = new IntOpenHashBigSet(maxNumKeys);
  for (int i = 0; i < maxNumKeys; i++) {
    int entry;
    do {
      entry = random.nextInt(maxKeyOrValue);
    } while (keySet.contains(entry));
    keysAndValues[i * 3] = entry;
    keysAndValues[i * 3 + 1] = random.nextInt(maxKeyOrValue);
    keysAndValues[i * 3 + 2] = random.nextInt(maxKeyOrValue);
    keySet.add(entry);
  }
  for (int i = 0; i < maxNumKeys; i++) {
    int nonKey;
    do {
      nonKey = random.nextInt(maxKeyOrValue);
    } while (keySet.contains(nonKey));
    nonKeys[i] = nonKey;
  }
  return new KeyTestInfo(keysAndValues, nonKeys);
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:25,代码来源:IntToIntPairMapTestHelper.java

示例4: learnNode

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
protected void learnNode(int node, IntSet successors ) throws IOException {
	
	for (int successor : successors) {
		classifier.learn(node2cat.get(node), node2cat.get(successor), true);
		anArcHasBeenLearned();
		pl.lightUpdate();
	}
	int nonSucc;
	for (int i = successors.size()-1; i >= 0; i--) {
		do { 
			nonSucc = rnd.nextInt(numNodes);
		} while (successors.contains(nonSucc));
		classifier.learn(node2cat.get(node), node2cat.get(nonSucc), false);
		anArcHasBeenLearned();
		pl.lightUpdate();
	}
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:18,代码来源:LatentMatrixEstimator.java

示例5: computeForQuery

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
@Override
public double computeForQuery(int query, UnexpectednessScorer retriever) {
	IntSet evaluatedDocs = groundtruth.getEvaluatedDocs(query);
	double R = groundtruth.getRelevants(query).size();
	double N = evaluatedDocs.size() - R;
	double minNR = Math.min(N, R);
	
	int[] retrieved = retriever.results(query);
	
	double bpref = 0, nonRelevantRankedFirst = 0;
	for (int doc : retrieved)
		if (evaluatedDocs.contains(doc)) {
			if (groundtruth.isRelevant(query, doc)) {
				bpref += 1.0 - (nonRelevantRankedFirst / minNR);
			} else {
				if (nonRelevantRankedFirst < R)
					nonRelevantRankedFirst ++;

			}
		}
	
	bpref /= R;
	printResult(this + "\t" + retriever + "\t" + query(query) + "\t" + bpref);
	
	return bpref;
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:27,代码来源:BPrefMeasure.java

示例6: mergeAndDedup

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
/**
 * Baseline implementation. Augments the "standard" list with alternatives.
 * 
 * @param l1
 * @param l2
 * @return
 */
public static <TK,FV> List<RichTranslation<TK,FV>> mergeAndDedup(List<RichTranslation<TK,FV>> standard,
    List<RichTranslation<TK,FV>> alt, int maxAltItems) {
  
  IntSet hashCodeSet = new IntOpenHashSet(standard.size());
  for (RichTranslation<TK,FV> s : standard) {
    hashCodeSet.add(derivationHashCode(s.getFeaturizable().derivation));
  }
  
  List<RichTranslation<TK,FV>> returnList = new ArrayList<>(standard);
  for (int i = 0, sz = Math.min(maxAltItems, alt.size()); i < sz; ++i) {
    RichTranslation<TK,FV> t = alt.get(i);
    int hashCode = derivationHashCode(t.getFeaturizable().derivation);
    if (! hashCodeSet.contains(hashCode)) returnList.add(t);
  }
  Collections.sort(returnList);
  
  return returnList;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:26,代码来源:NbestListUtils.java

示例7: calcRandomHits

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
int calcRandomHits(int _size, int _seed) {
  IntSet _cache = new IntOpenHashSet();
  IntList _list = new IntArrayList();
  Random _random = new Random(_seed);
  int _hitCnt = 0;
  for (int v : getTrace()) {
    if(_cache.contains(v)) {
      _hitCnt++;
    } else {
      if (_cache.size() == _size) {
        int cnt = _random.nextInt(_cache.size());
        _cache.remove(_list.get(cnt));
        _list.remove(cnt);
      }
      _cache.add(v);
      _list.add(v);
    }
  }
  return _hitCnt;
}
 
开发者ID:cache2k,项目名称:cache2k-benchmark,代码行数:21,代码来源:AccessTrace.java

示例8: intersectReferenced

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
void intersectReferenced(final IntSet attributes, final Attribute[] attributeIndex) {
  final IntIterator referencedIterator = referenced.iterator();
  while (referencedIterator.hasNext()) {
    final int ref = referencedIterator.nextInt();
    if (attributes.contains(ref)) {
      continue;
    }

    referencedIterator.remove();
    attributeIndex[ref].removeDependent(id);
  }
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:13,代码来源:Attribute.java

示例9: check

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void check(int node) {
	IntSet consideredSuccessors = evaluations.getEvaluatedDocs(node);
	IntSet unmatchedSuccessors = new IntOpenHashSet(consideredSuccessors);
	
	int howMany = (int) (graph.outdegree(node) * ALPHA);
	
	for (UnexpectednessScorer poolMember : pool ) {
		int resultsConsidered = 0;
		for (int succ : poolMember.results(node, howMany))
			if (consideredSuccessors.contains(succ)) {
				resultsConsidered++;
				unmatchedSuccessors.remove(succ);
			}
		
		if (resultsConsidered == 0)
			LOGGER.warn(
					poolMember.toString()
					+ " got no considered results for query " + id2name.get(node)
					);
		
		double fractionOfItsResultsOverConsideredResults =
				(double) resultsConsidered / consideredSuccessors.size();
		retriever2itsFraction.get(poolMember).addValue(fractionOfItsResultsOverConsideredResults);
		retriever2evaluatedTopResults.get(poolMember).addValue((double) resultsConsidered / howMany);
	}
	
	double unmatchedResultsOverConsideredResults =
			(double) unmatchedSuccessors.size() / consideredSuccessors.size();
	unmatchStats.addValue(unmatchedResultsOverConsideredResults);
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:31,代码来源:PooledDatasetChecker.java

示例10: checkAgreementWith

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void checkAgreementWith(ImmutableGraph g, Int2ObjectFunction<String> names)  {
	for (Entry<IntSet> q2ev : query2evaluateddocs.int2ObjectEntrySet()) {
		int query = q2ev.getIntKey();
		IntSet successors = new IntOpenHashSet(g.successorArray(query), 0, g.outdegree(query));
		for (int evaluated : q2ev.getValue()) {
			if (!successors.contains(evaluated)) {
				LOGGER.error(
						"The query " + names.get(query) + " contains evaluated document "
					    + names.get(evaluated) + ", but this was not present in its successors"
						);
			}
		}
	}
}
 
开发者ID:corradomonti,项目名称:llamafur,代码行数:15,代码来源:GroundTruth.java

示例11: notInTrain

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
/**
 * Item filter that discards items in the training preference data.
 *
 * @param <U> type of the users
 * @param <I> type of the items
 * @param trainData preference data
 * @return item filters for each using returning true if the
 * user-item pair was not observed in the preference data
 */
public static <U, I> Function<U, IntPredicate> notInTrain(FastPreferenceData<U, I> trainData) {
    return user -> {
        IntSet set = new IntOpenHashSet();
        trainData.getUidxPreferences(trainData.user2uidx(user))
                .mapToInt(IdxPref::v1)
                .forEach(set::add);

        return iidx -> !set.contains(iidx);
    };
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:20,代码来源:FastFilters.java

示例12: getTopNLinearSearch

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public static IntDoubleTopN getTopNLinearSearch(double[][] itemMatrix, double[] q, int n, IntSet excluded) {
    IntDoubleTopN topN = new IntDoubleTopN(n);

    for (int row = 0; row < itemMatrix.length; row++) {
        if (!excluded.contains(row)) {
            topN.add(row, dotProduct(q, itemMatrix[row]));
        }
    }

    return topN;
}
 
开发者ID:saulvargas,项目名称:BallTrees,代码行数:12,代码来源:IPTreeSearch.java

示例13: linearSearch

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
private static void linearSearch(Ball ball, double[] q, IntDoubleTopN topN, IntSet excluded) {
    for (int row : ball.getRows()) {
        if (!excluded.contains(row)) {
            topN.add(row, dotProduct(q, ball.getItemMatrix()[row]));
        }
    }
}
 
开发者ID:saulvargas,项目名称:BallTrees,代码行数:8,代码来源:IPTreeSearch.java

示例14: getQuantity

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
@Override
public double getQuantity(IClustering clustering) {
    final long numArcs = graph.numArcs();

    double result = 0;

    for (final ICluster cl : clustering.getClusters()) {
        final IntSet clusterNodes = new IntOpenHashSet(cl.getEntries().size());
        for (final String name : cl.getEntriesNames()) {
            final int nodeId = namer.getNodeId(name);

            Preconditions.checkState(nodeId >= 0);

            clusterNodes.add(nodeId);
        }

        int nodesInside = 0;
        int outDegree = 0;
        for (final int fstNode : clusterNodes) {

            outDegree += graph.outdegree(fstNode);

            final int[] succ = graph.successorArray(fstNode);
            final int succLength = graph.outdegree(fstNode);

            for (int i = 0; i < succLength; i++) {
                if (clusterNodes.contains(succ[i])) {
                    nodesInside++;
                }
            }
        }

        final double tmp = (1. * outDegree) / numArcs;
        result += (1. * nodesInside) / numArcs - tmp * tmp;
    }

    return result;
}
 
开发者ID:sokolm,项目名称:LGA,代码行数:39,代码来源:Modularity.java

示例15: GraphView

import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public GraphView(IGraph g, IntSet subNodes) {
	this.g = g;
	this.nodes = subNodes;
	this.edges = new IntOpenHashSet();

	// calculating edges
	for( int src : subNodes ) {
		IntSet neighs = g.getOutNeighbours(src);
		for( int neigh : neighs ) {
			if( subNodes.contains(neigh) ) {
				edges.add(g.getEdgeBetween(src, neigh));
			}
		}
	}
}
 
开发者ID:besil,项目名称:AuroraGraphManager,代码行数:16,代码来源:GraphView.java


注:本文中的it.unimi.dsi.fastutil.ints.IntSet.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。