本文整理汇总了Java中java.util.LinkedHashSet.contains方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedHashSet.contains方法的具体用法?Java LinkedHashSet.contains怎么用?Java LinkedHashSet.contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedHashSet
的用法示例。
在下文中一共展示了LinkedHashSet.contains方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: includeAdditionsSuperInterfaces2
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Adds all super-interfaces of pivot to acceptor except those listed in exclude
*
* @param acceptor
* list to add to
* @param exclude
* exclusion set
* @param pivot
* interface providing super-interfaces
*/
private <T extends TClassifier> void includeAdditionsSuperInterfaces2(LinkedHashSet<T> acceptor,
LinkedHashSet<T> exclude, T pivot, Class<T> castGuard) {
for (ParameterizedTypeRef superApiClassifier : pivot.getSuperClassifierRefs()) {
Type superApiDeclaredType = superApiClassifier.getDeclaredType();
if (castGuard.isAssignableFrom(superApiDeclaredType.getClass())) {
@SuppressWarnings("unchecked")
T superInterface = (T) superApiClassifier.getDeclaredType();
if (!exclude.contains(superInterface)) {
acceptor.add(superInterface);
}
} else {
// should we handle this or gracefully skip for broken models?
if (logger.isDebugEnabled()) {
logger.debug("Oopss ... Casting could not be performed Guard = " + castGuard.getName()
+ " DeclaredType of superApiClassifier '" + superApiDeclaredType.getClass().getName()
+ "' ");
}
}
}
}
示例2: calculateCycleDeadlockChains
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap,
Set<LinkedHashSet<ThreadInfo>> cycles) {
ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds());
Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>();
Set<Long> knownDeadlockedThreads = threadInfoMap.keySet();
for (ThreadInfo threadInfo : allThreads) {
Thread.State state = threadInfo.getThreadState();
if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) {
for (LinkedHashSet<ThreadInfo> cycle : cycles) {
if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) {
LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>();
ThreadInfo node = threadInfo;
while (!chain.contains(node)) {
chain.add(node);
node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId()));
}
deadlockChain.add(chain);
}
}
}
}
return deadlockChain;
}
示例3: getAllTypes
import java.util.LinkedHashSet; //导入方法依赖的package包/类
@SuppressWarnings("JdkObsolete")
static Set<GraphQLType> getAllTypes(GraphQLSchema schema) {
LinkedHashSet<GraphQLType> types = new LinkedHashSet<>();
LinkedList<GraphQLObjectType> loop = new LinkedList<>();
loop.add(schema.getQueryType());
types.add(schema.getQueryType());
while (!loop.isEmpty()) {
for (GraphQLFieldDefinition field : loop.pop().getFieldDefinitions()) {
GraphQLType type = field.getType();
if (type instanceof GraphQLList) {
type = ((GraphQLList) type).getWrappedType();
}
if (!types.contains(type)) {
if (type instanceof GraphQLEnumType) {
types.add(field.getType());
}
if (type instanceof GraphQLObjectType) {
types.add(type);
loop.add((GraphQLObjectType) type);
}
}
}
}
return types;
}
示例4: main
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public static void main(String[] args) {
//create object of LinkedHashSet
LinkedHashSet lhashSet = new LinkedHashSet();
//add elements to LinkedHashSet object
lhashSet.add(new Integer("1"));
lhashSet.add(new Integer("2"));
lhashSet.add(new Integer("3"));
/*
To check whether a particular value exists in LinkedHashSet use
boolean contains(Object value) method of LinkedHashSet class.
It returns true if the LinkedHashSet contains the value, otherwise false.
*/
boolean blnExists = lhashSet.contains(new Integer("3"));
System.out.println("3 exists in LinkedHashSet ? : " + blnExists);
}
示例5: setProjectedRowType
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private void setProjectedRowType(List<SchemaPath> projectedColumns){
if(projectedColumns != null){
LinkedHashSet<String> firstLevelPaths = new LinkedHashSet<>();
for(SchemaPath p : projectedColumns){
firstLevelPaths.add(p.getRootSegment().getNameSegment().getPath());
}
final RelDataTypeFactory factory = getCluster().getTypeFactory();
final FieldInfoBuilder builder = new FieldInfoBuilder(factory);
final Map<String, RelDataType> fields = new HashMap<>();
for(Field field : getBatchSchema()){
if(firstLevelPaths.contains(field.getName())){
fields.put(field.getName(), CompleteType.fromField(field).toCalciteType(factory));
}
}
Preconditions.checkArgument(firstLevelPaths.size() == fields.size(), "Projected column base size %d is not equal to outcome rowtype %d.", firstLevelPaths.size(), fields.size());
for(String path : firstLevelPaths){
builder.add(path, fields.get(path));
}
this.rowType = builder.build();
} else {
this.rowType = deriveRowType();
}
}
示例6: linkPathMatrix
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* 生成连接路径矩阵
* @param links
* @param paths
* @return
*/
public static DenseMatrix linkPathMatrix(List<Link> links, List<ArrayList<Vertex>> paths)
{
DenseMatrix linkPaths = DenseMatrix.Factory.zeros(links.size(), paths.size());
for(int i=0; i<paths.size();i++)
{
LinkedHashSet<Vertex> path = new LinkedHashSet<Vertex>(paths.get(i));
for(int j=0; j<links.size(); j++)
{
Vertex linkStartNode = links.get(j).getBegin(); //连接的起点
Vertex linkEndNode = links.get(j).getEnd(); //连接的终点
if(path.contains(linkStartNode) && path.contains(linkEndNode))
{
linkPaths.setAsInt(1, j, i);
}
}
}
return linkPaths;
}
示例7: getMaxDepth
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private static int getMaxDepth(final DependencyResolverImpl impl, final DependencyResolverManager manager,
final LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
int maxDepth = 0;
final LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(chainForDetectingCycles);
chainForDetectingCycles2.add(impl.getIdentifier());
for (final ModuleIdentifier dependencyName : impl.dependencies) {
final DependencyResolverImpl dependentDRI = manager.getOrCreate(dependencyName);
if (chainForDetectingCycles2.contains(dependencyName)) {
throw new IllegalStateException(
String.format("Cycle detected, %s contains %s", chainForDetectingCycles2, dependencyName));
}
int subDepth;
if (dependentDRI.maxDependencyDepth != null) {
subDepth = dependentDRI.maxDependencyDepth;
} else {
subDepth = getMaxDepth(dependentDRI, manager, chainForDetectingCycles2);
dependentDRI.maxDependencyDepth = subDepth;
}
if (subDepth + 1 > maxDepth) {
maxDepth = subDepth + 1;
}
}
impl.maxDependencyDepth = maxDepth;
return maxDepth;
}
示例8: calculateCycles
import java.util.LinkedHashSet; //导入方法依赖的package包/类
private Set<LinkedHashSet<ThreadInfo>> calculateCycles(Map<Long, ThreadInfo> threadInfoMap) {
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId()))) {
cycle.add(t);
}
if (!cycles.contains(cycle)) {
cycles.add(cycle);
}
}
return cycles;
}
示例9: restoreSavedSelectedTypes
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Restore previously selected types from the preferences.
*/
public void restoreSavedSelectedTypes() {
LinkedHashSet<String> typeList = Gate.getUserConfig().getSet(
AnnotationSetsView.class.getName() + ".types");
for (SetHandler sHandler : setHandlers){
String prefix = (sHandler.set.getName() == null) ?
"." : sHandler.set.getName() + ".";
for (TypeHandler tHandler : sHandler.typeHandlers) {
if (typeList.contains(prefix + tHandler.name)) {
tHandler.setSelected(true);
}
}
}
}
示例10: store
import java.util.LinkedHashSet; //导入方法依赖的package包/类
/**
* Stores the listed object under the specified hash key in map. Unlike a
* standard map, the listed object will not replace any object already at
* the appropriate Map location, but rather will be appended to a List
* stored in that location.
*/
private <H, L> void store(H hashed, L listed, Map<H, LinkedHashSet<L>> map) {
LinkedHashSet<L> list = map.get(hashed);
if (list == null) {
list = new LinkedHashSet<>(1);
map.put(hashed, list);
}
if (!list.contains(listed)) {
list.add(listed);
}
}
示例11: main
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public static void main(String[] args) {
String filename = "/home/zhanghao/Documents/GoogleNews-vectors-negative300.bin";
log.info("load google news embeddings and create word2vec...");
Word2Vec w2v = WordVectorSerializer.loadWord2VecModel(filename, true);
log.info("done...");
String word = "kill";
log.info("find top 5000 nearest words...");
List<Pair<String, Double>> wordLst = w2v.wordsNearest(word, 5000);
log.info("done...");
// Filtering
log.info("lemmatizing, filtering top 100 nearest distinct verbs...");
LinkedList<Pair<String, Double>> result = new LinkedList<>();
LinkedHashSet<String> vocab = new LinkedHashSet<>();
for (Pair<String, Double> aWordLst : wordLst) {
String str = Common.lemmatizer(aWordLst.getKey());
if (str.equals(word) || !WorNetUtils.isVerb(str))
continue;
if (vocab.contains(str))
continue;
vocab.add(str);
result.add(new Pair<>(str, aWordLst.getValue()));
}
result = result.stream().sorted((e1, e2) -> Double.valueOf(e2.getValue()).compareTo(Double.valueOf(e1.getValue())))
.limit(100).collect(Collectors.toCollection(LinkedList::new));
for (Pair<String, Double> pair : result) {
System.out.println(pair.toString());
}
log.info("done...");
}
示例12: getPlatformMappingsForFlavor
import java.util.LinkedHashSet; //导入方法依赖的package包/类
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) {
LinkedHashSet<String> natives = new LinkedHashSet<>(1);
if (df == null) {
return natives;
}
String charset = df.getParameter("charset");
String baseType = df.getPrimaryType() + "/" + df.getSubType();
String mimeType = baseType;
if (charset != null && DataTransferer.isFlavorCharsetTextType(df)) {
mimeType += ";charset=" + charset;
}
// Add a mapping to the MIME native whenever the representation class
// doesn't require translation.
if (df.getRepresentationClass() != null &&
(df.isRepresentationClassInputStream() ||
df.isRepresentationClassByteBuffer() ||
byte[].class.equals(df.getRepresentationClass()))) {
natives.add(mimeType);
}
if (DataFlavor.imageFlavor.equals(df)) {
String[] mimeTypes = ImageIO.getWriterMIMETypes();
if (mimeTypes != null) {
for (int i = 0; i < mimeTypes.length; i++) {
Iterator writers =
ImageIO.getImageWritersByMIMEType(mimeTypes[i]);
while (writers.hasNext()) {
ImageWriter imageWriter = (ImageWriter)writers.next();
ImageWriterSpi writerSpi =
imageWriter.getOriginatingProvider();
if (writerSpi != null &&
writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) {
natives.add(mimeTypes[i]);
break;
}
}
}
}
} else if (DataTransferer.isFlavorCharsetTextType(df)) {
// stringFlavor is semantically equivalent to the standard
// "text/plain" MIME type.
if (DataFlavor.stringFlavor.equals(df)) {
baseType = "text/plain";
}
for (String encoding : DataTransferer.standardEncodings()) {
if (!encoding.equals(charset)) {
natives.add(baseType + ";charset=" + encoding);
}
}
// Add a MIME format without specified charset.
if (!natives.contains(baseType)) {
natives.add(baseType);
}
}
return natives;
}
示例13: getPlatformMappingsForFlavor
import java.util.LinkedHashSet; //导入方法依赖的package包/类
@Override
public LinkedHashSet<String> getPlatformMappingsForFlavor(DataFlavor df) {
LinkedHashSet<String> natives = new LinkedHashSet<>(1);
if (df == null) {
return natives;
}
String charset = df.getParameter("charset");
String baseType = df.getPrimaryType() + "/" + df.getSubType();
String mimeType = baseType;
if (charset != null && DataFlavorUtil.isFlavorCharsetTextType(df)) {
mimeType += ";charset=" + charset;
}
// Add a mapping to the MIME native whenever the representation class
// doesn't require translation.
if (df.getRepresentationClass() != null &&
(df.isRepresentationClassInputStream() ||
df.isRepresentationClassByteBuffer() ||
byte[].class.equals(df.getRepresentationClass()))) {
natives.add(mimeType);
}
if (DataFlavor.imageFlavor.equals(df)) {
String[] mimeTypes = ImageIO.getWriterMIMETypes();
if (mimeTypes != null) {
for (String mime : mimeTypes) {
Iterator<ImageWriter> writers = ImageIO.getImageWritersByMIMEType(mime);
while (writers.hasNext()) {
ImageWriter imageWriter = writers.next();
ImageWriterSpi writerSpi = imageWriter.getOriginatingProvider();
if (writerSpi != null &&
writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) {
natives.add(mime);
break;
}
}
}
}
} else if (DataFlavorUtil.isFlavorCharsetTextType(df)) {
// stringFlavor is semantically equivalent to the standard
// "text/plain" MIME type.
if (DataFlavor.stringFlavor.equals(df)) {
baseType = "text/plain";
}
for (String encoding : DataFlavorUtil.standardEncodings()) {
if (!encoding.equals(charset)) {
natives.add(baseType + ";charset=" + encoding);
}
}
// Add a MIME format without specified charset.
if (!natives.contains(baseType)) {
natives.add(baseType);
}
}
return natives;
}