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


Java Set类代码示例

本文整理汇总了Java中java.util.Set的典型用法代码示例。如果您正苦于以下问题:Java Set类的具体用法?Java Set怎么用?Java Set使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: checkCorrect

import java.util.Set; //导入依赖的package包/类
/**
 * Checks that the given core is unsatisfiable with respect to the given
 * bounds.
 * 
 * @return true if the core is correct; false otherwise
 */
static boolean checkCorrect(Set<Formula> core, Bounds bounds) {
	System.out.print("checking correctness ... ");
	final long start = System.currentTimeMillis();
	Solver solver = solver();
	solver.options().setSolver(SATFactory.MiniSat);
	final Solution sol = solver.solve(Formula.and(core), bounds);
	final long end = System.currentTimeMillis();
	if (sol.instance() == null) {
		System.out.println("correct (" + (end - start) + " ms).");
		return true;
	} else {
		System.out.println("incorrect! (" + (end - start) + " ms). The core is satisfiable:");
		System.out.println(sol);
		return false;
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:23,代码来源:UCoreStats.java

示例2: getInstancesOfAnnotation

import java.util.Set; //导入依赖的package包/类
public static <T> List<T> getInstancesOfAnnotation(ASMDataTable asmDataTable, Class annotationClass, Class<T> instanceClass) {
	String annotationClassName = annotationClass.getCanonicalName();
	Set<ASMDataTable.ASMData> asmDatas = asmDataTable.getAll(annotationClassName);
	List<T> instances = new ArrayList<>();
	for (ASMDataTable.ASMData asmData : asmDatas) {
		try {
			Class<?> asmClass = Class.forName(asmData.getClassName());
			Class<? extends T> asmInstanceClass = asmClass.asSubclass(instanceClass);
			T instance = asmInstanceClass.newInstance();
			instances.add(instance);
		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | LinkageError e) {
			HarshenCastle.LOGGER.error("Failed to load: {}", asmData.getClassName(), e);
		}
	}
	return instances;
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:HarshenUtils.java

示例3: buildQuery

import java.util.Set; //导入依赖的package包/类
public static String buildQuery(Map<String, String> params, String charset) throws IOException {
    if (params == null || params.isEmpty()) {
        return null;
    }

    StringBuilder query = new StringBuilder();
    Set<Entry<String, String>> entries = params.entrySet();
    boolean hasParam = false;

    for (Entry<String, String> entry : entries) {
        String name = entry.getKey();
        String value = entry.getValue();
        // 忽略参数名或参数值为空的参数
        if (StringUtils.isAnyEmpty(name, value)) {
            if (hasParam) {
                query.append("&");
            } else {
                hasParam = true;
            }

            query.append(name).append("=").append(URLEncoder.encode(value, charset));
        }
    }

    return query.toString();
}
 
开发者ID:warlock-china,项目名称:azeroth,代码行数:27,代码来源:HttpUtils.java

示例4: executeWithThrowException

import java.util.Set; //导入依赖的package包/类
private void executeWithThrowException(FunctionContext context) {
  DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
  RegionFunctionContext rfContext = (RegionFunctionContext) context;
  LogWriter logger = ds.getLogWriter();
  logger.fine("Executing executeWithThrowException in TestFunction on Member : "
      + ds.getDistributedMember() + "with Context : " + context);
  if (context.getArguments() instanceof Boolean) {
    logger.fine("MyFunctionExecutionException Exception is intentionally thrown");
    throw new MyFunctionExecutionException("I have been thrown from TestFunction");
  } else if (rfContext.getArguments() instanceof Set) {
    Set origKeys = (Set) rfContext.getArguments();
    for (Iterator i = origKeys.iterator(); i.hasNext();) {
      Region r = PartitionRegionHelper.getLocalDataForContext(rfContext);
      Object key = i.next();
      Object val = r.get(key);
      if (val != null) {
        throw new MyFunctionExecutionException("I have been thrown from TestFunction");
      }
    }
  } else {
    logger.fine("Result sent back :" + Boolean.FALSE);
    rfContext.getResultSender().lastResult(Boolean.FALSE);
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:25,代码来源:TestFunction.java

示例5: getExtraOptionsLD

import java.util.Set; //导入依赖的package包/类
public Set <String> getExtraOptionsLD( boolean debug, boolean coreCopied ) {
    String chipkitCoreDirectory = data.get("build.core.path");
    String chipkitVariantDirectory = data.get("build.variant.path");
    String ldScriptDirectory = data.get("build.ldscript_dir.path");
    String ldscript = debug ? data.get("ldscript-debug") : data.get("ldscript");
    String ldcommon = data.get("ldcommon");
    Set <String> optionSet = new LinkedHashSet<>();
    parseOptions( optionSet, data.get("compiler.c.elf.flags") );
    removeRedundantCompilerOptions(optionSet);
    removeRedundantLinkerOptions(optionSet);
    optionSet.add("-mnewlib-libc");
    if ( coreCopied ) {
        optionSet.add("-T\"" + ldscript + "\"");
        optionSet.add("-T\"" + ldcommon + "\"");
    } else {
        Path ldcommonPath = Paths.get( chipkitCoreDirectory, ldcommon );
        Path ldscriptPath = Paths.get( debug && !ldScriptDirectory.isEmpty() ? ldScriptDirectory : chipkitCoreDirectory, ldscript );
        if ( !Files.exists(ldscriptPath) && !debug ) {
            ldscriptPath = Paths.get( chipkitVariantDirectory, ldscript );
        }
        optionSet.add("-T\"" + ldscriptPath.toString() + "\"");
        optionSet.add("-T\"" + ldcommonPath.toString() + "\"");
    }
    return optionSet;
}
 
开发者ID:chipKIT32,项目名称:chipKIT-importer,代码行数:26,代码来源:ChipKitBoardConfig.java

示例6: testBasicSubprojects

import java.util.Set; //导入依赖的package包/类
public void testBasicSubprojects() throws Exception {
    Set subprojects = simpleSubprojects.getSubprojects();
    
    assertTrue("no subprojects for simple", subprojects.isEmpty());
    assertEquals("no subprojects for simple", Collections.EMPTY_SET, subprojects);
    assertTrue("no subprojects for simple", subprojects.isEmpty());
    
    subprojects = extsrcrootSubprojects.getSubprojects();
    assertFalse("extsrcroot has simple as a subproject", subprojects.isEmpty());
    assertEquals("extsrcroot has simple as a subproject", Collections.singleton(simple), subprojects);
    assertFalse("extsrcroot has simple as a subproject", subprojects.isEmpty());
    
    subprojects = simple2Subprojects.getSubprojects();
    
    assertTrue("no subprojects for simple", subprojects.isEmpty());
    assertEquals("no subprojects for simple", Collections.EMPTY_SET, subprojects);
    assertTrue("no subprojects for simple", subprojects.isEmpty());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SubprojectsTest.java

示例7: diff

import java.util.Set; //导入依赖的package包/类
private static boolean diff(PrintWriter writer, PgDiffArguments arguments)
        throws InterruptedException, IOException, URISyntaxException {
    PgDiffScript script;
    try (PrintWriter encodedWriter = getDiffWriter(arguments)) {
        script = PgDiff.createDiff(encodedWriter != null ? encodedWriter : writer, arguments);
    }
    if (arguments.isSafeMode()) {
        Set<DangerStatement> dangerTypes = script.findDangers(arguments.getAllowedDangers());
        if (!dangerTypes.isEmpty()) {
            String msg = MessageFormat.format(Messages.Main_danger_statements,
                    dangerTypes.stream().map(DangerStatement::name)
                    .collect(Collectors.joining(", ")));
            writer.println(msg);
            try (PrintWriter encodedWriter = getDiffWriter(arguments)) {
                if (encodedWriter != null) {
                    encodedWriter.println("-- " + msg);
                }
            }
            return false;
        }
    }
    return true;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:24,代码来源:Main.java

示例8: checkIfGivenExpressionIsValid

import java.util.Set; //导入依赖的package包/类
private void checkIfGivenExpressionIsValid(Map<String, Class<?>> inputSchemaFields, Set<String> errors,
		ExpressionData expressionData, ErrorLogTableViewer errorLogTableViewer) {
	if(StringUtils.isBlank(expressionData.getExpressionEditorData().getExpression())){
		errors.add(Messages.EXPRESSION_IS_BLANK);
	}
	else{
		Display.getCurrent().asyncExec(new Runnable() {
			
			@Override
			public void run() {
				ExpressionEditorUtil.validateExpression(expressionData.getExpressionEditorData().getExpression(),
						inputSchemaFields,expressionData.getExpressionEditorData());
				if(!expressionData.getExpressionEditorData().isValid()){
					errors.add(Messages.EXPRESSION_IS_INVALID);
					errorLogTableViewer.refresh();
				}
			}
		});
		
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:22,代码来源:FilterOperationExpressionValidation.java

示例9: PKIXParameters

import java.util.Set; //导入依赖的package包/类
/**
 * Creates an instance of {@code PKIXParameters} that
 * populates the set of most-trusted CAs from the trusted
 * certificate entries contained in the specified {@code KeyStore}.
 * Only keystore entries that contain trusted {@code X509Certificates}
 * are considered; all other certificate types are ignored.
 *
 * @param keystore a {@code KeyStore} from which the set of
 * most-trusted CAs will be populated
 * @throws KeyStoreException if the keystore has not been initialized
 * @throws InvalidAlgorithmParameterException if the keystore does
 * not contain at least one trusted certificate entry
 * @throws NullPointerException if the keystore is {@code null}
 */
public PKIXParameters(KeyStore keystore)
    throws KeyStoreException, InvalidAlgorithmParameterException
{
    if (keystore == null)
        throw new NullPointerException("the keystore parameter must be " +
            "non-null");
    Set<TrustAnchor> hashSet = new HashSet<TrustAnchor>();
    Enumeration<String> aliases = keystore.aliases();
    while (aliases.hasMoreElements()) {
        String alias = aliases.nextElement();
        if (keystore.isCertificateEntry(alias)) {
            Certificate cert = keystore.getCertificate(alias);
            if (cert instanceof X509Certificate)
                hashSet.add(new TrustAnchor((X509Certificate)cert, null));
        }
    }
    setTrustAnchors(hashSet);
    this.unmodInitialPolicies = Collections.<String>emptySet();
    this.certPathCheckers = new ArrayList<PKIXCertPathChecker>();
    this.certStores = new ArrayList<CertStore>();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:36,代码来源:PKIXParameters.java

示例10: resolve

import java.util.Set; //导入依赖的package包/类
@Override
public List<String> resolve(Context context, List<String> expressions) {
    IndicesOptions options = context.getOptions();
    MetaData metaData = context.getState().metaData();
    if (options.expandWildcardsClosed() == false && options.expandWildcardsOpen() == false) {
        return expressions;
    }

    if (isEmptyOrTrivialWildcard(expressions)) {
        return resolveEmptyOrTrivialWildcard(options, metaData, true);
    }

    Set<String> result = innerResolve(context, expressions, options, metaData);

    if (result == null) {
        return expressions;
    }
    if (result.isEmpty() && !options.allowNoIndices()) {
        IndexNotFoundException infe = new IndexNotFoundException((String)null);
        infe.setResources("index_or_alias", expressions.toArray(new String[0]));
        throw infe;
    }
    return new ArrayList<>(result);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:IndexNameExpressionResolver.java

示例11: createPoolManager

import java.util.Set; //导入依赖的package包/类
private static ResourcePoolManager createPoolManager(Set<Archive> archives,
        Map<String, List<Entry>> entriesForModule,
        ByteOrder byteOrder,
        BasicImageWriter writer) throws IOException {
    ResourcePoolManager resources = new ResourcePoolManager(byteOrder, new StringTable() {

        @Override
        public int addString(String str) {
            return writer.addString(str);
        }

        @Override
        public String getString(int id) {
            return writer.getString(id);
        }
    });

    for (Archive archive : archives) {
        String mn = archive.moduleName();
        entriesForModule.get(mn).stream()
            .map(e -> new ArchiveEntryResourcePoolEntry(mn,
                                e.getResourcePoolEntryName(), e))
            .forEach(resources::add);
    }
    return resources;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ImageFileCreator.java

示例12: findContainers

import java.util.Set; //导入依赖的package包/类
public Set<String> findContainers(Collection<EClass> collection, String selectedType) {
  Set<String> result = new HashSet<String>();
  SigTrace typeTrace;
  try {
    typeTrace = getSigTraceByType(selectedType);
  } catch (TraceException e1) {
    return result;
  }
  EList<EClass> superTypes = typeTrace.getEClass().getEAllSuperTypes();
  for (EClass eClass : collection) {
    for (EReference eReference : eClass.getEAllReferences()) {
      if (eReference.isContainment()) {
        try {
          if (superTypes.stream()
              .anyMatch(s -> s.getName().equals(eReference.getEReferenceType().getName()))) {
            result.add(getSigTraceByClassName(eClass.getName()).getSigType());
          }
        } catch (TraceException e) {
          // no need to handle
        }
      }
    }
  }
  return result;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:26,代码来源:TraceManager.java

示例13: computeNodeWildcard

import java.util.Set; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Result computeNodeWildcard(Wildcard expr) {
    Result result = new Result();
    LabelVar var = expr.getWildcardId();
    Set<@NonNull TypeNode> candidates = new HashSet<>();
    if (var.hasName()) {
        candidates.addAll((Collection<@NonNull TypeNode>) this.varTyping.get(var));
    } else {
        candidates.addAll(this.typeGraph.nodeSet());
    }
    TypeGuard guard = expr.getWildcardGuard();
    for (TypeNode typeNode : guard.filter(candidates)) {
        result.add(typeNode, typeNode);
    }
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:17,代码来源:RegExprTyper.java

示例14: delegate

import java.util.Set; //导入依赖的package包/类
@Override
protected Set<TypeToken<? super T>> delegate() {
  ImmutableSet<TypeToken<? super T>> result = classes;
  if (result == null) {
    @SuppressWarnings({"unchecked", "rawtypes"})
    ImmutableList<TypeToken<? super T>> collectedTypes =
        (ImmutableList)
            TypeCollector.FOR_GENERIC_TYPE.classesOnly().collectTypes(TypeToken.this);
    return (classes =
        FluentIterable.from(collectedTypes)
            .filter(TypeFilter.IGNORE_TYPE_VARIABLE_OR_WILDCARD)
            .toSet());
  } else {
    return result;
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:17,代码来源:TypeToken.java

示例15: createPublicGroup

import java.util.Set; //导入依赖的package包/类
public Response createPublicGroup(GroupCreateRequest request) {
    Set<Long> permissions = request.permissions.stream().
        map(permission -> permission.getId()).collect(Collectors.toSet());
    Set<Long> roles = request.roles.stream().
        map(role -> role.getId()).collect(Collectors.toSet());
    String error = validateCreateRequest(request.name, permissions, roles);
    if (StringUtils.isNoneEmpty(error)) {
        throw new WebApplicationException(
            error,
            Response.Status.BAD_REQUEST);
    }

    Group group = new Group(request.name);
    return updateOrCreateGroup(group, permissions, roles);
}
 
开发者ID:tosinoni,项目名称:SECP,代码行数:16,代码来源:GroupController.java


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