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


Java Set.add方法代码示例

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


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

示例1: getBlockedThreads

import java.util.Set; //导入方法依赖的package包/类
public Set<Dependency<Thread, Serializable>> getBlockedThreads(Thread[] allThreads) {

    InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
    if (system == null) {
      return Collections.emptySet();
    }
    InternalDistributedMember myId = system.getDistributedMember();

    Set<Dependency<Thread, Serializable>> blockedThreads =
        new HashSet<Dependency<Thread, Serializable>>();
    for (Thread thread : allThreads) {
      ReplyProcessor21 processor = waitingProcessors.get(thread);
      if (processor != null && processor.getProcessorId() > 0) {
        blockedThreads.add(new Dependency<Thread, Serializable>(thread,
            new MessageKey(myId, processor.getProcessorId())));
      }
    }
    return blockedThreads;
  }
 
开发者ID:ampool,项目名称:monarch,代码行数:20,代码来源:MessageDependencyMonitor.java

示例2: showOperationsToIoSelect

import java.util.Set; //导入方法依赖的package包/类
/**
 * Translate set of {@link ShowOperation}s to set of
 * {@link IOSelect.AdditionalOperation}s.
 */
private Set<IOSelect.AdditionalOperation> showOperationsToIoSelect(
        Set<ShowOperation> operations) {
    Set<IOSelect.AdditionalOperation> res
            = EnumSet.noneOf(IOSelect.AdditionalOperation.class);
    for (ShowOperation so : operations) {
        switch (so) {
            case OPEN:
                res.add(IOSelect.AdditionalOperation.OPEN);
                break;
            case MAKE_VISIBLE:
                res.add(IOSelect.AdditionalOperation.REQUEST_VISIBLE);
                break;
            case ACTIVATE:
                res.add(IOSelect.AdditionalOperation.REQUEST_ACTIVE);
                break;
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BridgingInputOutputProvider.java

示例3: setPartiallyChecked

import java.util.Set; //导入方法依赖的package包/类
protected Collection setPartiallyChecked() {
    Set changedNodes = new HashSet();
    changedNodes.add(this);

    // Check if change is needed
    if (checkState == STATE_PARTIALLY_CHECKED) {
        return changedNodes;
    }

    // Update checkState of this node
    checkState = STATE_PARTIALLY_CHECKED;

    // Update checkState of parent
    TreeNode parent = getParent();

    if ((parent != null) && parent instanceof CheckTreeNode) {
        changedNodes.addAll(((CheckTreeNode) parent).setPartiallyChecked());
    }

    // Return Collection of leaf nodes changed by this operation
    return changedNodes;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CheckTreeNode.java

示例4: checkErasuresAndGetMin

import java.util.Set; //导入方法依赖的package包/类
private int checkErasuresAndGetMin(int[] erasures) throws ECFileCacheException {
  if (ArrayUtils.isEmpty(erasures)) {
    throw new ECFileCacheException("empty erasures array");
  }

  if (erasures.length > CODING_BLOCK_NUM) {
    String verbose = String.format("can not decode data with [%d] blocks erased.", erasures.length);
    LOGGER.warn(verbose);
    throw new ECFileCacheException(verbose);
  }

  int min = Integer.MAX_VALUE;
  Set<Integer> set = new HashSet<Integer>();
  for (final int erasure : erasures) {
    if (erasure < -1 || erasure >= EC_BLOCK_NUM || set.contains(erasure)) {
      throw new ECFileCacheException("invalid erasures array");
    }
    set.add(erasure);

    if (erasure < min) {
      min = erasure;
    }
  }

  return min;
}
 
开发者ID:XiaoMi,项目名称:ECFileCache,代码行数:27,代码来源:ECodec.java

示例5: save

import java.util.Set; //导入方法依赖的package包/类
@Override
public boolean save(SuspendedUserWrapperSettings xml)
{
	Set<String> right = new HashSet<String>();
	for( UserBean user : fsb.getRight() )
	{
		right.add(user.getUniqueID());
	}

	boolean saved = false;
	try
	{
		xml.setSuspendedUsers(right);
		saved = true;
	}
	catch( Exception e )
	{
		displayError(CurrentLocale.get("com.tle.admin.usermanagement.suspensionwrapper.errorsaving"), e); //$NON-NLS-1$
	}

	return saved;
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:SuspensionWrapper.java

示例6: createGroup

import java.util.Set; //导入方法依赖的package包/类
/**
    * Find or create a Group with the given name. Subclasses should use this method to locate the 'Roles' group or
    * create additional types of groups.
    *
    * @return A named Group from the principals set.
    */
   private Group createGroup(String name, Set<Principal> principals) {
Group roles = null;
for (Principal principal : principals) {
    if (principal instanceof Group) {
	Group grp = (Group) principal;
	if (grp.getName().equals(name)) {
	    roles = grp;
	    break;
	}
    }
}

// If we did not find a group create one
if (roles == null) {
    roles = new SimpleGroup(name);
    principals.add(roles);
}
return roles;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:UniversalLoginModule.java

示例7: _BUGtestSubClassQuery

import java.util.Set; //导入方法依赖的package包/类
public void _BUGtestSubClassQuery() throws Exception {
  Set add1 = new HashSet();
  Set add2 = new HashSet();
  add1.add(new Address("Hp3 9yf", "Apsley"));
  add1.add(new Address("Hp4 9yf", "Apsleyss"));
  add2.add(new Address("Hp3 8DZ", "Hemel"));
  add2.add(new Address("Hp4 8DZ", "Hemel"));
  Region region = CacheUtils.createRegion("employees", Employee.class);
  region.put("1", new Manager("aaa", 27, 270, "QA", 1800, add1, 2701));
  region.put("2", new Manager("bbb", 28, 280, "QA", 1900, add2, 2801));
  String queries[] = {"SELECT DISTINCT e.manager_id FROM /employees e"};
  for (int i = 0; i < queries.length; i++) {
    Query q = CacheUtils.getQueryService().newQuery(queries[i]);
    Object r = q.execute();
    String className =
        (((SelectResults) r).getCollectionType()).getElementType().getSimpleClassName();
    if (!className.equals("Employee")) {
      fail(
          "StructMemberAccessTest::testSubClassQuery:failed .Expected class name Employee. Actualy obtained="
              + className);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:24,代码来源:StructMemberAccessJUnitTest.java

示例8: getJobsUsingProfile

import java.util.Set; //导入方法依赖的package包/类
private Set<String> getJobsUsingProfile(Connection conn, String profileName)
        throws SQLException {
    Set<String> jobNames = new HashSet<String>();

    if (profileName == null) {
        return jobNames;
    }

    Statement stmt = conn.createStatement();
    ResultSet rs = DBUtils.executeQuery(stmt, GET_ALL_JOBS_AND_PROFILES_SQL);
    while (rs.next()) {
        String sourceProfileName = rs
                .getString(ManagedJobTableColumn.SOURCE_PROFILE_NAME.toString());
        if (sourceProfileName != null && sourceProfileName.equals(profileName)) {
            jobNames.add(rs.getString(ManagedJobTableColumn.JOB_NAME.toString()));
            continue;
        }
        String targetProfileName = rs
                .getString(CopyJobTableColumn.TARGET_PROFILE_NAME.toString());
        if (targetProfileName != null && targetProfileName.equals(profileName)) {
            jobNames.add(rs.getString(ManagedJobTableColumn.JOB_NAME.toString()));
        }
    }
    return jobNames;
}
 
开发者ID:Hitachi-Data-Systems,项目名称:Open-DM,代码行数:26,代码来源:ManagedJobsSchema.java

示例9: addFieldStringsFromParameter

import java.util.Set; //导入方法依赖的package包/类
public static void addFieldStringsFromParameter(TermVectorsRequest termVectorsRequest, String fields) {
    Set<String> selectedFields = termVectorsRequest.selectedFields();
    if (fields != null) {
        String[] paramFieldStrings = Strings.commaDelimitedListToStringArray(fields);
        for (String field : paramFieldStrings) {
            if (selectedFields == null) {
                selectedFields = new HashSet<>();
            }
            if (!selectedFields.contains(field)) {
                field = field.replaceAll("\\s", "");
                selectedFields.add(field);
            }
        }
    }
    if (selectedFields != null) {
        termVectorsRequest.selectedFields(selectedFields.toArray(new String[selectedFields.size()]));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:RestTermVectorsAction.java

示例10: testPermissions

import java.util.Set; //导入方法依赖的package包/类
@Test
public void testPermissions() {
    AppCreateDTO appCreateDTO = new AppCreateDTO();

    Set<String> permissions = new HashSet<>();
    permissions.add("TOP_SECRET");

    appCreateDTO.setPermissions(permissions);
    assertEquals("permissions are not equal",permissions, appCreateDTO.getPermissions());
}
 
开发者ID:tosinoni,项目名称:SECP,代码行数:11,代码来源:AppCreateDTOTest.java

示例11: getSetFromArray

import java.util.Set; //导入方法依赖的package包/类
private Set<Object> getSetFromArray(Object[] array) {
	Set<Object> s = new TreeSet<Object>();
	for (Object element : array) {
		s.add(element);
	}
	return s;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:8,代码来源:BDMapImpl.java

示例12: findSubwordsFrom

import java.util.Set; //导入方法依赖的package包/类
private Set<String> findSubwordsFrom(Letter root, Set<String> subwords, String prevChars) {
	for(Letter letter : root.getNextChars()) {
		String tmpSubword = prevChars;
		if(letter != null) {
			tmpSubword += letter.getValue();
			if(letter.isLast()) {
				subwords.add(tmpSubword);
			}
			findSubwordsFrom(letter, subwords, tmpSubword);
		}
	}
	return subwords;
}
 
开发者ID:alarit,项目名称:alar-trie,代码行数:14,代码来源:Trie.java

示例13: materializeVectors

import java.util.Set; //导入方法依赖的package包/类
public void materializeVectors(List<SchemaPath> columns, OutputMutator mutator) {
  Preconditions.checkNotNull(columns, "A scan's column selection cannot be null.");
  Set<String> selectedColumns = new HashSet<>();
  for (SchemaPath sp : columns) {
    selectedColumns.add(sp.getRootSegment().getNameSegment().getPath());
  }
  for (Field field : this) {
    if (columns != null && !selectedColumns.contains("*") && !selectedColumns.contains(field.getName())) {
      continue;
    }
    mutator.addField(field, CompleteType.fromField(field).getValueVectorClass());
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:BatchSchema.java

示例14: unmarshall

import java.util.Set; //导入方法依赖的package包/类
@Override
public Object unmarshall(AttributeValue value) {
    Set<Double> result = new HashSet<Double>();
    for (String s : value.ns()) {
        result.add(Double.valueOf(s));
    }
    return result;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:9,代码来源:DoubleSetUnmarshaller.java

示例15: findScriptClass

import java.util.Set; //导入方法依赖的package包/类
/**
 * 找出脚本类
 * @param clazzs
 * @return
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
@SuppressWarnings("unchecked")
private Set<Class<? extends T>> findScriptClass(Set<Class<?>> clazzs)
		throws InstantiationException, IllegalAccessException {
	Set<Class<? extends T>> scriptClazzs = new HashSet<Class<? extends T>>();
	for (Class<?> clazz : clazzs) {
		if (IScript.class.isAssignableFrom(clazz)) {
			Class<T> scriptClazz = (Class<T>) clazz;
			scriptClazzs.add(scriptClazz);
		}
	}
	return scriptClazzs;
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:20,代码来源:ScriptClassProvider.java


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