本文整理汇总了C#中Set.contains方法的典型用法代码示例。如果您正苦于以下问题:C# Set.contains方法的具体用法?C# Set.contains怎么用?C# Set.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Set
的用法示例。
在下文中一共展示了Set.contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkNumbersValidAndCorrectType
/**
* @param exampleNumberRequestedType type we are requesting an example number for
* @param possibleExpectedTypes acceptable types that this number should match, such as
* FIXED_LINE and FIXED_LINE_OR_MOBILE for a fixed line example number.
*/
private void checkNumbersValidAndCorrectType(PhoneNumberType exampleNumberRequestedType,
Set<PhoneNumberType> possibleExpectedTypes)
{
foreach(String regionCode in phoneNumberUtil.getSupportedRegions()) {
PhoneNumber exampleNumber =
phoneNumberUtil.getExampleNumberForType(regionCode, exampleNumberRequestedType);
if (exampleNumber != null) {
if (!phoneNumberUtil.isValidNumber(exampleNumber)) {
invalidCases.add(exampleNumber);
LOGGER.log(Level.SEVERE, "Failed validation for " + exampleNumber.toString());
} else {
// We know the number is valid, now we check the type.
PhoneNumberType exampleNumberType = phoneNumberUtil.getNumberType(exampleNumber);
if (!possibleExpectedTypes.contains(exampleNumberType)) {
wrongTypeCases.add(exampleNumber);
LOGGER.log(Level.SEVERE, "Wrong type for " +
exampleNumber.toString() +
": got " + exampleNumberType);
LOGGER.log(Level.WARNING, "Expected types: ");
foreach(PhoneNumberType type in possibleExpectedTypes) {
LOGGER.log(Level.WARNING, type.ToString());
}
}
}
}
}
}
示例2: findBestMatchingLanguageCode
private String findBestMatchingLanguageCode(
Set<String> setOfLangs, String language, String script, String region)
{
StringBuilder fullLocale = constructFullLocale(language, script, region);
String fullLocaleStr = fullLocale.toString();
String normalizedLocale = LOCALE_NORMALIZATION_MAP.get(fullLocaleStr);
if (normalizedLocale != null) {
if (setOfLangs.contains(normalizedLocale)) {
return normalizedLocale;
}
}
if (setOfLangs.contains(fullLocaleStr)) {
return fullLocaleStr;
}
if (onlyOneOfScriptOrRegionIsEmpty(script, region)) {
if (setOfLangs.contains(language)) {
return language;
}
} else if (script.length() > 0 && region.length() > 0) {
StringBuilder langWithScript = new StringBuilder(language).append('_').append(script);
String langWithScriptStr = langWithScript.toString();
if (setOfLangs.contains(langWithScriptStr)) {
return langWithScriptStr;
}
StringBuilder langWithRegion = new StringBuilder(language).append('_').append(region);
String langWithRegionStr = langWithRegion.toString();
if (setOfLangs.contains(langWithRegionStr)) {
return langWithRegionStr;
}
if (setOfLangs.contains(language)) {
return language;
}
}
return "";
}