本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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()]));
}
}
示例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());
}
示例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;
}
示例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;
}
示例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());
}
}
示例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;
}
示例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;
}