當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。