當前位置: 首頁>>代碼示例>>Java>>正文


Java HashSet.contains方法代碼示例

本文整理匯總了Java中java.util.HashSet.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java HashSet.contains方法的具體用法?Java HashSet.contains怎麽用?Java HashSet.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.HashSet的用法示例。


在下文中一共展示了HashSet.contains方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteUnknownLibs

import java.util.HashSet; //導入方法依賴的package包/類
private static void deleteUnknownLibs(Context context, PxAll all) {
    HashSet<String> names = new HashSet<>();
    for (PluginInfo p : all.getPlugins()) {
        names.add(p.getNativeLibsDir().getName());
    }

    File dir = context.getDir(AppConstant.LOCAL_PLUGIN_DATA_LIB_DIR, 0);
    File files[] = dir.listFiles();
    if (files != null) {
        for (File f : files) {
            if (names.contains(f.getName())) {
                continue;
            }
            if (LOG) {
                LogDebug.d(PLUGIN_TAG, "delete unknown libs=" + f.getAbsolutePath());
            }
            try {
                FileUtils.forceDelete(f);
            } catch (IOException e) {
                if (LOG) {
                    LogDebug.d(PLUGIN_TAG, "can't delete unknown libs=" + f.getAbsolutePath(), e);
                }
            }
        }
    }
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:27,代碼來源:Builder.java

示例2: getTypedWordAndPreviousSuggestions

import java.util.HashSet; //導入方法依賴的package包/類
public static ArrayList<SuggestedWordInfo> getTypedWordAndPreviousSuggestions(
        @Nonnull final SuggestedWordInfo typedWordInfo,
        @Nonnull final SuggestedWords previousSuggestions) {
    final ArrayList<SuggestedWordInfo> suggestionsList = new ArrayList<>();
    final HashSet<String> alreadySeen = new HashSet<>();
    suggestionsList.add(typedWordInfo);
    alreadySeen.add(typedWordInfo.mWord);
    final int previousSize = previousSuggestions.size();
    for (int index = 1; index < previousSize; index++) {
        final SuggestedWordInfo prevWordInfo = previousSuggestions.getInfo(index);
        final String prevWord = prevWordInfo.mWord;
        // Filter out duplicate suggestions.
        if (!alreadySeen.contains(prevWord)) {
            suggestionsList.add(prevWordInfo);
            alreadySeen.add(prevWord);
        }
    }
    return suggestionsList;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:20,代碼來源:SuggestedWords.java

示例3: getCommonPrefix

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Returns the longest string that is a prefix of all accepted strings and
 * visits each state at most once.  The automaton must be deterministic.
 * 
 * @return common prefix
 */
public static String getCommonPrefix(Automaton a) {
  if (a.isDeterministic() == false) {
    throw new IllegalArgumentException("input automaton must be deterministic");
  }
  StringBuilder b = new StringBuilder();
  HashSet<Integer> visited = new HashSet<>();
  int s = 0;
  boolean done;
  Transition t = new Transition();
  do {
    done = true;
    visited.add(s);
    if (a.isAccept(s) == false && a.getNumTransitions(s) == 1) {
      a.getTransition(s, 0, t);
      if (t.min == t.max && !visited.contains(t.dest)) {
        b.appendCodePoint(t.min);
        s = t.dest;
        done = false;
      }
    }
  } while (!done);

  return b.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:Operations.java

示例4: checkRecovery

import java.util.HashSet; //導入方法依賴的package包/類
public static boolean checkRecovery() {
	HashSet<String> projectNames = loadProjectsNames();
	boolean ret = false;
	
	if(projectNames.isEmpty()){
		// For debug purposes
		System.out.println("No projects to load");
	}else{
		System.out.println("Loading projects");
		for (String s : projectNames) {
			if(s.contains(Projet.FORMAT)) {
				if(projectNames.contains(Projet.RECOVERY+s)) {
					ret=true;
					break;
				}
			}
		}
	}
	return ret;
}
 
開發者ID:coco35700,項目名稱:uPMT,代碼行數:21,代碼來源:Utils.java

示例5: loadPages

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Loads pages from the specified directory.
 * 
 * @param directory The directory.
 * @param destinations Already added pages destinations.
 * 
 * @return A set of files that are not going to be copied because they already exist in the destination.
 * 
 * @throws LoadException If the specified file is not a directory.
 */

private final HashSet<String> loadPages(final File directory, final HashSet<String> destinations) throws LoadException {
	if(!directory.isDirectory()) {
		throw new LoadException("The file \"" + directory + "\" is not a directory.");
	}
	final HashSet<String> alreadyExist = new HashSet<String>();
	for(final File child : directory.listFiles()) {
		if(child.isDirectory()) {
			loadPages(child, destinations);
			continue;
		}
		if(FilenameUtils.getExtension(child.getName()).equalsIgnoreCase("md")) {
			final DocsPage page = new DocsPage(this, child);
			final String path = page.getBuildDestinationPath();
			if(destinations.contains(path)) {
				alreadyExist.add(path);
				continue;
			}
			destinations.add(path);
			addPages(page);
		}
	}
	return alreadyExist;
}
 
開發者ID:Skyost,項目名稱:SkyDocs,代碼行數:35,代碼來源:DocsProject.java

示例6: containsAnyUuid

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Returns true if there any common ParcelUuids in uuidA and uuidB.
 *
 * @param uuidA - List of ParcelUuids
 * @param uuidB - List of ParcelUuids
 */
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    if (uuidB == null) {
        return uuidA.length == 0;
    }

    HashSet<ParcelUuid> uuidSet = new HashSet<>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (uuidSet.contains(uuid)) return true;
    }
    return false;
}
 
開發者ID:Twelvelines,項目名稱:AndroidMuseumBleManager,代碼行數:24,代碼來源:BluetoothUuidCompat.java

示例7: scanMissingAddons

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * The sdk manager only lists valid addons. However here we also want to find "broken"
 * addons, i.e. addons that failed to load for some reason.
 * <p/>
 * Find any other sub-directories under the /add-ons root that hasn't been visited yet
 * and assume they contain broken addons.
 */
private void scanMissingAddons(SdkManager sdkManager,
        HashSet<File> visited,
        ArrayList<Package> packages,
        ILogger log) {
    File addons = new File(new File(sdkManager.getLocation()), SdkConstants.FD_ADDONS);

    for (File dir : listFilesNonNull(addons)) {
        if (dir.isDirectory() && !visited.contains(dir)) {
            Pair<Map<String, String>, String> infos =
                parseAddonProperties(dir, sdkManager.getTargets(), log);
            Properties sourceProps =
                parseProperties(new File(dir, SdkConstants.FN_SOURCE_PROP));

            Map<String, String> addonProps = infos.getFirst();
            String error = infos.getSecond();
            try {
                Package pkg = AddonPackage.createBroken(dir.getAbsolutePath(),
                                                        sourceProps,
                                                        addonProps,
                                                        error);
                packages.add(pkg);
                visited.add(dir);
            } catch (Exception e) {
                log.error(e, null);
            }
        }
    }
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:36,代碼來源:LocalSdkParser.java

示例8: eval

import java.util.HashSet; //導入方法依賴的package包/類
private BigDecimal eval(Interpreter interpreter, HashMap<String, BigDecimal> arguments, HashSet<String> reserved) throws SyntaxException, ArithmeticException, StackOverflowError {
    if (value == null) {
        BigDecimal l = left.eval(interpreter, arguments);
        BigDecimal r = right.eval(interpreter, arguments);
        switch (operator) {
            case '-': return l.subtract(r);
            case '+': return l.add(r);
            case '*': return l.multiply(r);
            case '%': return l.remainder(r);
            case '/': return l.divide(r, interpreter.getInternalRounding(), RoundingMode.HALF_UP);
            case '^': return l.pow(r.intValue());
        }
    }
    if (reserved.contains(value))
        throw new SyntaxException("Variable '" + value + "' is reserved");
    if(arguments.containsKey(value))
        return arguments.get(value);

    HashMap<String, BigDecimal> variables = interpreter.getVariables();
    if(variables.containsKey(value))
        return variables.get(value);
    if (value.contains("(")) {
        HashMap<String, Function> functions = interpreter.getFunctions();
        String name = value.split("\\(")[0];
        if(!functions.containsKey(name)) throw new SyntaxException("Function '" + name + "' not defined");
        String args = value.substring(name.length() + 1, value.length() - 1);
        return functions.get(name).eval(interpreter, arguments, args);
    }
    if(value.matches("[0-9]+(\\.[0-9]*)?"))
        return new BigDecimal(value);
    throw new SyntaxException("Variable '" + value + "' not defined");
}
 
開發者ID:Baizey,項目名稱:Helpers,代碼行數:33,代碼來源:ParserNode.java

示例9: chooseNewValue

import java.util.HashSet; //導入方法依賴的package包/類
private Object chooseNewValue(HashSet<Object> usedValues, Object[] allValues) {

		Object newValue = null;

		// if we do not have any constant values for the requested type, we
		// return null
		if (null == allValues || allValues.length == 0) {
			return null;
		}

		// if we havent used any values, just pick one
		if (null == usedValues || usedValues.size() == 0) {
			newValue = allValues[DeterministicRandom.theRandom.nextInt(allValues.length)];
		} else {
			if (!RETURN_DUPLICATES) {
				// if all values have been tried -> return null == out of values
				if (usedValues.size() == allValues.length) {
					return null;
				}

				do {
					newValue = allValues[DeterministicRandom.theRandom.nextInt(allValues.length)];
				} while (usedValues.contains(newValue));
			} else {
				// just choose one and dont care about duplicates
				newValue = allValues[DeterministicRandom.theRandom.nextInt(allValues.length)];
			}

		}

		return newValue;
	}
 
開發者ID:srasthofer,項目名稱:FuzzDroid,代碼行數:33,代碼來源:SourceConstantFuzzer.java

示例10: getStreamedSectors

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Додає в масив сектори відображення, які пов’язані між собою одним потоком
 * і знаходяться на одному функціональному блоці.
 *
 * @param sector - сектор, для якого будуть знайдені пов’язані.
 * @param v      Вектор в який будуть додані сектори відображення.
 */

public void getStreamedSectors(final PaintSector sector, final HashSet v) {
    getStreamedSectors(sector.getSector(), sector.getStart(), v, true);
    getStreamedSectors(sector.getSector(), sector.getEnd(), v, true);
    if (!v.contains(sector))
        v.add(sector);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:15,代碼來源:SectorRefactor.java

示例11: removeNetworkComponentsInverse

import java.util.HashSet; //導入方法依賴的package包/類
/**
 * Removes all network components if not in the specified list.
 * @param networkComponentsToKeep the network components to keep when deleting network components
 */
public HashSet<NetworkComponent> removeNetworkComponentsInverse(HashSet<NetworkComponent> networkComponentsToKeep) {
	HashSet<NetworkComponent> removed = new HashSet<NetworkComponent>();
	HashSet<String> networkComponentIDs = this.getNetworkComponentsIDs(networkComponentsToKeep);
	for (NetworkComponent networkComponent : new ArrayList<NetworkComponent>(this.networkComponents.values())) {
		if (networkComponentIDs.contains(networkComponent.getId())==false) {
			removeNetworkComponent(networkComponent, true, false);
			removed.add(networkComponent);
		}
	}
	this.refreshGraphElements();
	return removed;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:17,代碼來源:NetworkModel.java

示例12: configureMetaData

import java.util.HashSet; //導入方法依賴的package包/類
void configureMetaData() throws DataSetException {
    try {
        ResultSetMetaData e = this.getCachedResultSet().getMetaData();
        LinkedList columnNames = new LinkedList();
        LinkedList columnTypes = new LinkedList();
        HashSet usedNames = new HashSet();

        for(int columnIndex = 1; columnIndex <= e.getColumnCount(); ++columnIndex) {
            String dbColumnName = e.getColumnLabel(columnIndex);
            String columnName = dbColumnName;
            int valueType;
            if(usedNames.contains(dbColumnName)) {
                valueType = 1;

                do {
                    columnName = dbColumnName + "_" + valueType;
                    ++valueType;
                } while(usedNames.contains(columnName));
            }

            usedNames.add(columnName);
            columnNames.add(columnName);
            valueType = DatabaseHandler.getRapidMinerTypeIndex(e.getColumnType(columnIndex));
            columnTypes.add(ResultSetAdapterUtils.transformValueType(valueType));
        }

        this.metaData = new DefaultDataSetMetaData(columnNames, columnTypes);
    } catch (SQLException var9) {
        throw new DataSetException(var9.getMessage(), var9);
    }
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:32,代碼來源:DatabaseDataSource.java

示例13: removeDublicates

import java.util.HashSet; //導入方法依賴的package包/類
public void removeDublicates() {
    HashSet<RowArrayHolder> arrayHolders = new HashSet<RowArrayHolder>();

    List<Row[]> newRows = new ArrayList<Row[]>();

    for (Row[] rows : this.rows) {
        RowArrayHolder holder = new RowArrayHolder(rows);
        if (!arrayHolders.contains(holder)) {
            arrayHolders.add(holder);
            newRows.add(rows);
        }
    }
    rows = newRows;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:15,代碼來源:Table.java

示例14: mergeHashSet

import java.util.HashSet; //導入方法依賴的package包/類
@SafeVarargs
public static HashSet<String> mergeHashSet(HashSet<String>... list) {
	HashSet<String> mergedHashSet = new HashSet<>();
	for (HashSet<String> hashSet : list) {
		for(String str : hashSet)
			if(!mergedHashSet.contains(str))
				mergedHashSet.add(str);
	}
	return mergedHashSet;
}
 
開發者ID:guozhaotong,項目名稱:FacetExtract,代碼行數:11,代碼來源:iInherit.java

示例15: asString

import java.util.HashSet; //導入方法依賴的package包/類
public static String asString(HashSet<String> relevantRecipeNames, ArrayList<Recipe> allRecipes){
    //TODO: store recipes in hash instead
    StringBuilder recipes = new StringBuilder();
    for(Recipe recipe:allRecipes){
        if(relevantRecipeNames.contains(recipe.getName())){
            recipe.print(false);
            recipes.append(recipe.all());
        }
    }
    return recipes.toString();
}
 
開發者ID:greekyogurtkup,項目名稱:bake_it,代碼行數:12,代碼來源:Retrieve.java


注:本文中的java.util.HashSet.contains方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。