本文整理匯總了Java中java.util.TreeSet.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java TreeSet.contains方法的具體用法?Java TreeSet.contains怎麽用?Java TreeSet.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.TreeSet
的用法示例。
在下文中一共展示了TreeSet.contains方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: expandMethodLevelCluster2Bodies
import java.util.TreeSet; //導入方法依賴的package包/類
private TreeSet<LSDFact> expandMethodLevelCluster2Bodies (PrintStream p, List<LSDFact> methodLevelCluster) {
TreeSet<LSDFact> ontheflyDeltaKB = new TreeSet<LSDFact>();
TreeSet<String> methodConstants = null;
if (methodLevelCluster!=null) {
methodConstants= new TreeSet<String>();
for (LSDFact methodF: methodLevelCluster) {
methodConstants.add(methodF.getBindings().get(0).getGroundConst());
}
}
for (LSDFact fact:originalDeltaKB) {
String involvedMethod =null;
if (fact.getPredicate().getName().indexOf("_calls")>0) {
involvedMethod= fact.getBindings().get(0).getGroundConst();
}
else if (fact.getPredicate().getName().indexOf("_accesses")>0) {
involvedMethod = fact.getBindings().get(1).getGroundConst();
}
if (involvedMethod!=null && (methodConstants==null || methodConstants.contains(involvedMethod))){
if (p!=null) p.println("\t\t\t"+ fact);
ontheflyDeltaKB.add(fact);
}
}
return ontheflyDeltaKB;
}
示例2: contract
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Contracts a population vector to the necessary size depending on partially covered classes in smallPcs.
* @param largePopVec The population vector containing populations for each class in largePcs.
* @param largePcs The set of partially covered classes corresponding to the largePopVec.
* @param smallPcs The set of partially covered classes we want to find populations for.
* @return The population vector containing populations for each class in smallPcs.
*/
public PopulationVector contract(
PopulationVector largePopVec,
TreeSet<Integer> largePcs,
TreeSet<Integer> smallPcs) {
PopulationVector contracted = new PopulationVector(0, smallPcs.size());
int smallIdx = 0;
int largeIdx = 0;
for (int k : largePcs) {
if (smallPcs.contains(k)) {
contracted.set(smallIdx, largePopVec.get(largeIdx));
smallIdx++;
}
largeIdx++;
}
return contracted;
}
示例3: setIndexRelations
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* set user-defined index relationships, only available for tables with user-defined index
*
* @param list
* @throws IllegalIndexException
*/
public void setIndexRelations(List<IndexRelationship> list) throws IllegalIndexException {
if (!IndexType.isUserDefinedIndex(indexType)) {
throw new IllegalIndexException(tableName, indexType,
"should not has user-defined index table");
}
if (list == null || list.isEmpty()) indexRelations = null;
else {
indexRelations = list;
// check relations
for (IndexRelationship one : list) {
indexFamilyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
byte[] family = one.getMainColumn().getFamily();
TreeSet<byte[]> set = indexFamilyMap.get(family);
if (set == null) {
set = new TreeSet<>(Bytes.BYTES_COMPARATOR);
indexFamilyMap.put(family, set);
}
if (set.contains(one.getMainColumn().getQualifier()))
throw new IllegalIndexException(tableName, indexType,
" should not contain different index relations on the same column: " + ColumnInfo
.transToString(family, one.getMainColumn().getQualifier()));
set.add(one.getMainColumn().getQualifier());
}
}
}
示例4: addBlockingRegion
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Adds a new blocking region with unique name to current model
* @return search's key for created blocking region
*/
public Object addBlockingRegion() {
long num = 0L;
String baseName = Defaults.get("blockingRegionName");
// Gets all blocking region names to find an unique name
TreeSet<String> names = new TreeSet<String>();
Vector keys = getRegionKeys();
for (int i = 0; i < keys.size(); i++) {
names.add(getRegionName(keys.get(i)));
}
String name = baseName + num;
while (names.contains(name)) {
name = baseName + (++num);
}
return addBlockingRegion(name, Defaults.get("blockingRegionType"));
}
示例5: isIndexColumn
import java.util.TreeSet; //導入方法依賴的package包/類
public boolean isIndexColumn(byte[] f, byte[] q) {
if (indexType == IndexType.NoIndex) return false;
if (IndexType.isUserDefinedIndex(indexType)) {
for (IndexRelationship relationship : indexRelations) {
if (relationship.getMainColumn().isSameColumn(f, q)) return true;
}
return false;
} else {
TreeSet<byte[]> set = indexFamilyMap.get(f);
if (set == null) return false;
return set.contains(q);
}
}
示例6: dependsOnTransitively
import java.util.TreeSet; //導入方法依賴的package包/類
private boolean dependsOnTransitively(String kit1, String kit2,
TreeMap<String, TreeSet<String>> dependingKits) {
TreeSet<String> kits = dependingKits.get(kit1);
if (kits == null) {
return false;
}
return kits.contains(kit2);
}
示例7: expandTypeLevelCluster2Methods
import java.util.TreeSet; //導入方法依賴的package包/類
private TreeSet<LSDFact> expandTypeLevelCluster2Methods (PrintStream p, List<LSDFact> typeLevelCluster) {
TreeSet<LSDFact> ontheflyDeltaKB = new TreeSet<LSDFact>();
TreeSet<String> typeConstants = null;
TreeSet<String> methodConstants = new TreeSet<String>();
if (typeLevelCluster!=null) {
typeConstants= new TreeSet<String>();
for (LSDFact typeF: typeLevelCluster) {
typeConstants.add(typeF.getBindings().get(0).getGroundConst());
}
}
for (String kind: methodLevel.keySet()) {
for (LSDFact methodF: methodLevel.get(kind)) {
String containerType = methodF.getBindings().get(2).getGroundConst();
if (typeConstants==null || typeConstants.contains(containerType)){
if (p!=null) p.println("\t\t"+methodF);
ontheflyDeltaKB.add(methodF);
methodConstants.add(methodF.getBindings().get(0).getGroundConst());
}
}
}
// add _return facts that are related to added method level facts.
for (LSDFact fact : originalDeltaKB) {
if (fact.getPredicate().getName().indexOf("_return") > 0) {
String involvedMethod = fact.getBindings().get(0).getGroundConst();
if (methodConstants.contains(involvedMethod)) {
ontheflyDeltaKB.add(fact);
}
}
}
return ontheflyDeltaKB;
}
示例8: getCommonSet
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* get common keys from two sets
*
* @param larger
* @param smaller
* @return
*/
private static TreeSet<byte[]> getCommonSet(TreeSet<byte[]> larger, TreeSet<byte[]> smaller) {
if (larger.size() < smaller.size()) return getCommonSet(smaller, larger);
TreeSet<byte[]> commonSet = new TreeSet<>(Bytes.BYTES_COMPARATOR);
for (byte[] key : smaller) {
if (larger.contains(key)) {
commonSet.add(key);
}
}
return commonSet;
}
示例9: getUniqueClassName
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns given name if a class with the same name does not exist or makes it unique
* @param name class name
* @return unique name
*/
protected String getUniqueClassName(String name) {
// Map of all unique names with their first users
TreeSet<String> names = new TreeSet<String>();
Vector<Object> keys = getClassKeys();
// Finds all used names
for (int i = 0; i < keys.size(); i++) {
names.add(getClassName(keys.get(i)));
}
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例10: getUniqueStationName
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns given name if a station with the same name does not exist or makes it unique
* @param name station name
* @return unique name
*/
protected String getUniqueStationName(String name) {
// Map of all unique names with their first users
TreeSet<String> names = new TreeSet<String>();
Vector<Object> keys = getStationKeys();
// Finds all used names
for (int i = 0; i < keys.size(); i++) {
names.add(getStationName(keys.get(i)));
}
names.add(STATION_TYPE_FORK);
names.add(STATION_TYPE_CLASSSWITCH);
names.add(STATION_TYPE_SCALER);
names.add(STATION_TYPE_TRANSITION);
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例11: getUniqueClassName
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns given name if a class with the same name does not exists or makes it unique
* @param name class name
* @return unique name
*/
private String getUniqueClassName(String name) {
TreeSet<String> names = new TreeSet<String>(); // Map of all unique names with their first users
Vector keys = getClassKeys();
// Finds all used names
for (int i = 0; i < keys.size(); i++) {
names.add(this.getClassName(keys.get(i)));
}
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例12: getUniqueStationName
import java.util.TreeSet; //導入方法依賴的package包/類
/**
* Returns given name if a station with the same name does not exists or makes it unique
* @param name station name
* @return unique name
*/
private String getUniqueStationName(String name) {
TreeSet<String> names = new TreeSet<String>(); // Map of all unique names with their first users
Vector keys = getStationKeys();
// Finds all used names
for (int i = 0; i < keys.size(); i++) {
names.add(this.getStationName(keys.get(i)));
}
// If name is new, returns it
if (!names.contains(name)) {
return name;
}
int num;
// If format is already '*_[number]' increment number
char[] charname = name.toCharArray();
int n = charname.length - 1;
while (charname[n] >= '0' && charname[n] <= '9' && n > 0) {
n--;
}
if (charname[n] == '_') {
num = Integer.parseInt(name.substring(n + 1));
name = name.substring(0, n); // Removes suffix
}
// Otherwise uses number 1
else {
num = 1;
}
// Finds unique number
while (names.contains(name + "_" + num)) {
num++;
}
return name + "_" + num;
}
示例13: getPositiveIPList
import java.util.TreeSet; //導入方法依賴的package包/類
Collection<ipAddress> getPositiveIPList() {
TreeSet<ipAddress> ipsSorted = generateIPList();
Vector<ipAddress> ips = new Vector<ipAddress>();
for (ipAddress ia : ipsSorted) {
if (ia.included) ips.add(ia);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
// Include postive routes from the original set under < 4.4 since these might overrule the local
// network but only if no smaller negative route exists
for (ipAddress origIp : mIpAddresses) {
if (!origIp.included) continue;
// The netspace exists
if (ipsSorted.contains(origIp)) continue;
boolean skipIp = false;
// If there is any smaller net that is excluded we may not add the positive route back
for (ipAddress calculatedIp : ipsSorted) {
if (!calculatedIp.included && origIp.containsNet(calculatedIp)) {
skipIp = true;
break;
}
}
if (skipIp) continue;
// It is safe to include the IP
ips.add(origIp);
}
}
return ips;
}
示例14: getDefaultLocale
import java.util.TreeSet; //導入方法依賴的package包/類
private String getDefaultLocale()
{
Map<String, HtmlValueState> localeMap = state.getLocaleMap();
TreeSet<Locale> editableLocales = new TreeSet<Locale>(localeComparator);
Locale firstValidLoc = null;
for( Map.Entry<String, HtmlValueState> entry : localeMap.entrySet() )
{
Locale locale = LocaleUtils.parseLocale(entry.getKey());
if( !Check.isEmpty(entry.getValue().getValue()) && firstValidLoc == null )
{
firstValidLoc = locale;
}
editableLocales.add(locale);
}
Locale currentLocale = CurrentLocale.getLocale();
if( !editableLocales.contains(currentLocale) )
{
Locale closestLocale = LocaleUtils.getClosestLocale(editableLocales, currentLocale);
if( closestLocale != null )
{
currentLocale = closestLocale;
if( !isEmpty(localeMap.values()) && Check.isEmpty(localeMap.get(closestLocale.toString()).getValue()) )
{
currentLocale = firstValidLoc;
}
}
else
{
currentLocale = editableLocales.first();
}
}
return currentLocale.toString();
}
示例15: bestNode
import java.util.TreeSet; //導入方法依賴的package包/類
private DatanodeInfo bestNode(DFSClient dfs, DatanodeInfo[] nodes,
TreeSet<DatanodeInfo> deadNodes) throws IOException {
if ((nodes == null) ||
(nodes.length - deadNodes.size() < 1)) {
throw new IOException("No live nodes contain current block");
}
DatanodeInfo chosenNode;
do {
chosenNode = nodes[DFSUtil.getRandom().nextInt(nodes.length)];
} while (deadNodes.contains(chosenNode));
return chosenNode;
}