本文整理汇总了Java中java.util.Set.size方法的典型用法代码示例。如果您正苦于以下问题:Java Set.size方法的具体用法?Java Set.size怎么用?Java Set.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Set
的用法示例。
在下文中一共展示了Set.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import java.util.Set; //导入方法依赖的package包/类
@SuppressLint("MissingSuperCall")
@Override
protected void onCreate(Bundle savedInstanceState) {
final int titleResource;
final Intent intent = makeMyIntent();
final Set<String> categories = intent.getCategories();
if (Intent.ACTION_MAIN.equals(intent.getAction())
&& categories != null
&& categories.size() == 1
&& categories.contains(Intent.CATEGORY_HOME)) {
titleResource = R.string.choose;
} else {
titleResource = R.string.choose;
}
onCreate(savedInstanceState, intent, getResources().getText(titleResource),
null, null, true, VUserHandle.getCallingUserId());
}
示例2: loadInBackground
import java.util.Set; //导入方法依赖的package包/类
@Override
public ArrayList<Map<String, String>> loadInBackground() {
Set<String> regions = PhoneNumberUtil.getInstance().getSupportedRegions();
ArrayList<Map<String, String>> results = new ArrayList<Map<String, String>>(regions.size());
for (String region : regions) {
Map<String, String> data = new HashMap<String, String>(2);
data.put("country_name", PhoneNumberFormatter.getRegionDisplayName(region));
data.put("country_code", "+" +PhoneNumberUtil.getInstance().getCountryCodeForRegion(region));
results.add(data);
}
Collections.sort(results, new RegionComparator());
return results;
}
示例3: buildNewUri
import java.util.Set; //导入方法依赖的package包/类
private Uri buildNewUri(Uri uri, String targetAuthority) {
Uri.Builder b = new Builder();
b.scheme(uri.getScheme());
b.authority(targetAuthority);
b.path(uri.getPath());
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
Set<String> names = uri.getQueryParameterNames();
if (names != null && names.size() > 0) {
for (String name : names) {
if (!TextUtils.equals(name, Env.EXTRA_TARGET_AUTHORITY)) {
b.appendQueryParameter(name, uri.getQueryParameter(name));
}
}
}
} else {
b.query(uri.getQuery());
}
b.fragment(uri.getFragment());
return b.build();
}
示例4: withTableWriteItems
import java.util.Set; //导入方法依赖的package包/类
public BatchWriteItemSpec withTableWriteItems(
TableWriteItems... tableWriteItems) {
if (tableWriteItems == null) {
this.tableWriteItems = null;
} else {
Set<String> names = new LinkedHashSet<String>();
for (TableWriteItems e : tableWriteItems) {
names.add(e.getTableName());
}
if (names.size() != tableWriteItems.length) {
throw new IllegalArgumentException(
"table names must not duplicate in the list of TableWriteItems");
}
this.tableWriteItems = Arrays.asList(tableWriteItems);
}
return this;
}
示例5: collectingAndThen
import java.util.Set; //导入方法依赖的package包/类
/**
* Adapts a {@code Collector} to perform an additional finishing
* transformation. For example, one could adapt the {@link #toList()}
* collector to always produce an immutable list with:
* <pre>{@code
* List<String> people
* = people.stream().collect(collectingAndThen(toList(), Collections::unmodifiableList));
* }</pre>
*
* @param <T> the type of the input elements
* @param <A> intermediate accumulation type of the downstream collector
* @param <R> result type of the downstream collector
* @param <RR> result type of the resulting collector
* @param downstream a collector
* @param finisher a function to be applied to the final result of the downstream collector
* @return a collector which performs the action of the downstream collector,
* followed by an additional finishing step
*/
public static<T,A,R,RR> Collector<T,A,RR> collectingAndThen(Collector<T,A,R> downstream,
Function<R,RR> finisher) {
Set<Collector.Characteristics> characteristics = downstream.characteristics();
if (characteristics.contains(Collector.Characteristics.IDENTITY_FINISH)) {
if (characteristics.size() == 1)
characteristics = Collectors.CH_NOID;
else {
characteristics = EnumSet.copyOf(characteristics);
characteristics.remove(Collector.Characteristics.IDENTITY_FINISH);
characteristics = Collections.unmodifiableSet(characteristics);
}
}
return new CollectorImpl<>(downstream.supplier(),
downstream.accumulator(),
downstream.combiner(),
downstream.finisher().andThen(finisher),
characteristics);
}
示例6: getContainerGroups
import java.util.Set; //导入方法依赖的package包/类
/**
* Gets the groups that contain the specified authority
*
* @param person the user (cm:person) to get the containing groups for
*
* @return the containing groups as a JavaScript array
*/
public Scriptable getContainerGroups(ScriptNode person)
{
ParameterCheck.mandatory("Person", person);
Object[] parents = null;
Set<String> authorities = this.authorityService.getContainingAuthoritiesInZone(
AuthorityType.GROUP,
(String)person.getProperties().get(ContentModel.PROP_USERNAME),
AuthorityService.ZONE_APP_DEFAULT, null, 1000);
parents = new Object[authorities.size()];
int i = 0;
for (String authority : authorities)
{
ScriptNode group = getGroup(authority);
if (group != null)
{
parents[i++] = group;
}
}
return Context.getCurrentContext().newArray(getScope(), parents);
}
示例7: getWindowTitles
import java.util.Set; //导入方法依赖的package包/类
/**
* Returns the titles of all windows that the browser knows about
* @return array of all window titles
*/
@PublicAtsApi
public String[] getWindowTitles() {
Set<String> availableWindows = webDriver.getWindowHandles();
String[] windowTitles = new String[availableWindows.size()];
if (!availableWindows.isEmpty()) {
String currentWindowHandle = webDriver.getWindowHandle();
int i = 0;
for (String windowHandle : availableWindows) {
windowTitles[i++] = webDriver.switchTo().window(windowHandle).getTitle();
}
webDriver.switchTo().window(currentWindowHandle);
}
return windowTitles;
}
示例8: reportDifference
import java.util.Set; //导入方法依赖的package包/类
private static void reportDifference(Set<String> retrievedCountrySet, Set<String> expectedCountrySet) {
Set<String> retrievedSet = new HashSet<>(retrievedCountrySet);
Set<String> expectedSet = new HashSet<>(expectedCountrySet);
retrievedSet.removeAll(expectedCountrySet);
expectedSet.removeAll(retrievedCountrySet);
if ((retrievedSet.size() > 0) && (expectedSet.size() > 0)) {
throw new RuntimeException("Retrieved country codes set contains extra codes "
+ retrievedSet + " and missing codes " + expectedSet);
}
if (retrievedSet.size() > 0) {
throw new RuntimeException("Retrieved country codes set contains extra codes "
+ retrievedSet);
}
if (expectedSet.size() > 0) {
throw new RuntimeException("Retrieved country codes set is missing codes "
+ expectedSet);
}
}
示例9: degreeMatrix
import java.util.Set; //导入方法依赖的package包/类
public static double[][] degreeMatrix(SimpleGraph graph) {
Set set = graph.vertexSet();
Iterator it = set.iterator();
double[][] deg = new double[set.size()][set.size()];
int i = 0, j = 0;
while (it.hasNext()) {
Object p = it.next();
deg[i][j] = graph.degreeOf(p);
i++;
j++;
}
return deg;
}
示例10: snapshot
import java.util.Set; //导入方法依赖的package包/类
@Override
public ArtifactSet snapshot() {
ImmutableSet.Builder<ResolvedVariant> result = ImmutableSet.builder();
for (final VariantMetadata variant : variants) {
Set<? extends ComponentArtifactMetadata> artifacts = variant.getArtifacts();
Set<ResolvedArtifact> resolvedArtifacts = new LinkedHashSet<ResolvedArtifact>(artifacts.size());
// Add artifact type as an implicit attribute when there is a single artifact
AttributeContainerInternal attributes = variant.getAttributes();
if (artifacts.size() == 1 && !attributes.contains(ArtifactAttributes.ARTIFACT_FORMAT)) {
DefaultAttributeContainer implicitAttributes = new DefaultAttributeContainer(attributes);
implicitAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, artifacts.iterator().next().getName().getType());
attributes = implicitAttributes.asImmutable();
}
for (ComponentArtifactMetadata artifact : artifacts) {
IvyArtifactName artifactName = artifact.getName();
if (exclusions.excludeArtifact(moduleVersionIdentifier.getModule(), artifactName)) {
continue;
}
ResolvedArtifact resolvedArtifact = allResolvedArtifacts.get(artifact.getId());
if (resolvedArtifact == null) {
Factory<File> artifactSource = new LazyArtifactSource(artifact, moduleSource, artifactResolver);
resolvedArtifact = new DefaultResolvedArtifact(moduleVersionIdentifier, artifactName, artifact.getId(), artifact.getBuildDependencies(), artifactSource);
allResolvedArtifacts.put(artifact.getId(), resolvedArtifact);
}
resolvedArtifacts.add(resolvedArtifact);
}
result.add(new DefaultResolvedVariant(attributes, ArtifactBackedArtifactSet.of(resolvedArtifacts)));
}
return new ArtifactSetSnapshot(id, result.build());
}
示例11: isLastUser
import java.util.Set; //导入方法依赖的package包/类
public static boolean isLastUser(RsvpLspHopSeriesDto path, RsvpLspDto lsp) {
if (path == null) {
return false;
}
Set<RsvpLspDto> users = path.getRsvpLsps();
if (users != null && users.size() == 1) {
RsvpLspDto user = users.iterator().next();
if (DtoUtil.isSameMvoEntity(lsp, user)) {
return true;
}
}
return false;
}
示例12: writeProperties
import java.util.Set; //导入方法依赖的package包/类
/**
* Writes a <code>Properties</code> to a <code>DataOutput</code>.
* <P>
* NOTE: The <code>defaults</code> of the specified <code>props</code> are not serialized.
* <p>
* Note that even though <code>props</code> may be an instance of a subclass of
* <code>Properties</code>, <code>readProperties</code> will always return an instance of
* <code>Properties</code>, <B>not</B> an instance of the subclass. To preserve the class type of
* <code>props</code>, {@link #writeObject(Object, DataOutput)} should be used for data
* serialization.
*
* @throws IOException A problem occurs while writing to <code>out</code>
*
* @see #readProperties
*/
public static void writeProperties(Properties props, DataOutput out) throws IOException {
InternalDataSerializer.checkOut(out);
Set<Map.Entry<Object, Object>> s;
int size;
if (props == null) {
s = null;
size = -1;
} else {
s = props.entrySet();
size = s.size();
}
InternalDataSerializer.writeArrayLength(size, out);
if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
logger.trace(LogMarker.SERIALIZER, "Writing Properties with {} elements: {}", size, props);
}
if (size > 0) {
for (Map.Entry<Object, Object> entry : s) {
// although we should have just String instances in a Properties
// object our security code stores byte[] instances in them
// so the following code must use writeObject instead of writeString.
Object key = entry.getKey();
Object val = entry.getValue();
writeObject(key, out);
writeObject(val, out);
}
}
}
示例13: doValidate
import java.util.Set; //导入方法依赖的package包/类
private boolean doValidate(Object obj) {
final Set<ConstraintViolation<Object>> constraintViolations = VALIDATOR.validate(obj);
if (constraintViolations.size() > 0) {
for (ConstraintViolation<Object> violation : constraintViolations) {
final String msg = String.format(Locale.getDefault(), "%s (%s)", violation.getMessage(), violation.getPropertyPath().toString());
errors.add(new ConfigurationError(msg));
}
return false;
}
return true;
}
示例14: unboundNameToSymbol
import java.util.Set; //导入方法依赖的package包/类
private <S extends Symbol> S unboundNameToSymbol(String methodName,
String nameStr,
Class<S> clazz) {
if (modules.getDefaultModule() == syms.noModule) { //not a modular mode:
return nameToSymbol(syms.noModule, nameStr, clazz);
}
Set<S> found = new LinkedHashSet<>();
for (ModuleSymbol msym : modules.allModules()) {
S sym = nameToSymbol(msym, nameStr, clazz);
if (sym != null) {
if (!allowModules || clazz == ClassSymbol.class || !sym.members().isEmpty()) {
//do not add packages without members:
found.add(sym);
}
}
}
if (found.size() == 1) {
return found.iterator().next();
} else if (found.size() > 1) {
//more than one element found, produce a note:
if (alreadyWarnedDuplicates.add(methodName + ":" + nameStr)) {
String moduleNames = found.stream()
.map(s -> s.packge().modle)
.map(m -> m.toString())
.collect(Collectors.joining(", "));
log.note(Notes.MultipleElements(methodName, nameStr, moduleNames));
}
return null;
} else {
//not found, or more than one element found:
return null;
}
}
示例15: validate
import java.util.Set; //导入方法依赖的package包/类
public void validate() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set<ConstraintViolation<PipelineImpllinks>> constraintViolations = validator.validate(this);
if (constraintViolations.size() > 0) {
StringBuilder errors = new StringBuilder();
for (ConstraintViolation<PipelineImpllinks> contraintes : constraintViolations) {
errors.append(String.format("%s.%s %s\n",
contraintes.getRootBeanClass().getSimpleName(),
contraintes.getPropertyPath(),
contraintes.getMessage()));
}
throw new RuntimeException("Bean validation : " + errors);
}
}