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


Java SetView.size方法代码示例

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


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

示例1: analyze

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
public void analyze() {
	log.info("Starting analyzing for user: " + twitterUser);
	
	//Create the CSVFormat object
	createFileIfNotExisting(filenameFollowerIDsDelta());
	createFileIfNotExisting(filenameFollowerIDsCurrent());
	
	Set<String> currentIDsFromFile = readAllIDsFromCurrentFile(); 
	currentIDsFromTwitter = getAllFollwerIDsFromTwitter();
	
	SetView<String> symmetricDifference = Sets.symmetricDifference(currentIDsFromFile, currentIDsFromTwitter);
	
	if (symmetricDifference.size() == 0) {
		log.info("No new followers were found.");
	} else {
		processSyncDifferences(currentIDsFromFile, symmetricDifference);

		deleteAndRecreateFile(filenameFollowerIDsCurrent());
		writeCurrentFollowerIDFile(currentIDsFromTwitter);
	}
}
 
开发者ID:jojomay24,项目名称:TwitterAnalyzer,代码行数:22,代码来源:Main.java

示例2: getFamilyOfParents

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * 
 * 
 * <b>Note:</b> Depends on the collection of information through {@link #buildFamilyRelations()}. 
 * Calls {@link #buildFamilyRelations()} before returning the 
 * result if any structures have been added or removed after the last call 
 * to {@link #buildFamilyRelations()}, thus calling this method repeatedly 
 * after adding/removing structures is very inefficient.
 * 
 * @param parent1Id
 * @param parent2Id
 * @return
 */
public GedcomFamily getFamilyOfParents(String parent1Id, String parent2Id) {
	if (structuresModified) {
		buildFamilyRelations();
	}
	
	if (parent1Id == null && parent2Id == null) {
		return null;
	}
	
	Set<GedcomFamily> families1 = getFamiliesOfParent(parent1Id);
	Set<GedcomFamily> families2 = getFamiliesOfParent(parent2Id);
	
	//A comment in the guava docs: 
	//"I can use intersection as a Set directly, but copying it can be more 
	//efficient if I use it a lot."
	SetView<GedcomFamily> view = Sets.intersection(families1, families2);
	
	if (view.size() > 1) {
		throw new GedcomCreatorError("The parents " + parent1Id + " and " + parent2Id + 
				" have been found as parent in more than one (" + view.size() + ") family: " + view);
	}
	
	//Returns the first family, or null if there is none
	return Iterables.getFirst(view, null);
}
 
开发者ID:thnaeff,项目名称:GedcomCreator,代码行数:39,代码来源:GedcomCreatorStructureStorage.java

示例3: ObserversV2

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
public ObserversV2(Environment env, JsonObservers jco, Set<Column> strongColumns,
    Set<Column> weakColumns) {

  ObserverProvider obsProvider =
      ObserverStoreV2.newObserverProvider(jco.getObserverProviderClass());

  ObserverProviderContextImpl ctx = new ObserverProviderContextImpl(env);

  ObserverRegistry or = new ObserverRegistry(strongColumns, weakColumns);
  obsProvider.provide(or, ctx);

  this.observers = or.observers;
  this.aliases = or.aliases;
  this.observers.forEach((k, v) -> aliases.computeIfAbsent(k, col -> Hex.encNonAscii(col, ":")));

  // the following check ensures observers are provided for all previously configured columns
  SetView<Column> diff =
      Sets.difference(observers.keySet(), Sets.union(strongColumns, weakColumns));
  if (diff.size() > 0) {
    throw new FluoException("ObserverProvider " + jco.getObserverProviderClass()
        + " did not provide observers for columns " + diff);
  }
}
 
开发者ID:apache,项目名称:fluo,代码行数:24,代码来源:ObserversV2.java

示例4: isSinkHealthy

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * Returns the status of the sink.
 * 
 * @return the status of the sink.
 */
public boolean isSinkHealthy() {
    SetView<String> unclosedSinks = Sets.difference(rdfData.keySet(), closedSinks);
    if (unclosedSinks.size() > 0) {
        LOGGER.error("Some sinks have not been closed: " + unclosedSinks.toString());
        healthyness = false;
    }
    return healthyness;
}
 
开发者ID:dice-group,项目名称:Squirrel,代码行数:14,代码来源:InMemorySink.java

示例5: findExistingServers

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
 * Look for servers that may match.
 * 
 * @param modules the web modules to search for
 * @param exact if true, look for exact module match
 * @return an existing server
 */
@VisibleForTesting
public Collection<IServer> findExistingServers(IModule[] modules, boolean exact,
    SubMonitor progress) {
  if (modules.length == 1) {
    IServer defaultServer = ServerCore.getDefaultServer(modules[0]);
    if (defaultServer != null && LocalAppEngineServerDelegate.SERVER_TYPE_ID
        .equals(defaultServer.getServerType().getId())) {
      return Collections.singletonList(defaultServer);
    }
  }
  Set<IModule> myModules = ImmutableSet.copyOf(modules);
  List<IServer> matches = new ArrayList<>();
  // Look for servers that contain these modules
  // Could prioritize servers that have *exactly* these modules,
  // or that have the smallest overlap
  for (IServer server : ServerCore.getServers()) {
    // obsolete or unavailable server definitions have serverType == null
    if (server.getServerType() == null
        || !LocalAppEngineServerDelegate.SERVER_TYPE_ID.equals(server.getServerType().getId())) {
      continue;
    }
    Set<IModule> serverModules = ImmutableSet.copyOf(server.getModules());
    SetView<IModule> overlap = Sets.intersection(myModules, serverModules);
    if (overlap.size() == myModules.size()
        && (!exact || overlap.size() == serverModules.size())) {
      matches.add(server);
    }
  }
  return matches;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:38,代码来源:LaunchHelper.java

示例6: equals

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@Override
public boolean equals(Object other) {
  if (other instanceof ParallelWorkflowStep) {
    ParallelWorkflowStep otherStep = (ParallelWorkflowStep) other;
    SetView<SimpleWorkflowStep> intersection = Sets.intersection(this.steps, otherStep.steps);
    return intersection.size() == this.steps.size();
  }
  return false;
}
 
开发者ID:shillner,项目名称:maven-cdi-plugin-utils,代码行数:10,代码来源:ParallelWorkflowStep.java

示例7: refreshNNList

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
void refreshNNList(ArrayList<InetSocketAddress> addrs) throws IOException {
  Set<InetSocketAddress> oldAddrs = Sets.newHashSet();
  for (BPServiceActor actor : bpServices) {
    oldAddrs.add(actor.getNNSocketAddress());
  }
  Set<InetSocketAddress> newAddrs = Sets.newHashSet(addrs);

  SetView<InetSocketAddress> deadNNs = Sets.difference(oldAddrs, newAddrs);
  SetView<InetSocketAddress> newNNs = Sets.difference(newAddrs, oldAddrs);

  // stop the dead threads
  if (deadNNs.size() != 0) {
    for (InetSocketAddress deadNN : deadNNs) {
      BPServiceActor deadActor = stopAnActor(deadNN);
      bpServices.remove(
          deadActor); // NNs will not change frequently. so modification ops will not be expensive on the copyonwirte list
      LOG.debug("Stopped actor for " + deadActor.getNNSocketAddress());
    }
  }

  // start threads for new NNs
  if (newNNs.size() != 0) {
    for (InetSocketAddress newNN : newNNs) {
      BPServiceActor newActor = startAnActor(newNN);
      bpServices.add(
          newActor); // NNs will not change frequently. so modification ops will not be expensive on the copyonwirte list
      LOG.debug("Started actor for " + newActor.getNNSocketAddress());
    }
  }

}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:32,代码来源:BPOfferService.java

示例8: validateInput

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
private void validateInput(){
	{
		Set<V> rootPaired = Sets.intersection(rootNodes, pairedNodes);
		if(rootPaired.size()!= 0){
			throw new RuntimeException(rootPaired.size() + " duplicate elements found in root nodes and paired nodes: " + rootPaired);
		}
	}
	{
		Set<V> rootTerminal = Sets.intersection(rootNodes, terminalNodes);
		if(rootTerminal.size()!= 0){
			throw new RuntimeException(rootTerminal.size() + " duplicate elements found in root nodes and terminal nodes: " + rootTerminal);
		}
	}
	{
		Set<V> terminalPaired = Sets.intersection(terminalNodes, pairedNodes);
		if(terminalPaired.size()!= 0){
			throw new RuntimeException(terminalPaired.size() + " duplicate elements found in terminal nodes and paired nodes: " + terminalPaired);
		}
	}
	{
		Set<V> graphNodes = new HashSet<V>(graph.getVertices());
		SetView<V> all = Sets.union(Sets.union(rootNodes, terminalNodes),pairedNodes);
		SetView<V> graphNodesButNotAll = Sets.difference(graphNodes, all);
		if(graphNodesButNotAll.size() != 0 ){
			throw new RuntimeException(graphNodesButNotAll.size() + " found in graph but not in root, terminal, or paired: " + graphNodesButNotAll);
		}
		SetView<V> allButNotGraphNodes = Sets.difference(all,graphNodes);
		if(allButNotGraphNodes.size() != 0 ){
			throw new RuntimeException(allButNotGraphNodes.size() + " found in root, terminal, or paired but not graph: " + allButNotGraphNodes);
		}
	
	}
}
 
开发者ID:rma350,项目名称:kidneyExchange,代码行数:34,代码来源:KepProblemData.java

示例9: mergePairs

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
private Set<SetCount> mergePairs(Set<SetCount> pairs) {
	final Set<SetCount> res = Sets.newHashSet();
	final SetCount[] oldPairs = pairs.toArray(new SetCount[pairs.size()]);
	for (int i = 0; i < oldPairs.length; i++) {
		final SetCount a = oldPairs[i];
		nextPair: for (int j = i + 1; j < oldPairs.length; j++) {
			final SetCount b = oldPairs[j];
			final SetView<Integer> diff = Sets.difference(a.set, b.set);
			if (diff.size() == 2) {
				res.add(a.merge(b));
			}
		}
	}
	return res;
}
 
开发者ID:pshdl,项目名称:org.pshdl,代码行数:16,代码来源:FlagPacker.java

示例10: setsCompare

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
private String[] setsCompare(final Set<String> set1, final Set<String> set2) {
    if (set2 != null) {
        SetView<String> setdiff = Sets.difference(set1, set2);
        String diffarr[] = new String[setdiff.size()];
        setdiff.toArray(diffarr);
        return diffarr;
    } else {
        String set1arr[] = new String[set1.size()];
        set1.toArray(set1arr);
        return set1arr;
    }

}
 
开发者ID:guokr,项目名称:hebo,代码行数:14,代码来源:HeboEngineImpl.java

示例11: getEventType

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@Override
public EventType getEventType() {
    final SetView<EventType> eventTypesToUse =
            Sets.intersection(getPossibleEventTypes(), getProgramConclusion().getEventTypes().getTypes());

    if (eventTypesToUse.size() != 1) {
        throw new DomainException("error.program.conclusion.many.event.types");
    }

    return eventTypesToUse.iterator().next();
}
 
开发者ID:FenixEdu,项目名称:fenixedu-academic,代码行数:12,代码来源:RegistryDiplomaRequest.java

示例12: computeDiceSimilarity

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
double computeDiceSimilarity(Set<OWLIndividual> sourceInstances, Set<OWLIndividual> targetInstances) {
    SetView<OWLIndividual> intersection = Sets.intersection(sourceInstances, targetInstances);
    //		SetView<OWLIndividual> union = Sets.union(sourceInstances, targetInstances);

    /* Other approaches to compute coverage:
     * double jaccard = (double) intersection.size() / (double) targetInstances.size();
     * double overlap = (double) intersection.size() / (double) Math.min(sourceInstances.size(), targetInstances.size());
     * double alpha = 1, beta = 0.2;
     * SetView<OWLIndividual> sourceDifTarget = Sets.difference(sourceInstances, targetInstances);
     * SetView<OWLIndividual> targetDifsource = Sets.difference(targetInstances, sourceInstances);
     * double tversky = intersection.size() / (intersection.size() + alpha * sourceDifTarget.size() + beta * targetDifsource.size());*/

    double dice = 2 * ((double) intersection.size()) / (double)(sourceInstances.size() + targetInstances.size());
    return dice;
}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:16,代码来源:LASSIEController.java

示例13: countEntitiesAsMembersOfDisjointClasses

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
/**
	 * counts number of entities that are members of disjoint classes
	 * 
	 * @return the number of entities that are members of disjoint classes
	 */
	protected long countEntitiesAsMembersOfDisjointClasses() {
		long count = 0;
		
//		for (Map.Entry<String, Set<String>> entry : typesOfResource.entrySet()) {
		for (String entity : multipleTypeResource){
			// one entity in the dataset …
//			String entity = entry.getKey();
			// … and the classes it's an instance of
			Set<String> classes = typesOfResource.get(entity);
			
			if (classes.size() >= 2) {
				// we only need to check disjointness when there are at least 2 classes
				boolean isDisjoint = false;
				for (String s : classes){
					if (VocabularyLoader.getInstance().checkTerm(ModelFactory.createDefaultModel().createResource(s).asNode())){
						Set<String> _set = this.rdfNodeSetToString(VocabularyLoader.getInstance().getDisjointWith(ModelFactory.createDefaultModel().createResource(s).asNode()));
						
						SetView<String> setView = Sets.intersection(classes, _set);
						if (setView.size() > 0){
							isDisjoint = true;
							createProblemModel(ModelFactory.createDefaultModel().createResource(entity).asNode(), setView);
						}
					}
				}
				if (isDisjoint) count++;
//				SELECT DISTINCT * {
//					<http://social.mercedes-benz.com/mars/schema/InternalModelName> <http://www.w3.org/2000/01/rdf-schema#subClassOf>* ?s0 . 
//					<http://www.w3.org/2008/05/skos-xl#Label> <http://www.w3.org/2000/01/rdf-schema#subClassOf>* ?s1 . 
//					?s0 <http://www.w3.org/2002/07/owl#disjointWith> ?s1 . 
//					?s1 <http://www.w3.org/2002/07/owl#disjointWith> ?s0 . }
			}
		}
		metricCalculated = true;
		return count;
	}
 
开发者ID:diachron,项目名称:quality,代码行数:41,代码来源:AdvancedEntitiesAsMembersOfDisjointClasses.java

示例14: metricValue

import com.google.common.collect.Sets.SetView; //导入方法依赖的package包/类
@Override
public double metricValue() {
	
	if (!calculated){
		
		calculated = true;
		
		double totalDiffNs = differentNamespacesUsed.size();
		double totalNsInd = namespacesIndicated.size();
		
		SetView<String> view = Sets.intersection(differentNamespacesUsed, namespacesIndicated); // view of indicated and used
		
		
		statsLogger.info("Dataset: {} - Total # NS used : {}; # NS indicated by void : {} # NS used vis-a-vie indicated : {};"
				, this.getDatasetURI(), totalDiffNs, totalNsInd, view.size()); //TODO: these store in a seperate file

	
		if (view.size() == 0) value = 0.0;
		else if (totalDiffNs == 0) value = 0.0;
		else value = (double)view.size()/(double)totalDiffNs;
		
		
		//for problem report
		differentNamespacesUsed.removeAll(namespacesIndicated);
		
		for(String s : differentNamespacesUsed) this.createProblemQuad(s);
		
	}
	
	
	return value;
}
 
开发者ID:diachron,项目名称:quality,代码行数:33,代码来源:VocabularyUsageIndication.java


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